annotate amr-constants.lua @ 53:be5dc6c02f77 v19

minor tweaks for combat logging
author yellowfive
date Tue, 02 Dec 2014 16:57:32 -0800
parents 6f1bb8fcf64d
children
rev   line source
adam@17 1 local _, AskMrRobot = ...
adam@17 2 local L = AskMrRobot.L;
adam@17 3
adam@17 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
adam@17 5
adam@17 6 -- get an object with all of the parts fo the item link format that we care about
adam@17 7 function AskMrRobot.parseItemLink(itemLink)
adam@17 8 if not itemLink then return nil end
adam@17 9
adam@17 10 local str = string.match(itemLink, "|Hitem:([\-%d:]+)|")
adam@17 11 if not str then return nil end
adam@17 12
adam@17 13 local parts = { strsplit(":", str) }
adam@17 14
adam@17 15 local item = {}
adam@17 16 item.id = tonumber(parts[1])
adam@17 17 item.enchantId = tonumber(parts[2])
adam@17 18 item.gemIds = { tonumber(parts[3]), tonumber(parts[4]), tonumber(parts[5]), tonumber(parts[6]) }
adam@17 19 item.suffixId = math.abs(tonumber(parts[7])) -- convert suffix to positive number, that's what we use in our code
adam@17 20 --item.uniqueId = tonumber(parts[8])
adam@17 21 --item.level = tonumber(parts[9])
adam@17 22 item.upgradeId = tonumber(parts[10])
adam@17 23 --item.difficultyId = tonumber(parts[11])
adam@17 24
adam@17 25 local numBonuses = tonumber(parts[12])
adam@28 26 if numBonuses and numBonuses > 0 then
adam@17 27 item.bonusIds = {}
adam@17 28 for i = 13, 12 + numBonuses do
adam@17 29 table.insert(item.bonusIds, tonumber(parts[i]))
adam@17 30 end
yellowfive@39 31 table.sort(item.bonusIds)
adam@17 32 end
adam@17 33
adam@17 34 return item
adam@17 35 end
adam@17 36
yellowfive@31 37 -- 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@31 38
yellowfive@31 39 function AskMrRobot.createItemLink(itemObj)
yellowfive@31 40
yellowfive@31 41 if itemObj == nil or itemObj.id == nil or itemObj.id == 0 then return nil end
yellowfive@31 42
yellowfive@31 43 local parts = {}
yellowfive@31 44 table.insert(parts, "item")
yellowfive@31 45 table.insert(parts, itemObj.id)
yellowfive@31 46 table.insert(parts, itemObj.enchantId)
yellowfive@31 47 table.insert(parts, itemObj.gemIds[1])
yellowfive@31 48 table.insert(parts, itemObj.gemIds[2])
yellowfive@31 49 table.insert(parts, itemObj.gemIds[3])
yellowfive@31 50 table.insert(parts, itemObj.gemIds[4])
yellowfive@33 51
yellowfive@33 52 if itemObj.suffixId == 0 then
yellowfive@33 53 table.insert(parts, 0)
yellowfive@33 54 else
yellowfive@33 55 table.insert(parts, -math.abs(itemObj.suffixId))
yellowfive@33 56 end
yellowfive@33 57
yellowfive@31 58 table.insert(parts, 0)
yellowfive@31 59 table.insert(parts, UnitLevel("player"))
yellowfive@31 60 table.insert(parts, itemObj.upgradeId)
yellowfive@31 61 table.insert(parts, 0)
yellowfive@31 62
yellowfive@31 63 if itemObj.bonusIds then
yellowfive@31 64 table.insert(parts, #itemObj.bonusIds)
yellowfive@31 65 for i,v in ipairs(itemObj.bonusIds) do
yellowfive@31 66 table.insert(parts, v)
yellowfive@31 67 end
yellowfive@31 68 end
yellowfive@31 69
yellowfive@31 70 return table.concat(parts, ":")
yellowfive@31 71 end
yellowfive@31 72
yellowfive@31 73 function AskMrRobot.createGemLink(gemId)
yellowfive@31 74
yellowfive@31 75 end
yellowfive@31 76
adam@17 77 -- convenience to get just the item id (or 0 if not a valid link) from an item link
adam@17 78 function AskMrRobot.getItemIdFromLink(itemLink)
adam@17 79 if not itemLink then return 0 end
adam@17 80 local parts = { strsplit(":", itemLink) }
adam@17 81 local id = tonumber(parts[2])
adam@17 82 return (id and id ~= 0 and id or 0)
adam@17 83 end
adam@17 84
adam@17 85 function AskMrRobot.getItemUniqueId(item, noUpgrade)
adam@17 86 if item == nil then return "" end
adam@17 87 local ret = item.id .. ""
adam@17 88 if item.bonusIds then
adam@17 89 for i = 1, #item.bonusIds do
adam@17 90 ret = ret .. "b" .. item.bonusIds[i]
adam@17 91 end
adam@17 92 end
adam@17 93 if item.suffixId ~= 0 then
adam@17 94 ret = ret .. "s" .. item.suffixId
adam@17 95 end
adam@17 96 if not noUpgrade and item.upgradeId ~= 0 then
adam@17 97 ret = ret .. "u" .. item.upgradeId
adam@17 98 end
adam@17 99 return ret
adam@17 100 end
adam@17 101
adam@17 102 AskMrRobot.instanceIds = {
TuhMuffinMan>@51 103 Auchindoun = 1182,
TuhMuffinMan>@51 104 BloodmaulSlagMines = 1175,
TuhMuffinMan>@51 105 GrimrailDepot = 1208,
TuhMuffinMan>@51 106 IronDocks = 1195,
TuhMuffinMan>@51 107 ShadowmoonBurialGrounds = 1176,
TuhMuffinMan>@51 108 Skyreach = 1209,
TuhMuffinMan>@51 109 TheEverbloom = 1279,
TuhMuffinMan>@51 110 UpperBlackrockSpire = 1358,
TuhMuffinMan>@51 111 Highmaul = 1228,
TuhMuffinMan>@51 112 BlackrockFoundry = 1205
adam@17 113 }
adam@17 114
adam@17 115 -- instances that we currently support logging for
adam@17 116 AskMrRobot.supportedInstanceIds = {
yellowfive@53 117 --[1182] = true,
yellowfive@53 118 --[1175] = true,
yellowfive@53 119 --[1208] = true,
yellowfive@53 120 --[1195] = true,
yellowfive@53 121 --[1176] = true,
yellowfive@53 122 --[1209] = true,
yellowfive@53 123 --[1279] = true,
yellowfive@53 124 --[1358] = true,
TuhMuffinMan>@51 125 [1228] = true,
TuhMuffinMan>@51 126 [1205] = true
adam@17 127 }
adam@17 128
adam@17 129 -- returns true if currently in a supported instance
adam@17 130 function AskMrRobot.IsSupportedInstance()
adam@17 131
adam@17 132 local zone, _, difficultyIndex, _, _, _, _, instanceMapID = GetInstanceInfo()
adam@17 133 if AskMrRobot.supportedInstanceIds[tonumber(instanceMapID)] then
adam@17 134 return true
adam@17 135 else
adam@17 136 return false
adam@17 137 end
adam@17 138 end
adam@17 139
yellowfive@53 140 function AskMrRobot.IsSupportedInstanceId(instanceMapID)
yellowfive@53 141 if AskMrRobot.supportedInstanceIds[tonumber(instanceMapID)] then
yellowfive@53 142 return true
yellowfive@53 143 else
yellowfive@53 144 return false
yellowfive@53 145 end
yellowfive@53 146 end
yellowfive@53 147
yellowfive@41 148 AskMrRobot.regionNames = {
yellowfive@41 149 [1] = "US",
yellowfive@41 150 [2] = "KR",
yellowfive@41 151 [3] = "EU",
yellowfive@41 152 [4] = "TW",
yellowfive@41 153 [5] = "CN"
yellowfive@41 154 }
yellowfive@41 155
adam@17 156 AskMrRobot.classIds = {
adam@17 157 ["NONE"] = 0,
adam@17 158 ["DEATHKNIGHT"] = 1,
adam@17 159 ["DRUID"] = 2,
adam@17 160 ["HUNTER"] = 3,
adam@17 161 ["MAGE"] = 4,
adam@17 162 ["MONK"] = 5,
adam@17 163 ["PALADIN"] = 6,
adam@17 164 ["PRIEST"] = 7,
adam@17 165 ["ROGUE"] = 8,
adam@17 166 ["SHAMAN"] = 9,
adam@17 167 ["WARLOCK"] = 10,
adam@17 168 ["WARRIOR"] = 11,
adam@17 169 }
adam@17 170
adam@17 171 AskMrRobot.professionIds = {
adam@17 172 ["None"] = 0,
adam@17 173 ["Mining"] = 1,
adam@17 174 ["Skinning"] = 2,
adam@17 175 ["Herbalism"] = 3,
adam@17 176 ["Enchanting"] = 4,
adam@17 177 ["Jewelcrafting"] = 5,
adam@17 178 ["Engineering"] = 6,
adam@17 179 ["Blacksmithing"] = 7,
adam@17 180 ["Leatherworking"] = 8,
adam@17 181 ["Inscription"] = 9,
adam@17 182 ["Tailoring"] = 10,
adam@17 183 ["Alchemy"] = 11,
adam@17 184 ["Fishing"] = 12,
adam@17 185 ["Cooking"] = 13,
adam@17 186 ["First Aid"] = 14,
adam@17 187 ["Archaeology"] = 15
adam@17 188 }
adam@17 189
adam@17 190 AskMrRobot.raceIds = {
adam@17 191 ["None"] = 0,
adam@17 192 ["BloodElf"] = 1,
adam@17 193 ["Draenei"] = 2,
adam@17 194 ["Dwarf"] = 3,
adam@17 195 ["Gnome"] = 4,
adam@17 196 ["Human"] = 5,
adam@17 197 ["NightElf"] = 6,
adam@17 198 ["Orc"] = 7,
adam@17 199 ["Tauren"] = 8,
adam@17 200 ["Troll"] = 9,
adam@17 201 ["Scourge"] = 10,
adam@17 202 ["Undead"] = 10,
adam@17 203 ["Goblin"] = 11,
adam@17 204 ["Worgen"] = 12,
adam@17 205 ["Pandaren"] = 13
adam@17 206 }
adam@17 207
adam@17 208 AskMrRobot.factionIds = {
adam@17 209 ["None"] = 0,
adam@17 210 ["Alliance"] = 1,
adam@17 211 ["Horde"] = 2
adam@17 212 }
adam@17 213
adam@17 214 AskMrRobot.specIds = {
adam@17 215 [250] = 1, -- DeathKnightBlood
adam@17 216 [251] = 2, -- DeathKnightFrost
adam@17 217 [252] = 3, -- DeathKnightUnholy
adam@17 218 [102] = 4, -- DruidBalance
adam@17 219 [103] = 5, -- DruidFeral
adam@17 220 [104] = 6, -- DruidGuardian
adam@17 221 [105] = 7, -- DruidRestoration
adam@17 222 [253] = 8, -- HunterBeastMastery
adam@17 223 [254] = 9, -- HunterMarksmanship
adam@17 224 [255] = 10, -- HunterSurvival
adam@17 225 [62] = 11, -- MageArcane
adam@17 226 [63] = 12, -- MageFire
adam@17 227 [64] = 13, -- MageFrost
adam@17 228 [268] = 14, -- MonkBrewmaster
yellowfive@23 229 [270] = 15, -- MonkMistweaver
yellowfive@23 230 [269] = 16, -- MonkWindwalker
adam@17 231 [65] = 17, -- PaladinHoly
adam@17 232 [66] = 18, -- PaladinProtection
adam@17 233 [70] = 19, -- PaladinRetribution
adam@17 234 [256] = 20, -- PriestDiscipline
adam@17 235 [257] = 21, -- PriestHoly
adam@17 236 [258] = 22, -- PriestShadow
adam@17 237 [259] = 23, -- RogueAssassination
adam@17 238 [260] = 24, -- RogueCombat
adam@17 239 [261] = 25, -- RogueSubtlety
adam@17 240 [262] = 26, -- ShamanElemental
adam@17 241 [263] = 27, -- ShamanEnhancement
adam@17 242 [264] = 28, -- ShamanRestoration
adam@17 243 [265] = 29, -- WarlockAffliction
adam@17 244 [266] = 30, -- WarlockDemonology
adam@17 245 [267] = 31, -- WarlockDestruction
adam@17 246 [71] = 32, -- WarriorArms
adam@17 247 [72] = 33, -- WarriorFury
adam@17 248 [73] = 34 -- WarriorProtection
adam@17 249 }
adam@17 250
adam@17 251 -- reverse map of our spec ID to the game's spec ID
adam@17 252 AskMrRobot.gameSpecIds = {}
adam@17 253 for k,v in pairs(AskMrRobot.specIds) do
adam@17 254 AskMrRobot.gameSpecIds[v] = k
adam@17 255 end
adam@17 256
adam@17 257 -- lookup from our socket color ID to string
adam@17 258 AskMrRobot.socketColorIds = {
adam@17 259 [0] = "Prismatic",
adam@17 260 [1] = "Red",
adam@17 261 [2] = "Yellow",
adam@17 262 [3] = "Blue",
adam@17 263 [4] = "Meta",
adam@17 264 [5] = "Cogwheel",
adam@17 265 [6] = "ShaTouched"
adam@17 266 }
adam@17 267
adam@17 268 -- map of game slot names to slot IDs (same both in our code and in-game)
adam@17 269 AskMrRobot.slotNameToId = {
adam@17 270 ["HeadSlot"] = 1,
adam@17 271 ["NeckSlot"] = 2,
adam@17 272 ["ShoulderSlot"] = 3,
adam@17 273 ["ChestSlot"] = 5,
adam@17 274 ["WaistSlot"] = 6,
adam@17 275 ["LegsSlot"] = 7,
adam@17 276 ["FeetSlot"] = 8,
adam@17 277 ["WristSlot"] = 9,
adam@17 278 ["HandsSlot"] = 10,
adam@17 279 ["Finger0Slot"] = 11,
adam@17 280 ["Finger1Slot"] = 12,
adam@17 281 ["Trinket0Slot"] = 13,
adam@17 282 ["Trinket1Slot"] = 14,
adam@17 283 ["BackSlot"] = 15,
adam@17 284 ["MainHandSlot"] = 16,
adam@17 285 ["SecondaryHandSlot"] = 17
adam@17 286 }
adam@17 287
adam@17 288 -- map of slot ID to display text
adam@17 289 AskMrRobot.slotDisplayText = {
adam@17 290 [1] = _G["HEADSLOT"],
adam@17 291 [2] = _G["NECKSLOT"],
adam@17 292 [3] = _G["SHOULDERSLOT"],
adam@17 293 [5] = _G["CHESTSLOT"],
adam@17 294 [6] = _G["WAISTSLOT"],
adam@17 295 [7] = _G["LEGSSLOT"],
adam@17 296 [8] = _G["FEETSLOT"],
yellowfive@31 297 [9] = _G["WRISTSLOT"],
adam@17 298 [10] = _G["HANDSSLOT"],
yellowfive@31 299 [11] = _G["FINGER0SLOT"] .. " 1",
yellowfive@31 300 [12] = _G["FINGER1SLOT"] .. " 2",
yellowfive@31 301 [13] = _G["TRINKET0SLOT"] .. " 1",
yellowfive@31 302 [14] = _G["TRINKET1SLOT"] .. " 2",
adam@17 303 [15] = _G["BACKSLOT"],
adam@17 304 [16] = _G["MAINHANDSLOT"],
adam@17 305 [17] = _G["SECONDARYHANDSLOT"]
adam@17 306 }
adam@17 307
adam@17 308 -- all slot IDs that we care about, ordered in our standard display order
adam@17 309 AskMrRobot.slotIds = { 16, 17, 1, 2, 3, 15, 5, 9, 10, 6, 7, 8, 11, 12, 13, 14 }
adam@17 310
adam@17 311 -- cache slot orders to make slot sorting easier
adam@17 312 local _slotIdToOrder = {}
adam@17 313 for i = 1, #AskMrRobot.slotIds do
adam@17 314 _slotIdToOrder[AskMrRobot.slotIds[i]] = i
adam@17 315 end
adam@17 316
adam@17 317 -- given a table where the keys are slot IDs, sort in the standard slot order
adam@17 318 function AskMrRobot.sortSlots(t)
adam@17 319 return AskMrRobot.spairs(t, function(x, a, b)
adam@17 320 if a == nil and b == nil then return 0 end
adam@17 321 return _slotIdToOrder[a] < _slotIdToOrder[b]
adam@17 322 end)
TuhMuffinMan>@51 323 end