yellowfive@57
|
1 -- AskMrRobot-Serializer will serialize and communicate character data between users.
|
yellowfive@57
|
2 -- This is used primarily to associate character information to logs uploaded to askmrrobot.com.
|
yellowfive@57
|
3
|
yellowfive@57
|
4 local MAJOR, MINOR = "AskMrRobot-Serializer", 21
|
yellowfive@57
|
5 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
|
yellowfive@57
|
6
|
yellowfive@57
|
7 if not Amr then return end -- already loaded by something else
|
yellowfive@57
|
8
|
yellowfive@57
|
9 -- event and comm used for player snapshotting on entering combat
|
yellowfive@57
|
10 LibStub("AceEvent-3.0"):Embed(Amr)
|
yellowfive@57
|
11 LibStub("AceComm-3.0"):Embed(Amr)
|
yellowfive@57
|
12
|
yellowfive@57
|
13 ----------------------------------------------------------------------------------------
|
yellowfive@57
|
14 -- Constants
|
yellowfive@57
|
15 ----------------------------------------------------------------------------------------
|
yellowfive@57
|
16
|
yellowfive@57
|
17 -- prefix used for communicating gear snapshots created by the AMR serializer
|
yellowfive@57
|
18 Amr.ChatPrefix = "_AMRS"
|
yellowfive@57
|
19
|
yellowfive@57
|
20 -- map of region ids to AMR region names
|
yellowfive@57
|
21 Amr.RegionNames = {
|
yellowfive@57
|
22 [1] = "US",
|
yellowfive@57
|
23 [2] = "KR",
|
yellowfive@57
|
24 [3] = "EU",
|
yellowfive@57
|
25 [4] = "TW",
|
yellowfive@57
|
26 [5] = "CN"
|
yellowfive@57
|
27 }
|
yellowfive@57
|
28
|
yellowfive@57
|
29 -- map of the skillLine returned by profession API to the AMR profession name
|
yellowfive@57
|
30 Amr.ProfessionSkillLineToName = {
|
yellowfive@57
|
31 [794] = "Archaeology",
|
yellowfive@57
|
32 [171] = "Alchemy",
|
yellowfive@57
|
33 [164] = "Blacksmithing",
|
yellowfive@57
|
34 [185] = "Cooking",
|
yellowfive@57
|
35 [333] = "Enchanting",
|
yellowfive@57
|
36 [202] = "Engineering",
|
yellowfive@57
|
37 [129] = "First Aid",
|
yellowfive@57
|
38 [356] = "Fishing",
|
yellowfive@57
|
39 [182] = "Herbalism",
|
yellowfive@57
|
40 [773] = "Inscription",
|
yellowfive@57
|
41 [755] = "Jewelcrafting",
|
yellowfive@57
|
42 [165] = "Leatherworking",
|
yellowfive@57
|
43 [186] = "Mining",
|
yellowfive@57
|
44 [393] = "Skinning",
|
yellowfive@57
|
45 [197] = "Tailoring"
|
yellowfive@57
|
46 }
|
yellowfive@57
|
47
|
yellowfive@57
|
48 -- all slot IDs that we care about, ordered in AMR standard display order
|
yellowfive@57
|
49 Amr.SlotIds = { 16, 17, 1, 2, 3, 15, 5, 9, 10, 6, 7, 8, 11, 12, 13, 14 }
|
yellowfive@57
|
50
|
yellowfive@57
|
51 Amr.SpecIds = {
|
yellowfive@57
|
52 [250] = 1, -- DeathKnightBlood
|
yellowfive@57
|
53 [251] = 2, -- DeathKnightFrost
|
yellowfive@57
|
54 [252] = 3, -- DeathKnightUnholy
|
yellowfive@57
|
55 [102] = 4, -- DruidBalance
|
yellowfive@57
|
56 [103] = 5, -- DruidFeral
|
yellowfive@57
|
57 [104] = 6, -- DruidGuardian
|
yellowfive@57
|
58 [105] = 7, -- DruidRestoration
|
yellowfive@57
|
59 [253] = 8, -- HunterBeastMastery
|
yellowfive@57
|
60 [254] = 9, -- HunterMarksmanship
|
yellowfive@57
|
61 [255] = 10, -- HunterSurvival
|
yellowfive@57
|
62 [62] = 11, -- MageArcane
|
yellowfive@57
|
63 [63] = 12, -- MageFire
|
yellowfive@57
|
64 [64] = 13, -- MageFrost
|
yellowfive@57
|
65 [268] = 14, -- MonkBrewmaster
|
yellowfive@57
|
66 [270] = 15, -- MonkMistweaver
|
yellowfive@57
|
67 [269] = 16, -- MonkWindwalker
|
yellowfive@57
|
68 [65] = 17, -- PaladinHoly
|
yellowfive@57
|
69 [66] = 18, -- PaladinProtection
|
yellowfive@57
|
70 [70] = 19, -- PaladinRetribution
|
yellowfive@57
|
71 [256] = 20, -- PriestDiscipline
|
yellowfive@57
|
72 [257] = 21, -- PriestHoly
|
yellowfive@57
|
73 [258] = 22, -- PriestShadow
|
yellowfive@57
|
74 [259] = 23, -- RogueAssassination
|
yellowfive@57
|
75 [260] = 24, -- RogueCombat
|
yellowfive@57
|
76 [261] = 25, -- RogueSubtlety
|
yellowfive@57
|
77 [262] = 26, -- ShamanElemental
|
yellowfive@57
|
78 [263] = 27, -- ShamanEnhancement
|
yellowfive@57
|
79 [264] = 28, -- ShamanRestoration
|
yellowfive@57
|
80 [265] = 29, -- WarlockAffliction
|
yellowfive@57
|
81 [266] = 30, -- WarlockDemonology
|
yellowfive@57
|
82 [267] = 31, -- WarlockDestruction
|
yellowfive@57
|
83 [71] = 32, -- WarriorArms
|
yellowfive@57
|
84 [72] = 33, -- WarriorFury
|
yellowfive@57
|
85 [73] = 34 -- WarriorProtection
|
yellowfive@57
|
86 }
|
yellowfive@57
|
87
|
yellowfive@57
|
88 Amr.ClassIds = {
|
yellowfive@57
|
89 ["NONE"] = 0,
|
yellowfive@57
|
90 ["DEATHKNIGHT"] = 1,
|
yellowfive@57
|
91 ["DRUID"] = 2,
|
yellowfive@57
|
92 ["HUNTER"] = 3,
|
yellowfive@57
|
93 ["MAGE"] = 4,
|
yellowfive@57
|
94 ["MONK"] = 5,
|
yellowfive@57
|
95 ["PALADIN"] = 6,
|
yellowfive@57
|
96 ["PRIEST"] = 7,
|
yellowfive@57
|
97 ["ROGUE"] = 8,
|
yellowfive@57
|
98 ["SHAMAN"] = 9,
|
yellowfive@57
|
99 ["WARLOCK"] = 10,
|
yellowfive@57
|
100 ["WARRIOR"] = 11,
|
yellowfive@57
|
101 }
|
yellowfive@57
|
102
|
yellowfive@57
|
103 Amr.ProfessionIds = {
|
yellowfive@57
|
104 ["None"] = 0,
|
yellowfive@57
|
105 ["Mining"] = 1,
|
yellowfive@57
|
106 ["Skinning"] = 2,
|
yellowfive@57
|
107 ["Herbalism"] = 3,
|
yellowfive@57
|
108 ["Enchanting"] = 4,
|
yellowfive@57
|
109 ["Jewelcrafting"] = 5,
|
yellowfive@57
|
110 ["Engineering"] = 6,
|
yellowfive@57
|
111 ["Blacksmithing"] = 7,
|
yellowfive@57
|
112 ["Leatherworking"] = 8,
|
yellowfive@57
|
113 ["Inscription"] = 9,
|
yellowfive@57
|
114 ["Tailoring"] = 10,
|
yellowfive@57
|
115 ["Alchemy"] = 11,
|
yellowfive@57
|
116 ["Fishing"] = 12,
|
yellowfive@57
|
117 ["Cooking"] = 13,
|
yellowfive@57
|
118 ["First Aid"] = 14,
|
yellowfive@57
|
119 ["Archaeology"] = 15
|
yellowfive@57
|
120 }
|
yellowfive@57
|
121
|
yellowfive@57
|
122 Amr.RaceIds = {
|
yellowfive@57
|
123 ["None"] = 0,
|
yellowfive@57
|
124 ["BloodElf"] = 1,
|
yellowfive@57
|
125 ["Draenei"] = 2,
|
yellowfive@57
|
126 ["Dwarf"] = 3,
|
yellowfive@57
|
127 ["Gnome"] = 4,
|
yellowfive@57
|
128 ["Human"] = 5,
|
yellowfive@57
|
129 ["NightElf"] = 6,
|
yellowfive@57
|
130 ["Orc"] = 7,
|
yellowfive@57
|
131 ["Tauren"] = 8,
|
yellowfive@57
|
132 ["Troll"] = 9,
|
yellowfive@57
|
133 ["Scourge"] = 10,
|
yellowfive@57
|
134 ["Undead"] = 10,
|
yellowfive@57
|
135 ["Goblin"] = 11,
|
yellowfive@57
|
136 ["Worgen"] = 12,
|
yellowfive@57
|
137 ["Pandaren"] = 13
|
yellowfive@57
|
138 }
|
yellowfive@57
|
139
|
yellowfive@57
|
140 Amr.FactionIds = {
|
yellowfive@57
|
141 ["None"] = 0,
|
yellowfive@57
|
142 ["Alliance"] = 1,
|
yellowfive@57
|
143 ["Horde"] = 2
|
yellowfive@57
|
144 }
|
yellowfive@57
|
145
|
yellowfive@57
|
146 Amr.InstanceIds = {
|
yellowfive@57
|
147 Auchindoun = 1182,
|
yellowfive@57
|
148 BloodmaulSlagMines = 1175,
|
yellowfive@57
|
149 GrimrailDepot = 1208,
|
yellowfive@57
|
150 IronDocks = 1195,
|
yellowfive@57
|
151 ShadowmoonBurialGrounds = 1176,
|
yellowfive@57
|
152 Skyreach = 1209,
|
yellowfive@57
|
153 TheEverbloom = 1279,
|
yellowfive@57
|
154 UpperBlackrockSpire = 1358,
|
yellowfive@57
|
155 Highmaul = 1228,
|
yellowfive@57
|
156 BlackrockFoundry = 1205
|
yellowfive@57
|
157 }
|
yellowfive@57
|
158
|
yellowfive@57
|
159 -- instances that AskMrRobot currently supports logging for
|
yellowfive@57
|
160 Amr.SupportedInstanceIds = {
|
yellowfive@57
|
161 --[1182] = true,
|
yellowfive@57
|
162 --[1175] = true,
|
yellowfive@57
|
163 --[1208] = true,
|
yellowfive@57
|
164 --[1195] = true,
|
yellowfive@57
|
165 --[1176] = true,
|
yellowfive@57
|
166 --[1209] = true,
|
yellowfive@57
|
167 --[1279] = true,
|
yellowfive@57
|
168 --[1358] = true,
|
yellowfive@57
|
169 [1228] = true,
|
yellowfive@57
|
170 [1205] = true
|
yellowfive@57
|
171 }
|
yellowfive@57
|
172
|
yellowfive@57
|
173 Amr.SPEC_WARRIORPROTECTION = 34
|
yellowfive@57
|
174 Amr.SUBSPEC_WARRIORPROTECTION = 38
|
yellowfive@57
|
175 Amr.SUBSPEC_WARRIORPROTECTIONGLAD = 39
|
yellowfive@57
|
176 Amr.SPELL_ID_GLADIATOR_STANCE = 156291
|
yellowfive@57
|
177 Amr.SPELL_ID_DEFENSIVE_STANCE = 71
|
yellowfive@57
|
178
|
yellowfive@57
|
179 -- IDs of set tokens that we would care about in a player's inventory
|
yellowfive@57
|
180 Amr.SetTokenIds = {
|
yellowfive@57
|
181 [120285] = true,
|
yellowfive@57
|
182 [120284] = true,
|
yellowfive@57
|
183 [120283] = true,
|
yellowfive@57
|
184 [120282] = true,
|
yellowfive@57
|
185 [120281] = true,
|
yellowfive@57
|
186 [120280] = true,
|
yellowfive@57
|
187 [120279] = true,
|
yellowfive@57
|
188 [120278] = true,
|
yellowfive@57
|
189 [120277] = true,
|
yellowfive@57
|
190 [120256] = true,
|
yellowfive@57
|
191 [120255] = true,
|
yellowfive@57
|
192 [120254] = true,
|
yellowfive@57
|
193 [120253] = true,
|
yellowfive@57
|
194 [120252] = true,
|
yellowfive@57
|
195 [120251] = true,
|
yellowfive@57
|
196 [120250] = true,
|
yellowfive@57
|
197 [120249] = true,
|
yellowfive@57
|
198 [120248] = true,
|
yellowfive@57
|
199 [120247] = true,
|
yellowfive@57
|
200 [120246] = true,
|
yellowfive@57
|
201 [120245] = true,
|
yellowfive@57
|
202 [120244] = true,
|
yellowfive@57
|
203 [120243] = true,
|
yellowfive@57
|
204 [120242] = true,
|
yellowfive@57
|
205 [120241] = true,
|
yellowfive@57
|
206 [120240] = true,
|
yellowfive@57
|
207 [120239] = true,
|
yellowfive@57
|
208 [120238] = true,
|
yellowfive@57
|
209 [120237] = true,
|
yellowfive@57
|
210 [120236] = true,
|
yellowfive@57
|
211 [120235] = true,
|
yellowfive@57
|
212 [120234] = true,
|
yellowfive@57
|
213 [120233] = true,
|
yellowfive@57
|
214 [120232] = true,
|
yellowfive@57
|
215 [120231] = true,
|
yellowfive@57
|
216 [120230] = true,
|
yellowfive@57
|
217 [120229] = true,
|
yellowfive@57
|
218 [120228] = true,
|
yellowfive@57
|
219 [120227] = true,
|
yellowfive@57
|
220 [120226] = true,
|
yellowfive@57
|
221 [120225] = true,
|
yellowfive@57
|
222 [120224] = true,
|
yellowfive@57
|
223 [120223] = true,
|
yellowfive@57
|
224 [120222] = true,
|
yellowfive@57
|
225 [120221] = true,
|
yellowfive@57
|
226 [120220] = true,
|
yellowfive@57
|
227 [120219] = true,
|
yellowfive@57
|
228 [120218] = true,
|
yellowfive@57
|
229 [120217] = true,
|
yellowfive@57
|
230 [120216] = true,
|
yellowfive@57
|
231 [120215] = true,
|
yellowfive@57
|
232 [120214] = true,
|
yellowfive@57
|
233 [120213] = true,
|
yellowfive@57
|
234 [120212] = true,
|
yellowfive@57
|
235 [120211] = true,
|
yellowfive@57
|
236 [120210] = true,
|
yellowfive@57
|
237 [120209] = true,
|
yellowfive@57
|
238 [120208] = true,
|
yellowfive@57
|
239 [120207] = true,
|
yellowfive@57
|
240 [120206] = true,
|
yellowfive@57
|
241 [119323] = true,
|
yellowfive@57
|
242 [119322] = true,
|
yellowfive@57
|
243 [119321] = true,
|
yellowfive@57
|
244 [119320] = true,
|
yellowfive@57
|
245 [119319] = true,
|
yellowfive@57
|
246 [119318] = true,
|
yellowfive@57
|
247 [119316] = true,
|
yellowfive@57
|
248 [119315] = true,
|
yellowfive@57
|
249 [119314] = true,
|
yellowfive@57
|
250 [119313] = true,
|
yellowfive@57
|
251 [119312] = true,
|
yellowfive@57
|
252 [119311] = true,
|
yellowfive@57
|
253 [119310] = true,
|
yellowfive@57
|
254 [119309] = true,
|
yellowfive@57
|
255 [119308] = true,
|
yellowfive@57
|
256 [119307] = true,
|
yellowfive@57
|
257 [119306] = true,
|
yellowfive@57
|
258 [119305] = true,
|
yellowfive@57
|
259 [105868] = true,
|
yellowfive@57
|
260 [105867] = true,
|
yellowfive@57
|
261 [105866] = true,
|
yellowfive@57
|
262 [105865] = true,
|
yellowfive@57
|
263 [105864] = true,
|
yellowfive@57
|
264 [105863] = true,
|
yellowfive@57
|
265 [105862] = true,
|
yellowfive@57
|
266 [105861] = true,
|
yellowfive@57
|
267 [105860] = true,
|
yellowfive@57
|
268 [105859] = true,
|
yellowfive@57
|
269 [105858] = true,
|
yellowfive@57
|
270 [105857] = true,
|
yellowfive@57
|
271 [99756] = true,
|
yellowfive@57
|
272 [99755] = true,
|
yellowfive@57
|
273 [99754] = true,
|
yellowfive@57
|
274 [99753] = true,
|
yellowfive@57
|
275 [99752] = true,
|
yellowfive@57
|
276 [99751] = true,
|
yellowfive@57
|
277 [99750] = true,
|
yellowfive@57
|
278 [99749] = true,
|
yellowfive@57
|
279 [99748] = true,
|
yellowfive@57
|
280 [99747] = true,
|
yellowfive@57
|
281 [99746] = true,
|
yellowfive@57
|
282 [99745] = true,
|
yellowfive@57
|
283 [99744] = true,
|
yellowfive@57
|
284 [99743] = true,
|
yellowfive@57
|
285 [99742] = true,
|
yellowfive@57
|
286 [99740] = true,
|
yellowfive@57
|
287 [99739] = true,
|
yellowfive@57
|
288 [99738] = true,
|
yellowfive@57
|
289 [99737] = true,
|
yellowfive@57
|
290 [99736] = true,
|
yellowfive@57
|
291 [99735] = true,
|
yellowfive@57
|
292 [99734] = true,
|
yellowfive@57
|
293 [99733] = true,
|
yellowfive@57
|
294 [99732] = true,
|
yellowfive@57
|
295 [99731] = true,
|
yellowfive@57
|
296 [99730] = true,
|
yellowfive@57
|
297 [99729] = true,
|
yellowfive@57
|
298 [99728] = true,
|
yellowfive@57
|
299 [99727] = true,
|
yellowfive@57
|
300 [99726] = true,
|
yellowfive@57
|
301 [99725] = true,
|
yellowfive@57
|
302 [99724] = true,
|
yellowfive@57
|
303 [99723] = true,
|
yellowfive@57
|
304 [99722] = true,
|
yellowfive@57
|
305 [99721] = true,
|
yellowfive@57
|
306 [99720] = true,
|
yellowfive@57
|
307 [99719] = true,
|
yellowfive@57
|
308 [99718] = true,
|
yellowfive@57
|
309 [99717] = true,
|
yellowfive@57
|
310 [99716] = true,
|
yellowfive@57
|
311 [99715] = true,
|
yellowfive@57
|
312 [99714] = true,
|
yellowfive@57
|
313 [99713] = true,
|
yellowfive@57
|
314 [99712] = true,
|
yellowfive@57
|
315 [99711] = true,
|
yellowfive@57
|
316 [99710] = true,
|
yellowfive@57
|
317 [99709] = true,
|
yellowfive@57
|
318 [99708] = true,
|
yellowfive@57
|
319 [99707] = true,
|
yellowfive@57
|
320 [99706] = true,
|
yellowfive@57
|
321 [99705] = true,
|
yellowfive@57
|
322 [99704] = true,
|
yellowfive@57
|
323 [99703] = true,
|
yellowfive@57
|
324 [99702] = true,
|
yellowfive@57
|
325 [99701] = true,
|
yellowfive@57
|
326 [99700] = true,
|
yellowfive@57
|
327 [99699] = true,
|
yellowfive@57
|
328 [99698] = true,
|
yellowfive@57
|
329 [99697] = true,
|
yellowfive@57
|
330 [99696] = true,
|
yellowfive@57
|
331 [99695] = true,
|
yellowfive@57
|
332 [99694] = true,
|
yellowfive@57
|
333 [99693] = true,
|
yellowfive@57
|
334 [99692] = true,
|
yellowfive@57
|
335 [99691] = true,
|
yellowfive@57
|
336 [99690] = true,
|
yellowfive@57
|
337 [99689] = true,
|
yellowfive@57
|
338 [99688] = true,
|
yellowfive@57
|
339 [99687] = true,
|
yellowfive@57
|
340 [99686] = true,
|
yellowfive@57
|
341 [99685] = true,
|
yellowfive@57
|
342 [99684] = true,
|
yellowfive@57
|
343 [99683] = true,
|
yellowfive@57
|
344 [99682] = true,
|
yellowfive@57
|
345 [99681] = true,
|
yellowfive@57
|
346 [99680] = true,
|
yellowfive@57
|
347 [99679] = true,
|
yellowfive@57
|
348 [99678] = true,
|
yellowfive@57
|
349 [99677] = true,
|
yellowfive@57
|
350 [99676] = true,
|
yellowfive@57
|
351 [99675] = true,
|
yellowfive@57
|
352 [99674] = true,
|
yellowfive@57
|
353 [99673] = true,
|
yellowfive@57
|
354 [99672] = true,
|
yellowfive@57
|
355 [99671] = true,
|
yellowfive@57
|
356 [99670] = true,
|
yellowfive@57
|
357 [99669] = true,
|
yellowfive@57
|
358 [99668] = true,
|
yellowfive@57
|
359 [99667] = true,
|
yellowfive@57
|
360 [96701] = true,
|
yellowfive@57
|
361 [96700] = true,
|
yellowfive@57
|
362 [96699] = true,
|
yellowfive@57
|
363 [96633] = true,
|
yellowfive@57
|
364 [96632] = true,
|
yellowfive@57
|
365 [96631] = true,
|
yellowfive@57
|
366 [96625] = true,
|
yellowfive@57
|
367 [96624] = true,
|
yellowfive@57
|
368 [96623] = true,
|
yellowfive@57
|
369 [96601] = true,
|
yellowfive@57
|
370 [96600] = true,
|
yellowfive@57
|
371 [96599] = true,
|
yellowfive@57
|
372 [96568] = true,
|
yellowfive@57
|
373 [96567] = true,
|
yellowfive@57
|
374 [96566] = true,
|
yellowfive@57
|
375 [95957] = true,
|
yellowfive@57
|
376 [95956] = true,
|
yellowfive@57
|
377 [95955] = true,
|
yellowfive@57
|
378 [95889] = true,
|
yellowfive@57
|
379 [95888] = true,
|
yellowfive@57
|
380 [95887] = true,
|
yellowfive@57
|
381 [95881] = true,
|
yellowfive@57
|
382 [95880] = true,
|
yellowfive@57
|
383 [95879] = true,
|
yellowfive@57
|
384 [95857] = true,
|
yellowfive@57
|
385 [95856] = true,
|
yellowfive@57
|
386 [95855] = true,
|
yellowfive@57
|
387 [95824] = true,
|
yellowfive@57
|
388 [95823] = true,
|
yellowfive@57
|
389 [95822] = true,
|
yellowfive@57
|
390 [95583] = true,
|
yellowfive@57
|
391 [95582] = true,
|
yellowfive@57
|
392 [95581] = true,
|
yellowfive@57
|
393 [95580] = true,
|
yellowfive@57
|
394 [95579] = true,
|
yellowfive@57
|
395 [95578] = true,
|
yellowfive@57
|
396 [95577] = true,
|
yellowfive@57
|
397 [95576] = true,
|
yellowfive@57
|
398 [95575] = true,
|
yellowfive@57
|
399 [95574] = true,
|
yellowfive@57
|
400 [95573] = true,
|
yellowfive@57
|
401 [95572] = true,
|
yellowfive@57
|
402 [95571] = true,
|
yellowfive@57
|
403 [95570] = true,
|
yellowfive@57
|
404 [95569] = true,
|
yellowfive@57
|
405 [89278] = true,
|
yellowfive@57
|
406 [89277] = true,
|
yellowfive@57
|
407 [89276] = true,
|
yellowfive@57
|
408 [89275] = true,
|
yellowfive@57
|
409 [89274] = true,
|
yellowfive@57
|
410 [89273] = true,
|
yellowfive@57
|
411 [89272] = true,
|
yellowfive@57
|
412 [89271] = true,
|
yellowfive@57
|
413 [89270] = true,
|
yellowfive@57
|
414 [89269] = true,
|
yellowfive@57
|
415 [89268] = true,
|
yellowfive@57
|
416 [89267] = true,
|
yellowfive@57
|
417 [89266] = true,
|
yellowfive@57
|
418 [89265] = true,
|
yellowfive@57
|
419 [89264] = true,
|
yellowfive@57
|
420 [89263] = true,
|
yellowfive@57
|
421 [89262] = true,
|
yellowfive@57
|
422 [89261] = true,
|
yellowfive@57
|
423 [89260] = true,
|
yellowfive@57
|
424 [89259] = true,
|
yellowfive@57
|
425 [89258] = true,
|
yellowfive@57
|
426 [89257] = true,
|
yellowfive@57
|
427 [89256] = true,
|
yellowfive@57
|
428 [89255] = true,
|
yellowfive@57
|
429 [89254] = true,
|
yellowfive@57
|
430 [89253] = true,
|
yellowfive@57
|
431 [89252] = true,
|
yellowfive@57
|
432 [89251] = true,
|
yellowfive@57
|
433 [89250] = true,
|
yellowfive@57
|
434 [89249] = true,
|
yellowfive@57
|
435 [89248] = true,
|
yellowfive@57
|
436 [89247] = true,
|
yellowfive@57
|
437 [89246] = true,
|
yellowfive@57
|
438 [89245] = true,
|
yellowfive@57
|
439 [89244] = true,
|
yellowfive@57
|
440 [89243] = true,
|
yellowfive@57
|
441 [89242] = true,
|
yellowfive@57
|
442 [89241] = true,
|
yellowfive@57
|
443 [89240] = true,
|
yellowfive@57
|
444 [89239] = true,
|
yellowfive@57
|
445 [89238] = true,
|
yellowfive@57
|
446 [89237] = true,
|
yellowfive@57
|
447 [89236] = true,
|
yellowfive@57
|
448 [89235] = true,
|
yellowfive@57
|
449 [89234] = true,
|
yellowfive@57
|
450 [78876] = true,
|
yellowfive@57
|
451 [78875] = true,
|
yellowfive@57
|
452 [78874] = true,
|
yellowfive@57
|
453 [78873] = true,
|
yellowfive@57
|
454 [78872] = true,
|
yellowfive@57
|
455 [78871] = true,
|
yellowfive@57
|
456 [78867] = true,
|
yellowfive@57
|
457 [78866] = true,
|
yellowfive@57
|
458 [78865] = true,
|
yellowfive@57
|
459 [78864] = true,
|
yellowfive@57
|
460 [78863] = true,
|
yellowfive@57
|
461 [78862] = true,
|
yellowfive@57
|
462 [78861] = true,
|
yellowfive@57
|
463 [78860] = true,
|
yellowfive@57
|
464 [78859] = true,
|
yellowfive@57
|
465 [78858] = true,
|
yellowfive@57
|
466 [78857] = true,
|
yellowfive@57
|
467 [78856] = true,
|
yellowfive@57
|
468 [78855] = true,
|
yellowfive@57
|
469 [78854] = true,
|
yellowfive@57
|
470 [78853] = true,
|
yellowfive@57
|
471 [78849] = true,
|
yellowfive@57
|
472 [78848] = true,
|
yellowfive@57
|
473 [78847] = true,
|
yellowfive@57
|
474 [78184] = true,
|
yellowfive@57
|
475 [78183] = true,
|
yellowfive@57
|
476 [78181] = true,
|
yellowfive@57
|
477 [78180] = true,
|
yellowfive@57
|
478 [78179] = true,
|
yellowfive@57
|
479 [78178] = true,
|
yellowfive@57
|
480 [78176] = true,
|
yellowfive@57
|
481 [78175] = true,
|
yellowfive@57
|
482 [78174] = true,
|
yellowfive@57
|
483 [78173] = true,
|
yellowfive@57
|
484 [78171] = true,
|
yellowfive@57
|
485 [78170] = true,
|
yellowfive@57
|
486 [71687] = true,
|
yellowfive@57
|
487 [71686] = true,
|
yellowfive@57
|
488 [71685] = true,
|
yellowfive@57
|
489 [71683] = true,
|
yellowfive@57
|
490 [71682] = true,
|
yellowfive@57
|
491 [71680] = true,
|
yellowfive@57
|
492 [71679] = true,
|
yellowfive@57
|
493 [71678] = true,
|
yellowfive@57
|
494 [71676] = true,
|
yellowfive@57
|
495 [71675] = true,
|
yellowfive@57
|
496 [71673] = true,
|
yellowfive@57
|
497 [71672] = true,
|
yellowfive@57
|
498 [71671] = true,
|
yellowfive@57
|
499 [71669] = true,
|
yellowfive@57
|
500 [71668] = true,
|
yellowfive@57
|
501 [67431] = true,
|
yellowfive@57
|
502 [67430] = true,
|
yellowfive@57
|
503 [67429] = true,
|
yellowfive@57
|
504 [67428] = true,
|
yellowfive@57
|
505 [67427] = true,
|
yellowfive@57
|
506 [67426] = true,
|
yellowfive@57
|
507 [67425] = true,
|
yellowfive@57
|
508 [67424] = true,
|
yellowfive@57
|
509 [67423] = true,
|
yellowfive@57
|
510 [66998] = true,
|
yellowfive@57
|
511 [65089] = true,
|
yellowfive@57
|
512 [65088] = true,
|
yellowfive@57
|
513 [65087] = true,
|
yellowfive@57
|
514 [63684] = true,
|
yellowfive@57
|
515 [63683] = true,
|
yellowfive@57
|
516 [63682] = true,
|
yellowfive@57
|
517 [45652] = true,
|
yellowfive@57
|
518 [45651] = true,
|
yellowfive@57
|
519 [45650] = true,
|
yellowfive@57
|
520 [45649] = true,
|
yellowfive@57
|
521 [45648] = true,
|
yellowfive@57
|
522 [45647] = true,
|
yellowfive@57
|
523 [45643] = true,
|
yellowfive@57
|
524 [45642] = true,
|
yellowfive@57
|
525 [45641] = true,
|
yellowfive@57
|
526 [40630] = true,
|
yellowfive@57
|
527 [40629] = true,
|
yellowfive@57
|
528 [40628] = true,
|
yellowfive@57
|
529 [40621] = true,
|
yellowfive@57
|
530 [40620] = true,
|
yellowfive@57
|
531 [40619] = true,
|
yellowfive@57
|
532 [40618] = true,
|
yellowfive@57
|
533 [40617] = true,
|
yellowfive@57
|
534 [40616] = true,
|
yellowfive@57
|
535 [34544] = true,
|
yellowfive@57
|
536 [31100] = true,
|
yellowfive@57
|
537 [31099] = true,
|
yellowfive@57
|
538 [31098] = true,
|
yellowfive@57
|
539 [31097] = true,
|
yellowfive@57
|
540 [31096] = true,
|
yellowfive@57
|
541 [31095] = true,
|
yellowfive@57
|
542 [30247] = true,
|
yellowfive@57
|
543 [30246] = true,
|
yellowfive@57
|
544 [30245] = true,
|
yellowfive@57
|
545 [30244] = true,
|
yellowfive@57
|
546 [30243] = true,
|
yellowfive@57
|
547 [30242] = true,
|
yellowfive@57
|
548 [29767] = true,
|
yellowfive@57
|
549 [29766] = true,
|
yellowfive@57
|
550 [29765] = true,
|
yellowfive@57
|
551 [29761] = true,
|
yellowfive@57
|
552 [29760] = true,
|
yellowfive@57
|
553 [29759] = true
|
yellowfive@57
|
554 }
|
yellowfive@57
|
555
|
yellowfive@57
|
556
|
yellowfive@57
|
557 ----------------------------------------------------------------------------------------
|
yellowfive@57
|
558 -- Public Utility Methods
|
yellowfive@57
|
559 ----------------------------------------------------------------------------------------
|
yellowfive@57
|
560
|
yellowfive@57
|
561 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r
|
yellowfive@57
|
562 -- get an object with all of the parts of the item link format that we care about
|
yellowfive@57
|
563 function Amr.ParseItemLink(itemLink)
|
yellowfive@57
|
564 if not itemLink then return nil end
|
yellowfive@57
|
565
|
yellowfive@57
|
566 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|")
|
yellowfive@57
|
567 if not str then return nil end
|
yellowfive@57
|
568
|
yellowfive@57
|
569 local parts = { strsplit(":", str) }
|
yellowfive@57
|
570
|
yellowfive@57
|
571 local item = {}
|
yellowfive@57
|
572 item.id = tonumber(parts[1])
|
yellowfive@57
|
573 item.enchantId = tonumber(parts[2])
|
yellowfive@57
|
574 item.gemIds = { tonumber(parts[3]), tonumber(parts[4]), tonumber(parts[5]), tonumber(parts[6]) }
|
yellowfive@57
|
575 item.suffixId = math.abs(tonumber(parts[7])) -- convert suffix to positive number, that's what we use in our code
|
yellowfive@57
|
576 --item.uniqueId = tonumber(parts[8])
|
yellowfive@57
|
577 --item.level = tonumber(parts[9])
|
yellowfive@57
|
578 item.upgradeId = tonumber(parts[10])
|
yellowfive@57
|
579 --item.difficultyId = tonumber(parts[11])
|
yellowfive@57
|
580
|
yellowfive@57
|
581 local numBonuses = tonumber(parts[12])
|
yellowfive@57
|
582 if numBonuses and numBonuses > 0 then
|
yellowfive@57
|
583 item.bonusIds = {}
|
yellowfive@57
|
584 for i = 13, 12 + numBonuses do
|
yellowfive@57
|
585 table.insert(item.bonusIds, tonumber(parts[i]))
|
yellowfive@57
|
586 end
|
yellowfive@57
|
587 table.sort(item.bonusIds)
|
yellowfive@57
|
588 end
|
yellowfive@57
|
589
|
yellowfive@57
|
590 return item
|
yellowfive@57
|
591 end
|
yellowfive@57
|
592
|
yellowfive@57
|
593 -- returns true if this is an instance that AskMrRobot supports for logging
|
yellowfive@57
|
594 function Amr.IsSupportedInstanceId(instanceMapID)
|
yellowfive@57
|
595 if Amr.SupportedInstanceIds[tonumber(instanceMapID)] then
|
yellowfive@57
|
596 return true
|
yellowfive@57
|
597 else
|
yellowfive@57
|
598 return false
|
yellowfive@57
|
599 end
|
yellowfive@57
|
600 end
|
yellowfive@57
|
601
|
yellowfive@57
|
602 -- returns true if currently in a supported instance for logging
|
yellowfive@57
|
603 function Amr.IsSupportedInstance()
|
yellowfive@57
|
604 local zone, _, difficultyIndex, _, _, _, _, instanceMapID = GetInstanceInfo()
|
yellowfive@57
|
605 return Amr.IsSupportedInstanceId(instanceMapID)
|
yellowfive@57
|
606 end
|
yellowfive@57
|
607
|
yellowfive@57
|
608
|
yellowfive@57
|
609 ----------------------------------------------------------------------------------------
|
yellowfive@57
|
610 -- Character Reading
|
yellowfive@57
|
611 ----------------------------------------------------------------------------------------
|
yellowfive@57
|
612
|
yellowfive@57
|
613 local function readProfessionInfo(prof, ret)
|
yellowfive@57
|
614 if prof then
|
yellowfive@57
|
615 local name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier = GetProfessionInfo(prof);
|
yellowfive@57
|
616 if Amr.ProfessionSkillLineToName[skillLine] ~= nil then
|
yellowfive@57
|
617 ret.Professions[Amr.ProfessionSkillLineToName[skillLine]] = skillLevel;
|
yellowfive@57
|
618 end
|
yellowfive@57
|
619 end
|
yellowfive@57
|
620 end
|
yellowfive@57
|
621
|
yellowfive@57
|
622 local function getSpecId(specGroup)
|
yellowfive@57
|
623 local spec = GetSpecialization(false, false, specGroup);
|
yellowfive@57
|
624 return spec and GetSpecializationInfo(spec);
|
yellowfive@57
|
625 end
|
yellowfive@57
|
626
|
yellowfive@57
|
627 local function getTalents(specGroup)
|
yellowfive@57
|
628 local talentInfo = {}
|
yellowfive@57
|
629 local maxTiers = 7
|
yellowfive@57
|
630 for tier = 1, maxTiers do
|
yellowfive@57
|
631 for col = 1, 3 do
|
yellowfive@57
|
632 local id, name, texture, selected, available = GetTalentInfo(tier, col, specGroup)
|
yellowfive@57
|
633 if selected then
|
yellowfive@57
|
634 talentInfo[tier] = col
|
yellowfive@57
|
635 end
|
yellowfive@57
|
636 end
|
yellowfive@57
|
637 end
|
yellowfive@57
|
638
|
yellowfive@57
|
639 local str = ""
|
yellowfive@57
|
640 for i = 1, maxTiers do
|
yellowfive@57
|
641 if talentInfo[i] then
|
yellowfive@57
|
642 str = str .. talentInfo[i]
|
yellowfive@57
|
643 else
|
yellowfive@57
|
644 str = str .. '0'
|
yellowfive@57
|
645 end
|
yellowfive@57
|
646 end
|
yellowfive@57
|
647
|
yellowfive@57
|
648 return str
|
yellowfive@57
|
649 end
|
yellowfive@57
|
650
|
yellowfive@57
|
651 local function getGlyphs(specGroup)
|
yellowfive@57
|
652 local glyphs = {}
|
yellowfive@57
|
653 for i = 1, NUM_GLYPH_SLOTS do
|
yellowfive@57
|
654 local _, _, _, glyphSpellID, _, glyphID = GetGlyphSocketInfo(i, specGroup)
|
yellowfive@57
|
655 if (glyphID) then
|
yellowfive@57
|
656 table.insert(glyphs, glyphSpellID)
|
yellowfive@57
|
657 end
|
yellowfive@57
|
658 end
|
yellowfive@57
|
659 return glyphs;
|
yellowfive@57
|
660 end
|
yellowfive@57
|
661
|
yellowfive@57
|
662 -- get specs, talents, and glyphs
|
yellowfive@57
|
663 local function readSpecs(ret, subspecs)
|
yellowfive@57
|
664
|
yellowfive@57
|
665 for group = 1, GetNumSpecGroups() do
|
yellowfive@57
|
666 -- spec, convert game spec id to one of our spec ids
|
yellowfive@57
|
667 local specId = getSpecId(group)
|
yellowfive@57
|
668 if specId then
|
yellowfive@57
|
669 ret.Specs[group] = Amr.SpecIds[specId]
|
yellowfive@57
|
670
|
yellowfive@57
|
671 -- if this is a protection warrior, use buffs to determine subspec
|
yellowfive@57
|
672 if ret.Specs[group] == Amr.SPEC_WARRIORPROTECTION then
|
yellowfive@57
|
673 local subspec = 0
|
yellowfive@57
|
674
|
yellowfive@57
|
675 if ret.ActiveSpec ~= group then
|
yellowfive@57
|
676 -- this spec isn't active, so we can't use current buffs to determine spec, see if any old data is compatible
|
yellowfive@57
|
677 if subspecs and (subspecs[group] == Amr.SUBSPEC_WARRIORPROTECTION or subspecs[group] == Amr.SUBSPEC_WARRIORPROTECTIONGLAD) then
|
yellowfive@57
|
678 subspec = subspecs[group]
|
yellowfive@57
|
679 end
|
yellowfive@57
|
680 else
|
yellowfive@57
|
681 for i=1,40 do
|
yellowfive@57
|
682 local name,_,_,_,_,_,_,_,_,_,spellId = UnitAura("player", i, "HELPFUL")
|
yellowfive@57
|
683 if not name then break end
|
yellowfive@57
|
684
|
yellowfive@57
|
685 if spellId == Amr.SPELL_ID_DEFENSIVE_STANCE then
|
yellowfive@57
|
686 subspec = Amr.SUBSPEC_WARRIORPROTECTION
|
yellowfive@57
|
687 break
|
yellowfive@57
|
688 elseif spellId == Amr.SPELL_ID_GLADIATOR_STANCE then
|
yellowfive@57
|
689 subspec = Amr.SUBSPEC_WARRIORPROTECTIONGLAD
|
yellowfive@57
|
690 break
|
yellowfive@57
|
691 end
|
yellowfive@57
|
692 end
|
yellowfive@57
|
693 end
|
yellowfive@57
|
694
|
yellowfive@57
|
695 if subspec == 0 then
|
yellowfive@57
|
696 ret.SubSpecs[group] = nil
|
yellowfive@57
|
697 else
|
yellowfive@57
|
698 ret.SubSpecs[group] = subspec
|
yellowfive@57
|
699 end
|
yellowfive@57
|
700 end
|
yellowfive@57
|
701 else
|
yellowfive@57
|
702 ret.Specs[group] = 0
|
yellowfive@57
|
703 end
|
yellowfive@57
|
704
|
yellowfive@57
|
705 ret.Talents[group] = getTalents(group)
|
yellowfive@57
|
706 ret.Glyphs[group] = getGlyphs(group)
|
yellowfive@57
|
707 end
|
yellowfive@57
|
708 end
|
yellowfive@57
|
709
|
yellowfive@57
|
710 -- get currently equipped items, store with currently active spec
|
yellowfive@57
|
711 local function readEquippedItems(ret)
|
yellowfive@57
|
712 local equippedItems = {};
|
yellowfive@57
|
713 for slotNum = 1, #Amr.SlotIds do
|
yellowfive@57
|
714 local slotId = Amr.SlotIds[slotNum]
|
yellowfive@57
|
715 local itemLink = GetInventoryItemLink("player", slotId)
|
yellowfive@57
|
716 if itemLink then
|
yellowfive@57
|
717 equippedItems[slotId] = itemLink
|
yellowfive@57
|
718 end
|
yellowfive@57
|
719 end
|
yellowfive@57
|
720
|
yellowfive@57
|
721 -- store last-seen equipped gear for each spec
|
yellowfive@57
|
722 ret.Equipped[GetActiveSpecGroup()] = equippedItems
|
yellowfive@57
|
723 end
|
yellowfive@57
|
724
|
yellowfive@57
|
725 -- Get all data about the player as an object, includes:
|
yellowfive@57
|
726 -- serializer version
|
yellowfive@57
|
727 -- region/realm/name
|
yellowfive@57
|
728 -- guild
|
yellowfive@57
|
729 -- race
|
yellowfive@57
|
730 -- faction
|
yellowfive@57
|
731 -- level
|
yellowfive@57
|
732 -- professions
|
yellowfive@57
|
733 -- spec/talent/glyphs for both specs
|
yellowfive@57
|
734 -- equipped gear for the current spec
|
yellowfive@57
|
735 --
|
yellowfive@57
|
736 function Amr:GetPlayerData(subspecs)
|
yellowfive@57
|
737
|
yellowfive@57
|
738 local ret = {}
|
yellowfive@57
|
739
|
yellowfive@57
|
740 ret.Region = Amr.RegionNames[GetCurrentRegion()]
|
yellowfive@57
|
741 ret.Realm = GetRealmName()
|
yellowfive@57
|
742 ret.Name = UnitName("player")
|
yellowfive@57
|
743 ret.Guild = GetGuildInfo("player")
|
yellowfive@57
|
744 ret.ActiveSpec = GetActiveSpecGroup()
|
yellowfive@57
|
745 ret.Level = UnitLevel("player");
|
yellowfive@57
|
746
|
yellowfive@57
|
747 local cls, clsEn = UnitClass("player")
|
yellowfive@57
|
748 ret.Class = clsEn;
|
yellowfive@57
|
749
|
yellowfive@57
|
750 local race, raceEn = UnitRace("player")
|
yellowfive@57
|
751 ret.Race = raceEn;
|
yellowfive@57
|
752 ret.Faction = UnitFactionGroup("player")
|
yellowfive@57
|
753
|
yellowfive@57
|
754 ret.Professions = {};
|
yellowfive@57
|
755 local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions();
|
yellowfive@57
|
756 readProfessionInfo(prof1, ret)
|
yellowfive@57
|
757 readProfessionInfo(prof2, ret)
|
yellowfive@57
|
758 readProfessionInfo(archaeology, ret)
|
yellowfive@57
|
759 readProfessionInfo(fishing, ret)
|
yellowfive@57
|
760 readProfessionInfo(cooking, ret)
|
yellowfive@57
|
761 readProfessionInfo(firstAid, ret)
|
yellowfive@57
|
762
|
yellowfive@57
|
763 ret.Specs = {}
|
yellowfive@57
|
764 ret.SubSpecs = {} -- only filled in for ambiguous cases, right now just prot/glad warrior
|
yellowfive@57
|
765 ret.Talents = {}
|
yellowfive@57
|
766 ret.Glyphs = {}
|
yellowfive@57
|
767 readSpecs(ret, subspecs)
|
yellowfive@57
|
768
|
yellowfive@57
|
769 ret.Equipped = {}
|
yellowfive@57
|
770 readEquippedItems(ret)
|
yellowfive@57
|
771
|
yellowfive@57
|
772 return ret
|
yellowfive@57
|
773 end
|
yellowfive@57
|
774
|
yellowfive@57
|
775
|
yellowfive@57
|
776 ----------------------------------------------------------------------------------------
|
yellowfive@57
|
777 -- Serialization
|
yellowfive@57
|
778 ----------------------------------------------------------------------------------------
|
yellowfive@57
|
779
|
yellowfive@57
|
780 local function toCompressedNumberList(list)
|
yellowfive@57
|
781 -- ensure the values are numbers, sorted from lowest to highest
|
yellowfive@57
|
782 local nums = {}
|
yellowfive@57
|
783 for i, v in ipairs(list) do
|
yellowfive@57
|
784 table.insert(nums, tonumber(v))
|
yellowfive@57
|
785 end
|
yellowfive@57
|
786 table.sort(nums)
|
yellowfive@57
|
787
|
yellowfive@57
|
788 local ret = {}
|
yellowfive@57
|
789 local prev = 0
|
yellowfive@57
|
790 for i, v in ipairs(nums) do
|
yellowfive@57
|
791 local diff = v - prev
|
yellowfive@57
|
792 table.insert(ret, diff)
|
yellowfive@57
|
793 prev = v
|
yellowfive@57
|
794 end
|
yellowfive@57
|
795
|
yellowfive@57
|
796 return table.concat(ret, ",")
|
yellowfive@57
|
797 end
|
yellowfive@57
|
798
|
yellowfive@57
|
799 -- make this utility publicly available
|
yellowfive@57
|
800 function Amr:ToCompressedNumberList(list)
|
yellowfive@57
|
801 return toCompressedNumberList(list)
|
yellowfive@57
|
802 end
|
yellowfive@57
|
803
|
yellowfive@57
|
804 -- appends a list of items to the export
|
yellowfive@57
|
805 local function appendItemsToExport(fields, itemObjects)
|
yellowfive@57
|
806
|
yellowfive@57
|
807 -- sort by item id so we can compress it more easily
|
yellowfive@57
|
808 table.sort(itemObjects, function(a, b) return a.id < b.id end)
|
yellowfive@57
|
809
|
yellowfive@57
|
810 -- append to the export string
|
yellowfive@57
|
811 local prevItemId = 0
|
yellowfive@57
|
812 local prevGemId = 0
|
yellowfive@57
|
813 local prevEnchantId = 0
|
yellowfive@57
|
814 local prevUpgradeId = 0
|
yellowfive@57
|
815 local prevBonusId = 0
|
yellowfive@57
|
816 for i, itemData in ipairs(itemObjects) do
|
yellowfive@57
|
817 local itemParts = {}
|
yellowfive@57
|
818
|
yellowfive@57
|
819 table.insert(itemParts, itemData.id - prevItemId)
|
yellowfive@57
|
820 prevItemId = itemData.id
|
yellowfive@57
|
821
|
yellowfive@57
|
822 if itemData.slot ~= nil then table.insert(itemParts, "s" .. itemData.slot) end
|
yellowfive@57
|
823 if itemData.suffixId ~= 0 then table.insert(itemParts, "f" .. itemData.suffixId) end
|
yellowfive@57
|
824 if itemData.upgradeId ~= 0 then
|
yellowfive@57
|
825 table.insert(itemParts, "u" .. (itemData.upgradeId - prevUpgradeId))
|
yellowfive@57
|
826 prevUpgradeId = itemData.upgradeId
|
yellowfive@57
|
827 end
|
yellowfive@57
|
828 if itemData.bonusIds then
|
yellowfive@57
|
829 for bIndex, bValue in ipairs(itemData.bonusIds) do
|
yellowfive@57
|
830 table.insert(itemParts, "b" .. (bValue - prevBonusId))
|
yellowfive@57
|
831 prevBonusId = bValue
|
yellowfive@57
|
832 end
|
yellowfive@57
|
833 end
|
yellowfive@57
|
834 if itemData.gemIds[1] ~= 0 then
|
yellowfive@57
|
835 table.insert(itemParts, "x" .. (itemData.gemIds[1] - prevGemId))
|
yellowfive@57
|
836 prevGemId = itemData.gemIds[1]
|
yellowfive@57
|
837 end
|
yellowfive@57
|
838 if itemData.gemIds[2] ~= 0 then
|
yellowfive@57
|
839 table.insert(itemParts, "y" .. (itemData.gemIds[2] - prevGemId))
|
yellowfive@57
|
840 prevGemId = itemData.gemIds[2]
|
yellowfive@57
|
841 end
|
yellowfive@57
|
842 if itemData.gemIds[3] ~= 0 then
|
yellowfive@57
|
843 table.insert(itemParts, "z" .. (itemData.gemIds[3] - prevGemId))
|
yellowfive@57
|
844 prevGemId = itemData.gemIds[3]
|
yellowfive@57
|
845 end
|
yellowfive@57
|
846 if itemData.enchantId ~= 0 then
|
yellowfive@57
|
847 table.insert(itemParts, "e" .. (itemData.enchantId - prevEnchantId))
|
yellowfive@57
|
848 prevEnchantId = itemData.enchantId
|
yellowfive@57
|
849 end
|
yellowfive@57
|
850
|
yellowfive@57
|
851 table.insert(fields, table.concat(itemParts, ""))
|
yellowfive@57
|
852 end
|
yellowfive@57
|
853 end
|
yellowfive@57
|
854
|
yellowfive@57
|
855 -- Serialize just the identity portion of a player (region/realm/name) in the same format used by the full serialization
|
yellowfive@57
|
856 function Amr:SerializePlayerIdentity(data)
|
yellowfive@57
|
857 local fields = {}
|
yellowfive@57
|
858 table.insert(fields, MINOR)
|
yellowfive@57
|
859 table.insert(fields, data.Region)
|
yellowfive@57
|
860 table.insert(fields, data.Realm)
|
yellowfive@57
|
861 table.insert(fields, data.Name)
|
yellowfive@57
|
862 return "$" .. table.concat(fields, ";") .. "$"
|
yellowfive@57
|
863 end
|
yellowfive@57
|
864
|
yellowfive@57
|
865 -- Serialize player data gathered by GetPlayerData. This can be augmented with extra data if desired (augmenting used mainly by AskMrRobot addon).
|
yellowfive@57
|
866 -- Pass complete = true to do a complete export of this extra information, otherwise it is ignored.
|
yellowfive@57
|
867 -- Extra data can include:
|
yellowfive@57
|
868 -- equipped gear for the player's inactive spec, slot id to item link dictionary
|
yellowfive@57
|
869 -- Reputations
|
yellowfive@57
|
870 -- BagItems, BankItems, VoidItems, lists of item links
|
yellowfive@57
|
871 --
|
yellowfive@57
|
872 function Amr:SerializePlayerData(data, complete)
|
yellowfive@57
|
873
|
yellowfive@57
|
874 local fields = {}
|
yellowfive@57
|
875
|
yellowfive@57
|
876 -- compressed string uses a fixed order rather than inserting identifiers
|
yellowfive@57
|
877 table.insert(fields, MINOR)
|
yellowfive@57
|
878 table.insert(fields, data.Region)
|
yellowfive@57
|
879 table.insert(fields, data.Realm)
|
yellowfive@57
|
880 table.insert(fields, data.Name)
|
yellowfive@57
|
881
|
yellowfive@57
|
882 -- guild name
|
yellowfive@57
|
883 if data.Guild == nil then
|
yellowfive@57
|
884 table.insert(fields, "")
|
yellowfive@57
|
885 else
|
yellowfive@57
|
886 table.insert(fields, data.Guild)
|
yellowfive@57
|
887 end
|
yellowfive@57
|
888
|
yellowfive@57
|
889 -- race, default to pandaren if we can't read it for some reason
|
yellowfive@57
|
890 local raceval = Amr.RaceIds[data.Race]
|
yellowfive@57
|
891 if raceval == nil then raceval = 13 end
|
yellowfive@57
|
892 table.insert(fields, raceval)
|
yellowfive@57
|
893
|
yellowfive@57
|
894 -- faction, default to alliance if we can't read it for some reason
|
yellowfive@57
|
895 raceval = Amr.FactionIds[data.Faction]
|
yellowfive@57
|
896 if raceval == nil then raceval = 1 end
|
yellowfive@57
|
897 table.insert(fields, raceval)
|
yellowfive@57
|
898
|
yellowfive@57
|
899 table.insert(fields, data.Level)
|
yellowfive@57
|
900
|
yellowfive@57
|
901 local profs = {}
|
yellowfive@57
|
902 local noprofs = true
|
yellowfive@57
|
903 if data.Professions then
|
yellowfive@57
|
904 for k, v in pairs(data.Professions) do
|
yellowfive@57
|
905 local profval = Amr.ProfessionIds[k]
|
yellowfive@57
|
906 if profval ~= nil then
|
yellowfive@57
|
907 noprofs = false
|
yellowfive@57
|
908 table.insert(profs, profval .. ":" .. v)
|
yellowfive@57
|
909 end
|
yellowfive@57
|
910 end
|
yellowfive@57
|
911 end
|
yellowfive@57
|
912
|
yellowfive@57
|
913 if noprofs then
|
yellowfive@57
|
914 table.insert(profs, "0:0")
|
yellowfive@57
|
915 end
|
yellowfive@57
|
916
|
yellowfive@57
|
917 table.insert(fields, table.concat(profs, ","))
|
yellowfive@57
|
918
|
yellowfive@57
|
919 -- export specs
|
yellowfive@57
|
920 table.insert(fields, data.ActiveSpec)
|
yellowfive@57
|
921 for spec = 1, 2 do
|
yellowfive@57
|
922 if data.Specs[spec] and (complete or spec == data.ActiveSpec) then
|
yellowfive@57
|
923 table.insert(fields, ".s" .. spec) -- indicates the start of a spec block
|
yellowfive@57
|
924
|
yellowfive@57
|
925 -- we use subspec for some ambiguous specs like prot/glad warrior
|
yellowfive@57
|
926 if data.SubSpecs[spec] then
|
yellowfive@57
|
927 table.insert(fields, string.format("s%s", data.SubSpecs[spec]))
|
yellowfive@57
|
928 else
|
yellowfive@57
|
929 table.insert(fields, data.Specs[spec])
|
yellowfive@57
|
930 end
|
yellowfive@57
|
931
|
yellowfive@57
|
932 table.insert(fields, data.Talents[spec])
|
yellowfive@57
|
933 table.insert(fields, toCompressedNumberList(data.Glyphs[spec]))
|
yellowfive@57
|
934 end
|
yellowfive@57
|
935 end
|
yellowfive@57
|
936
|
yellowfive@57
|
937 -- export equipped gear
|
yellowfive@57
|
938 if data.Equipped then
|
yellowfive@57
|
939 for spec = 1, 2 do
|
yellowfive@57
|
940 if data.Equipped[spec] and (complete or spec == data.ActiveSpec) then
|
yellowfive@57
|
941 table.insert(fields, ".q" .. spec) -- indicates the start of an equipped gear block
|
yellowfive@57
|
942
|
yellowfive@57
|
943 local itemObjects = {}
|
yellowfive@57
|
944 for k, v in pairs(data.Equipped[spec]) do
|
yellowfive@57
|
945 local itemData = Amr.ParseItemLink(v)
|
yellowfive@57
|
946 itemData.slot = k
|
yellowfive@57
|
947 table.insert(itemObjects, itemData)
|
yellowfive@57
|
948 end
|
yellowfive@57
|
949
|
yellowfive@57
|
950 appendItemsToExport(fields, itemObjects)
|
yellowfive@57
|
951 end
|
yellowfive@57
|
952 end
|
yellowfive@57
|
953 end
|
yellowfive@57
|
954
|
yellowfive@57
|
955 -- if doing a complete export, include reputations and bank/bag items too
|
yellowfive@57
|
956 if complete then
|
yellowfive@57
|
957
|
yellowfive@57
|
958 -- export reputations
|
yellowfive@57
|
959 local reps = {}
|
yellowfive@57
|
960 local noreps = true
|
yellowfive@57
|
961 if data.Reputations then
|
yellowfive@57
|
962 for k, v in pairs(data.Reputations) do
|
yellowfive@57
|
963 noreps = false
|
yellowfive@57
|
964 table.insert(reps, k .. ":" .. v)
|
yellowfive@57
|
965 end
|
yellowfive@57
|
966 end
|
yellowfive@57
|
967 if noreps then
|
yellowfive@57
|
968 table.insert(reps, "_")
|
yellowfive@57
|
969 end
|
yellowfive@57
|
970
|
yellowfive@57
|
971 table.insert(fields, ".r")
|
yellowfive@57
|
972 table.insert(fields, table.concat(reps, ","))
|
yellowfive@57
|
973
|
yellowfive@57
|
974 -- export bag and bank
|
yellowfive@57
|
975 local itemObjects = {}
|
yellowfive@57
|
976 if data.BagItems then
|
yellowfive@57
|
977 for i, v in ipairs(data.BagItems) do
|
yellowfive@57
|
978 local itemData = Amr.ParseItemLink(v)
|
yellowfive@57
|
979 if itemData ~= nil and (IsEquippableItem(v) or Amr.SetTokenIds[itemData.id]) then
|
yellowfive@57
|
980 table.insert(itemObjects, itemData)
|
yellowfive@57
|
981 end
|
yellowfive@57
|
982 end
|
yellowfive@57
|
983 end
|
yellowfive@57
|
984 if data.BankItems then
|
yellowfive@57
|
985 for i, v in ipairs(data.BankItems) do
|
yellowfive@57
|
986 local itemData = Amr.ParseItemLink(v)
|
yellowfive@57
|
987 if itemData ~= nil and (IsEquippableItem(v) or Amr.SetTokenIds[itemData.id]) then
|
yellowfive@57
|
988 table.insert(itemObjects, itemData)
|
yellowfive@57
|
989 end
|
yellowfive@57
|
990 end
|
yellowfive@57
|
991 end
|
yellowfive@57
|
992 if data.VoidItems then
|
yellowfive@57
|
993 for i, v in ipairs(data.VoidItems) do
|
yellowfive@57
|
994 local itemData = Amr.ParseItemLink(v)
|
yellowfive@57
|
995 if itemData ~= nil and (IsEquippableItem(v) or Amr.SetTokenIds[itemData.id]) then
|
yellowfive@57
|
996 table.insert(itemObjects, itemData)
|
yellowfive@57
|
997 end
|
yellowfive@57
|
998 end
|
yellowfive@57
|
999 end
|
yellowfive@57
|
1000
|
yellowfive@57
|
1001 table.insert(fields, ".inv")
|
yellowfive@57
|
1002 appendItemsToExport(fields, itemObjects)
|
yellowfive@57
|
1003 end
|
yellowfive@57
|
1004
|
yellowfive@57
|
1005 return "$" .. table.concat(fields, ";") .. "$"
|
yellowfive@57
|
1006
|
yellowfive@57
|
1007 end
|
yellowfive@57
|
1008
|
yellowfive@57
|
1009 -- Shortcut for the common use case: serialize the player's currently active setup with no extras.
|
yellowfive@57
|
1010 function Amr:SerializePlayer()
|
yellowfive@57
|
1011 local data = self:GetPlayerData()
|
yellowfive@57
|
1012 return self:SerializePlayerData(data)
|
yellowfive@57
|
1013 end
|
yellowfive@57
|
1014
|
yellowfive@57
|
1015
|
yellowfive@57
|
1016 ----------------------------------------------------------------------------------------------------------------------
|
yellowfive@57
|
1017 -- Character Snapshots
|
yellowfive@57
|
1018 -- This feature snapshots a player's gear/talents/glyphs when entering combat. It is enabled by default. Consumers
|
yellowfive@57
|
1019 -- of this library can create a setting to enable/disable it as desired per a user setting.
|
yellowfive@57
|
1020 --
|
yellowfive@57
|
1021 -- You should register for the AMR_SNAPSHOT_STATE_CHANGED message (sent via AceEvent-3.0 messaging) to ensure that
|
yellowfive@57
|
1022 -- your addon settings stay in sync with any other addon that may also be trying to control the enabled state.
|
yellowfive@57
|
1023 --
|
yellowfive@57
|
1024 -- Note that if a user has the main AMR addon installed, it will always enable snapshotting, and override any attempt
|
yellowfive@57
|
1025 -- to disable it by immediately re-enabling it and thus re-triggering AMR_SNAPSHOT_STATE_CHANGED.
|
yellowfive@57
|
1026 ----------------------------------------------------------------------------------------------------------------------
|
yellowfive@57
|
1027 Amr._snapshotEnabled = true
|
yellowfive@57
|
1028
|
yellowfive@57
|
1029 -- Enable snapshotting of character data when entering combat. Sends this player's character data to anyone logging with the AskMrRobot addon.
|
yellowfive@57
|
1030 function Amr:EnableSnapshots()
|
yellowfive@57
|
1031 self._snapshotEnabled = true
|
yellowfive@57
|
1032 self:SendMessage("AMR_SNAPSHOT_STATE_CHANGED", self._snapshotEnabled)
|
yellowfive@57
|
1033 end
|
yellowfive@57
|
1034
|
yellowfive@57
|
1035 -- Disable snapshotting of character data when entering combat.
|
yellowfive@57
|
1036 function Amr:DisableSnapshots()
|
yellowfive@57
|
1037 self._snapshotEnabled = false
|
yellowfive@57
|
1038 self:SendMessage("AMR_SNAPSHOT_STATE_CHANGED", self._snapshotEnabled)
|
yellowfive@57
|
1039 end
|
yellowfive@57
|
1040
|
yellowfive@57
|
1041 function Amr:IsSnapshotEnabled()
|
yellowfive@57
|
1042 return self._snapshotEnabled
|
yellowfive@57
|
1043 end
|
yellowfive@57
|
1044
|
yellowfive@57
|
1045
|
yellowfive@57
|
1046 function Amr:PLAYER_REGEN_DISABLED()
|
yellowfive@57
|
1047 --function Amr:GARRISON_MISSION_NPC_OPENED()
|
yellowfive@57
|
1048
|
yellowfive@57
|
1049 -- send data about this character when a player enters combat in a supported zone
|
yellowfive@57
|
1050 if self._snapshotEnabled and Amr.IsSupportedInstance() then
|
yellowfive@57
|
1051 local t = time()
|
yellowfive@57
|
1052 local player = self:GetPlayerData()
|
yellowfive@57
|
1053 local msg = self:SerializePlayerData(player)
|
yellowfive@57
|
1054 msg = string.format("%s\r%s\n%s\n%s\n%s\n%s", MINOR, t, player.Region, player.Realm, player.Name, msg)
|
yellowfive@57
|
1055
|
yellowfive@57
|
1056 self:SendCommMessage(Amr.ChatPrefix, msg, "RAID")
|
yellowfive@57
|
1057 end
|
yellowfive@57
|
1058 end
|
yellowfive@57
|
1059
|
yellowfive@57
|
1060 Amr:RegisterEvent("PLAYER_REGEN_DISABLED")
|
yellowfive@57
|
1061 --Amr:RegisterEvent("GARRISON_MISSION_NPC_OPENED") -- for debugging, fire this event when open mission table |