diff --git a/.luacheckrc b/.luacheckrc index 81cfda2..6a15379 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -347,6 +347,8 @@ stds.ecs = { "C_Debug.TeleportToMapLocation", "C_Engraving", "C_Engraving.GetRuneForEquipmentSlot", + "C_EventUtils", + "C_EventUtils.IsEventValid", "C_FriendList.AddFriend", "C_FriendList.AddIgnore", "C_FriendList.AddOrDelIgnore", @@ -1742,6 +1744,7 @@ stds.ecs = { "KBSystem_GetServerNotice", "KBSystem_GetServerStatus", "LE_EXPANSION_BURNING_CRUSADE", + "LE_UNIT_STAT_SPIRIT", "LearnTalent", "LeaveBattlefield", "LeaveChannelByLocalID", diff --git a/Modules/Data/Constants.lua b/Modules/Data/Constants.lua index a880a09..af47531 100755 --- a/Modules/Data/Constants.lua +++ b/Modules/Data/Constants.lua @@ -64,6 +64,90 @@ Data.Aura = { [17800] = (ECS.IsWotlk and -5 or nil), -- Shadow Mastery 5/5 [22959] = (ECS.IsWotlk and -5 or nil), -- Improved Scorch }, + HealthRegen = { + [433] = 17, -- Food + [434] = 58, -- Food + [435] = 115, -- Food + [1127] = 162, -- Food + [1129] = 232, -- Food + [1131] = 358, -- Food + [2639] = 70, -- Food + [5004] = 17, -- Food + [5005] = 58, -- Food + [5006] = 115, -- Food + [5007] = 162, -- Food + [6410] = 70, -- Food + [7737] = 10, -- Food + [9177] = 134, -- Tigule's Strawberry Ice Cream + [10256] = 232, -- Food + [10257] = 358, -- Food + [12732] = 13, -- Shard of Afrasa + [13787] = 7, -- Demon Armor + [18124] = 358, -- Blessed Sunfruit + [18229] = 162, -- Food + [18230] = 162, -- Food + [18231] = 162, -- Food + [18232] = 162, -- Food + [18233] = 162, -- Food + [18234] = (ECS.IsClassic and 358 or 720), -- Food + [20798] = 3, -- Demon Skin + [21149] = 17, -- Egg Nog + [22731] = 358, -- Food + [24800] = 358, -- Food + [25660] = (ECS.IsClassic and 425 or 720), -- Food + [25695] = 358, -- Food + [25697] = 358, -- Old Enriched Manna Biscuit + [25700] = 37, -- Food + [25702] = 90, -- Food + [25886] = 135, -- Food + [25888] = 200, -- Food + [26030] = 358, -- Windblossom Berries + [26260] = 735, -- Food + [26401] = (ECS.IsClassic and 425 or 720), -- Food + [26472] = 268, -- Food + [26474] = 37, -- Food + [28616] = 597, -- Food + [29008] = 358, -- Food + [29038] = 200, -- Fizzy Energy Drink + [29041] = 368, -- Tasty Summer Treat + [29073] = (ECS.IsClassic and 530 or 720), -- Food + [446713] = 538, -- Food + [470362] = 358, -- Food + [470369] = 232, -- Food + [1225769] = 425, -- Food + [1225771] = 425, -- Food + [1225772] = 425, -- Food + [1225774] = 425, -- Food + }, + HealthRegenModifier = { + [3150] = -0.5, -- Rabies + [8384] = 0.5, -- Pure Water + [16143] = (ECS.IsWotlk and -0.5 or -1), -- Cadaver Worms + [16573] = (ECS.IsWotlk and -0.5 or -1), -- Putrid Bile + [24705] = (ECS.IsClassic and 0.25 or nil), -- Invocation of the Wickerman + [25794] = 1, -- Ahn'Qiraj Reward Buff (Melee - 20) + [25795] = 1, -- Ahn'Qiraj Reward Buff (Melee - 40) + [25796] = 1, -- Ahn'Qiraj Reward Buff (Melee - 60) + [30843] = -1, -- Enfeeble + [41292] = -1, -- Aura of Suffering + [430493] = -0.99, -- WoW Variety Show - Unhealthy! + }, + IsFelOrDemonArmor = { + [706] = true, + [1086] = true, + [11733] = true, + [11734] = true, + [11735] = true, + [27260] = true, + [28176] = true, + [28189] = true, + [44520] = true, + [44977] = true, + [47793] = true, + [47889] = true, + [47892] = true, + [47893] = true, + }, IsFeralForm = { [768] = true, -- Cat Form [5487] = true, -- Bear Form @@ -222,15 +306,15 @@ Data.Aura = { [10491] = (ECS.IsWotlk and 5/2 or nil), -- Mana Spring rank 2 [10493] = (ECS.IsWotlk and 5/2 or nil), -- Mana Spring rank 3 [10494] = (ECS.IsWotlk and 5/2 or nil), -- Mana Spring rank 4 - [19742] = ((ECS.IsTbc or ECS.IsWotlk) and 1 or nil), -- Blessing of Wisdom rank 1 - [19850] = ((ECS.IsTbc or ECS.IsWotlk) and 1 or nil), -- Blessing of Wisdom rank 2 - [19852] = ((ECS.IsTbc or ECS.IsWotlk) and 1 or nil), -- Blessing of Wisdom rank 3 - [19853] = ((ECS.IsTbc or ECS.IsWotlk) and 1 or nil), -- Blessing of Wisdom rank 4 - [19854] = ((ECS.IsTbc or ECS.IsWotlk) and 1 or nil), -- Blessing of Wisdom rank 5 - [25290] = ((ECS.IsTbc or ECS.IsWotlk) and 1 or nil), -- Blessing of Wisdom rank 6 + [19742] = (ECS.IsClassic and nil or 1), -- Blessing of Wisdom rank 1 + [19850] = (ECS.IsClassic and nil or 1), -- Blessing of Wisdom rank 2 + [19852] = (ECS.IsClassic and nil or 1), -- Blessing of Wisdom rank 3 + [19853] = (ECS.IsClassic and nil or 1), -- Blessing of Wisdom rank 4 + [19854] = (ECS.IsClassic and nil or 1), -- Blessing of Wisdom rank 5 + [25290] = (ECS.IsClassic and nil or 1), -- Blessing of Wisdom rank 6 [25569] = (ECS.IsWotlk and 5/2 or nil), -- Mana Spring rank 5 - [25894] = ((ECS.IsTbc or ECS.IsWotlk) and 1 or nil), -- Greater Blessing of Wisdom rank 1 - [25918] = ((ECS.IsTbc or ECS.IsWotlk) and 1 or nil), -- Greater Blessing of Wisdom rank 2 + [25894] = (ECS.IsClassic and nil or 1), -- Greater Blessing of Wisdom rank 1 + [25918] = (ECS.IsClassic and nil or 1), -- Greater Blessing of Wisdom rank 2 [27142] = 1, -- Blessing of Wisdom rank 7 [27143] = 1, -- Greater Blessing of Wisdom rank 3 [48935] = 1, -- Blessing of Wisdom rank 8 @@ -242,13 +326,83 @@ Data.Aura = { [58776] = 5/2, -- Mana Spring rank 7 [58777] = 5/2, -- Mana Spring rank 8 }, + PercentageHealthRegen = { + [1234] = 1.01*5, -- Tony's God Mode + [1908] = (ECS.IsClassic and 1/3 or 1/0.5)*5, -- Uber Heal Over Time + [16488] = (ECS.IsWotlk and 0.01/3 or 0.01/6)*5, -- Blood Craze Rank 1 + [16490] = (ECS.IsWotlk and 0.01/1.5 or 0.01/3)*5, -- Blood Craze Rank 2 + [16491] = (ECS.IsWotlk and 0.01 or 0.01/2)*5, -- Blood Craze Rank 3 + [18790] = (ECS.IsClassic and 0.03 or 0.02)/4*5, -- Fel Stamina + [20578] = 0.07/2*5, -- Cannibalize + [24005] = 0.02*5, -- Food + [24707] = 0.03*5, -- Food + [24869] = 0.02*5, -- Food + [25990] = 0.05*5, -- Graccu's Mince Meat Fruitcake + [26263] = 0.04*5, -- Dim Sum + [28176] = (ECS.IsWotlk and 0.02/5*5 or nil), -- Fel Armor Rank 1 + [28189] = (ECS.IsWotlk and 0.02/5*5 or nil), -- Fel Armor Rank 2 + [29055] = 0.04*5, -- Refreshing Red Apple + [29841] = 0.01/2*5, -- Second Wind + [29842] = 0.02/2*5, -- Second Wind + [29963] = 0.06*5, -- Mass Polymorph + [30839] = 1/3*5, -- Debuff Uber Heal Over Time + [30874] = 0.05*5, -- Gift of the Water Spirit + [36506] = 0.05*5, -- Energy Charge + [37460] = 0.05*5, -- Regeneration + [37709] = 0.04/2*5, -- Wild Regeneration + [38730] = 0.09/2*5, -- Refreshing Mist + [39578] = 0.05*5, -- Spirit Bond + [40503] = 0.2*5, -- Possession Transfer + [41962] = 0.2*5, -- Possession Transfer + [42771] = 0.01*5, -- Second Wind + [47892] = 0.02/5*5, -- Fel Armor Rank 3 + [47893] = 0.02/5*5, -- Fel Armor Rank 4 + [48082] = 0.05/5*5, -- Seed Pod + [48591] = 1*5, -- Periodic Heal Full Health Self + [48775] = 0.05*5, -- Healing Beam + [52011] = 0.04/2*5, -- Renewing Beam + [52067] = 0.04/2*5, -- Aura of Regeneration + [52979] = 0.05*5, -- Frigid Absorbtion + [53073] = 0.02*5, -- Worgen's Blood + [53087] = 0.02*5, -- Worgen's Blood + [53088] = 0.02*5, -- Worgen's Blood + [53089] = 0.02*5, -- Worgen's Blood + [53642] = 0.2*5, -- The Might of Mograine + [55549] = 0.1/2*5, -- Healing Winds + [55694] = 0.03*5, -- Enraged Regeneration + [57056] = 0.04/2*5, -- Aura of Regeneration + [58026] = 0.1/2*5, -- Blessing of the Crusade + [58361] = 0.25/2*5, -- The Might of Mograine + [60509] = 0.1*5, -- Strength of Wrynn + [60964] = 0.25*5, -- Strength of Wrynn + [61212] = 0.25*5, -- Warchief's Blessing + [61874] = 0.02*5, -- Food + [64660] = 0.3*5, -- First Aid Kit + [64670] = 0.25*5, -- Warchief's Blessing + [69634] = 0.05/2*5, -- Taste of Blood + [71068] = 0.04*5, -- Food + [71071] = 0.04*5, -- Food + [71073] = 0.04/5, -- Food + [71953] = 0.03/3*5, -- Radiance Aura + [74079] = 0.25*5, -- Elemental Blessing + [74503] = 0.25*5, -- Surgeon General's Warding + [75341] = 0.25*5, -- Elemental Blessing + [402913] = 0.04*5, -- Enraged Regeneration + [403619] = 0.02, -- Fel Armor + [413433] = 1.01/5*5, -- Degreelessness Mode + [413548] = 1.01, -- Degreelessness Mode + [437791] = 0.2*5, -- Ritual Leader + [449879] = 0.06*5, -- Dream Fog + [1226808] = 0.05*5, -- Food + [1231444] = 0.04/2*5, -- Eat Apple + }, PercentageMp5 = { - [12051] = ((ECS.IsTbc or ECS.IsWotlk) and 0.15/2*5 or nil), -- Evocation - [18792] = ((ECS.IsTbc or ECS.IsWotlk) and 0.03/4 or 0.02/4)*5, -- Fel Energy + [12051] = (ECS.IsClassic and nil or 0.15/2*5), -- Evocation + [18792] = (ECS.IsClassic and 0.02/4 or 0.03/4)*5, -- Fel Energy [24355] = 0.02*5, -- Drink [24707] = 0.03*5, -- Food [25990] = 0.05*5, -- Graccu's Mince Meat Fruitcake - [26263] = ((ECS.IsTbc or ECS.IsWotlk) and 0.03 or 0.04)*5, -- Dim Sum + [26263] = (ECS.IsClassic and 0.04 or 0.03)*5, -- Dim Sum [29055] = 0.04*5, -- Refreshing Red Apple [30024] = 0.2*5, -- Drink [30254] = 0.05*5, -- Evocation @@ -325,19 +479,19 @@ Data.Aura = { [10491] = (ECS.IsWotlk and nil or 5/2), -- Mana Spring rank 2 [10493] = (ECS.IsWotlk and nil or 5/2), -- Mana Spring rank 3 [10494] = (ECS.IsWotlk and nil or 5/2), -- Mana Spring rank 4 - [19742] = ((ECS.IsTbc or ECS.IsWotlk) and nil or 1), -- Blessing of Wisdom rank 1 - [19850] = ((ECS.IsTbc or ECS.IsWotlk) and nil or 1), -- Blessing of Wisdom rank 2 - [19852] = ((ECS.IsTbc or ECS.IsWotlk) and nil or 1), -- Blessing of Wisdom rank 3 - [19853] = ((ECS.IsTbc or ECS.IsWotlk) and nil or 1), -- Blessing of Wisdom rank 4 - [19854] = ((ECS.IsTbc or ECS.IsWotlk) and nil or 1), -- Blessing of Wisdom rank 5 + [19742] = (ECS.IsClassic and 1 or nil), -- Blessing of Wisdom rank 1 + [19850] = (ECS.IsClassic and 1 or nil), -- Blessing of Wisdom rank 2 + [19852] = (ECS.IsClassic and 1 or nil), -- Blessing of Wisdom rank 3 + [19853] = (ECS.IsClassic and 1 or nil), -- Blessing of Wisdom rank 4 + [19854] = (ECS.IsClassic and 1 or nil), -- Blessing of Wisdom rank 5 [24853] = 5/2, -- Mana Spring - [25290] = ((ECS.IsTbc or ECS.IsWotlk) and nil or 1), -- Blessing of Wisdom rank 6 + [25290] = (ECS.IsClassic and 1 or nil), -- Blessing of Wisdom rank 6 [25569] = (ECS.IsWotlk and nil or 5/2), -- Mana Spring rank 5 - [25894] = ((ECS.IsTbc or ECS.IsWotlk) and nil or 1), -- Greater Blessing of Wisdom rank 1 - [25918] = ((ECS.IsTbc or ECS.IsWotlk) and nil or 1), -- Greater Blessing of Wisdom rank 2 + [25894] = (ECS.IsClassic and 1 or nil), -- Greater Blessing of Wisdom rank 1 + [25918] = (ECS.IsClassic and 1 or nil), -- Greater Blessing of Wisdom rank 2 }, SpellCrit = { - [24907] = ((ECS.IsTBC or ECS.IsWotlk) and 5 or nil), -- Moonkin Aura + [24907] = (ECS.IsClassic and nil or 5), -- Moonkin Aura [29177] = 6, -- Elemental Devastation Rank 2 [29178] = 9, -- Elemental Devastation Rank 3 [30165] = 3, -- Elemental Devastation Rank 1 @@ -355,6 +509,10 @@ Data.Enchant = { [3849] = 81, -- Titanium Plating [7633] = 15, -- Presence of Valor }, + CombatHealthRegen = { + [2656] = 4, -- Enchant Boots - Vitality + [3244] = 7, -- Enchant Boots - Greater Vitality + }, Ids = { BIZNICK_SCOPE = 2523, -- 3% Hit from Biznicks 247x128 Accurascope }, @@ -460,3 +618,14 @@ Data.setNames = { VESTMENTS_OF_TRANSCENDENCE = "Vestments of Transcendence", WINDHAWK_ARMOR = "Windhawk Armor", } +Data.SpiritToHP5Constants = { + [Data.DRUID] = {0.09, 6.5}, + [Data.HUNTER] = {0.25, 6}, + [Data.MAGE] = {0.10, 6}, + [Data.PALADIN] = {0.25, 6}, + [Data.PRIEST] = {0.10, 6}, + [Data.ROGUE] = {0.50, 2}, + [Data.SHAMAN] = {0.11, 7}, + [Data.WARLOCK] = {0.07, 6}, + [Data.WARRIOR] = {0.80, 6}, +} diff --git a/Modules/Data/General.lua b/Modules/Data/General.lua index 711f1b8..bf5bdf5 100644 --- a/Modules/Data/General.lua +++ b/Modules/Data/General.lua @@ -3,6 +3,9 @@ local Data = ECSLoader:ImportModule("Data") ---@type DataUtils local DataUtils = ECSLoader:ImportModule("DataUtils") +local _HP5 = {} + +local _, _, classId = UnitClass("player") ---@return string function Data:GetMovementSpeed() @@ -20,4 +23,93 @@ function Data:GetMovementSpeed() currentSpeed = currentSpeed / 7 * 100 return DataUtils:Round(currentSpeed, 0) .. "%" -end \ No newline at end of file +end + +---@return number, number +function Data:GetHP5() + local bonusHp5 = _HP5:GetMP5FromSpirit() + local bonusCombatHp5 = 0 + local mod = 1 + local talentMod = _HP5:GetDemonicAegisTalentModifier() + 1 + local combatModifier = 0 + local maxhealth = UnitHealthMax("player") + + if C_SpellBook.IsSpellKnown(20555) then -- Troll passive + mod = mod + 0.1 + combatModifier = combatModifier + 0.1 + end + + for i = 1, 18 do + local itemLink = GetInventoryItemLink("player", i) + if itemLink then + local stats = GetItemStats(itemLink) + if stats then + local statHP5 = stats["ITEM_MOD_HEALTH_REGENERATION_SHORT"] + if statHP5 then + bonusHp5 = bonusHp5 + statHP5 + 1 + end + end + local enchant = DataUtils:GetEnchantFromItemLink(itemLink) + if enchant then + bonusCombatHp5 = bonusCombatHp5 + (Data.Enchant.CombatHealthRegen[enchant] or 0) + end + end + end + + local i = 1 + repeat + local aura = C_UnitAuras.GetBuffDataByIndex("player", i) + if aura and aura.spellId then + local DemonicAegis = (Data.IsFelOrDemonArmor[aura.spellId] and talentMod or 1) + if aura.spellId == 2645 and C_SpellBook.IsSpellKnown(59289) then + bonusHp5 = bonusHp5 + 0.01 * 5 * maxhealth -- Glyph of Ghost Wolf + end + mod = mod + (Data.Aura.HealthRegenModifier[aura.spellId] or 0) + bonusHp5 = bonusHp5 + (Data.Aura.HealthRegen[aura.spellId] or 0) * DemonicAegis + bonusHp5 = bonusHp5 + (Data.Aura.PercentageHealthRegen[aura.spellId] or 0) * maxhealth * DemonicAegis + end + i = i + 1 + until (not aura) + + i = 1 + repeat + local aura = C_UnitAuras.GetDebuffDataByIndex("player", i) + if aura and aura.spellId then + bonusHp5 = bonusHp5 + (Data.Aura.PercentageHealthRegen[aura.spellId] or 0) * maxhealth + mod = mod + (Data.Aura.HealthRegenModifier[aura.spellId] or 0) + end + i = i + 1 + until (not aura) + + local hp5 = bonusHp5 * mod + local combatHp5 = bonusCombatHp5 * mod + hp5 * combatModifier + return hp5, combatHp5 +end + +---@return number +function _HP5:GetHP5FromSpirit() + local c = Data.SpiritToHP5Constants[classId] + local spirit, _, _, _ = UnitStat("player", LE_UNIT_STAT_SPIRIT) + local hp5 = c[1] * spirit + if spirit >= 50 then + hp5 = hp5 + c[2] + else + hp5 = hp5 + c[2] * spirit / 50 + end + return DataUtils:Round(hp5 * 5, 2) +end + +---@return number +function _HP5:GetDemonicAegisTalentModifier() + local mod = 0 + if classId == Data.WARLOCK then + if C_SpellBook.IsSpellKnown(30145) then + mod = 0.3 -- Demonic Aegis Rank 3 + elseif C_SpellBook.IsSpellKnown(30144) then + mod = 0.2 -- Demonic Aegis Rank 2 + elseif C_SpellBook.IsSpellKnown(30143) then + mod = 0.1 -- Demonic Aegis Rank 1 + end + end + return mod +end diff --git a/Modules/EventHandler.lua b/Modules/EventHandler.lua index 646380d..5c55a7e 100644 --- a/Modules/EventHandler.lua +++ b/Modules/EventHandler.lua @@ -43,6 +43,9 @@ function EventHandler.HandleOnEvent(self,event, ...) if event == "ACTIVE_TALENT_GROUP_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "COMBAT_RATING_UPDATE" or + event == "GLYPH_ADDED" or + event == "GLYPH_REMOVED" or + event == "GLYPH_UPDATED" or event == "PLAYER_LEVEL_UP" or event == "PLAYER_MOUNT_DISPLAY_CHANGED" or event == "PLAYER_TALENT_UPDATE" or @@ -56,6 +59,7 @@ function EventHandler.HandleOnEvent(self,event, ...) event == "UNIT_ATTACK_SPEED" or event == "UNIT_AURA" or event == "UNIT_DAMAGE" or + event == "UNIT_MAXHEALTH" or (event == "UNIT_MAXPOWER" and args[2] == "MANA") or event == "UNIT_SPELL_HASTE" or event == "UNIT_STATS" or @@ -67,7 +71,6 @@ function EventHandler.HandleOnEvent(self,event, ...) statsFrame:SetScript("OnUpdate", DelayedUpdateInformation) end end - if (event == "INSPECT_READY" and args[1] == UnitGUID("player")) or event == "PLAYER_EQUIPMENT_CHANGED" then DelayedUpdateGearColorFrames() end diff --git a/Modules/Init.lua b/Modules/Init.lua index cfc14dd..35a65d5 100644 --- a/Modules/Init.lua +++ b/Modules/Init.lua @@ -92,13 +92,15 @@ function _Init.RegisterEvents(eventFrame) eventFrame:RegisterUnitEvent("UNIT_ATTACK_POWER", "player") eventFrame:RegisterUnitEvent("UNIT_AURA", "player") -- Triggers whenever the player gains or loses a buff/debuff eventFrame:RegisterUnitEvent("UNIT_DAMAGE", "player") + eventFrame:RegisterUnitEvent("UNIT_MAXHEALTH", "player") eventFrame:RegisterUnitEvent("UNIT_MAXPOWER", "player") eventFrame:RegisterUnitEvent("UNIT_SPELL_HASTE", "player") eventFrame:RegisterUnitEvent("UNIT_STATS", "player") eventFrame:RegisterUnitEvent("UNIT_RANGED_ATTACK_POWER", "player") eventFrame:RegisterUnitEvent("UNIT_RANGEDDAMAGE", "player") eventFrame:RegisterEvent("UPDATE_SHAPESHIFT_FORM") - if ECS.IsTbc or ECS.IsWotlk then + + if (C_EventUtils.IsEventValid("SOCKET_INFO_SUCCESS")) then eventFrame:RegisterEvent("SOCKET_INFO_SUCCESS") -- Triggers whenever the player successfully sockets an item GearManagerDialog:HookScript("OnShow", function() @@ -108,7 +110,12 @@ function _Init.RegisterEvents(eventFrame) Stats:ShowWindow() end) end - if ECS.IsSoD then + if (C_EventUtils.IsEventValid("GLYPH_ADDED")) then + eventFrame:RegisterEvent("GLYPH_ADDED") + eventFrame:RegisterEvent("GLYPH_UPDATED") + eventFrame:RegisterEvent("GLYPH_REMOVED") + end + if (C_EventUtils.IsEventValid("RUNE_UPDATED")) then eventFrame:RegisterEvent("RUNE_UPDATED") -- Triggers whenever the player changed a rune end end