Mercurial > wow > askmrrobot
comparison amr-constants.lua @ 17:e77e01abce98
Warlords of Draenor pre-patch
author | Adam tegen <adam.tegen@gmail.com> |
---|---|
date | Mon, 13 Oct 2014 21:28:32 -0500 |
parents | |
children | eca0f3b6d141 |
comparison
equal
deleted
inserted
replaced
16:9793e8b683d2 | 17:e77e01abce98 |
---|---|
1 local _, AskMrRobot = ... | |
2 local L = AskMrRobot.L; | |
3 | |
4 -- item link format: |cffa335ee|Hitem:itemID:enchant:gem1:gem2:gem3:gem4:suffixID:uniqueID:level:upgradeId:instanceDifficultyID:numBonusIDs:bonusID1:bonusID2...|h[item name]|h|r | |
5 | |
6 -- get an object with all of the parts fo the item link format that we care about | |
7 function AskMrRobot.parseItemLink(itemLink) | |
8 if not itemLink then return nil end | |
9 | |
10 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|") | |
11 if not str then return nil end | |
12 | |
13 local parts = { strsplit(":", str) } | |
14 | |
15 local item = {} | |
16 item.id = tonumber(parts[1]) | |
17 item.enchantId = tonumber(parts[2]) | |
18 item.gemIds = { tonumber(parts[3]), tonumber(parts[4]), tonumber(parts[5]), tonumber(parts[6]) } | |
19 item.suffixId = math.abs(tonumber(parts[7])) -- convert suffix to positive number, that's what we use in our code | |
20 --item.uniqueId = tonumber(parts[8]) | |
21 --item.level = tonumber(parts[9]) | |
22 item.upgradeId = tonumber(parts[10]) | |
23 --item.difficultyId = tonumber(parts[11]) | |
24 | |
25 local numBonuses = tonumber(parts[12]) | |
26 if numBonuses > 0 then | |
27 item.bonusIds = {} | |
28 for i = 13, 12 + numBonuses do | |
29 table.insert(item.bonusIds, tonumber(parts[i])) | |
30 end | |
31 end | |
32 | |
33 return item | |
34 end | |
35 | |
36 -- convenience to get just the item id (or 0 if not a valid link) from an item link | |
37 function AskMrRobot.getItemIdFromLink(itemLink) | |
38 if not itemLink then return 0 end | |
39 local parts = { strsplit(":", itemLink) } | |
40 local id = tonumber(parts[2]) | |
41 return (id and id ~= 0 and id or 0) | |
42 end | |
43 | |
44 function AskMrRobot.getItemUniqueId(item, noUpgrade) | |
45 if item == nil then return "" end | |
46 local ret = item.id .. "" | |
47 if item.bonusIds then | |
48 for i = 1, #item.bonusIds do | |
49 ret = ret .. "b" .. item.bonusIds[i] | |
50 end | |
51 end | |
52 if item.suffixId ~= 0 then | |
53 ret = ret .. "s" .. item.suffixId | |
54 end | |
55 if not noUpgrade and item.upgradeId ~= 0 then | |
56 ret = ret .. "u" .. item.upgradeId | |
57 end | |
58 return ret | |
59 end | |
60 | |
61 AskMrRobot.instanceIds = { | |
62 HeartOfFear = 1009, | |
63 MogushanVaults = 1008, | |
64 SiegeOfOrgrimmar = 1136, | |
65 TerraceOfEndlessSpring = 996, | |
66 ThroneOfThunder = 1098 | |
67 } | |
68 | |
69 -- instances that we currently support logging for | |
70 AskMrRobot.supportedInstanceIds = { | |
71 [1136] = true | |
72 } | |
73 | |
74 -- returns true if currently in a supported instance | |
75 function AskMrRobot.IsSupportedInstance() | |
76 | |
77 local zone, _, difficultyIndex, _, _, _, _, instanceMapID = GetInstanceInfo() | |
78 if AskMrRobot.supportedInstanceIds[tonumber(instanceMapID)] then | |
79 return true | |
80 else | |
81 return false | |
82 end | |
83 end | |
84 | |
85 AskMrRobot.classIds = { | |
86 ["NONE"] = 0, | |
87 ["DEATHKNIGHT"] = 1, | |
88 ["DRUID"] = 2, | |
89 ["HUNTER"] = 3, | |
90 ["MAGE"] = 4, | |
91 ["MONK"] = 5, | |
92 ["PALADIN"] = 6, | |
93 ["PRIEST"] = 7, | |
94 ["ROGUE"] = 8, | |
95 ["SHAMAN"] = 9, | |
96 ["WARLOCK"] = 10, | |
97 ["WARRIOR"] = 11, | |
98 } | |
99 | |
100 AskMrRobot.professionIds = { | |
101 ["None"] = 0, | |
102 ["Mining"] = 1, | |
103 ["Skinning"] = 2, | |
104 ["Herbalism"] = 3, | |
105 ["Enchanting"] = 4, | |
106 ["Jewelcrafting"] = 5, | |
107 ["Engineering"] = 6, | |
108 ["Blacksmithing"] = 7, | |
109 ["Leatherworking"] = 8, | |
110 ["Inscription"] = 9, | |
111 ["Tailoring"] = 10, | |
112 ["Alchemy"] = 11, | |
113 ["Fishing"] = 12, | |
114 ["Cooking"] = 13, | |
115 ["First Aid"] = 14, | |
116 ["Archaeology"] = 15 | |
117 } | |
118 | |
119 AskMrRobot.raceIds = { | |
120 ["None"] = 0, | |
121 ["BloodElf"] = 1, | |
122 ["Draenei"] = 2, | |
123 ["Dwarf"] = 3, | |
124 ["Gnome"] = 4, | |
125 ["Human"] = 5, | |
126 ["NightElf"] = 6, | |
127 ["Orc"] = 7, | |
128 ["Tauren"] = 8, | |
129 ["Troll"] = 9, | |
130 ["Scourge"] = 10, | |
131 ["Undead"] = 10, | |
132 ["Goblin"] = 11, | |
133 ["Worgen"] = 12, | |
134 ["Pandaren"] = 13 | |
135 } | |
136 | |
137 AskMrRobot.factionIds = { | |
138 ["None"] = 0, | |
139 ["Alliance"] = 1, | |
140 ["Horde"] = 2 | |
141 } | |
142 | |
143 AskMrRobot.specIds = { | |
144 [250] = 1, -- DeathKnightBlood | |
145 [251] = 2, -- DeathKnightFrost | |
146 [252] = 3, -- DeathKnightUnholy | |
147 [102] = 4, -- DruidBalance | |
148 [103] = 5, -- DruidFeral | |
149 [104] = 6, -- DruidGuardian | |
150 [105] = 7, -- DruidRestoration | |
151 [253] = 8, -- HunterBeastMastery | |
152 [254] = 9, -- HunterMarksmanship | |
153 [255] = 10, -- HunterSurvival | |
154 [62] = 11, -- MageArcane | |
155 [63] = 12, -- MageFire | |
156 [64] = 13, -- MageFrost | |
157 [268] = 14, -- MonkBrewmaster | |
158 [269] = 15, -- MonkMistweaver | |
159 [270] = 16, -- MonkWindwalker | |
160 [65] = 17, -- PaladinHoly | |
161 [66] = 18, -- PaladinProtection | |
162 [70] = 19, -- PaladinRetribution | |
163 [256] = 20, -- PriestDiscipline | |
164 [257] = 21, -- PriestHoly | |
165 [258] = 22, -- PriestShadow | |
166 [259] = 23, -- RogueAssassination | |
167 [260] = 24, -- RogueCombat | |
168 [261] = 25, -- RogueSubtlety | |
169 [262] = 26, -- ShamanElemental | |
170 [263] = 27, -- ShamanEnhancement | |
171 [264] = 28, -- ShamanRestoration | |
172 [265] = 29, -- WarlockAffliction | |
173 [266] = 30, -- WarlockDemonology | |
174 [267] = 31, -- WarlockDestruction | |
175 [71] = 32, -- WarriorArms | |
176 [72] = 33, -- WarriorFury | |
177 [73] = 34 -- WarriorProtection | |
178 } | |
179 | |
180 -- reverse map of our spec ID to the game's spec ID | |
181 AskMrRobot.gameSpecIds = {} | |
182 for k,v in pairs(AskMrRobot.specIds) do | |
183 AskMrRobot.gameSpecIds[v] = k | |
184 end | |
185 | |
186 -- lookup from our socket color ID to string | |
187 AskMrRobot.socketColorIds = { | |
188 [0] = "Prismatic", | |
189 [1] = "Red", | |
190 [2] = "Yellow", | |
191 [3] = "Blue", | |
192 [4] = "Meta", | |
193 [5] = "Cogwheel", | |
194 [6] = "ShaTouched" | |
195 } | |
196 | |
197 -- map of game slot names to slot IDs (same both in our code and in-game) | |
198 AskMrRobot.slotNameToId = { | |
199 ["HeadSlot"] = 1, | |
200 ["NeckSlot"] = 2, | |
201 ["ShoulderSlot"] = 3, | |
202 ["ChestSlot"] = 5, | |
203 ["WaistSlot"] = 6, | |
204 ["LegsSlot"] = 7, | |
205 ["FeetSlot"] = 8, | |
206 ["WristSlot"] = 9, | |
207 ["HandsSlot"] = 10, | |
208 ["Finger0Slot"] = 11, | |
209 ["Finger1Slot"] = 12, | |
210 ["Trinket0Slot"] = 13, | |
211 ["Trinket1Slot"] = 14, | |
212 ["BackSlot"] = 15, | |
213 ["MainHandSlot"] = 16, | |
214 ["SecondaryHandSlot"] = 17 | |
215 } | |
216 | |
217 -- map of slot ID to display text | |
218 AskMrRobot.slotDisplayText = { | |
219 [1] = _G["HEADSLOT"], | |
220 [2] = _G["NECKSLOT"], | |
221 [3] = _G["SHOULDERSLOT"], | |
222 [5] = _G["CHESTSLOT"], | |
223 [6] = _G["WAISTSLOT"], | |
224 [7] = _G["LEGSSLOT"], | |
225 [8] = _G["FEETSLOT"], | |
226 [9] = _G["WROSTSLOT"], | |
227 [10] = _G["HANDSSLOT"], | |
228 [11] = _G["FINGER0SLOT"], | |
229 [12] = _G["FINGER1SLOT"], | |
230 [13] = _G["TRINKET0SLOT"], | |
231 [14] = _G["TRINKET1SLOT"], | |
232 [15] = _G["BACKSLOT"], | |
233 [16] = _G["MAINHANDSLOT"], | |
234 [17] = _G["SECONDARYHANDSLOT"] | |
235 } | |
236 | |
237 -- all slot IDs that we care about, ordered in our standard display order | |
238 AskMrRobot.slotIds = { 16, 17, 1, 2, 3, 15, 5, 9, 10, 6, 7, 8, 11, 12, 13, 14 } | |
239 | |
240 -- cache slot orders to make slot sorting easier | |
241 local _slotIdToOrder = {} | |
242 for i = 1, #AskMrRobot.slotIds do | |
243 _slotIdToOrder[AskMrRobot.slotIds[i]] = i | |
244 end | |
245 | |
246 -- given a table where the keys are slot IDs, sort in the standard slot order | |
247 function AskMrRobot.sortSlots(t) | |
248 return AskMrRobot.spairs(t, function(x, a, b) | |
249 if a == nil and b == nil then return 0 end | |
250 return _slotIdToOrder[a] < _slotIdToOrder[b] | |
251 end) | |
252 end |