annotate Main.lua @ 121:ea4e4d3cc673

Removed some unused fields from action_data - renamed two for clarity.
author James D. Callahan III <jcallahan@curse.com>
date Mon, 17 Sep 2012 14:19:23 -0500
parents 8df432f8a15a
children 3c47401c3407
rev   line source
jcallahan@0 1 -----------------------------------------------------------------------
jcallahan@0 2 -- Upvalued Lua API.
jcallahan@0 3 -----------------------------------------------------------------------
jcallahan@0 4 local _G = getfenv(0)
jcallahan@0 5
jcallahan@0 6 local pairs = _G.pairs
jcallahan@1 7 local tonumber = _G.tonumber
jcallahan@1 8
jcallahan@1 9 local bit = _G.bit
jcallahan@1 10 local math = _G.math
jcallahan@1 11 local table = _G.table
jcallahan@1 12
jcallahan@78 13 local select = _G.select
jcallahan@78 14
jcallahan@0 15
jcallahan@0 16 -----------------------------------------------------------------------
jcallahan@0 17 -- AddOn namespace.
jcallahan@0 18 -----------------------------------------------------------------------
jcallahan@0 19 local ADDON_NAME, private = ...
jcallahan@0 20
jcallahan@0 21 local LibStub = _G.LibStub
jcallahan@0 22 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0")
jcallahan@0 23
jcallahan@48 24 local deformat = LibStub("LibDeformat-3.0")
jcallahan@115 25 local LPJ = LibStub("LibPetJournal-2.0")
jcallahan@48 26
jcallahan@4 27 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate")
jcallahan@5 28 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE")
jcallahan@5 29
jcallahan@0 30
jcallahan@0 31 -----------------------------------------------------------------------
jcallahan@0 32 -- Local constants.
jcallahan@0 33 -----------------------------------------------------------------------
jcallahan@109 34 local DB_VERSION = 5
jcallahan@63 35
jcallahan@92 36
jcallahan@0 37 local DATABASE_DEFAULTS = {
jcallahan@0 38 global = {
jcallahan@0 39 items = {},
jcallahan@0 40 npcs = {},
jcallahan@0 41 objects = {},
jcallahan@0 42 quests = {},
jcallahan@17 43 zones = {},
jcallahan@0 44 }
jcallahan@0 45 }
jcallahan@0 46
jcallahan@0 47
jcallahan@1 48 local EVENT_MAPPING = {
jcallahan@90 49 AUCTION_HOUSE_SHOW = true,
jcallahan@90 50 BANKFRAME_OPENED = true,
jcallahan@90 51 BATTLEFIELDS_SHOW = true,
jcallahan@56 52 BLACK_MARKET_ITEM_UPDATE = true,
jcallahan@48 53 CHAT_MSG_LOOT = true,
jcallahan@95 54 CHAT_MSG_MONSTER_SAY = "RecordQuote",
jcallahan@95 55 CHAT_MSG_MONSTER_WHISPER = "RecordQuote",
jcallahan@95 56 CHAT_MSG_MONSTER_YELL = "RecordQuote",
jcallahan@40 57 CHAT_MSG_SYSTEM = true,
jcallahan@23 58 COMBAT_LOG_EVENT_UNFILTERED = true,
jcallahan@18 59 COMBAT_TEXT_UPDATE = true,
jcallahan@90 60 FORGE_MASTER_OPENED = true,
jcallahan@90 61 GOSSIP_SHOW = true,
jcallahan@93 62 GUILDBANKFRAME_OPENED = true,
jcallahan@42 63 ITEM_TEXT_BEGIN = true,
jcallahan@1 64 LOOT_OPENED = true,
jcallahan@89 65 MAIL_SHOW = true,
jcallahan@7 66 MERCHANT_SHOW = "UpdateMerchantItems",
jcallahan@61 67 MERCHANT_UPDATE = "UpdateMerchantItems",
jcallahan@25 68 PET_BAR_UPDATE = true,
jcallahan@115 69 PET_JOURNAL_LIST_UPDATE = true,
jcallahan@2 70 PLAYER_TARGET_CHANGED = true,
jcallahan@9 71 QUEST_COMPLETE = true,
jcallahan@9 72 QUEST_DETAIL = true,
jcallahan@9 73 QUEST_LOG_UPDATE = true,
jcallahan@97 74 QUEST_PROGRESS = true,
jcallahan@88 75 TAXIMAP_OPENED = true,
jcallahan@92 76 TRADE_SKILL_SHOW = true,
jcallahan@27 77 TRAINER_SHOW = true,
jcallahan@90 78 TRANSMOGRIFY_OPEN = true,
jcallahan@4 79 UNIT_QUEST_LOG_CHANGED = true,
jcallahan@1 80 UNIT_SPELLCAST_FAILED = "HandleSpellFailure",
jcallahan@1 81 UNIT_SPELLCAST_FAILED_QUIET = "HandleSpellFailure",
jcallahan@1 82 UNIT_SPELLCAST_INTERRUPTED = "HandleSpellFailure",
jcallahan@1 83 UNIT_SPELLCAST_SENT = true,
jcallahan@1 84 UNIT_SPELLCAST_SUCCEEDED = true,
jcallahan@90 85 VOID_STORAGE_OPEN = true,
jcallahan@0 86 }
jcallahan@0 87
jcallahan@4 88
jcallahan@92 89 local OBJECT_ID_ANVIL = 192628
jcallahan@92 90 local OBJECT_ID_FORGE = 1685
jcallahan@92 91
jcallahan@92 92
jcallahan@1 93 local AF = private.ACTION_TYPE_FLAGS
jcallahan@0 94
jcallahan@4 95
jcallahan@27 96 local PLAYER_CLASS = _G.select(2, _G.UnitClass("player"))
jcallahan@100 97 local PLAYER_FACTION = _G.UnitFactionGroup("player")
jcallahan@34 98 local PLAYER_GUID = _G.UnitGUID("player")
jcallahan@95 99 local PLAYER_NAME = _G.UnitName("player")
jcallahan@39 100 local PLAYER_RACE = _G.select(2, _G.UnitRace("player"))
jcallahan@27 101
jcallahan@95 102
jcallahan@112 103 local CLIENT_LOCALE = _G.GetLocale()
jcallahan@112 104
jcallahan@112 105
jcallahan@112 106 local ALLOWED_LOCALES = {
jcallahan@112 107 enUS = true,
jcallahan@112 108 enGB = true,
jcallahan@112 109 }
jcallahan@112 110
jcallahan@112 111
jcallahan@0 112 -----------------------------------------------------------------------
jcallahan@0 113 -- Local variables.
jcallahan@0 114 -----------------------------------------------------------------------
jcallahan@92 115 local anvil_spell_ids = {}
jcallahan@92 116 local currently_drunk
jcallahan@0 117 local db
jcallahan@0 118 local durability_timer_handle
jcallahan@92 119 local faction_standings = {}
jcallahan@92 120 local forge_spell_ids = {}
jcallahan@95 121 local languages_known = {}
jcallahan@95 122 local name_to_id_map = {}
jcallahan@92 123 local reputation_npc_id
jcallahan@2 124 local target_location_timer_handle
jcallahan@86 125 local current_target_id
jcallahan@1 126
jcallahan@121 127 -----------------------------------------------------------------------
jcallahan@121 128 -- Data for our current action. Including possible values as a reference.
jcallahan@121 129 -----------------------------------------------------------------------
jcallahan@121 130 local action_data = {
jcallahan@121 131 identifier = nil,
jcallahan@121 132 loot_label = nil,
jcallahan@121 133 loot_list = nil,
jcallahan@121 134 loot_sources = nil,
jcallahan@121 135 map_level = nil,
jcallahan@121 136 spell_label = nil,
jcallahan@121 137 type = nil,
jcallahan@121 138 x = nil,
jcallahan@121 139 y = nil,
jcallahan@121 140 zone_data = nil,
jcallahan@121 141
jcallahan@121 142 }
jcallahan@92 143
jcallahan@1 144 -----------------------------------------------------------------------
jcallahan@1 145 -- Helper Functions.
jcallahan@1 146 -----------------------------------------------------------------------
jcallahan@39 147 local ActualCopperCost
jcallahan@39 148 do
jcallahan@39 149 local BARTERING_SPELL_ID = 83964
jcallahan@39 150
jcallahan@39 151 local STANDING_DISCOUNTS = {
jcallahan@39 152 HATED = 0,
jcallahan@39 153 HOSTILE = 0,
jcallahan@39 154 UNFRIENDLY = 0,
jcallahan@39 155 NEUTRAL = 0,
jcallahan@39 156 FRIENDLY = 0.05,
jcallahan@39 157 HONORED = 0.1,
jcallahan@39 158 REVERED = 0.15,
jcallahan@39 159 EXALTED = 0.2,
jcallahan@39 160 }
jcallahan@39 161
jcallahan@39 162
jcallahan@39 163 function ActualCopperCost(copper_cost, rep_standing)
jcallahan@39 164 if not copper_cost or copper_cost == 0 then
jcallahan@39 165 return 0
jcallahan@39 166 end
jcallahan@39 167 local modifier = 1
jcallahan@39 168
jcallahan@39 169 if _G.IsSpellKnown(BARTERING_SPELL_ID) then
jcallahan@39 170 modifier = modifier - 0.1
jcallahan@39 171 end
jcallahan@39 172
jcallahan@39 173 if rep_standing then
jcallahan@39 174 if PLAYER_RACE == "Goblin" then
jcallahan@39 175 modifier = modifier - STANDING_DISCOUNTS["EXALTED"]
jcallahan@39 176 elseif STANDING_DISCOUNTS[rep_standing] then
jcallahan@39 177 modifier = modifier - STANDING_DISCOUNTS[rep_standing]
jcallahan@39 178 end
jcallahan@39 179 end
jcallahan@39 180 return math.floor(copper_cost / modifier)
jcallahan@39 181 end
jcallahan@39 182 end -- do-block
jcallahan@39 183
jcallahan@39 184
jcallahan@29 185 local function InstanceDifficultyToken()
jcallahan@29 186 local _, instance_type, instance_difficulty, difficulty_name, _, _, is_dynamic = _G.GetInstanceInfo()
jcallahan@59 187 if not difficulty_name or difficulty_name == "" then
jcallahan@29 188 difficulty_name = "NONE"
jcallahan@29 189 end
jcallahan@59 190
jcallahan@59 191 if not instance_type or instance_type == "" then
jcallahan@59 192 instance_type = "NONE"
jcallahan@59 193 end
jcallahan@29 194 return ("%s:%s:%s"):format(instance_type:upper(), difficulty_name:upper():gsub(" ", "_"), _G.tostring(is_dynamic))
jcallahan@29 195 end
jcallahan@29 196
jcallahan@29 197
jcallahan@19 198 local function DBEntry(data_type, unit_id)
jcallahan@19 199 if not data_type or not unit_id then
jcallahan@6 200 return
jcallahan@6 201 end
jcallahan@19 202 local unit = db[data_type][unit_id]
jcallahan@6 203
jcallahan@10 204 if not unit then
jcallahan@19 205 db[data_type][unit_id] = {}
jcallahan@19 206 unit = db[data_type][unit_id]
jcallahan@6 207 end
jcallahan@10 208 return unit
jcallahan@6 209 end
jcallahan@6 210
jcallahan@6 211
jcallahan@29 212 local function NPCEntry(identifier)
jcallahan@29 213 local npc = DBEntry("npcs", identifier)
jcallahan@29 214
jcallahan@29 215 if not npc then
jcallahan@29 216 return
jcallahan@22 217 end
jcallahan@29 218 local instance_token = InstanceDifficultyToken()
jcallahan@29 219 npc.encounter_data = npc.encounter_data or {}
jcallahan@29 220 npc.encounter_data[instance_token] = npc.encounter_data[instance_token] or {}
jcallahan@30 221 npc.encounter_data[instance_token].stats = npc.encounter_data[instance_token].stats or {}
jcallahan@29 222 return npc
jcallahan@22 223 end
jcallahan@22 224
jcallahan@22 225
jcallahan@1 226 local function CurrentLocationData()
jcallahan@104 227 _G.SetMapToCurrentZone()
jcallahan@104 228
jcallahan@1 229 local map_level = _G.GetCurrentMapDungeonLevel() or 0
jcallahan@1 230 local x, y = _G.GetPlayerMapPosition("player")
jcallahan@1 231
jcallahan@1 232 x = x or 0
jcallahan@1 233 y = y or 0
jcallahan@1 234
jcallahan@1 235 if x == 0 and y == 0 then
jcallahan@1 236 for level_index = 1, _G.GetNumDungeonMapLevels() do
jcallahan@1 237 _G.SetDungeonMapLevel(level_index)
jcallahan@1 238 x, y = _G.GetPlayerMapPosition("player")
jcallahan@1 239
jcallahan@1 240 if x and y and (x > 0 or y > 0) then
jcallahan@1 241 _G.SetDungeonMapLevel(map_level)
jcallahan@1 242 map_level = level_index
jcallahan@1 243 break
jcallahan@1 244 end
jcallahan@1 245 end
jcallahan@1 246 end
jcallahan@1 247
jcallahan@1 248 if _G.DungeonUsesTerrainMap() then
jcallahan@1 249 map_level = map_level - 1
jcallahan@1 250 end
jcallahan@31 251 local x = _G.floor(x * 1000)
jcallahan@31 252 local y = _G.floor(y * 1000)
jcallahan@28 253
jcallahan@31 254 if x % 2 ~= 0 then
jcallahan@31 255 x = x + 1
jcallahan@28 256 end
jcallahan@28 257
jcallahan@31 258 if y % 2 ~= 0 then
jcallahan@31 259 y = y + 1
jcallahan@28 260 end
jcallahan@31 261 return _G.GetRealZoneText(), _G.GetCurrentMapAreaID(), x, y, map_level, InstanceDifficultyToken()
jcallahan@1 262 end
jcallahan@1 263
jcallahan@1 264
jcallahan@1 265 local function ItemLinkToID(item_link)
jcallahan@1 266 if not item_link then
jcallahan@1 267 return
jcallahan@1 268 end
jcallahan@7 269 return tonumber(item_link:match("item:(%d+)"))
jcallahan@1 270 end
jcallahan@0 271
jcallahan@4 272
jcallahan@34 273 local ParseGUID
jcallahan@4 274 do
jcallahan@4 275 local UNIT_TYPE_BITMASK = 0x007
jcallahan@4 276
jcallahan@34 277 function ParseGUID(guid)
jcallahan@5 278 if not guid then
jcallahan@5 279 return
jcallahan@5 280 end
jcallahan@4 281 local types = private.UNIT_TYPES
jcallahan@4 282 local unit_type = _G.bit.band(tonumber(guid:sub(1, 5)), UNIT_TYPE_BITMASK)
jcallahan@4 283
jcallahan@10 284 if unit_type ~= types.PLAYER and unit_type ~= types.PET then
jcallahan@66 285 return unit_type, tonumber(guid:sub(6, 10), 16)
jcallahan@4 286 end
jcallahan@4 287 return unit_type
jcallahan@4 288 end
jcallahan@4 289 end -- do-block
jcallahan@4 290
jcallahan@4 291
jcallahan@52 292 local function UpdateDBEntryLocation(entry_type, identifier)
jcallahan@10 293 if not identifier then
jcallahan@10 294 return
jcallahan@10 295 end
jcallahan@31 296 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData()
jcallahan@41 297 local entry = DBEntry(entry_type, identifier)
jcallahan@41 298 entry[difficulty_token] = entry[difficulty_token] or {}
jcallahan@52 299 entry[difficulty_token].locations = entry[difficulty_token].locations or {}
jcallahan@10 300
jcallahan@31 301 local zone_token = ("%s:%d"):format(zone_name, area_id)
jcallahan@52 302 local zone_data = entry[difficulty_token].locations[zone_token]
jcallahan@24 303
jcallahan@31 304 if not zone_data then
jcallahan@31 305 zone_data = {}
jcallahan@52 306 entry[difficulty_token].locations[zone_token] = zone_data
jcallahan@10 307 end
jcallahan@41 308 local location_token = ("%s:%s:%s"):format(map_level, x, y)
jcallahan@41 309 zone_data[location_token] = zone_data[location_token] or true
jcallahan@41 310 return zone_data
jcallahan@10 311 end
jcallahan@10 312
jcallahan@10 313
jcallahan@19 314 local function HandleItemUse(item_link, bag_index, slot_index)
jcallahan@19 315 if not item_link then
jcallahan@19 316 return
jcallahan@19 317 end
jcallahan@19 318 local item_id = ItemLinkToID(item_link)
jcallahan@19 319
jcallahan@19 320 if not bag_index or not slot_index then
jcallahan@19 321 for new_bag_index = 0, _G.NUM_BAG_FRAMES do
jcallahan@19 322 for new_slot_index = 1, _G.GetContainerNumSlots(new_bag_index) do
jcallahan@19 323 if item_id == ItemLinkToID(_G.GetContainerItemLink(new_bag_index, new_slot_index)) then
jcallahan@19 324 bag_index = new_bag_index
jcallahan@19 325 slot_index = new_slot_index
jcallahan@19 326 break
jcallahan@19 327 end
jcallahan@19 328 end
jcallahan@19 329 end
jcallahan@19 330 end
jcallahan@19 331
jcallahan@19 332 if not bag_index or not slot_index then
jcallahan@19 333 return
jcallahan@19 334 end
jcallahan@19 335 local _, _, _, _, _, is_lootable = _G.GetContainerItemInfo(bag_index, slot_index)
jcallahan@19 336
jcallahan@19 337 if not is_lootable then
jcallahan@19 338 return
jcallahan@19 339 end
jcallahan@19 340 DatamineTT:ClearLines()
jcallahan@19 341 DatamineTT:SetBagItem(bag_index, slot_index)
jcallahan@19 342
jcallahan@19 343 for line_index = 1, DatamineTT:NumLines() do
jcallahan@19 344 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
jcallahan@19 345
jcallahan@19 346 if not current_line then
jcallahan@19 347 break
jcallahan@19 348 end
jcallahan@19 349
jcallahan@19 350 if current_line:GetText() == _G.ITEM_OPENABLE then
jcallahan@19 351 table.wipe(action_data)
jcallahan@19 352 action_data.type = AF.ITEM
jcallahan@28 353 action_data.identifier = item_id
jcallahan@105 354 action_data.loot_label = "contains"
jcallahan@19 355 break
jcallahan@19 356 end
jcallahan@19 357 end
jcallahan@19 358 end
jcallahan@19 359
jcallahan@19 360
jcallahan@39 361 local UnitFactionStanding
jcallahan@32 362 local UpdateFactionData
jcallahan@32 363 do
jcallahan@32 364 local MAX_FACTION_INDEX = 1000
jcallahan@20 365
jcallahan@32 366 local STANDING_NAMES = {
jcallahan@32 367 "HATED",
jcallahan@32 368 "HOSTILE",
jcallahan@32 369 "UNFRIENDLY",
jcallahan@32 370 "NEUTRAL",
jcallahan@32 371 "FRIENDLY",
jcallahan@32 372 "HONORED",
jcallahan@32 373 "REVERED",
jcallahan@32 374 "EXALTED",
jcallahan@32 375 }
jcallahan@32 376
jcallahan@39 377
jcallahan@39 378 function UnitFactionStanding(unit)
jcallahan@39 379 UpdateFactionData()
jcallahan@39 380 DatamineTT:ClearLines()
jcallahan@39 381 DatamineTT:SetUnit(unit)
jcallahan@39 382
jcallahan@39 383 for line_index = 1, DatamineTT:NumLines() do
jcallahan@64 384 local faction_name = _G["WDPDatamineTTTextLeft" .. line_index]:GetText():trim()
jcallahan@39 385
jcallahan@39 386 if faction_name and faction_standings[faction_name] then
jcallahan@39 387 return faction_name, faction_standings[faction_name]
jcallahan@39 388 end
jcallahan@39 389 end
jcallahan@39 390 end
jcallahan@39 391
jcallahan@39 392
jcallahan@32 393 function UpdateFactionData()
jcallahan@32 394 for faction_index = 1, MAX_FACTION_INDEX do
jcallahan@32 395 local faction_name, _, current_standing, _, _, _, _, _, is_header = _G.GetFactionInfo(faction_index)
jcallahan@32 396
jcallahan@86 397 if faction_name then
jcallahan@32 398 faction_standings[faction_name] = STANDING_NAMES[current_standing]
jcallahan@32 399 elseif not faction_name then
jcallahan@32 400 break
jcallahan@32 401 end
jcallahan@20 402 end
jcallahan@20 403 end
jcallahan@32 404 end -- do-block
jcallahan@20 405
jcallahan@48 406
jcallahan@75 407 local GenericLootUpdate
jcallahan@75 408 do
jcallahan@77 409 local function LootTable(entry, loot_type, top_field)
jcallahan@75 410 if top_field then
jcallahan@75 411 entry[top_field] = entry[top_field] or {}
jcallahan@75 412 entry[top_field][loot_type] = entry[top_field][loot_type] or {}
jcallahan@75 413 return entry[top_field][loot_type]
jcallahan@75 414 end
jcallahan@48 415 entry[loot_type] = entry[loot_type] or {}
jcallahan@75 416 return entry[loot_type]
jcallahan@48 417 end
jcallahan@48 418
jcallahan@75 419 function GenericLootUpdate(data_type, top_field)
jcallahan@105 420 local loot_type = action_data.loot_label or "drops"
jcallahan@75 421 local loot_count = ("%s_count"):format(loot_type)
jcallahan@77 422 local source_list = {}
jcallahan@75 423
jcallahan@119 424 if action_data.loot_sources then
jcallahan@119 425 for source_guid, loot_data in pairs(action_data.loot_sources) do
jcallahan@119 426 local entry, source_id
jcallahan@78 427
jcallahan@119 428 if action_data.type == AF.ITEM then
jcallahan@119 429 -- Items return the player as the source, so we need to use the item's ID (disenchant, milling, etc)
jcallahan@119 430 source_id = action_data.identifier
jcallahan@119 431 entry = DBEntry(data_type, source_id)
jcallahan@119 432 elseif action_data.type == AF.OBJECT then
jcallahan@119 433 source_id = ("%s:%s"):format(action_data.spell_label, select(2, ParseGUID(source_guid)))
jcallahan@119 434 entry = DBEntry(data_type, source_id)
jcallahan@119 435 else
jcallahan@119 436 source_id = select(2, ParseGUID(source_guid))
jcallahan@119 437 entry = DBEntry(data_type, source_id)
jcallahan@119 438 end
jcallahan@75 439
jcallahan@119 440 if entry then
jcallahan@119 441 local loot_table = LootTable(entry, loot_type, top_field)
jcallahan@77 442
jcallahan@119 443 if not source_list[source_guid] then
jcallahan@119 444 if top_field then
jcallahan@119 445 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1
jcallahan@119 446 else
jcallahan@119 447 entry[loot_count] = (entry[loot_count] or 0) + 1
jcallahan@119 448 end
jcallahan@119 449 source_list[source_guid] = true
jcallahan@77 450 end
jcallahan@119 451 UpdateDBEntryLocation(data_type, source_id)
jcallahan@75 452
jcallahan@119 453 for item_id, quantity in pairs(loot_data) do
jcallahan@119 454 table.insert(loot_table, ("%d:%d"):format(item_id, quantity))
jcallahan@119 455 end
jcallahan@75 456 end
jcallahan@75 457 end
jcallahan@75 458 end
jcallahan@121 459
jcallahan@121 460 -- This is used for Gas Extractions.
jcallahan@82 461 if #action_data.loot_list <= 0 then
jcallahan@78 462 return
jcallahan@78 463 end
jcallahan@82 464 local entry
jcallahan@82 465
jcallahan@82 466 -- At this point we only have a name if it's an object.
jcallahan@82 467 if action_data.type == AF.OBJECT then
jcallahan@121 468 entry = DBEntry(data_type, ("%s:%s"):format(action_data.spell_label, action_data.object_name))
jcallahan@82 469 else
jcallahan@82 470 entry = DBEntry(data_type, action_data.identifier)
jcallahan@82 471 end
jcallahan@75 472
jcallahan@75 473 if not entry then
jcallahan@75 474 return
jcallahan@75 475 end
jcallahan@77 476 local loot_table = LootTable(entry, loot_type, top_field)
jcallahan@77 477
jcallahan@77 478 if not source_list[action_data.identifier] then
jcallahan@77 479 if top_field then
jcallahan@77 480 entry[top_field][loot_count] = (entry[top_field][loot_count] or 0) + 1
jcallahan@77 481 else
jcallahan@77 482 entry[loot_count] = (entry[loot_count] or 0) + 1
jcallahan@77 483 end
jcallahan@77 484 end
jcallahan@75 485
jcallahan@75 486 for index = 1, #action_data.loot_list do
jcallahan@75 487 table.insert(loot_table, action_data.loot_list[index])
jcallahan@75 488 end
jcallahan@48 489 end
jcallahan@75 490 end -- do-block
jcallahan@48 491
jcallahan@97 492
jcallahan@97 493 local ReplaceKeywords
jcallahan@97 494 do
jcallahan@97 495 local KEYWORD_SUBSTITUTIONS = {
jcallahan@97 496 class = PLAYER_CLASS,
jcallahan@97 497 name = PLAYER_NAME,
jcallahan@97 498 race = PLAYER_RACE,
jcallahan@97 499 }
jcallahan@97 500
jcallahan@97 501
jcallahan@97 502 function ReplaceKeywords(text)
jcallahan@97 503 if not text or text == "" then
jcallahan@97 504 return ""
jcallahan@97 505 end
jcallahan@97 506
jcallahan@97 507 for category, lookup in pairs(KEYWORD_SUBSTITUTIONS) do
jcallahan@97 508 local category_format = ("<%s>"):format(category)
jcallahan@97 509 text = text:gsub(lookup, category_format):gsub(lookup:lower(), category_format)
jcallahan@97 510 end
jcallahan@97 511 return text
jcallahan@97 512 end
jcallahan@97 513 end -- do-block
jcallahan@97 514
jcallahan@97 515
jcallahan@0 516 -----------------------------------------------------------------------
jcallahan@0 517 -- Methods.
jcallahan@0 518 -----------------------------------------------------------------------
jcallahan@0 519 function WDP:OnInitialize()
jcallahan@0 520 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global
jcallahan@14 521
jcallahan@14 522 local raw_db = _G["WoWDBProfilerData"]
jcallahan@18 523 local build_num = tonumber(private.build_num)
jcallahan@14 524
jcallahan@74 525 -- TODO: Merge this with the DB version check when MoP goes live.
jcallahan@35 526 -- if raw_db.build_num and raw_db.build_num < build_num then
jcallahan@74 527 if raw_db.version and raw_db.version < DB_VERSION then
jcallahan@74 528 for entry in pairs(DATABASE_DEFAULTS.global) do
jcallahan@74 529 db[entry] = {}
jcallahan@74 530 end
jcallahan@74 531 end
jcallahan@35 532 raw_db.build_num = build_num
jcallahan@63 533 raw_db.version = DB_VERSION
jcallahan@0 534 end
jcallahan@0 535
jcallahan@0 536
jcallahan@0 537 function WDP:OnEnable()
jcallahan@0 538 for event_name, mapping in pairs(EVENT_MAPPING) do
jcallahan@1 539 self:RegisterEvent(event_name, (_G.type(mapping) ~= "boolean") and mapping or nil)
jcallahan@0 540 end
jcallahan@95 541
jcallahan@95 542 for index = 1, _G.GetNumLanguages() do
jcallahan@95 543 languages_known[_G.GetLanguageByIndex(index)] = true
jcallahan@95 544 end
jcallahan@0 545 durability_timer_handle = self:ScheduleRepeatingTimer("ProcessDurability", 30)
jcallahan@31 546 target_location_timer_handle = self:ScheduleRepeatingTimer("UpdateTargetLocation", 0.5)
jcallahan@19 547
jcallahan@19 548 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit)
jcallahan@19 549 if target_unit then
jcallahan@19 550 return
jcallahan@19 551 end
jcallahan@19 552 HandleItemUse(_G.GetContainerItemLink(bag_index, slot_index), bag_index, slot_index)
jcallahan@19 553 end)
jcallahan@19 554
jcallahan@19 555 _G.hooksecurefunc("UseItemByName", function(identifier, target_unit)
jcallahan@19 556 if target_unit then
jcallahan@19 557 return
jcallahan@19 558 end
jcallahan@19 559 local _, item_link = _G.GetItemInfo(identifier)
jcallahan@19 560 HandleItemUse(item_link)
jcallahan@19 561 end)
jcallahan@0 562 end
jcallahan@0 563
jcallahan@0 564
jcallahan@0 565 local function RecordDurability(item_id, durability)
jcallahan@0 566 if not durability or durability <= 0 then
jcallahan@0 567 return
jcallahan@0 568 end
jcallahan@0 569
jcallahan@0 570 if not db.items[item_id] then
jcallahan@0 571 db.items[item_id] = {}
jcallahan@0 572 end
jcallahan@0 573 db.items[item_id].durability = durability
jcallahan@0 574 end
jcallahan@0 575
jcallahan@0 576
jcallahan@0 577 function WDP:ProcessDurability()
jcallahan@0 578 for slot_index = 0, _G.INVSLOT_LAST_EQUIPPED do
jcallahan@1 579 local item_id = _G.GetInventoryItemID("player", slot_index)
jcallahan@0 580
jcallahan@0 581 if item_id and item_id > 0 then
jcallahan@1 582 local _, max_durability = _G.GetInventoryItemDurability(slot_index)
jcallahan@0 583 RecordDurability(item_id, max_durability)
jcallahan@0 584 end
jcallahan@0 585 end
jcallahan@0 586
jcallahan@0 587 for bag_index = 0, _G.NUM_BAG_SLOTS do
jcallahan@0 588 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do
jcallahan@1 589 local item_id = _G.GetContainerItemID(bag_index, slot_index)
jcallahan@0 590
jcallahan@0 591 if item_id and item_id > 0 then
jcallahan@1 592 local _, max_durability = _G.GetContainerItemDurability(bag_index, slot_index)
jcallahan@0 593 RecordDurability(item_id, max_durability)
jcallahan@0 594 end
jcallahan@0 595 end
jcallahan@0 596 end
jcallahan@0 597 end
jcallahan@0 598
jcallahan@118 599
jcallahan@118 600 local PlayerTarget
jcallahan@118 601 do
jcallahan@118 602 local GENDER_NAMES = {
jcallahan@118 603 "UNKNOWN",
jcallahan@118 604 "MALE",
jcallahan@118 605 "FEMALE",
jcallahan@118 606 }
jcallahan@118 607
jcallahan@118 608
jcallahan@118 609 local REACTION_NAMES = {
jcallahan@118 610 "HATED",
jcallahan@118 611 "HOSTILE",
jcallahan@118 612 "UNFRIENDLY",
jcallahan@118 613 "NEUTRAL",
jcallahan@118 614 "FRIENDLY",
jcallahan@118 615 "HONORED",
jcallahan@118 616 "REVERED",
jcallahan@118 617 "EXALTED",
jcallahan@118 618 }
jcallahan@118 619
jcallahan@118 620
jcallahan@118 621 local POWER_TYPE_NAMES = {
jcallahan@118 622 ["0"] = "MANA",
jcallahan@118 623 ["1"] = "RAGE",
jcallahan@118 624 ["2"] = "FOCUS",
jcallahan@118 625 ["3"] = "ENERGY",
jcallahan@118 626 ["6"] = "RUNIC_POWER",
jcallahan@118 627 }
jcallahan@118 628
jcallahan@118 629
jcallahan@118 630 function PlayerTarget()
jcallahan@118 631 if not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or currently_drunk then
jcallahan@118 632 current_target_id = nil
jcallahan@118 633 return
jcallahan@118 634 end
jcallahan@118 635 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
jcallahan@118 636
jcallahan@118 637 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
jcallahan@118 638 return
jcallahan@118 639 end
jcallahan@118 640 current_target_id = unit_idnum
jcallahan@118 641
jcallahan@118 642 local npc = NPCEntry(unit_idnum)
jcallahan@118 643 local _, class_token = _G.UnitClass("target")
jcallahan@118 644 npc.class = class_token
jcallahan@118 645 npc.faction = UnitFactionStanding("target")
jcallahan@118 646 npc.genders = npc.genders or {}
jcallahan@118 647 npc.genders[GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED"] = true
jcallahan@118 648 npc.is_pvp = _G.UnitIsPVP("target") and true or nil
jcallahan@118 649 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")])
jcallahan@118 650
jcallahan@118 651 local encounter_data = npc.encounter_data[InstanceDifficultyToken()].stats
jcallahan@118 652 local npc_level = ("level_%d"):format(_G.UnitLevel("target"))
jcallahan@118 653
jcallahan@118 654 if not encounter_data[npc_level] then
jcallahan@118 655 encounter_data[npc_level] = {
jcallahan@118 656 max_health = _G.UnitHealthMax("target"),
jcallahan@118 657 }
jcallahan@118 658
jcallahan@118 659 local max_power = _G.UnitManaMax("target")
jcallahan@118 660
jcallahan@118 661 if max_power > 0 then
jcallahan@118 662 local power_type = _G.UnitPowerType("target")
jcallahan@118 663 encounter_data[npc_level].power = ("%s:%d"):format(POWER_TYPE_NAMES[_G.tostring(power_type)] or power_type, max_power)
jcallahan@118 664 end
jcallahan@118 665 end
jcallahan@118 666 name_to_id_map[_G.UnitName("target")] = unit_idnum
jcallahan@118 667
jcallahan@118 668 table.wipe(action_data)
jcallahan@118 669 action_data.type = AF.NPC
jcallahan@118 670 action_data.identifier = unit_idnum
jcallahan@118 671 return npc, unit_idnum
jcallahan@118 672 end
jcallahan@118 673 end -- do-block
jcallahan@118 674
jcallahan@118 675
jcallahan@113 676 do
jcallahan@113 677 local COORD_MAX = 5
jcallahan@0 678
jcallahan@113 679 function WDP:UpdateTargetLocation()
jcallahan@113 680 if currently_drunk or not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or (_G.UnitIsTapped("target") and not _G.UnitIsDead("target")) then
jcallahan@2 681 return
jcallahan@2 682 end
jcallahan@113 683
jcallahan@113 684 for index = 1, 4 do
jcallahan@113 685 if not _G.CheckInteractDistance("target", index) then
jcallahan@113 686 return
jcallahan@113 687 end
jcallahan@113 688 end
jcallahan@118 689 local npc = PlayerTarget()
jcallahan@113 690
jcallahan@113 691 if not npc then
jcallahan@113 692 return
jcallahan@113 693 end
jcallahan@113 694 local zone_name, area_id, x, y, map_level, difficulty_token = CurrentLocationData()
jcallahan@113 695 local npc_data = npc.encounter_data[difficulty_token].stats[("level_%d"):format(_G.UnitLevel("target"))]
jcallahan@113 696 local zone_token = ("%s:%d"):format(zone_name, area_id)
jcallahan@118 697 npc_data.locations = npc_data.locations or {} -- TODO: Fix this. It is broken. Possibly something to do with the timed updates.
jcallahan@113 698
jcallahan@113 699 local zone_data = npc_data.locations[zone_token]
jcallahan@113 700
jcallahan@113 701 if not zone_data then
jcallahan@113 702 zone_data = {}
jcallahan@113 703 npc_data.locations[zone_token] = zone_data
jcallahan@113 704 end
jcallahan@113 705
jcallahan@113 706 for location_token in pairs(zone_data) do
jcallahan@113 707 local loc_level, loc_x, loc_y = (":"):split(location_token)
jcallahan@113 708 loc_level = tonumber(loc_level)
jcallahan@113 709
jcallahan@113 710 if map_level == loc_level and math.abs(x - loc_x) <= COORD_MAX and math.abs(y - loc_y) <= COORD_MAX then
jcallahan@113 711 return
jcallahan@113 712 end
jcallahan@113 713 end
jcallahan@113 714 zone_data[("%s:%s:%s"):format(map_level, x, y)] = true
jcallahan@2 715 end
jcallahan@113 716 end -- do-block
jcallahan@2 717
jcallahan@118 718
jcallahan@0 719 -----------------------------------------------------------------------
jcallahan@0 720 -- Event handlers.
jcallahan@0 721 -----------------------------------------------------------------------
jcallahan@90 722 function WDP:BLACK_MARKET_ITEM_UPDATE(event_name)
jcallahan@56 723 local num_items = _G.C_BlackMarket.GetNumItems()
jcallahan@56 724
jcallahan@56 725 for index = 1, num_items do
jcallahan@56 726 local name, texture, quantity, item_type, is_usable, level, level_type, seller_name, min_bid, min_increment, current_bid, has_high_bid, num_bids, time_left, item_link, market_id = _G.C_BlackMarket.GetItemInfoByIndex(index);
jcallahan@56 727
jcallahan@56 728 if item_link then
jcallahan@56 729 DBEntry("items", ItemLinkToID(item_link)).black_market = seller_name or "UNKNOWN"
jcallahan@56 730 end
jcallahan@56 731 end
jcallahan@56 732 end
jcallahan@56 733
jcallahan@56 734
jcallahan@75 735 function WDP:CHAT_MSG_LOOT(event_name, message)
jcallahan@48 736 if action_data.spell_label ~= "EXTRACT_GAS" then
jcallahan@48 737 return
jcallahan@48 738 end
jcallahan@48 739 local item_link, quantity = deformat(message, _G.LOOT_ITEM_PUSHED_SELF_MULTIPLE)
jcallahan@48 740
jcallahan@48 741 if not item_link then
jcallahan@48 742 quantity, item_link = 1, deformat(message, _G.LOOT_ITEM_PUSHED_SELF)
jcallahan@48 743 end
jcallahan@48 744
jcallahan@48 745 if not item_link then
jcallahan@48 746 return
jcallahan@48 747 end
jcallahan@48 748 local item_id = ItemLinkToID(item_link)
jcallahan@48 749
jcallahan@48 750 if not item_id then
jcallahan@48 751 return
jcallahan@48 752 end
jcallahan@48 753 action_data.loot_list = {
jcallahan@48 754 ("%d:%d"):format(item_id, quantity)
jcallahan@48 755 }
jcallahan@48 756 GenericLootUpdate("zones")
jcallahan@48 757 table.wipe(action_data)
jcallahan@48 758 end
jcallahan@48 759
jcallahan@48 760
jcallahan@97 761 function WDP:RecordQuote(event_name, message, source_name, language_name)
jcallahan@112 762 if not ALLOWED_LOCALES[CLIENT_LOCALE] or not source_name or not name_to_id_map[source_name] or (language_name ~= "" and not languages_known[language_name]) then
jcallahan@97 763 return
jcallahan@95 764 end
jcallahan@97 765 local npc = NPCEntry(name_to_id_map[source_name])
jcallahan@97 766 npc.quotes = npc.quotes or {}
jcallahan@97 767 npc.quotes[event_name] = npc.quotes[event_name] or {}
jcallahan@97 768 npc.quotes[event_name][ReplaceKeywords(message)] = true
jcallahan@97 769 end
jcallahan@95 770
jcallahan@95 771
jcallahan@95 772 do
jcallahan@40 773 local SOBER_MATCH = _G.DRUNK_MESSAGE_ITEM_SELF1:gsub("%%s", ".+")
jcallahan@40 774
jcallahan@40 775 local DRUNK_COMPARES = {
jcallahan@40 776 _G.DRUNK_MESSAGE_SELF2,
jcallahan@40 777 _G.DRUNK_MESSAGE_SELF3,
jcallahan@40 778 _G.DRUNK_MESSAGE_SELF4,
jcallahan@40 779 }
jcallahan@40 780
jcallahan@40 781 local DRUNK_MATCHES = {
jcallahan@40 782 _G.DRUNK_MESSAGE_SELF2:gsub("%%s", ".+"),
jcallahan@40 783 _G.DRUNK_MESSAGE_SELF3:gsub("%%s", ".+"),
jcallahan@40 784 _G.DRUNK_MESSAGE_SELF4:gsub("%%s", ".+"),
jcallahan@40 785 }
jcallahan@40 786
jcallahan@92 787 function WDP:CHAT_MSG_SYSTEM(event_name, message)
jcallahan@40 788 if currently_drunk then
jcallahan@40 789 if message == _G.DRUNK_MESSAGE_SELF1 or message:match(SOBER_MATCH) then
jcallahan@40 790 currently_drunk = nil
jcallahan@40 791 end
jcallahan@40 792 return
jcallahan@40 793 end
jcallahan@40 794
jcallahan@40 795 for index = 1, #DRUNK_MATCHES do
jcallahan@40 796 if message == DRUNK_COMPARES[index] or message:match(DRUNK_MATCHES[index]) then
jcallahan@40 797 currently_drunk = true
jcallahan@40 798 break
jcallahan@40 799 end
jcallahan@40 800 end
jcallahan@40 801 end
jcallahan@40 802 end
jcallahan@40 803
jcallahan@40 804 -- do-block
jcallahan@40 805
jcallahan@40 806 do
jcallahan@23 807 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC)
jcallahan@23 808 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC)
jcallahan@23 809
jcallahan@23 810 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
jcallahan@23 811 if not spell_id then
jcallahan@23 812 return
jcallahan@23 813 end
jcallahan@34 814 local source_type, source_id = ParseGUID(source_guid)
jcallahan@23 815
jcallahan@23 816 if not source_id or source_type ~= private.UNIT_TYPES.NPC then
jcallahan@23 817 return
jcallahan@23 818 end
jcallahan@23 819
jcallahan@23 820 if bit.band(FLAGS_NPC_CONTROL, source_flags) == FLAGS_NPC_CONTROL and bit.band(FLAGS_NPC, source_flags) ~= 0 then
jcallahan@29 821 local encounter_data = NPCEntry(source_id).encounter_data[InstanceDifficultyToken()]
jcallahan@28 822 encounter_data.spells = encounter_data.spells or {}
jcallahan@28 823 encounter_data.spells[spell_id] = (encounter_data.spells[spell_id] or 0) + 1
jcallahan@23 824 end
jcallahan@23 825 end
jcallahan@23 826
jcallahan@115 827 local HEAL_BATTLE_PETS_SPELL_ID = 125801
jcallahan@115 828
jcallahan@23 829 local COMBAT_LOG_FUNCS = {
jcallahan@23 830 SPELL_AURA_APPLIED = RecordNPCSpell,
jcallahan@23 831 SPELL_CAST_START = RecordNPCSpell,
jcallahan@115 832 SPELL_CAST_SUCCESS = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
jcallahan@115 833 if spell_id == HEAL_BATTLE_PETS_SPELL_ID then
jcallahan@115 834 local unit_type, unit_idnum = ParseGUID(source_guid)
jcallahan@115 835
jcallahan@115 836 if unit_type == private.UNIT_TYPES.NPC and unit_idnum then
jcallahan@115 837 NPCEntry(unit_idnum).stable_master = true
jcallahan@115 838 end
jcallahan@115 839 end
jcallahan@115 840 RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
jcallahan@115 841 end,
jcallahan@65 842 UNIT_DIED = function(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id, spell_name)
jcallahan@65 843 local unit_type, unit_idnum = ParseGUID(dest_guid)
jcallahan@65 844
jcallahan@65 845 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
jcallahan@67 846 reputation_npc_id = nil
jcallahan@98 847 private.harvesting = nil
jcallahan@65 848 return
jcallahan@65 849 end
jcallahan@67 850 reputation_npc_id = unit_idnum
jcallahan@65 851 end,
jcallahan@23 852 }
jcallahan@23 853
jcallahan@23 854
jcallahan@92 855 function WDP:COMBAT_LOG_EVENT_UNFILTERED(event_name, time_stamp, sub_event, hide_caster, source_guid, source_name, source_flags, source_raid_flags, dest_guid, dest_name, dest_flags, dest_raid_flags, ...)
jcallahan@23 856 local combat_log_func = COMBAT_LOG_FUNCS[sub_event]
jcallahan@23 857
jcallahan@23 858 if not combat_log_func then
jcallahan@23 859 return
jcallahan@23 860 end
jcallahan@23 861 combat_log_func(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, ...)
jcallahan@23 862 end
jcallahan@23 863
jcallahan@44 864 local DIPLOMACY_SPELL_ID = 20599
jcallahan@44 865 local MR_POP_RANK1_SPELL_ID = 78634
jcallahan@44 866 local MR_POP_RANK2_SPELL_ID = 78635
jcallahan@44 867
jcallahan@44 868 local REP_BUFFS = {
jcallahan@44 869 [_G.GetSpellInfo(30754)] = "CENARION_FAVOR",
jcallahan@44 870 [_G.GetSpellInfo(24705)] = "GRIM_VISAGE",
jcallahan@44 871 [_G.GetSpellInfo(32098)] = "HONOR_HOLD_FAVOR",
jcallahan@44 872 [_G.GetSpellInfo(39913)] = "NAZGRELS_FERVOR",
jcallahan@44 873 [_G.GetSpellInfo(39953)] = "SONG_OF_BATTLE",
jcallahan@44 874 [_G.GetSpellInfo(61849)] = "SPIRIT_OF_SHARING",
jcallahan@44 875 [_G.GetSpellInfo(32096)] = "THRALLMARS_FAVOR",
jcallahan@44 876 [_G.GetSpellInfo(39911)] = "TROLLBANES_COMMAND",
jcallahan@44 877 [_G.GetSpellInfo(95987)] = "UNBURDENED",
jcallahan@44 878 [_G.GetSpellInfo(100951)] = "WOW_ANNIVERSARY",
jcallahan@44 879 }
jcallahan@44 880
jcallahan@44 881
jcallahan@44 882 local FACTION_NAMES = {
jcallahan@44 883 CENARION_CIRCLE = _G.GetFactionInfoByID(609),
jcallahan@44 884 HONOR_HOLD = _G.GetFactionInfoByID(946),
jcallahan@44 885 THE_SHATAR = _G.GetFactionInfoByID(935),
jcallahan@44 886 THRALLMAR = _G.GetFactionInfoByID(947),
jcallahan@44 887 }
jcallahan@44 888
jcallahan@44 889
jcallahan@44 890 local MODIFIERS = {
jcallahan@44 891 CENARION_FAVOR = {
jcallahan@44 892 faction = FACTION_NAMES.CENARION_CIRCLE,
jcallahan@44 893 modifier = 0.25,
jcallahan@44 894 },
jcallahan@44 895 GRIM_VISAGE = {
jcallahan@44 896 modifier = 0.1,
jcallahan@44 897 },
jcallahan@44 898 HONOR_HOLD_FAVOR = {
jcallahan@44 899 faction = FACTION_NAMES.HONOR_HOLD,
jcallahan@44 900 modifier = 0.25,
jcallahan@44 901 },
jcallahan@44 902 NAZGRELS_FERVOR = {
jcallahan@44 903 faction = FACTION_NAMES.THRALLMAR,
jcallahan@44 904 modifier = 0.1,
jcallahan@44 905 },
jcallahan@44 906 SONG_OF_BATTLE = {
jcallahan@44 907 faction = FACTION_NAMES.THE_SHATAR,
jcallahan@44 908 modifier = 0.1,
jcallahan@44 909 },
jcallahan@44 910 SPIRIT_OF_SHARING = {
jcallahan@44 911 modifier = 0.1,
jcallahan@44 912 },
jcallahan@44 913 THRALLMARS_FAVOR = {
jcallahan@44 914 faction = FACTION_NAMES.THRALLMAR,
jcallahan@44 915 modifier = 0.25,
jcallahan@44 916 },
jcallahan@44 917 TROLLBANES_COMMAND = {
jcallahan@44 918 faction = FACTION_NAMES.HONOR_HOLD,
jcallahan@44 919 modifier = 0.1,
jcallahan@44 920 },
jcallahan@44 921 UNBURDENED = {
jcallahan@44 922 modifier = 0.1,
jcallahan@44 923 },
jcallahan@44 924 WOW_ANNIVERSARY = {
jcallahan@44 925 modifier = 0.08,
jcallahan@44 926 }
jcallahan@44 927 }
jcallahan@44 928
jcallahan@44 929
jcallahan@92 930 function WDP:COMBAT_TEXT_UPDATE(event_name, message_type, faction_name, amount)
jcallahan@67 931 if message_type ~= "FACTION" or not reputation_npc_id then
jcallahan@44 932 return
jcallahan@44 933 end
jcallahan@44 934 UpdateFactionData()
jcallahan@44 935
jcallahan@46 936 if not faction_name or not faction_standings[faction_name] then
jcallahan@46 937 return
jcallahan@46 938 end
jcallahan@67 939 local npc = NPCEntry(reputation_npc_id)
jcallahan@98 940 reputation_npc_id = nil
jcallahan@46 941
jcallahan@44 942 if not npc then
jcallahan@98 943 private.harvesting = nil
jcallahan@44 944 return
jcallahan@44 945 end
jcallahan@98 946 npc.harvested = private.harvesting
jcallahan@98 947 private.harvesting = nil
jcallahan@98 948
jcallahan@44 949 local modifier = 1
jcallahan@44 950
jcallahan@44 951 if _G.IsSpellKnown(DIPLOMACY_SPELL_ID) then
jcallahan@44 952 modifier = modifier + 0.1
jcallahan@44 953 end
jcallahan@44 954
jcallahan@44 955 if _G.IsSpellKnown(MR_POP_RANK2_SPELL_ID) then
jcallahan@44 956 modifier = modifier + 0.1
jcallahan@44 957 elseif _G.IsSpellKnown(MR_POP_RANK1_SPELL_ID) then
jcallahan@44 958 modifier = modifier + 0.05
jcallahan@44 959 end
jcallahan@44 960
jcallahan@44 961 for buff_name, buff_label in pairs(REP_BUFFS) do
jcallahan@44 962 if _G.UnitBuff("player", buff_name) then
jcallahan@44 963 local modded_faction = MODIFIERS[buff_label].faction
jcallahan@44 964
jcallahan@44 965 if not modded_faction or faction_name == modded_faction then
jcallahan@44 966 modifier = modifier + MODIFIERS[buff_label].modifier
jcallahan@44 967 end
jcallahan@44 968 end
jcallahan@44 969 end
jcallahan@65 970 npc.reputations = npc.reputations or {}
jcallahan@65 971 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier)
jcallahan@32 972 end
jcallahan@44 973 end -- do-block
jcallahan@18 974
jcallahan@18 975
jcallahan@92 976 function WDP:ITEM_TEXT_BEGIN(event_name)
jcallahan@42 977 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
jcallahan@42 978
jcallahan@42 979 if not unit_idnum or unit_type ~= private.UNIT_TYPES.OBJECT or _G.UnitName("npc") ~= _G.ItemTextGetItem() then
jcallahan@42 980 return
jcallahan@42 981 end
jcallahan@42 982 UpdateDBEntryLocation("objects", unit_idnum)
jcallahan@42 983 end
jcallahan@42 984
jcallahan@42 985
jcallahan@13 986 do
jcallahan@40 987 local RE_GOLD = _G.GOLD_AMOUNT:gsub("%%d", "(%%d+)")
jcallahan@40 988 local RE_SILVER = _G.SILVER_AMOUNT:gsub("%%d", "(%%d+)")
jcallahan@40 989 local RE_COPPER = _G.COPPER_AMOUNT:gsub("%%d", "(%%d+)")
jcallahan@13 990
jcallahan@13 991
jcallahan@13 992 local function _moneyMatch(money, re)
jcallahan@13 993 return money:match(re) or 0
jcallahan@1 994 end
jcallahan@1 995
jcallahan@0 996
jcallahan@13 997 local function _toCopper(money)
jcallahan@13 998 if not money then
jcallahan@13 999 return 0
jcallahan@13 1000 end
jcallahan@40 1001 return _moneyMatch(money, RE_GOLD) * 10000 + _moneyMatch(money, RE_SILVER) * 100 + _moneyMatch(money, RE_COPPER)
jcallahan@1 1002 end
jcallahan@1 1003
jcallahan@1 1004
jcallahan@13 1005 local LOOT_VERIFY_FUNCS = {
jcallahan@16 1006 [AF.ITEM] = function()
jcallahan@16 1007 local locked_item_id
jcallahan@16 1008
jcallahan@16 1009 for bag_index = 0, _G.NUM_BAG_FRAMES do
jcallahan@16 1010 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do
jcallahan@16 1011 local _, _, is_locked = _G.GetContainerItemInfo(bag_index, slot_index)
jcallahan@16 1012
jcallahan@16 1013 if is_locked then
jcallahan@16 1014 locked_item_id = ItemLinkToID(_G.GetContainerItemLink(bag_index, slot_index))
jcallahan@16 1015 end
jcallahan@16 1016 end
jcallahan@16 1017 end
jcallahan@16 1018
jcallahan@28 1019 if not locked_item_id or (action_data.identifier and action_data.identifier ~= locked_item_id) then
jcallahan@16 1020 return false
jcallahan@16 1021 end
jcallahan@28 1022 action_data.identifier = locked_item_id
jcallahan@16 1023 return true
jcallahan@16 1024 end,
jcallahan@13 1025 [AF.NPC] = function()
jcallahan@17 1026 if not _G.UnitExists("target") or _G.UnitIsFriend("player", "target") or _G.UnitIsPlayer("target") or _G.UnitPlayerControlled("target") then
jcallahan@15 1027 return false
jcallahan@13 1028 end
jcallahan@34 1029 local unit_type, id_num = ParseGUID(_G.UnitGUID("target"))
jcallahan@27 1030 action_data.identifier = id_num
jcallahan@13 1031 return true
jcallahan@13 1032 end,
jcallahan@14 1033 [AF.OBJECT] = true,
jcallahan@17 1034 [AF.ZONE] = function()
jcallahan@38 1035 return _G.IsFishingLoot()
jcallahan@17 1036 end,
jcallahan@13 1037 }
jcallahan@13 1038
jcallahan@13 1039
jcallahan@13 1040 local LOOT_UPDATE_FUNCS = {
jcallahan@16 1041 [AF.ITEM] = function()
jcallahan@28 1042 GenericLootUpdate("items")
jcallahan@28 1043 end,
jcallahan@28 1044 [AF.NPC] = function()
jcallahan@75 1045 local difficulty_token = InstanceDifficultyToken()
jcallahan@105 1046 local loot_type = action_data.loot_label or "drops"
jcallahan@77 1047 local source_list = {}
jcallahan@75 1048
jcallahan@78 1049 for source_guid, loot_data in pairs(action_data.loot_sources) do
jcallahan@78 1050 local source_id = select(2, ParseGUID(source_guid))
jcallahan@75 1051 local npc = NPCEntry(source_id)
jcallahan@75 1052
jcallahan@75 1053 if npc then
jcallahan@75 1054 local encounter_data = npc.encounter_data[difficulty_token]
jcallahan@75 1055 encounter_data[loot_type] = encounter_data[loot_type] or {}
jcallahan@75 1056
jcallahan@78 1057 if not source_list[source_guid] then
jcallahan@77 1058 encounter_data.loot_counts = encounter_data.loot_counts or {}
jcallahan@77 1059 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1
jcallahan@77 1060 source_list[source_id] = true
jcallahan@77 1061 end
jcallahan@77 1062
jcallahan@75 1063 for item_id, quantity in pairs(loot_data) do
jcallahan@75 1064 table.insert(encounter_data[loot_type], ("%d:%d"):format(item_id, quantity))
jcallahan@75 1065 end
jcallahan@75 1066 end
jcallahan@75 1067 end
jcallahan@75 1068
jcallahan@75 1069 -- TODO: Remove this when GetLootSourceInfo() has values for money
jcallahan@79 1070 if #action_data.loot_list <= 0 then
jcallahan@79 1071 return
jcallahan@79 1072 end
jcallahan@29 1073 local npc = NPCEntry(action_data.identifier)
jcallahan@28 1074
jcallahan@28 1075 if not npc then
jcallahan@28 1076 return
jcallahan@28 1077 end
jcallahan@75 1078 local encounter_data = npc.encounter_data[difficulty_token]
jcallahan@29 1079 encounter_data[loot_type] = encounter_data[loot_type] or {}
jcallahan@16 1080
jcallahan@77 1081 if not source_list[action_data.identifier] then
jcallahan@77 1082 encounter_data.loot_counts = encounter_data.loot_counts or {}
jcallahan@77 1083 encounter_data.loot_counts[loot_type] = (encounter_data.loot_counts[loot_type] or 0) + 1
jcallahan@77 1084 end
jcallahan@77 1085
jcallahan@17 1086 for index = 1, #action_data.loot_list do
jcallahan@29 1087 table.insert(encounter_data[loot_type], action_data.loot_list[index])
jcallahan@16 1088 end
jcallahan@16 1089 end,
jcallahan@13 1090 [AF.OBJECT] = function()
jcallahan@28 1091 GenericLootUpdate("objects", InstanceDifficultyToken())
jcallahan@17 1092 end,
jcallahan@17 1093 [AF.ZONE] = function()
jcallahan@41 1094 local location_token = ("%s:%s:%s"):format(action_data.map_level, action_data.x, action_data.y)
jcallahan@41 1095
jcallahan@41 1096 -- This will start life as a boolean true.
jcallahan@41 1097 if _G.type(action_data.zone_data[location_token]) ~= "table" then
jcallahan@41 1098 action_data.zone_data[location_token] = {
jcallahan@41 1099 drops = {}
jcallahan@41 1100 }
jcallahan@41 1101 end
jcallahan@105 1102 local loot_count = ("%s_count"):format(action_data.loot_label or "drops")
jcallahan@41 1103 action_data.zone_data[location_token][loot_count] = (action_data.zone_data[location_token][loot_count] or 0) + 1
jcallahan@41 1104
jcallahan@41 1105 for index = 1, #action_data.loot_list do
jcallahan@41 1106 table.insert(action_data.zone_data[location_token].drops, action_data.loot_list[index])
jcallahan@41 1107 end
jcallahan@13 1108 end,
jcallahan@13 1109 }
jcallahan@13 1110
jcallahan@79 1111 -- Prevent opening the same loot window multiple times from recording data multiple times.
jcallahan@79 1112 local loot_guid_registry = {}
jcallahan@13 1113
jcallahan@92 1114 function WDP:LOOT_OPENED(event_name)
jcallahan@106 1115 if action_data.looting or not action_data.type then
jcallahan@18 1116 return
jcallahan@18 1117 end
jcallahan@13 1118 local verify_func = LOOT_VERIFY_FUNCS[action_data.type]
jcallahan@13 1119 local update_func = LOOT_UPDATE_FUNCS[action_data.type]
jcallahan@13 1120
jcallahan@14 1121 if not verify_func or not update_func then
jcallahan@13 1122 return
jcallahan@13 1123 end
jcallahan@13 1124
jcallahan@14 1125 if _G.type(verify_func) == "function" and not verify_func() then
jcallahan@14 1126 return
jcallahan@14 1127 end
jcallahan@80 1128 local guids_used = {}
jcallahan@17 1129 action_data.loot_list = {}
jcallahan@75 1130 action_data.loot_sources = {}
jcallahan@18 1131 action_data.looting = true
jcallahan@13 1132
jcallahan@55 1133 for loot_slot = 1, _G.GetNumLootItems() do
jcallahan@55 1134 local icon_texture, item_text, quantity, quality, locked = _G.GetLootSlotInfo(loot_slot)
jcallahan@55 1135 local slot_type = _G.GetLootSlotType(loot_slot)
jcallahan@13 1136
jcallahan@77 1137 -- TODO: Move LOOT_SLOT_X checks within loop when money is detectable via GetLootSourceInfo
jcallahan@77 1138 if slot_type == _G.LOOT_SLOT_ITEM then
jcallahan@78 1139 local loot_info = {
jcallahan@77 1140 _G.GetLootSourceInfo(loot_slot)
jcallahan@77 1141 }
jcallahan@75 1142
jcallahan@75 1143 -- TODO: Remove debugging
jcallahan@77 1144 -- print(("Loot slot %d: Source count: %d"):format(loot_slot, floor((#sources / 2) + 0.5)))
jcallahan@75 1145
jcallahan@77 1146 -- Odd index is GUID, even is count.
jcallahan@78 1147 for loot_index = 1, #loot_info, 2 do
jcallahan@78 1148 local source_guid = loot_info[loot_index]
jcallahan@77 1149
jcallahan@79 1150 if not loot_guid_registry[source_guid] then
jcallahan@79 1151 local loot_quantity = loot_info[loot_index + 1]
jcallahan@79 1152 local source_type, source_id = ParseGUID(source_guid)
jcallahan@79 1153 -- TODO: Remove debugging
jcallahan@79 1154 -- local source_key = ("%s:%d"):format(private.UNIT_TYPE_NAMES[source_type + 1], source_id)
jcallahan@79 1155 -- print(("GUID: %s - Type:ID: %s - Amount: %d"):format(loot_info[loot_index], source_key, loot_quantity))
jcallahan@79 1156
jcallahan@79 1157 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot))
jcallahan@79 1158 action_data.loot_sources[source_guid] = action_data.loot_sources[source_guid] or {}
jcallahan@79 1159 action_data.loot_sources[source_guid][item_id] = action_data.loot_sources[source_guid][item_id] or 0 + loot_quantity
jcallahan@80 1160 guids_used[source_guid] = true
jcallahan@79 1161 end
jcallahan@75 1162 end
jcallahan@82 1163 -- elseif slot_type == _G.LOOT_SLOT_MONEY then
jcallahan@82 1164 -- table.insert(action_data.loot_list, ("money:%d"):format(_toCopper(item_text)))
jcallahan@77 1165 elseif slot_type == _G.LOOT_SLOT_CURRENCY then
jcallahan@77 1166 table.insert(action_data.loot_list, ("currency:%d:%s"):format(quantity, icon_texture:match("[^\\]+$"):lower()))
jcallahan@13 1167 end
jcallahan@13 1168 end
jcallahan@80 1169
jcallahan@81 1170 for guid in pairs(guids_used) do
jcallahan@80 1171 loot_guid_registry[guid] = true
jcallahan@80 1172 end
jcallahan@13 1173 update_func()
jcallahan@106 1174 table.wipe(action_data)
jcallahan@1 1175 end
jcallahan@13 1176 end -- do-block
jcallahan@0 1177
jcallahan@0 1178
jcallahan@89 1179 function WDP:MAIL_SHOW(event_name)
jcallahan@89 1180 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
jcallahan@89 1181
jcallahan@89 1182 if not unit_idnum or unit_type ~= private.UNIT_TYPES.OBJECT then
jcallahan@89 1183 return
jcallahan@89 1184 end
jcallahan@89 1185 UpdateDBEntryLocation("objects", unit_idnum)
jcallahan@89 1186 end
jcallahan@89 1187
jcallahan@89 1188
jcallahan@44 1189 do
jcallahan@44 1190 local POINT_MATCH_PATTERNS = {
jcallahan@44 1191 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING:gsub("%%d", "(%%d+)")), -- May no longer be necessary
jcallahan@44 1192 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3:gsub("%%d", "(%%d+)")), -- May no longer be necessary
jcallahan@44 1193 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_5V5:gsub("%%d", "(%%d+)")), -- May no longer be necessary
jcallahan@44 1194 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_BG:gsub("%%d", "(%%d+)")),
jcallahan@44 1195 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3_BG:gsub("%%d", "(%%d+)")),
jcallahan@44 1196 }
jcallahan@5 1197
jcallahan@68 1198 local ITEM_REQ_REPUTATION_MATCH = "Requires (.-) %- (.*)"
jcallahan@87 1199 local ITEM_REQ_QUEST_MATCH1 = "Requires: .*"
jcallahan@87 1200 local ITEM_REQ_QUEST_MATCH2 = "Must have completed: .*"
jcallahan@68 1201
jcallahan@89 1202 function WDP:UpdateMerchantItems(event_name)
jcallahan@44 1203 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
jcallahan@4 1204
jcallahan@44 1205 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
jcallahan@44 1206 return
jcallahan@44 1207 end
jcallahan@55 1208 local current_filters = _G.GetMerchantFilter()
jcallahan@44 1209 local _, merchant_standing = UnitFactionStanding("target")
jcallahan@44 1210 local merchant = NPCEntry(unit_idnum)
jcallahan@44 1211 merchant.sells = merchant.sells or {}
jcallahan@5 1212
jcallahan@57 1213 _G.SetMerchantFilter(_G.LE_LOOT_FILTER_ALL)
jcallahan@57 1214 _G.MerchantFrame_Update()
jcallahan@57 1215
jcallahan@57 1216 local num_items = _G.GetMerchantNumItems()
jcallahan@35 1217
jcallahan@44 1218 for item_index = 1, num_items do
jcallahan@44 1219 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index)
jcallahan@44 1220 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index))
jcallahan@5 1221
jcallahan@44 1222 if item_id and item_id > 0 then
jcallahan@44 1223 local price_string = ActualCopperCost(copper_price, merchant_standing)
jcallahan@5 1224
jcallahan@68 1225 DatamineTT:ClearLines()
jcallahan@68 1226 DatamineTT:SetMerchantItem(item_index)
jcallahan@68 1227
jcallahan@68 1228 local num_lines = DatamineTT:NumLines()
jcallahan@68 1229
jcallahan@68 1230 for line_index = 1, num_lines do
jcallahan@68 1231 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
jcallahan@68 1232
jcallahan@68 1233 if not current_line then
jcallahan@68 1234 break
jcallahan@68 1235 end
jcallahan@68 1236 local faction, reputation = current_line:GetText():match(ITEM_REQ_REPUTATION_MATCH)
jcallahan@68 1237
jcallahan@68 1238 if faction or reputation then
jcallahan@68 1239 DBEntry("items", item_id).req_reputation = ("%s:%s"):format(faction:gsub("-", ""), reputation:upper())
jcallahan@68 1240 break
jcallahan@68 1241 end
jcallahan@68 1242 end
jcallahan@68 1243
jcallahan@87 1244 for line_index = 1, num_lines do
jcallahan@87 1245 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
jcallahan@87 1246
jcallahan@87 1247 if not current_line then
jcallahan@87 1248 break
jcallahan@87 1249 end
jcallahan@87 1250 local line_text = current_line:GetText()
jcallahan@87 1251 local quest_name = line_text:match(ITEM_REQ_QUEST_MATCH1) or line_text:match(ITEM_REQ_QUEST_MATCH2)
jcallahan@87 1252
jcallahan@87 1253 if quest_name then
jcallahan@87 1254 DBEntry("items", item_id).req_quest = ("%s"):format(quest_name:gsub("(.+): ", ""), quest_name)
jcallahan@87 1255 break
jcallahan@87 1256 end
jcallahan@87 1257 end
jcallahan@87 1258
jcallahan@44 1259 if extended_cost then
jcallahan@53 1260 local battleground_rating = 0
jcallahan@53 1261 local personal_rating = 0
jcallahan@53 1262 local required_season_amount
jcallahan@5 1263
jcallahan@68 1264 for line_index = 1, num_lines do
jcallahan@44 1265 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
jcallahan@5 1266
jcallahan@44 1267 if not current_line then
jcallahan@44 1268 break
jcallahan@44 1269 end
jcallahan@53 1270 required_season_amount = current_line:GetText():match("Requires earning a total of (%d+)\n(.-) for the season.")
jcallahan@5 1271
jcallahan@44 1272 for match_index = 1, #POINT_MATCH_PATTERNS do
jcallahan@44 1273 local match1, match2 = current_line:GetText():match(POINT_MATCH_PATTERNS[match_index])
jcallahan@53 1274 personal_rating = personal_rating + (match1 or 0)
jcallahan@53 1275 battleground_rating = battleground_rating + (match2 or 0)
jcallahan@5 1276
jcallahan@44 1277 if match1 or match2 then
jcallahan@44 1278 break
jcallahan@44 1279 end
jcallahan@44 1280 end
jcallahan@5 1281 end
jcallahan@44 1282 local currency_list = {}
jcallahan@44 1283 local item_count = _G.GetMerchantItemCostInfo(item_index)
jcallahan@50 1284
jcallahan@50 1285 -- Keeping this around in case Blizzard makes the two points diverge at some point.
jcallahan@53 1286 -- price_string = ("%s:%s:%s:%s"):format(price_string, battleground_rating, personal_rating, required_season_amount or 0)
jcallahan@53 1287 price_string = ("%s:%s:%s"):format(price_string, personal_rating, required_season_amount or 0)
jcallahan@5 1288
jcallahan@44 1289 for cost_index = 1, item_count do
jcallahan@44 1290 local icon_texture, amount_required, currency_link = _G.GetMerchantItemCostItem(item_index, cost_index)
jcallahan@44 1291 local currency_id = currency_link and ItemLinkToID(currency_link) or nil
jcallahan@44 1292
jcallahan@44 1293 if (not currency_id or currency_id < 1) and icon_texture then
jcallahan@44 1294 currency_id = icon_texture:match("[^\\]+$"):lower()
jcallahan@44 1295 end
jcallahan@44 1296
jcallahan@44 1297 if currency_id then
jcallahan@44 1298 currency_list[#currency_list + 1] = ("(%s:%s)"):format(amount_required, currency_id)
jcallahan@44 1299 end
jcallahan@44 1300 end
jcallahan@44 1301
jcallahan@44 1302 for currency_index = 1, #currency_list do
jcallahan@44 1303 price_string = ("%s:%s"):format(price_string, currency_list[currency_index])
jcallahan@5 1304 end
jcallahan@5 1305 end
jcallahan@61 1306 merchant.sells[item_id] = ("%s:%s:[%s]"):format(num_available, stack_size, price_string)
jcallahan@44 1307 end
jcallahan@44 1308 end
jcallahan@5 1309
jcallahan@44 1310 if _G.CanMerchantRepair() then
jcallahan@44 1311 merchant.can_repair = true
jcallahan@5 1312 end
jcallahan@57 1313 _G.SetMerchantFilter(current_filters)
jcallahan@57 1314 _G.MerchantFrame_Update()
jcallahan@4 1315 end
jcallahan@44 1316 end -- do-block
jcallahan@4 1317
jcallahan@89 1318
jcallahan@92 1319 function WDP:PET_BAR_UPDATE(event_name)
jcallahan@105 1320 if action_data.spell_label ~= "MIND_CONTROL" then
jcallahan@25 1321 return
jcallahan@25 1322 end
jcallahan@34 1323 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("pet"))
jcallahan@25 1324
jcallahan@25 1325 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
jcallahan@25 1326 return
jcallahan@25 1327 end
jcallahan@29 1328 NPCEntry(unit_idnum).mind_control = true
jcallahan@25 1329 table.wipe(action_data)
jcallahan@25 1330 end
jcallahan@25 1331
jcallahan@25 1332
jcallahan@115 1333 function WDP:PET_JOURNAL_LIST_UPDATE(event_name)
jcallahan@115 1334 local num_pets = LPJ:NumPets()
jcallahan@115 1335
jcallahan@115 1336 for index, pet_id in LPJ:IteratePetIDs() do
jcallahan@115 1337 local _, _, is_owned, _, level, _, _, name, icon, pet_type, npc_id, _, _, is_wild = _G.C_PetJournal.GetPetInfoByIndex(index)
jcallahan@115 1338
jcallahan@115 1339 if is_owned then
jcallahan@115 1340 local health, max_health, attack, speed, rarity = _G.C_PetJournal.GetPetStats(pet_id)
jcallahan@115 1341 local rarity_name = _G["ITEM_QUALITY" .. rarity - 1 .. "_DESC"]
jcallahan@115 1342 local npc = NPCEntry(npc_id)
jcallahan@115 1343 npc.wild_pet = is_wild or nil
jcallahan@115 1344 npc.battle_pet_data = npc.battle_pet_data or {}
jcallahan@115 1345 npc.battle_pet_data[rarity_name] = npc.battle_pet_data[rarity_name] or {}
jcallahan@115 1346 npc.battle_pet_data[rarity_name]["level_" .. level] = npc.battle_pet_data[rarity_name]["level_" .. level] or {}
jcallahan@115 1347
jcallahan@115 1348 local data = npc.battle_pet_data[rarity_name]["level_" .. level]
jcallahan@115 1349 data.max_health = max_health
jcallahan@115 1350 data.attack = attack
jcallahan@115 1351 data.speed = speed
jcallahan@115 1352 end
jcallahan@115 1353 end
jcallahan@115 1354 end
jcallahan@115 1355
jcallahan@115 1356
jcallahan@118 1357 function WDP:PLAYER_TARGET_CHANGED(event_name)
jcallahan@118 1358 if not PlayerTarget() then
jcallahan@118 1359 return
jcallahan@2 1360 end
jcallahan@118 1361 self:UpdateTargetLocation()
jcallahan@118 1362 end
jcallahan@2 1363
jcallahan@89 1364
jcallahan@12 1365 do
jcallahan@12 1366 local function UpdateQuestJuncture(point)
jcallahan@12 1367 local unit_name = _G.UnitName("questnpc")
jcallahan@9 1368
jcallahan@12 1369 if not unit_name then
jcallahan@12 1370 return
jcallahan@12 1371 end
jcallahan@34 1372 local unit_type, unit_id = ParseGUID(_G.UnitGUID("questnpc"))
jcallahan@9 1373
jcallahan@12 1374 if unit_type == private.UNIT_TYPES.OBJECT then
jcallahan@38 1375 UpdateDBEntryLocation("objects", unit_id)
jcallahan@12 1376 end
jcallahan@19 1377 local quest = DBEntry("quests", _G.GetQuestID())
jcallahan@12 1378 quest[point] = quest[point] or {}
jcallahan@12 1379 quest[point][("%s:%d"):format(private.UNIT_TYPE_NAMES[unit_type + 1], unit_id)] = true
jcallahan@24 1380
jcallahan@24 1381 return quest
jcallahan@12 1382 end
jcallahan@10 1383
jcallahan@12 1384
jcallahan@92 1385 function WDP:QUEST_COMPLETE(event_name)
jcallahan@97 1386 local quest = UpdateQuestJuncture("end")
jcallahan@97 1387
jcallahan@112 1388 if ALLOWED_LOCALES[CLIENT_LOCALE] then
jcallahan@112 1389 quest.reward_text = ReplaceKeywords(_G.GetRewardText())
jcallahan@112 1390 end
jcallahan@67 1391 -- Make sure the quest NPC isn't erroneously recorded as giving reputation for quests which award it.
jcallahan@67 1392 reputation_npc_id = nil
jcallahan@10 1393 end
jcallahan@10 1394
jcallahan@12 1395
jcallahan@92 1396 function WDP:QUEST_DETAIL(event_name)
jcallahan@24 1397 local quest = UpdateQuestJuncture("begin")
jcallahan@24 1398
jcallahan@46 1399 if not quest then
jcallahan@46 1400 return
jcallahan@46 1401 end
jcallahan@24 1402 quest.classes = quest.classes or {}
jcallahan@27 1403 quest.classes[PLAYER_CLASS] = true
jcallahan@24 1404
jcallahan@24 1405 quest.races = quest.races or {}
jcallahan@100 1406 quest.races[(PLAYER_RACE == "Pandaren") and ("%s_%s"):format(PLAYER_RACE, PLAYER_FACTION or "Neutral") or PLAYER_RACE] = true
jcallahan@10 1407 end
jcallahan@12 1408 end -- do-block
jcallahan@9 1409
jcallahan@9 1410
jcallahan@92 1411 function WDP:QUEST_LOG_UPDATE(event_name)
jcallahan@38 1412 local selected_quest = _G.GetQuestLogSelection() -- Save current selection to be restored when we're done.
jcallahan@36 1413 local entry_index, processed_quests = 1, 0
jcallahan@36 1414 local _, num_quests = _G.GetNumQuestLogEntries()
jcallahan@36 1415
jcallahan@36 1416 while processed_quests <= num_quests do
jcallahan@36 1417 local _, _, _, _, is_header, _, _, _, quest_id = _G.GetQuestLogTitle(entry_index)
jcallahan@36 1418
jcallahan@84 1419 if quest_id == 0 then
jcallahan@84 1420 processed_quests = processed_quests + 1
jcallahan@84 1421 elseif not is_header then
jcallahan@36 1422 _G.SelectQuestLogEntry(entry_index);
jcallahan@36 1423
jcallahan@36 1424 local quest = DBEntry("quests", quest_id)
jcallahan@36 1425 quest.timer = _G.GetQuestLogTimeLeft()
jcallahan@37 1426 quest.can_share = _G.GetQuestLogPushable() and true or nil
jcallahan@36 1427 processed_quests = processed_quests + 1
jcallahan@36 1428 end
jcallahan@36 1429 entry_index = entry_index + 1
jcallahan@36 1430 end
jcallahan@36 1431 _G.SelectQuestLogEntry(selected_quest)
jcallahan@4 1432 self:UnregisterEvent("QUEST_LOG_UPDATE")
jcallahan@4 1433 end
jcallahan@4 1434
jcallahan@4 1435
jcallahan@97 1436 function WDP:QUEST_PROGRESS(event_name)
jcallahan@112 1437 if not ALLOWED_LOCALES[CLIENT_LOCALE] then
jcallahan@112 1438 return
jcallahan@112 1439 end
jcallahan@97 1440 DBEntry("quests", _G.GetQuestID()).progress_text = ReplaceKeywords(_G.GetProgressText())
jcallahan@97 1441 end
jcallahan@97 1442
jcallahan@97 1443
jcallahan@92 1444 function WDP:UNIT_QUEST_LOG_CHANGED(event_name, unit_id)
jcallahan@4 1445 if unit_id ~= "player" then
jcallahan@4 1446 return
jcallahan@4 1447 end
jcallahan@4 1448 self:RegisterEvent("QUEST_LOG_UPDATE")
jcallahan@4 1449 end
jcallahan@4 1450
jcallahan@4 1451
jcallahan@92 1452 do
jcallahan@92 1453 local TRADESKILL_TOOLS = {
jcallahan@92 1454 Anvil = anvil_spell_ids,
jcallahan@92 1455 Forge = forge_spell_ids,
jcallahan@92 1456 }
jcallahan@92 1457
jcallahan@92 1458
jcallahan@92 1459 function WDP:TRADE_SKILL_SHOW(event_name)
jcallahan@92 1460 local profession_name, prof_level = _G.GetTradeSkillLine()
jcallahan@92 1461
jcallahan@92 1462 if profession_name == _G.UNKNOWN then
jcallahan@92 1463 return
jcallahan@92 1464 end
jcallahan@92 1465
jcallahan@92 1466 if _G.TradeSkillFrame and _G.TradeSkillFrame:IsVisible() then
jcallahan@92 1467 -- Clear the search box focus so the scan will have correct results.
jcallahan@92 1468 local search_box = _G.TradeSkillFrameSearchBox
jcallahan@92 1469 search_box:SetText("")
jcallahan@92 1470 _G.TradeSkillSearch_OnTextChanged(search_box)
jcallahan@92 1471 search_box:ClearFocus()
jcallahan@92 1472 search_box:GetScript("OnEditFocusLost")(search_box)
jcallahan@92 1473 end
jcallahan@92 1474 local header_list = {}
jcallahan@92 1475
jcallahan@92 1476 -- Save the current state of the TradeSkillFrame so it can be restored after we muck with it.
jcallahan@92 1477 local have_materials = _G.TradeSkillFrame.filterTbl.hasMaterials
jcallahan@92 1478 local have_skillup = _G.TradeSkillFrame.filterTbl.hasSkillUp
jcallahan@92 1479
jcallahan@92 1480 if have_materials then
jcallahan@92 1481 _G.TradeSkillFrame.filterTbl.hasMaterials = false
jcallahan@92 1482 _G.TradeSkillOnlyShowMakeable(false)
jcallahan@92 1483 end
jcallahan@92 1484
jcallahan@92 1485 if have_skillup then
jcallahan@92 1486 _G.TradeSkillFrame.filterTbl.hasSkillUp = false
jcallahan@92 1487 _G.TradeSkillOnlyShowSkillUps(false)
jcallahan@92 1488 end
jcallahan@92 1489 _G.SetTradeSkillInvSlotFilter(0, 1, 1)
jcallahan@92 1490 _G.TradeSkillUpdateFilterBar()
jcallahan@92 1491 _G.TradeSkillFrame_Update()
jcallahan@92 1492
jcallahan@92 1493 -- Expand all headers so we can see all the recipes there are
jcallahan@92 1494 for tradeskill_index = 1, _G.GetNumTradeSkills() do
jcallahan@92 1495 local name, tradeskill_type, _, is_expanded = _G.GetTradeSkillInfo(tradeskill_index)
jcallahan@92 1496
jcallahan@94 1497 if tradeskill_type == "header" or tradeskill_type == "subheader" then
jcallahan@92 1498 if not is_expanded then
jcallahan@92 1499 header_list[name] = true
jcallahan@92 1500 _G.ExpandTradeSkillSubClass(tradeskill_index)
jcallahan@92 1501 end
jcallahan@92 1502 else
jcallahan@92 1503 local spell_id = tonumber(_G.GetTradeSkillRecipeLink(tradeskill_index):match("^|c%x%x%x%x%x%x%x%x|H%w+:(%d+)"))
jcallahan@92 1504 local required_tool = _G.GetTradeSkillTools(tradeskill_index)
jcallahan@92 1505
jcallahan@92 1506 if required_tool then
jcallahan@92 1507 for tool_name, registry in pairs(TRADESKILL_TOOLS) do
jcallahan@92 1508 if required_tool:find(tool_name) then
jcallahan@92 1509 registry[spell_id] = true
jcallahan@92 1510 end
jcallahan@92 1511 end
jcallahan@92 1512 end
jcallahan@92 1513 end
jcallahan@92 1514 end
jcallahan@92 1515
jcallahan@92 1516 -- Restore the state of the things we changed.
jcallahan@92 1517 for tradeskill_index = 1, _G.GetNumTradeSkills() do
jcallahan@92 1518 local name, tradeskill_type, _, is_expanded = _G.GetTradeSkillInfo(tradeskill_index)
jcallahan@92 1519
jcallahan@92 1520 if header_list[name] then
jcallahan@92 1521 _G.CollapseTradeSkillSubClass(tradeskill_index)
jcallahan@92 1522 end
jcallahan@92 1523 end
jcallahan@92 1524 _G.TradeSkillFrame.filterTbl.hasMaterials = have_materials
jcallahan@92 1525 _G.TradeSkillOnlyShowMakeable(have_materials)
jcallahan@92 1526 _G.TradeSkillFrame.filterTbl.hasSkillUp = have_skillup
jcallahan@92 1527 _G.TradeSkillOnlyShowSkillUps(have_skillup)
jcallahan@92 1528
jcallahan@92 1529 _G.TradeSkillUpdateFilterBar()
jcallahan@92 1530 _G.TradeSkillFrame_Update()
jcallahan@92 1531 end
jcallahan@92 1532 end -- do-block
jcallahan@92 1533
jcallahan@92 1534
jcallahan@92 1535 function WDP:TRAINER_SHOW(event_name)
jcallahan@34 1536 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
jcallahan@29 1537 local npc = NPCEntry(unit_idnum)
jcallahan@58 1538
jcallahan@58 1539 if not npc then
jcallahan@58 1540 return
jcallahan@58 1541 end
jcallahan@27 1542 npc.teaches = npc.teaches or {}
jcallahan@27 1543
jcallahan@27 1544 -- Get the initial trainer filters
jcallahan@27 1545 local available = _G.GetTrainerServiceTypeFilter("available")
jcallahan@27 1546 local unavailable = _G.GetTrainerServiceTypeFilter("unavailable")
jcallahan@27 1547 local used = _G.GetTrainerServiceTypeFilter("used")
jcallahan@27 1548
jcallahan@27 1549 -- Clear the trainer filters
jcallahan@27 1550 _G.SetTrainerServiceTypeFilter("available", 1)
jcallahan@27 1551 _G.SetTrainerServiceTypeFilter("unavailable", 1)
jcallahan@27 1552 _G.SetTrainerServiceTypeFilter("used", 1)
jcallahan@27 1553
jcallahan@27 1554 for index = 1, _G.GetNumTrainerServices(), 1 do
jcallahan@27 1555 local spell_name, rank_name, _, _, required_level = _G.GetTrainerServiceInfo(index)
jcallahan@27 1556
jcallahan@27 1557 if spell_name then
jcallahan@27 1558 DatamineTT:ClearLines()
jcallahan@27 1559 DatamineTT:SetTrainerService(index)
jcallahan@27 1560
jcallahan@27 1561 local _, _, spell_id = DatamineTT:GetSpell()
jcallahan@27 1562
jcallahan@43 1563 if spell_id then
jcallahan@43 1564 local profession, min_skill = _G.GetTrainerServiceSkillReq(index)
jcallahan@43 1565 profession = profession or "General"
jcallahan@43 1566
jcallahan@43 1567 local class_professions = npc.teaches[PLAYER_CLASS]
jcallahan@43 1568 if not class_professions then
jcallahan@43 1569 npc.teaches[PLAYER_CLASS] = {}
jcallahan@43 1570 class_professions = npc.teaches[PLAYER_CLASS]
jcallahan@43 1571 end
jcallahan@43 1572
jcallahan@43 1573 local profession_skills = class_professions[profession]
jcallahan@43 1574 if not profession_skills then
jcallahan@43 1575 class_professions[profession] = {}
jcallahan@43 1576 profession_skills = class_professions[profession]
jcallahan@43 1577 end
jcallahan@43 1578 profession_skills[spell_id] = ("%d:%d"):format(required_level, min_skill)
jcallahan@27 1579 end
jcallahan@27 1580 end
jcallahan@27 1581 end
jcallahan@27 1582
jcallahan@27 1583 -- Reset the filters to what they were before
jcallahan@27 1584 _G.SetTrainerServiceTypeFilter("available", available or 0)
jcallahan@27 1585 _G.SetTrainerServiceTypeFilter("unavailable", unavailable or 0)
jcallahan@27 1586 _G.SetTrainerServiceTypeFilter("used", used or 0)
jcallahan@27 1587 end
jcallahan@27 1588
jcallahan@27 1589
jcallahan@1 1590 function WDP:UNIT_SPELLCAST_SENT(event_name, unit_id, spell_name, spell_rank, target_name, spell_line)
jcallahan@1 1591 if private.tracked_line or unit_id ~= "player" then
jcallahan@1 1592 return
jcallahan@1 1593 end
jcallahan@1 1594 local spell_label = private.SPELL_LABELS_BY_NAME[spell_name]
jcallahan@1 1595
jcallahan@1 1596 if not spell_label then
jcallahan@1 1597 return
jcallahan@1 1598 end
jcallahan@18 1599 table.wipe(action_data)
jcallahan@1 1600
jcallahan@1 1601 local tt_item_name, tt_item_link = _G.GameTooltip:GetItem()
jcallahan@1 1602 local tt_unit_name, tt_unit_id = _G.GameTooltip:GetUnit()
jcallahan@1 1603
jcallahan@1 1604 if not tt_unit_name and _G.UnitName("target") == target_name then
jcallahan@1 1605 tt_unit_name = target_name
jcallahan@1 1606 tt_unit_id = "target"
jcallahan@1 1607 end
jcallahan@1 1608 local spell_flags = private.SPELL_FLAGS_BY_LABEL[spell_label]
jcallahan@28 1609 local zone_name, area_id, x, y, map_level, instance_token = CurrentLocationData()
jcallahan@28 1610
jcallahan@28 1611 action_data.instance_token = instance_token
jcallahan@28 1612 action_data.map_level = map_level
jcallahan@28 1613 action_data.x = x
jcallahan@28 1614 action_data.y = y
jcallahan@121 1615 action_data.zone_data = ("%s:%d"):format(zone_name, area_id)
jcallahan@76 1616 action_data.spell_label = spell_label
jcallahan@105 1617
jcallahan@105 1618 if not private.NON_LOOT_SPELL_LABELS[spell_label] then
jcallahan@105 1619 action_data.loot_label = spell_label:lower()
jcallahan@105 1620 end
jcallahan@1 1621
jcallahan@16 1622 if tt_unit_name and not tt_item_name then
jcallahan@16 1623 if bit.band(spell_flags, AF.NPC) == AF.NPC then
jcallahan@16 1624 if not tt_unit_id or tt_unit_name ~= target_name then
jcallahan@16 1625 return
jcallahan@16 1626 end
jcallahan@16 1627 action_data.type = AF.NPC
jcallahan@16 1628 end
jcallahan@16 1629 elseif bit.band(spell_flags, AF.ITEM) == AF.ITEM then
jcallahan@16 1630 action_data.type = AF.ITEM
jcallahan@16 1631
jcallahan@16 1632 if tt_item_name and tt_item_name == target_name then
jcallahan@28 1633 action_data.identifier = ItemLinkToID(tt_item_link)
jcallahan@16 1634 elseif target_name and target_name ~= "" then
jcallahan@16 1635 local _, target_item_link = _G.GetItemInfo(target_name)
jcallahan@28 1636 action_data.identifier = ItemLinkToID(target_item_link)
jcallahan@16 1637 end
jcallahan@16 1638 elseif not tt_item_name and not tt_unit_name then
jcallahan@1 1639 if bit.band(spell_flags, AF.OBJECT) == AF.OBJECT then
jcallahan@17 1640 if target_name == "" then
jcallahan@17 1641 return
jcallahan@17 1642 end
jcallahan@121 1643 action_data.object_name = target_name
jcallahan@1 1644 action_data.type = AF.OBJECT
jcallahan@1 1645 elseif bit.band(spell_flags, AF.ZONE) == AF.ZONE then
jcallahan@38 1646 local identifier = ("%s:%s"):format(spell_label, _G["GameTooltipTextLeft1"]:GetText() or "NONE") -- Possible fishing pool name.
jcallahan@52 1647 action_data.zone_data = UpdateDBEntryLocation("zones", identifier)
jcallahan@17 1648 action_data.type = AF.ZONE
jcallahan@38 1649 action_data.identifier = identifier
jcallahan@1 1650 end
jcallahan@1 1651 end
jcallahan@1 1652 private.tracked_line = spell_line
jcallahan@0 1653 end
jcallahan@0 1654
jcallahan@94 1655
jcallahan@1 1656 function WDP:UNIT_SPELLCAST_SUCCEEDED(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id)
jcallahan@1 1657 if unit_id ~= "player" then
jcallahan@1 1658 return
jcallahan@1 1659 end
jcallahan@1 1660 private.tracked_line = nil
jcallahan@85 1661
jcallahan@86 1662 if spell_name:match("^Harvest.+") then
jcallahan@86 1663 reputation_npc_id = current_target_id
jcallahan@98 1664 private.harvesting = true
jcallahan@85 1665 end
jcallahan@92 1666
jcallahan@92 1667 if anvil_spell_ids[spell_id] then
jcallahan@92 1668 UpdateDBEntryLocation("objects", OBJECT_ID_ANVIL)
jcallahan@92 1669 elseif forge_spell_ids[spell_id] then
jcallahan@92 1670 UpdateDBEntryLocation("objects", OBJECT_ID_FORGE)
jcallahan@92 1671 end
jcallahan@0 1672 end
jcallahan@0 1673
jcallahan@90 1674
jcallahan@1 1675 function WDP:HandleSpellFailure(event_name, unit_id, spell_name, spell_rank, spell_line, spell_id)
jcallahan@1 1676 if unit_id ~= "player" then
jcallahan@1 1677 return
jcallahan@1 1678 end
jcallahan@0 1679
jcallahan@1 1680 if private.tracked_line == spell_line then
jcallahan@1 1681 private.tracked_line = nil
jcallahan@103 1682 table.wipe(action_data)
jcallahan@1 1683 end
jcallahan@0 1684 end
jcallahan@90 1685
jcallahan@90 1686
jcallahan@90 1687 do
jcallahan@90 1688 local function SetUnitField(field, required_type)
jcallahan@90 1689 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
jcallahan@90 1690
jcallahan@90 1691 if not unit_idnum or (required_type and unit_type ~= required_type) then
jcallahan@90 1692 return
jcallahan@90 1693 end
jcallahan@90 1694
jcallahan@90 1695 if unit_type == private.UNIT_TYPES.NPC then
jcallahan@90 1696 NPCEntry(unit_idnum)[field] = true
jcallahan@90 1697 elseif unit_type == private.UNIT_TYPES.OBJECT then
jcallahan@90 1698 DBEntry("objects", unit_idnum)[field] = true
jcallahan@93 1699 UpdateDBEntryLocation("objects", unit_idnum)
jcallahan@90 1700 end
jcallahan@90 1701 end
jcallahan@90 1702
jcallahan@90 1703
jcallahan@90 1704 function WDP:AUCTION_HOUSE_SHOW(event_name)
jcallahan@90 1705 SetUnitField("auctioneer", private.UNIT_TYPES.NPC)
jcallahan@90 1706 end
jcallahan@90 1707
jcallahan@90 1708
jcallahan@90 1709 function WDP:BANKFRAME_OPENED(event_name)
jcallahan@90 1710 SetUnitField("banker", private.UNIT_TYPES.NPC)
jcallahan@90 1711 end
jcallahan@90 1712
jcallahan@90 1713
jcallahan@90 1714 function WDP:BATTLEFIELDS_SHOW(event_name)
jcallahan@90 1715 SetUnitField("battlemaster", private.UNIT_TYPES.NPC)
jcallahan@90 1716 end
jcallahan@90 1717
jcallahan@90 1718
jcallahan@92 1719 function WDP:FORGE_MASTER_OPENED(event_name)
jcallahan@90 1720 SetUnitField("arcane_reforger", private.UNIT_TYPES.NPC)
jcallahan@90 1721 end
jcallahan@90 1722
jcallahan@90 1723
jcallahan@92 1724 function WDP:GOSSIP_SHOW(event_name)
jcallahan@90 1725 local gossip_options = { _G.GetGossipOptions() }
jcallahan@90 1726
jcallahan@90 1727 for index = 2, #gossip_options, 2 do
jcallahan@90 1728 if gossip_options[index] == "binder" then
jcallahan@90 1729 SetUnitField("innkeeper", private.UNIT_TYPES.NPC)
jcallahan@90 1730 return
jcallahan@90 1731 end
jcallahan@90 1732 end
jcallahan@90 1733 end
jcallahan@90 1734
jcallahan@90 1735
jcallahan@93 1736 function WDP:GUILDBANKFRAME_OPENED(event_name)
jcallahan@93 1737 SetUnitField("guild_bank", private.UNIT_TYPES.OBJECT)
jcallahan@93 1738 end
jcallahan@93 1739
jcallahan@93 1740
jcallahan@90 1741 function WDP:TAXIMAP_OPENED(event_name)
jcallahan@90 1742 SetUnitField("flight_master", private.UNIT_TYPES.NPC)
jcallahan@90 1743 end
jcallahan@90 1744
jcallahan@90 1745
jcallahan@90 1746 function WDP:TRANSMOGRIFY_OPEN(event_name)
jcallahan@90 1747 SetUnitField("transmogrifier", private.UNIT_TYPES.NPC)
jcallahan@90 1748 end
jcallahan@90 1749
jcallahan@90 1750
jcallahan@90 1751 function WDP:VOID_STORAGE_OPEN(event_name)
jcallahan@90 1752 SetUnitField("void_storage", private.UNIT_TYPES.NPC)
jcallahan@90 1753 end
jcallahan@90 1754 end -- do-block