comparison Main.lua @ 558:d423605eccf0

Updated Interface for Patch 8.0.1. Consolidated many constants left in Main.lua file. Removed Legion support. Added new BFA data.
author Caleb Atherton <atcaleb@twitch.tv>
date Tue, 17 Jul 2018 18:52:43 -0400
parents 98eb25ffc0c4
children eb77bf9c8e2f
comparison
equal deleted inserted replaced
557:b1db703b7340 558:d423605eccf0
25 25
26 local LibStub = _G.LibStub 26 local LibStub = _G.LibStub
27 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceConsole-3.0", "AceEvent-3.0") 27 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceConsole-3.0", "AceEvent-3.0")
28 28
29 local deformat = LibStub("LibDeformat-3.0") 29 local deformat = LibStub("LibDeformat-3.0")
30 local HereBeDragons -- This is set later, using 2.0 for BFA 30 local HereBeDragons = LibStub("HereBeDragons-2.0")
31 31
32 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate") 32 local DatamineTT = _G.CreateFrame("GameTooltip", "WDPDatamineTT", _G.UIParent, "GameTooltipTemplate")
33 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE") 33 DatamineTT:SetOwner(_G.WorldFrame, "ANCHOR_NONE")
34 34
35 35
36 -- CONSTANTS ---------------------------------------------------------- 36 -- CONSTANTS ----------------------------------------------------------
37 37
38 local AF = private.ACTION_TYPE_FLAGS 38 local AF = private.ACTION_TYPE_FLAGS
39 local CLIENT_LOCALE = _G.GetLocale() 39 local CLIENT_LOCALE = _G.GetLocale()
40 local DB_VERSION = 18 -- This is increased to 19 later for BFA 40 local DB_VERSION = 18
41 local DEBUGGING = false 41 local DEBUGGING = false
42 local EVENT_DEBUG = false 42 local EVENT_DEBUG = false
43 local IS_BFA = false -- This is set later if the Interface version is 80000
44 43
45 -- Timer durations in seconds 44 -- Timer durations in seconds
46 local DELAY_PROCESS_ITEMS = 30 45 local DELAY_PROCESS_ITEMS = 30
47 local DELAY_PROCESS_WORLD_QUESTS = 60 46 local DELAY_PROCESS_WORLD_QUESTS = 60
48 local DELAY_UPDATE_TARGET_LOCATION = 0.5 47 local DELAY_UPDATE_TARGET_LOCATION = 0.5
278 277
279 local ActualCopperCost 278 local ActualCopperCost
280 do 279 do
281 local BARTERING_SPELL_ID = 83964 280 local BARTERING_SPELL_ID = 83964
282 281
283 local STANDING_DISCOUNTS = {
284 HATED = 0,
285 HOSTILE = 0,
286 UNFRIENDLY = 0,
287 NEUTRAL = 0,
288 FRIENDLY = 0.05,
289 HONORED = 0.1,
290 REVERED = 0.15,
291 EXALTED = 0.2,
292 }
293
294
295 function ActualCopperCost(copper_cost, rep_standing) 282 function ActualCopperCost(copper_cost, rep_standing)
296 if not copper_cost or copper_cost == 0 then 283 if not copper_cost or copper_cost == 0 then
297 return 0 284 return 0
298 end 285 end
299 local modifier = 1 286 local modifier = 1
302 modifier = modifier - 0.1 289 modifier = modifier - 0.1
303 end 290 end
304 291
305 if rep_standing then 292 if rep_standing then
306 if PLAYER_RACE == "Goblin" then 293 if PLAYER_RACE == "Goblin" then
307 modifier = modifier - STANDING_DISCOUNTS["EXALTED"] 294 modifier = modifier - private.STANDING_DISCOUNTS["EXALTED"]
308 elseif STANDING_DISCOUNTS[rep_standing] then 295 elseif private.STANDING_DISCOUNTS[rep_standing] then
309 modifier = modifier - STANDING_DISCOUNTS[rep_standing] 296 modifier = modifier - private.STANDING_DISCOUNTS[rep_standing]
310 end 297 end
311 end 298 end
312 return math.floor(copper_cost / modifier) 299 return math.floor(copper_cost / modifier)
313 end 300 end
314 end -- do-block 301 end -- do-block
876 global_db = db.global 863 global_db = db.global
877 char_db = db.char 864 char_db = db.char
878 865
879 local raw_db = _G.WoWDBProfilerData 866 local raw_db = _G.WoWDBProfilerData
880 local build_num = tonumber(private.build_num) 867 local build_num = tonumber(private.build_num)
881
882 -- Check if it is Battle for Azeroth
883 if (tonumber(private.interface_num) == 80000) then
884 IS_BFA = true
885 HereBeDragons = LibStub("HereBeDragons-2.0")
886 DB_VERSION = 19
887 else
888 HereBeDragons = LibStub("HereBeDragons-1.0")
889 end
890 868
891 -- Get current region from API (flawed) 869 -- Get current region from API (flawed)
892 local current_region = _G.GetCurrentRegionName() or "XX" 870 local current_region = _G.GetCurrentRegionName() or "XX"
893 871
894 -- Wipe all data if DB version or build number changed 872 -- Wipe all data if DB version or build number changed
1181 end 1159 end
1182 end 1160 end
1183 end 1161 end
1184 1162
1185 1163
1186 local TargetedNPC 1164 local function TargetedNPC()
1187 do 1165 if not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or currently_drunk then
1188 local GENDER_NAMES = { 1166 current_target_id = nil
1189 "UNKNOWN", 1167 return
1190 "MALE", 1168 end
1191 "FEMALE", 1169 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
1192 } 1170
1193 1171 if not unit_idnum or not UnitTypeIsNPC(unit_type) then
1194 1172 return
1195 local REACTION_NAMES = { 1173 end
1196 "HATED", 1174 current_target_id = unit_idnum
1197 "HOSTILE", 1175
1198 "UNFRIENDLY", 1176 local npc = NPCEntry(unit_idnum)
1199 "NEUTRAL", 1177 local _, class_token = _G.UnitClass("target")
1200 "FRIENDLY", 1178 npc.class = class_token
1201 "HONORED", 1179 npc.faction = UnitFactionStanding("target")
1202 "REVERED", 1180 npc.genders = npc.genders or {}
1203 "EXALTED", 1181 npc.genders[private.GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED"] = true
1204 } 1182 npc.is_pvp = _G.UnitIsPVP("target") and true or nil
1205 1183 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), private.REACTION_NAMES[_G.UnitReaction("player", "target")])
1206 1184
1207 -- We should just use IDs here someday; WoWDB site knows all about different power types 1185 local encounter_data = npc:EncounterData(InstanceDifficultyToken()).stats
1208 local POWER_TYPE_NAMES = { 1186 local npc_level = ("level_%d"):format(_G.UnitLevel("target"))
1209 ["0"] = "MANA", 1187 local level_data = encounter_data[npc_level]
1210 ["1"] = "RAGE", 1188
1211 ["2"] = "FOCUS", 1189 if not level_data then
1212 ["3"] = "ENERGY", 1190 level_data = {}
1213 ["6"] = "RUNIC_POWER", 1191 encounter_data[npc_level] = level_data
1214 } 1192 end
1215 1193 level_data.max_health = level_data.max_health or _G.UnitHealthMax("target")
1216 1194
1217 function TargetedNPC() 1195 -- May not capture as much data as it could, since the API changed in Legion to report multiple types of power
1218 if not _G.UnitExists("target") or _G.UnitPlayerControlled("target") or currently_drunk then 1196 if not level_data.power then
1219 current_target_id = nil 1197 local max_power = _G.UnitPowerMax("target")
1220 return 1198
1221 end 1199 if max_power > 0 then
1222 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) 1200 local power_type = _G.UnitPowerType("target")
1223 1201 level_data.power = ("%s:%d"):format(private.POWER_TYPE_NAMES[tostring(power_type)] or power_type, max_power)
1224 if not unit_idnum or not UnitTypeIsNPC(unit_type) then 1202 end
1225 return 1203 end
1226 end 1204 name_to_id_map[_G.UnitName("target")] = unit_idnum
1227 current_target_id = unit_idnum 1205 return npc, unit_idnum
1228 1206 end
1229 local npc = NPCEntry(unit_idnum)
1230 local _, class_token = _G.UnitClass("target")
1231 npc.class = class_token
1232 npc.faction = UnitFactionStanding("target")
1233 npc.genders = npc.genders or {}
1234 npc.genders[GENDER_NAMES[_G.UnitSex("target")] or "UNDEFINED"] = true
1235 npc.is_pvp = _G.UnitIsPVP("target") and true or nil
1236 npc.reaction = ("%s:%s:%s"):format(_G.UnitLevel("player"), _G.UnitFactionGroup("player"), REACTION_NAMES[_G.UnitReaction("player", "target")])
1237
1238 local encounter_data = npc:EncounterData(InstanceDifficultyToken()).stats
1239 local npc_level = ("level_%d"):format(_G.UnitLevel("target"))
1240 local level_data = encounter_data[npc_level]
1241
1242 if not level_data then
1243 level_data = {}
1244 encounter_data[npc_level] = level_data
1245 end
1246 level_data.max_health = level_data.max_health or _G.UnitHealthMax("target")
1247
1248 -- May not capture as much data as it could, since the API changed in Legion to report multiple types of power
1249 if not level_data.power then
1250 local max_power = _G.UnitPowerMax("target")
1251
1252 if max_power > 0 then
1253 local power_type = _G.UnitPowerType("target")
1254 level_data.power = ("%s:%d"):format(POWER_TYPE_NAMES[tostring(power_type)] or power_type, max_power)
1255 end
1256 end
1257 name_to_id_map[_G.UnitName("target")] = unit_idnum
1258 return npc, unit_idnum
1259 end
1260 end -- do-block
1261 1207
1262 1208
1263 do 1209 do
1264 local COORD_MAX = 5 1210 local COORD_MAX = 5
1265 1211
1598 end 1544 end
1599 update_func(currency_id, quantity) 1545 update_func(currency_id, quantity)
1600 end 1546 end
1601 1547
1602 1548
1603 local BLACKLISTED_ITEMS = {
1604 [114116] = true,
1605 [114119] = true,
1606 [114120] = true,
1607 [116980] = true,
1608 [120319] = true,
1609 [120320] = true,
1610 [139593] = true,
1611 [139594] = true,
1612 [140590] = true,
1613 }
1614
1615
1616 local CHAT_MSG_LOOT_UPDATE_FUNCS = { 1549 local CHAT_MSG_LOOT_UPDATE_FUNCS = {
1617 [AF.ITEM] = function(item_id, quantity) 1550 [AF.ITEM] = function(item_id, quantity)
1618 -- Verify that we're still assigning data to the right items 1551 -- Verify that we're still assigning data to the right items
1619 if chat_loot_data.identifier and (private.CONTAINER_ITEM_ID_LIST[chat_loot_data.identifier] ~= nil) then 1552 if chat_loot_data.identifier and (private.CONTAINER_ITEM_ID_LIST[chat_loot_data.identifier] ~= nil) then
1620 Debug("CHAT_MSG_LOOT: AF.ITEM %d (%d)", item_id, quantity) 1553 Debug("CHAT_MSG_LOOT: AF.ITEM %d (%d)", item_id, quantity)
1682 -- We still want to record the item's data, even if it doesn't need its drop location recorded 1615 -- We still want to record the item's data, even if it doesn't need its drop location recorded
1683 RecordItemData(item_id, item_link, true) 1616 RecordItemData(item_id, item_link, true)
1684 1617
1685 -- Take action based on update category 1618 -- Take action based on update category
1686 local update_func = CHAT_MSG_LOOT_UPDATE_FUNCS[category] 1619 local update_func = CHAT_MSG_LOOT_UPDATE_FUNCS[category]
1687 if not category or not update_func or BLACKLISTED_ITEMS[item_id] then 1620 if not category or not update_func or private.BLACKLISTED_ITEMS[item_id] then
1688 return 1621 return
1689 end 1622 end
1690 update_func(item_id, quantity) 1623 update_func(item_id, quantity)
1691 end 1624 end
1692 end 1625 end
1795 1728
1796 do 1729 do
1797 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC) 1730 local FLAGS_NPC = bit.bor(_G.COMBATLOG_OBJECT_TYPE_GUARDIAN, _G.COMBATLOG_OBJECT_CONTROL_NPC)
1798 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC) 1731 local FLAGS_NPC_CONTROL = bit.bor(_G.COMBATLOG_OBJECT_AFFILIATION_OUTSIDER, _G.COMBATLOG_OBJECT_CONTROL_NPC)
1799 1732
1800 -- Spells that are cast by players/NPCs that are mistakely assigned as being cast by the target; must be blacklisted
1801 local BLACKLISTED_SPELLS = {
1802 [117526] = true, -- Binding Shot (cast by Hunters)
1803 [121308] = true, -- Disguise (cast by Rogues)
1804 [132464] = true, -- Chi Wave (cast by Monks)
1805 [132467] = true, -- Chi Wave (cast by Monks)
1806 [167432] = true, -- Savagery (cast by Warsong Commander)
1807 [175077] = true, -- Fearsome Battle Standard (cast by Fearsome Battle Standard item)
1808 [176813] = true, -- Itchy Spores (cast by Marsh Creatures in Ashran)
1809 [183901] = true, -- Stolen Strength (cast by Felblood NPCs in Tanaan Jungle)
1810 [183904] = true, -- Stolen Speed (cast by Felblood NPCs in Tanaan Jungle)
1811 [183907] = true, -- Stolen Fervor (cast by Felblood NPCs in Tanaan Jungle)
1812 [195802] = true, -- Moonkin Feather (applied by Moonfeather Statue; first stage buff)
1813 [195805] = true, -- Moonkin Molting (applied by Moonfeather Statue; second stage buff)
1814 [195810] = true, -- Feeling Moonkin (applied by Moonfeather Statue; third stage buff)
1815 [195816] = true, -- Owlvercome wth the Fever (applied by Moonfeather Statue; final stage buff)
1816 [213738] = true, -- Taste of Blood (applied by Fate and Fortune, Combat Rogue artifacts)
1817 [213877] = true, -- Vampiric Aura (used by Nathrezim Invasion bosses and transformed players)
1818 [215377] = true, -- The Maw Must Feed (applied by Maw of the Damned, Blood Death Knight artifact)
1819 [218136] = true, -- Arcane Invigoration (cast by Duskwatch Rune Scribes in The Arcway)
1820 [224762] = true, -- Leyline Rift (summoned by players with Leyline Mastery in Suramar)
1821 [225832] = true, -- Nightglow Wisp (cast by players using Wisp in a Bottle toy)
1822 }
1823
1824 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id) 1733 local function RecordNPCSpell(sub_event, source_guid, source_name, source_flags, dest_guid, dest_name, dest_flags, spell_id)
1825 if not spell_id or BLACKLISTED_SPELLS[spell_id] then 1734 if not spell_id or private.BLACKLISTED_SPELLS[spell_id] then
1826 return 1735 return
1827 end 1736 end
1828 local source_type, source_id = ParseGUID(source_guid) 1737 local source_type, source_id = ParseGUID(source_guid)
1829 1738
1830 if not source_id or not UnitTypeIsNPC(source_type) then 1739 if not source_id or not UnitTypeIsNPC(source_type) then
1900 SWING_DAMAGE = true, 1809 SWING_DAMAGE = true,
1901 } 1810 }
1902 1811
1903 1812
1904 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, spell_id, ...) 1813 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, spell_id, ...)
1905 if IS_BFA then 1814 time_stamp, sub_event, hide_caster, source_guid, source_name, source_flags, source_raid_flags, dest_guid, dest_name, dest_flags, dest_raid_flags, spell_id = CombatLogGetCurrentEventInfo()
1906 time_stamp, sub_event, hide_caster, source_guid, source_name, source_flags, source_raid_flags, dest_guid, dest_name, dest_flags, dest_raid_flags, spell_id = CombatLogGetCurrentEventInfo()
1907 end
1908 1815
1909 local combat_log_func = COMBAT_LOG_FUNCS[sub_event] 1816 local combat_log_func = COMBAT_LOG_FUNCS[sub_event]
1910 1817
1911 if not combat_log_func then 1818 if not combat_log_func then
1912 if DAMAGE_EVENTS[sub_event] then 1819 if DAMAGE_EVENTS[sub_event] then