diff --git a/Modules/Config/Config.lua b/Modules/Config/Config.lua index a0d2ac2a..fc7286f9 100755 --- a/Modules/Config/Config.lua +++ b/Modules/Config/Config.lua @@ -1,3 +1,9 @@ +local ECS = ECS +local ECSLoader = ECSLoader +local insert = table.insert +local LibStub = LibStub +local ReloadUI = ReloadUI + ------------------------------------------------------------------ -- Modules ------------------------------------------------------------------ @@ -35,7 +41,7 @@ function Config.CreateWindow() configFrame:Hide(); ECSConfigFrame = configFrame.frame; - table.insert(UISpecialFrames, "ECSConfigFrame"); + insert(UISpecialFrames, "ECSConfigFrame"); end _CreateGUI = function() diff --git a/Modules/Config/DefenseSection.lua b/Modules/Config/DefenseSection.lua index 202a3a54..b2d94291 100755 --- a/Modules/Config/DefenseSection.lua +++ b/Modules/Config/DefenseSection.lua @@ -1,3 +1,7 @@ +local ECSLoader = ECSLoader +local IsClassic = ECS.IsClassic +local IsSpellKnown = C_SpellBook.IsSpellKnown + ---@class Config local Config = ECSLoader:ImportModule("Config") local _Config = Config.private @@ -113,7 +117,7 @@ function _Config:LoadDefenseSection() name = function() return i18n("Defense Rating") end, desc = function() return i18n("Shows/Hides the defense rating.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return (not ExtendedCharacterStats.profile.defense.display); end, get = function () return ExtendedCharacterStats.profile.defense.defenseRating.display; end, set = function (_, value) @@ -195,7 +199,7 @@ function _Config:LoadDefenseSection() name = function() return i18n("Resilience") end, desc = function() return i18n("Shows/Hides the resilience value.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return (not ExtendedCharacterStats.profile.defense.display); end, get = function () return ExtendedCharacterStats.profile.defense.resilienceRating.display; end, set = function (_, value) diff --git a/Modules/Config/GeneralSection.lua b/Modules/Config/GeneralSection.lua index 8adafb23..aa18d286 100644 --- a/Modules/Config/GeneralSection.lua +++ b/Modules/Config/GeneralSection.lua @@ -1,3 +1,5 @@ +local ECSLoader = ECSLoader + ---@class Config local Config = ECSLoader:ImportModule("Config") local _Config = Config.private diff --git a/Modules/Config/ManaSection.lua b/Modules/Config/ManaSection.lua index d62c4f5c..741dcc0d 100755 --- a/Modules/Config/ManaSection.lua +++ b/Modules/Config/ManaSection.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local UnitHasMana = UnitHasMana + ---@class Config local Config = ECSLoader:ImportModule("Config") local _Config = Config.private diff --git a/Modules/Config/MeleeSection.lua b/Modules/Config/MeleeSection.lua index 65683234..f905210c 100755 --- a/Modules/Config/MeleeSection.lua +++ b/Modules/Config/MeleeSection.lua @@ -1,3 +1,8 @@ +local CanDualWield = CanDualWield +local ECSLoader = ECSLoader +local IsClassic = ECS.IsClassic +local IsWotlk = ECS.IsWotlk + ---@class Config local Config = ECSLoader:ImportModule("Config") local _Config = Config.private @@ -59,7 +64,7 @@ function _Config:LoadMeleeSection() name = function() return i18n("Armor Pen.") end, desc = function() return i18n("Shows/Hides the armor penetration value.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return (not ExtendedCharacterStats.profile.melee.display); end, get = function () return ExtendedCharacterStats.profile.melee.penetration.display; end, set = function (_, value) @@ -73,7 +78,7 @@ function _Config:LoadMeleeSection() name = function() return i18n("Armor Pen. Rating") end, desc = function() return i18n("Shows/Hides the armor penetration rating value.") end, width = 1.5, - hidden = function() return not ECS.IsWotlk end, + hidden = function() return not IsWotlk end, disabled = function() return (not ExtendedCharacterStats.profile.melee.display); end, get = function () return ExtendedCharacterStats.profile.melee.penetrationRating.display; end, set = function (_, value) @@ -87,7 +92,7 @@ function _Config:LoadMeleeSection() name = function() return i18n("Expertise") end, desc = function() return i18n("Shows/Hides the expertise value.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return (not ExtendedCharacterStats.profile.melee.display); end, get = function () return ExtendedCharacterStats.profile.melee.expertise.display; end, set = function (_, value) @@ -101,7 +106,7 @@ function _Config:LoadMeleeSection() name = function() return i18n("Expertise Rating") end, desc = function() return i18n("Shows/Hides the expertise rating.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return (not ExtendedCharacterStats.profile.melee.display); end, get = function () return ExtendedCharacterStats.profile.melee.expertiseRating.display; end, set = function (_, value) @@ -115,7 +120,7 @@ function _Config:LoadMeleeSection() name = function() return i18n("Haste Rating") end, desc = function() return i18n("Shows/Hides the melee haste rating.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return (not ExtendedCharacterStats.profile.melee.display); end, get = function () return ExtendedCharacterStats.profile.melee.hasteRating.display; end, set = function (_, value) @@ -129,7 +134,7 @@ function _Config:LoadMeleeSection() name = function() return i18n("Haste Bonus") end, desc = function() return i18n("Shows/Hides the melee haste bonus value.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return (not ExtendedCharacterStats.profile.melee.display); end, get = function () return ExtendedCharacterStats.profile.melee.hasteBonus.display; end, set = function (_, value) @@ -162,7 +167,7 @@ function _Config:LoadMeleeSection() name = function() return i18n("Hit Rating") end, desc = function() return i18n("Shows/Hides the melee hit rating.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return ((not ExtendedCharacterStats.profile.melee.display) or (not ExtendedCharacterStats.profile.melee.hit.display)) @@ -229,7 +234,7 @@ function _Config:LoadMeleeSection() name = function() return i18n("Glancing Blow") end, desc = function() return i18n("Shows/Hides all glancing blow stats") end, width = 1.5, - hidden = function() return ECS.IsWotlk end, + hidden = function() return IsWotlk end, disabled = function() return (not ExtendedCharacterStats.profile.melee.display); end, get = function () return ExtendedCharacterStats.profile.melee.glance.display; end, set = function (_, value) @@ -242,7 +247,7 @@ function _Config:LoadMeleeSection() order = 6, inline = true, name = function() return i18n("Melee Glance Values") end, - hidden = function() return ECS.IsWotlk end, + hidden = function() return IsWotlk end, args = { meleeGlance = { type = "toggle", diff --git a/Modules/Config/RangeSection.lua b/Modules/Config/RangeSection.lua index 56a5213f..55b43ef2 100755 --- a/Modules/Config/RangeSection.lua +++ b/Modules/Config/RangeSection.lua @@ -1,3 +1,8 @@ +local ECSLoader = ECSLoader +local IsClassic = ECS.IsClassic +local IsWotlk = ECS.IsWotlk +local UnitHasRelicSlot = UnitHasRelicSlot + ---@class Config local Config = ECSLoader:ImportModule("Config") local _Config = Config.private @@ -73,7 +78,7 @@ function _Config:LoadRangeSection() name = function() return i18n("Armor Pen. Rating") end, desc = function() return i18n("Shows/Hides the armor penetration rating value.") end, width = 1.5, - hidden = function() return (not ECS.IsWotlk) end, + hidden = function() return (not IsWotlk) end, disabled = function() return (not ExtendedCharacterStats.profile.ranged.display); end, get = function () return ExtendedCharacterStats.profile.ranged.penetrationRating.display; end, set = function (_, value) @@ -87,7 +92,7 @@ function _Config:LoadRangeSection() name = function() return i18n("Haste Rating") end, desc = function() return i18n("Shows/Hides the ranged haste rating.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return (not ExtendedCharacterStats.profile.ranged.display); end, get = function () return ExtendedCharacterStats.profile.ranged.hasteRating.display; end, set = function (_, value) @@ -101,7 +106,7 @@ function _Config:LoadRangeSection() name = function() return i18n("Haste Bonus") end, desc = function() return i18n("Shows/Hides the ranged haste bonus value.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return (not ExtendedCharacterStats.profile.ranged.display); end, get = function () return ExtendedCharacterStats.profile.ranged.hasteBonus.display; end, set = function (_, value) @@ -147,7 +152,7 @@ function _Config:LoadRangeSection() name = function() return i18n("Hit Rating") end, desc = function() return i18n("Shows/Hides the ranged hit rating.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return ((not ExtendedCharacterStats.profile.ranged.display) or (not ExtendedCharacterStats.profile.ranged.hit.display)) diff --git a/Modules/Config/SpellSchoolsSection.lua b/Modules/Config/SpellSchoolsSection.lua index bc3b5881..6024029d 100644 --- a/Modules/Config/SpellSchoolsSection.lua +++ b/Modules/Config/SpellSchoolsSection.lua @@ -1,3 +1,5 @@ +local ECSLoader = ECSLoader + ---@class Config local Config = ECSLoader:ImportModule("Config") local _Config = Config.private diff --git a/Modules/Config/SpellSection.lua b/Modules/Config/SpellSection.lua index 3e971d7e..4f7fbe42 100755 --- a/Modules/Config/SpellSection.lua +++ b/Modules/Config/SpellSection.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local IsClassic = ECS.IsClassic + ---@class Config local Config = ECSLoader:ImportModule("Config") local _Config = Config.private @@ -46,7 +49,7 @@ function _Config:LoadSpellSection() name = function() return i18n("Haste Rating") end, desc = function() return i18n("Shows/Hides the spell haste rating value.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return (not ExtendedCharacterStats.profile.spell.display); end, get = function () return ExtendedCharacterStats.profile.spell.hasteRating.display; end, set = function (_, value) @@ -92,7 +95,7 @@ function _Config:LoadSpellSection() name = function() return i18n("Hit Rating") end, desc = function() return i18n("Shows/Hides the spell hit rating.") end, width = 1.5, - hidden = function() return ECS.IsClassic end, + hidden = function() return IsClassic end, disabled = function() return ((not ExtendedCharacterStats.profile.spell.display) or (not ExtendedCharacterStats.profile.spell.hit.display)) diff --git a/Modules/Data/Constants.lua b/Modules/Data/Constants.lua index 7f424a18..0d99403b 100755 --- a/Modules/Data/Constants.lua +++ b/Modules/Data/Constants.lua @@ -1,3 +1,7 @@ +local ECSLoader = ECSLoader +local IsClassic = ECS.IsClassic +local IsWotlk = ECS.IsWotlk + ---@class Data local Data = ECSLoader:ImportModule("Data") @@ -22,14 +26,14 @@ Data.DRUID = 11 Data.Aura = { AllowCastingManaRegeneration = { - [6117] = (ECS.IsWotlk and 0.5 or 0.3), -- Mage Armor rank 1 + [6117] = (IsWotlk and 0.5 or 0.3), -- Mage Armor rank 1 [12051] = 1, -- Evocation - [15271] = (ECS.IsWotlk and 0.83 or 0.5), -- Spirit Tap + [15271] = (IsWotlk and 0.83 or 0.5), -- Spirit Tap [18371] = 0.5, -- Soul Siphon - [22782] = (ECS.IsWotlk and 0.5 or 0.3), -- Mage Armor rank 2 - [22783] = (ECS.IsWotlk and 0.5 or 0.3), -- Mage Armor rank 3 + [22782] = (IsWotlk and 0.5 or 0.3), -- Mage Armor rank 2 + [22783] = (IsWotlk and 0.5 or 0.3), -- Mage Armor rank 3 [23684] = 1, -- Aura of the Blue Dragon - [27125] = (ECS.IsWotlk and 0.5 or 0.3), -- Mage Armor rank 4 + [27125] = (IsWotlk and 0.5 or 0.3), -- Mage Armor rank 4 [29166] = 1, -- Innervate [32932] = 1, -- Sun Shield [38346] = 0.15, -- Meditation @@ -47,9 +51,9 @@ Data.Aura = { [1213422] = 1, -- Aura of the Blue Dragon }, CritReductionAll = { - [21183] = (ECS.IsWotlk and -1 or nil), -- Hearth of the Crusader + [21183] = (IsWotlk and -1 or nil), -- Hearth of the Crusader [30482] = 5, -- Molten Armor - [30708] = (ECS.IsWotlk and -3 or nil), -- totem of wrath + [30708] = (IsWotlk and -3 or nil), -- totem of wrath [31966] = -3, -- Physical Debuffs 2 [33143] = 1000, -- Blessed Resilience [35915] = 5, -- Molten Armor @@ -72,12 +76,12 @@ Data.Aura = { [408680] = 6, -- way of earth }, CritReductionSpell = { - [17794] = (ECS.IsWotlk and -1 or nil), -- Shadow Mastery 1/5 - [17797] = (ECS.IsWotlk and -3 or nil), -- Shadow Mastery 2/5 - [17798] = (ECS.IsWotlk and -2 or nil), -- Shadow Mastery 3/5 - [17799] = (ECS.IsWotlk and -4 or nil), -- Shadow Mastery 4/5 - [17800] = (ECS.IsWotlk and -5 or nil), -- Shadow Mastery 5/5 - [22959] = (ECS.IsWotlk and -5 or nil), -- Improved Scorch + [17794] = (IsWotlk and -1 or nil), -- Shadow Mastery 1/5 + [17797] = (IsWotlk and -3 or nil), -- Shadow Mastery 2/5 + [17798] = (IsWotlk and -2 or nil), -- Shadow Mastery 3/5 + [17799] = (IsWotlk and -4 or nil), -- Shadow Mastery 4/5 + [17800] = (IsWotlk and -5 or nil), -- Shadow Mastery 5/5 + [22959] = (IsWotlk and -5 or nil), -- Improved Scorch }, IsFeralForm = { [768] = true, -- Cat Form @@ -124,12 +128,12 @@ Data.Aura = { [10250] = 800, -- drink [16609] = 10, -- Warchief's Blessing [18140] = 735, -- Blessed Sunfruit Juice - [18194] = (ECS.IsWotlk and 10 or 8), -- Mana Regeneration + [18194] = (IsWotlk and 10 or 8), -- Mana Regeneration [21172] = 75, -- Grip of Command [21174] = 50, -- Aura of Battle [22734] = 700, -- drink [23698] = 735, -- Alterac Spring Water - [24363] = (ECS.IsWotlk and 15 or 12), -- Mana Regeneration + [24363] = (IsWotlk and 15 or 12), -- Mana Regeneration [24398] = 43, -- Water Shield Rank 1 TBC / 7 WOTLK [25696] = 735, -- Drink [25697] = 735, -- Old Enriched Manna Biscuit @@ -142,36 +146,36 @@ Data.Aura = { [26473] = 367, -- drink [26475] = 551, -- drink [27089] = 240*5, -- Drink - [28145] = (ECS.IsWotlk and 14 or 11), -- Power of the Guardian - [28509] = (ECS.IsWotlk and 20 or 16), -- Greater Mana Regeneration - [28519] = (ECS.IsWotlk and 31 or 25), -- Flask of Mighty Restoration - [28795] = (ECS.IsWotlk and 35 or 28), -- Holy Power - [28804] = (ECS.IsWotlk and 30 or 24), -- Epiphany - [28820] = (ECS.IsWotlk and 19 or 15), -- Lightning Shield - [28824] = (ECS.IsWotlk and 35 or 28), -- Totemic Power + [28145] = (IsWotlk and 14 or 11), -- Power of the Guardian + [28509] = (IsWotlk and 20 or 16), -- Greater Mana Regeneration + [28519] = (IsWotlk and 31 or 25), -- Flask of Mighty Restoration + [28795] = (IsWotlk and 35 or 28), -- Holy Power + [28804] = (IsWotlk and 30 or 24), -- Epiphany + [28820] = (IsWotlk and 19 or 15), -- Lightning Shield + [28824] = (IsWotlk and 35 or 28), -- Totemic Power [29007] = 489, -- Drink [29039] = 300, -- Fizzy Energy Drink - [31036] = (ECS.IsWotlk and 56 or 45), -- Verdant Flame + [31036] = (IsWotlk and 56 or 45), -- Verdant Flame [31462] = 12, -- Moonwell Restoration [32548] = 33, -- Symbol of Hope - [33265] = (ECS.IsWotlk and 10 or 8), -- well fed + [33265] = (IsWotlk and 10 or 8), -- well fed [33736] = 50, -- Water Shield Rank 2 TBC / 8 WOTLK [33774] = 735, -- Underspore Pod [34291] = 850, -- drink [34410] = 10, -- Hellscream's Warsong - [35095] = (ECS.IsWotlk and 26 or 21), -- Enlightenment - [37656] = (ECS.IsWotlk and 95 or 76), -- wisdom - [38437] = (ECS.IsWotlk and 19 or 15), -- Totemic Mastery - [40568] = (ECS.IsWotlk and 12 or 8), -- Unstable Flask of the Elder Only works in Blade's Edge Mountains Plateaus and Gruul's Lair. - [40582] = (ECS.IsWotlk and 12 or 8), -- Unstable Flask of the Elder Only works in Blade's Edge Mountains Plateaus and Gruul's Lair. - [41605] = (ECS.IsWotlk and 31 or 25), -- Mighty Restoration of Shattrath Only active in Tempest Keep, Serpentshrine Cavern, Caverns of Time: Mount Hyjal, Black Temple and the Sunwell Plateau. - [41610] = (ECS.IsWotlk and 31 or 25), -- Mighty Restoration of Shattrath Only active in Tempest Keep, Serpentshrine Cavern, Caverns of Time: Mount Hyjal, Black Temple and the Sunwell Plateau. + [35095] = (IsWotlk and 26 or 21), -- Enlightenment + [37656] = (IsWotlk and 95 or 76), -- wisdom + [38437] = (IsWotlk and 19 or 15), -- Totemic Mastery + [40568] = (IsWotlk and 12 or 8), -- Unstable Flask of the Elder Only works in Blade's Edge Mountains Plateaus and Gruul's Lair. + [40582] = (IsWotlk and 12 or 8), -- Unstable Flask of the Elder Only works in Blade's Edge Mountains Plateaus and Gruul's Lair. + [41605] = (IsWotlk and 31 or 25), -- Mighty Restoration of Shattrath Only active in Tempest Keep, Serpentshrine Cavern, Caverns of Time: Mount Hyjal, Black Temple and the Sunwell Plateau. + [41610] = (IsWotlk and 31 or 25), -- Mighty Restoration of Shattrath Only active in Tempest Keep, Serpentshrine Cavern, Caverns of Time: Mount Hyjal, Black Temple and the Sunwell Plateau. [42308] = 1250, -- brain food [42312] = 1200, -- Brain Food [43154] = 489, -- Drink [43182] = 428*5, -- Drink [43183] = 640*5, -- Drink - [43742] = (ECS.IsWotlk and 28 or 22), -- Grace of the Naaru + [43742] = (IsWotlk and 28 or 22), -- Grace of the Naaru [44107] = 42, -- Brewfest Drink [44109] = 104, -- Brewfest Drink [44110] = 174, -- Brewfest Drink @@ -183,7 +187,7 @@ Data.Aura = { [44116] = 1200, -- Brewfest Drink [45019] = 332, -- Holiday Drink [45020] = 1200, -- Holiday Drink - [46386] = (ECS.IsWotlk and 83 or 66), -- Luminous Bluetail + [46386] = (IsWotlk and 83 or 66), -- Luminous Bluetail [46755] = 240, -- drink [49472] = 240*5, -- Drink Coffee [49623] = 125, -- Effervescence @@ -233,19 +237,19 @@ Data.Aura = { [1220685] = 28, -- Totemic Power }, MP5Tooltip = { - [5677] = (ECS.IsWotlk and 5/2 or nil), -- Mana Spring rank 1 - [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] = ((not ECS.IsClassic) and 1 or nil), -- Blessing of Wisdom rank 1 - [19850] = ((not ECS.IsClassic) and 1 or nil), -- Blessing of Wisdom rank 2 - [19852] = ((not ECS.IsClassic) and 1 or nil), -- Blessing of Wisdom rank 3 - [19853] = ((not ECS.IsClassic) and 1 or nil), -- Blessing of Wisdom rank 4 - [19854] = ((not ECS.IsClassic) and 1 or nil), -- Blessing of Wisdom rank 5 - [25290] = ((not ECS.IsClassic) and 1 or nil), -- Blessing of Wisdom rank 6 - [25569] = (ECS.IsWotlk and 5/2 or nil), -- Mana Spring rank 5 - [25894] = ((not ECS.IsClassic) and 1 or nil), -- Greater Blessing of Wisdom rank 1 - [25918] = ((not ECS.IsClassic) and 1 or nil), -- Greater Blessing of Wisdom rank 2 + [5677] = (IsWotlk and 5/2 or nil), -- Mana Spring rank 1 + [10491] = (IsWotlk and 5/2 or nil), -- Mana Spring rank 2 + [10493] = (IsWotlk and 5/2 or nil), -- Mana Spring rank 3 + [10494] = (IsWotlk and 5/2 or nil), -- Mana Spring rank 4 + [19742] = ((not IsClassic) and 1 or nil), -- Blessing of Wisdom rank 1 + [19850] = ((not IsClassic) and 1 or nil), -- Blessing of Wisdom rank 2 + [19852] = ((not IsClassic) and 1 or nil), -- Blessing of Wisdom rank 3 + [19853] = ((not IsClassic) and 1 or nil), -- Blessing of Wisdom rank 4 + [19854] = ((not IsClassic) and 1 or nil), -- Blessing of Wisdom rank 5 + [25290] = ((not IsClassic) and 1 or nil), -- Blessing of Wisdom rank 6 + [25569] = (IsWotlk and 5/2 or nil), -- Mana Spring rank 5 + [25894] = ((not IsClassic) and 1 or nil), -- Greater Blessing of Wisdom rank 1 + [25918] = ((not IsClassic) and 1 or nil), -- 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 @@ -258,12 +262,12 @@ Data.Aura = { [58777] = 5/2, -- Mana Spring rank 8 }, PercentageMp5 = { - [12051] = ((not ECS.IsClassic) and 0.15/2*5 or nil), -- Evocation - [18792] = (ECS.IsClassic and 0.02/4 or 0.03/4)*5, -- Fel Energy + [12051] = ((not IsClassic) and 0.15/2*5 or nil), -- Evocation + [18792] = (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.IsClassic and 0.04 or 0.03)*5, -- Dim Sum + [26263] = (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 @@ -336,23 +340,23 @@ Data.Aura = { [462858] = 750, -- Circle of Flame }, PeriodicallyGiveManaTooltip = { - [5677] = ((not ECS.IsWotlk) and 5/2 or nil), -- Mana Spring rank 1 - [10491] = ((not ECS.IsWotlk) and 5/2 or nil), -- Mana Spring rank 2 - [10493] = ((not ECS.IsWotlk) and 5/2 or nil), -- Mana Spring rank 3 - [10494] = ((not ECS.IsWotlk) and 5/2 or nil), -- Mana Spring rank 4 - [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 + [5677] = ((not IsWotlk) and 5/2 or nil), -- Mana Spring rank 1 + [10491] = ((not IsWotlk) and 5/2 or nil), -- Mana Spring rank 2 + [10493] = ((not IsWotlk) and 5/2 or nil), -- Mana Spring rank 3 + [10494] = ((not IsWotlk) and 5/2 or nil), -- Mana Spring rank 4 + [19742] = (IsClassic and 1 or nil), -- Blessing of Wisdom rank 1 + [19850] = (IsClassic and 1 or nil), -- Blessing of Wisdom rank 2 + [19852] = (IsClassic and 1 or nil), -- Blessing of Wisdom rank 3 + [19853] = (IsClassic and 1 or nil), -- Blessing of Wisdom rank 4 + [19854] = (IsClassic and 1 or nil), -- Blessing of Wisdom rank 5 [24853] = 5/2, -- Mana Spring - [25290] = (ECS.IsClassic and 1 or nil), -- Blessing of Wisdom rank 6 - [25569] = ((not ECS.IsWotlk) and 5/2 or nil), -- Mana Spring rank 5 - [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 + [25290] = (IsClassic and 1 or nil), -- Blessing of Wisdom rank 6 + [25569] = ((not IsWotlk) and 5/2 or nil), -- Mana Spring rank 5 + [25894] = (IsClassic and 1 or nil), -- Greater Blessing of Wisdom rank 1 + [25918] = (IsClassic and 1 or nil), -- Greater Blessing of Wisdom rank 2 }, SpellCrit = { - [24907] = ((not ECS.IsClassic) and 5 or nil), -- Moonkin Aura + [24907] = ((not IsClassic) and 5 or nil), -- Moonkin Aura [29177] = 6, -- Elemental Devastation Rank 2 [29178] = 9, -- Elemental Devastation Rank 3 [30165] = 3, -- Elemental Devastation Rank 1 diff --git a/Modules/Data/Data.lua b/Modules/Data/Data.lua index 4d1f3fe1..07ecee01 100755 --- a/Modules/Data/Data.lua +++ b/Modules/Data/Data.lua @@ -1,3 +1,7 @@ +local ECSLoader = ECSLoader +local IsClassic = ECS.IsClassic +local IsWotlk = ECS.IsWotlk + ---@class Data local Data = ECSLoader:CreateModule("Data") @@ -22,11 +26,11 @@ dataFunctionRefs = { -- Melee ["MeleeAttackPower"] = function() return Data:GetMeleeAttackPower() end, ["MeleeCritChance"] = function() return Data:MeleeCrit() end, - ["Expertise"] = function() return ECS.IsClassic and 0 or Data:GetExpertise() end, - ["ExpertiseRating"] = function() return ECS.IsClassic and 0 or Data:GetExpertiseRating() end, + ["Expertise"] = function() return IsClassic and 0 or Data:GetExpertise() end, + ["ExpertiseRating"] = function() return IsClassic and 0 or Data:GetExpertiseRating() end, ["MeleeArmorPenetration"] = function() return Data:GetArmorPenetration() end, - ["MeleeArmorPenetrationRating"] = function() return ECS.IsWotlk and Data:GetArmorPenetrationRating() or 0 end, - ["MeleeHitRating"] = function() return ECS.IsClassic and 0 or Data:MeleeHitRating() end, + ["MeleeArmorPenetrationRating"] = function() return IsWotlk and Data:GetArmorPenetrationRating() or 0 end, + ["MeleeHitRating"] = function() return IsClassic and 0 or Data:MeleeHitRating() end, ["MeleeHitBonus"] = function() return Data:MeleeHitBonus() end, ["MeleeHitSameLevel"] = function() return Data:MeleeHitMissChanceSameLevel() end, ["MeleeHitBossLevel"] = function() return Data:MeleeHitMissChanceBossLevel() end, @@ -37,20 +41,20 @@ dataFunctionRefs = { ["GlanceDamageSameLevel"] = function() return Data:GlanceDamageSameLevel() end, ["GlanceDamageBossLevel"] = function() return Data:GlanceDamageBossLevel() end, - ["MeleeHasteRating"] = function() return ECS.IsClassic and 0 or Data:GetMeleeHasteRating() end, + ["MeleeHasteRating"] = function() return IsClassic and 0 or Data:GetMeleeHasteRating() end, ["MeleeHasteBonus"] = function() return Data:GetMeleeHasteBonus() end, ["MeleeAttackSpeedMainHand"] = function() return Data:GetMeleeAttackSpeedMainHand() end, ["MeleeAttackSpeedOffHand"] = function() return Data:GetMeleeAttackSpeedOffHand() end, -- Ranged ["RangeAttackpower"] = function() return Data:GetRangeAttackPower() end, ["RangedCritChance"] = function() return Data:RangedCrit() end, - ["RangedHitRating"] = function() return ECS.IsClassic and 0 or Data:RangeHitRating() end, + ["RangedHitRating"] = function() return IsClassic and 0 or Data:RangeHitRating() end, ["RangedHitBonus"] = function() return Data:RangeHitBonus() end, ["RangedHitSameLevel"] = function() return Data:RangeMissChanceSameLevel() end, ["RangedArmorPenetration"] = function() return Data:GetArmorPenetration() end, - ["RangedArmorPenetrationRating"] = function() return ECS.IsWotlk and Data:GetArmorPenetrationRating() or 0 end, + ["RangedArmorPenetrationRating"] = function() return IsWotlk and Data:GetArmorPenetrationRating() or 0 end, ["RangedHitBossLevel"] = function() return Data.RangeMissChanceBossLevel() end, - ["RangedHasteRating"] = function() return ECS.IsClassic and 0 or Data:GetRangedHasteRating() end, + ["RangedHasteRating"] = function() return IsClassic and 0 or Data:GetRangedHasteRating() end, ["RangedHasteBonus"] = function() return Data:GetRangedHasteBonus() end, ["RangedAttackSpeed"] = function() return Data:GetRangedAttackSpeed() end, -- Defense @@ -60,22 +64,22 @@ dataFunctionRefs = { ["SpellCritReduction"] = function() return Data:GetSpellCritReduction() end, ["Avoidance"] = function() return Data:GetAvoidance(playerLevel) end, ["AvoidanceBoss"] = function() return Data:GetAvoidance(enemyLevel) end, - ["DefenseRating"] = function() return ECS.IsClassic and 0 or Data:GetDefenseRating() end, + ["DefenseRating"] = function() return IsClassic and 0 or Data:GetDefenseRating() end, ["DefenseValue"] = function() return Data:GetDefenseValue() end, ["DodgeChance"] = function() return Data:GetDodgeChance() end, ["ParryChance"] = function() return Data:GetParryChance() end, ["BlockChance"] = function() return Data:GetBlockChance() end, ["BlockValue"] = function() return Data:GetBlockValue() end, - ["ResilienceValue"] = function() return ECS.IsClassic and 0 or Data:GetResilienceRating() end, + ["ResilienceValue"] = function() return IsClassic and 0 or Data:GetResilienceRating() end, -- Spell - ["SpellHitRating"] = function() return ECS.IsClassic and 0 or Data:SpellHitRating() end, + ["SpellHitRating"] = function() return IsClassic and 0 or Data:SpellHitRating() end, ["SpellHitBonus"] = function() return Data.SpellHitBonus(Data.HOLY_SCHOOL) end, ["SpellHitSameLevel"] = function() return Data:SpellMissChanceSameLevel(Data.HOLY_SCHOOL) end, ["SpellHitBossLevel"] = function() return Data:SpellMissChanceBossLevel(Data.HOLY_SCHOOL) end, ["SpellCritChance"] = function() return Data:GetSpellCrit(Data.HOLY_SCHOOL) end, - ["SpellHasteRating"] = function() return ECS.IsClassic and 0 or Data:GetSpellHasteRating() end, + ["SpellHasteRating"] = function() return IsClassic and 0 or Data:GetSpellHasteRating() end, ["SpellHasteBonus"] = function() return Data:GetSpellHasteBonus() end, - ["SpellPenetration"] = function() return Data:GetSpellPenetration() end, + ["SpellPenetration"] = function() return Data:SpellPenetration() end, -- MP5 ["MP5Items"] = function() return Data:GetMP5FromItems() end, ["MP5Spirit"] = function() return Data:GetMP5FromSpirit() end, diff --git a/Modules/Data/DataUtils.lua b/Modules/Data/DataUtils.lua index ba8acc34..944f9176 100644 --- a/Modules/Data/DataUtils.lua +++ b/Modules/Data/DataUtils.lua @@ -1,10 +1,21 @@ +local ECSLoader = ECSLoader +local floor = math.floor +local GetBuffDataByIndex = C_UnitAuras.GetBuffDataByIndex +local GetInventoryItemID = GetInventoryItemID +local GetInventoryItemLink = GetInventoryItemLink +local GetItemInfo = C_Item.GetItemInfo +local GetRuneForEquipmentSlot = C_Engraving.GetRuneForEquipmentSlot +local IsSoD = ECS.IsSoD +local IsSpellKnown = C_SpellBook.IsSpellKnown +local IsWotlk = ECS.IsWotlk +local strsplit = strsplit +local tonumber = tonumber + ---@class DataUtils local DataUtils = ECSLoader:CreateModule("DataUtils") ---@type Data local Data = ECSLoader:ImportModule("Data") -local IsSpellKnown = C_SpellBook.IsSpellKnown - --- Rounds every number down to the given decimal places ---@param num number ---@param decimalPlaces number @@ -14,14 +25,14 @@ function DataUtils:Round(num, decimalPlaces) return 0 end local mult = 10^(decimalPlaces) - return math.floor(num * mult + 0.5) / mult + return floor(num * mult + 0.5) / mult end ---@return boolean function DataUtils:IsShapeshifted() local i = 1 repeat - local aura = C_UnitAuras.GetBuffDataByIndex("player", i) + local aura = GetBuffDataByIndex("player", i) i = i + 1 if aura and aura.spellId then if Data.Aura.IsFeralForm[aura.spellId] then @@ -44,7 +55,7 @@ function DataUtils.GetMissChanceByDifference(weaponSkill, defenseValue) -- For a difference of 11-14 each point in weapon skill is worth 0.4% miss chance reduction local extraWeaponSkillDifference = ((15 - delta) * 0.2) return DataUtils:Round(6 + delta * 0.2 - extraWeaponSkillDifference, 2) - elseif ECS.IsWotlk then + elseif IsWotlk then -- For a difference of 15+ each point in weapon skill is worth 0.2% miss chance reduction return 5 + delta * 0.2 else @@ -107,7 +118,7 @@ end ---@return number|nil function DataUtils:GetEnchantFromItemLink(itemLink) if itemLink then - local _, itemStringLink = C_Item.GetItemInfo(itemLink) + local _, itemStringLink = GetItemInfo(itemLink) if itemStringLink then local _, _, enchant, _ = strsplit(":", itemStringLink, 4) return tonumber(enchant) @@ -120,7 +131,7 @@ end ---@return number|nil function DataUtils.GetRuneForEquipSlot(equipSlot) local slotId, _ = GetInventorySlotInfo(equipSlot) - local runeInfo = C_Engraving.GetRuneForEquipmentSlot(slotId) + local runeInfo = GetRuneForEquipmentSlot(slotId) if runeInfo then return runeInfo.itemEnchantmentID @@ -133,7 +144,7 @@ end ---@return string | nil, string | nil, string | nil function DataUtils:GetSocketedGemsFromItemLink(itemLink) if itemLink then - local _, itemStringLink = C_Item.GetItemInfo(itemLink) + local _, itemStringLink = GetItemInfo(itemLink) if itemStringLink then local _, _, gem1, gem2, gem3, _ = strsplit(":", itemStringLink, 6) return gem1, gem2, gem3 @@ -157,7 +168,7 @@ end ---@return number function DataUtils:GetActiveTalentSpell(talentList) for i = #talentList,1,-1 do - if C_SpellBook.IsSpellKnown(talentList[i]) then + if IsSpellKnown(talentList[i]) then return i end end @@ -167,7 +178,7 @@ function DataUtils:GetActiveTalentSpell(talentList) ---@return number function DataUtils:CountTimewornItems() local timeworn = 0 - if ECS.IsSoD then + if IsSoD then for i = 1, 18 do local id, _ = GetInventoryItemID("player", i) if Data.Item.IsTimeworn[id] then diff --git a/Modules/Data/Defense.lua b/Modules/Data/Defense.lua index f9511d57..f4421082 100755 --- a/Modules/Data/Defense.lua +++ b/Modules/Data/Defense.lua @@ -1,3 +1,25 @@ +local CR_DEFENSE_SKILL = CR_DEFENSE_SKILL +local ECSLoader = ECSLoader +local floor = math.floor +local GetBlockChance = GetBlockChance +local GetBuffDataByIndex = C_UnitAuras.GetBuffDataByIndex +local GetCombatRating = GetCombatRating +local GetCombatRatingBonus = GetCombatRatingBonus +local GetDebuffDataByIndex = C_UnitAuras.GetDebuffDataByIndex +local GetDodgeChance = GetBlockChance +local GetInventoryItemLink = GetInventoryItemLink +local GetParryChance = GetBlockChance +local GetShieldBlock = GetShieldBlock +local IsClassic = ECS.IsClassic +local IsSoD = ECS.IsSoD +local IsSpellKnown = C_SpellBook.IsSpellKnown +local IsTBC = ECS.IsTBC +local IsWotlk = ECS.IsWotlk +local OffhandHasShield = C_PaperDollInfo.OffhandHasShield +local UnitArmor = UnitArmor +local UnitClass = UnitClass +local UnitLevel = UnitLevel + ---@class Data local Data = ECSLoader:ImportModule("Data") ---@type DataUtils @@ -29,27 +51,27 @@ function _Defense:GetCritReduction() local spellCritReduction = 0 local i = 1 repeat - local aura = C_UnitAuras.GetAuraDataByIndex("player", i, "HELPFUL") + local aura = GetBuffDataByIndex("player", i) i = i + 1 if aura and aura.spellId then buffBonus = buffBonus + (Data.Aura.CritReductionAll[aura.spellId] or 0) meleeCritReduction = meleeCritReduction + (Data.Aura.CritReductionMelee[aura.spellId] or 0) - if ECS.IsWotlk and aura.spellId == 22812 and C_SpellBook.IsSpellKnown(63058) then + if IsWotlk and aura.spellId == 22812 and IsSpellKnown(63058) then buffBonus = buffBonus + 25 -- Glyph of Barkskin end end until (not aura) i = 1 repeat - local aura = C_UnitAuras.GetAuraDataByIndex("player", i, "HARMFUL") + local aura = GetDebuffDataByIndex("player", i) i = i + 1 if aura and aura.spellId then buffBonus = buffBonus + (Data.Aura.CritReductionAll[aura.spellId] or 0) meleeCritReduction = meleeCritReduction + (Data.Aura.CritReductionMelee[aura.spellId] or 0) spellCritReduction = spellCritReduction + (Data.Aura.CritReductionSpell[aura.spellId] or 0) - if ECS.IsWotlk and aura.spellId == 12579 then + if IsWotlk and aura.spellId == 12579 then spellCritReduction = spellCritReduction - 1 * aura.applications -- Winter's Chill - elseif ECS.IsSoD and aura.spellId == 1231399 then -- Legislate + elseif IsSoD and aura.spellId == 1231399 then -- Legislate buffBonus = buffBonus - 3 * aura.applications end end @@ -63,10 +85,10 @@ function _Defense:GetCritReduction() local critReducingFromResilience = GetCombatRatingBonus(15) if classId == Data.DRUID then - local coeff = ECS.IsWotlk and 2 or 1 + local coeff = IsWotlk and 2 or 1 meleeCritReduction = meleeCritReduction + coeff * DataUtils:GetActiveTalentSpell({33853,33855,33856}) -- Survival of the Fittest elseif classId == Data.PRIEST then - if ECS.IsTBC then + if IsTBC then spellCritReduction = spellCritReduction + 2 * DataUtils:GetActiveTalentSpell({14910,33371}) -- shadow resilience end elseif classId == Data.ROGUE then @@ -74,14 +96,14 @@ function _Defense:GetCritReduction() meleeCritReduction = meleeCritReduction + mod rangedCritReduction = rangedCritReduction + mod elseif classId == Data.WARLOCK then - if not ECS.IsClassic then + if not IsClassic then local mod = 1 * DataUtils:GetActiveTalentSpell({30319,30320,30321}) -- Demonic Resilience meleeCritReduction = meleeCritReduction + mod rangedCritReduction = rangedCritReduction + mod end end - if ECS.IsSoD then + if IsSoD then if classId == Data.DRUID or classId == Data.ROGUE then local chestRune = DataUtils.GetRuneForEquipSlot(Utils.CHAR_EQUIP_SLOTS.Chest) if chestRune and (chestRune == 6710 or chestRune == 6972) then @@ -121,8 +143,8 @@ function _Defense:GetEnemyMissChance(enemyLevel) local enemyAttackRating = enemyLevel * 5 local miss - if ECS.IsWotlk then - local defense = math.floor(GetCombatRatingBonus(CR_DEFENSE_SKILL)); + if IsWotlk then + local defense = floor(GetCombatRatingBonus(CR_DEFENSE_SKILL)); local enemyMissCoef = classId == Data.DRUID and 0.972 or 0.956; -- 0.972 for bears local baseMissChance = 5 - (enemyAttackRating - select(1, UnitDefense("player"))) * 0.04; -- vs lvl 80 if defense > 0 then -- avoid possible division by 0 @@ -142,7 +164,7 @@ end ---@return number function _Defense:GetBlockChance() local block = 0 - if C_SpellBook.IsSpellKnown(107) and C_PaperDollInfo.OffhandHasShield() then + if IsSpellKnown(107) and OffhandHasShield() then block = GetBlockChance() end return block @@ -151,7 +173,7 @@ end ---@return number function _Defense:GetParryChance() local parry = 0 - if C_SpellBook.IsSpellKnown(3127) or C_SpellBook.IsSpellKnown(18848) or C_SpellBook.IsSpellKnown(3124) then + if IsSpellKnown(3127) or IsSpellKnown(18848) or IsSpellKnown(3124) then parry = GetParryChance() end return parry @@ -160,7 +182,7 @@ end ---@return number function _Defense:GetDodgeChance() local dodge = 0 - if C_SpellBook.IsSpellKnown(81) then + if IsSpellKnown(81) then dodge = GetDodgeChance() end return dodge @@ -211,7 +233,7 @@ end ---@return number function Data:GetBlockValue() local blockValue = 0 - if C_SpellBook.IsSpellKnown(107) and C_PaperDollInfo.OffhandHasShield() then + if IsSpellKnown(107) and OffhandHasShield() then blockValue = blockValue + GetShieldBlock() + _Defense:GetEnchantsBlockValue() end return DataUtils:Round(blockValue, 2) diff --git a/Modules/Data/General.lua b/Modules/Data/General.lua index d8c8f7e2..f69cea20 100644 --- a/Modules/Data/General.lua +++ b/Modules/Data/General.lua @@ -1,3 +1,9 @@ +local ECSLoader = ECSLoader +local GetUnitSpeed = GetUnitSpeed +local IsClassic = ECS.IsClassic +local IsFlying = IsFlying +local IsSwimming = IsSwimming + ---@class Data local Data = ECSLoader:ImportModule("Data") ---@type DataUtils @@ -10,7 +16,7 @@ function Data:GetMovementSpeed() local currentSpeed - if (not ECS.IsClassic) and IsFlying() then + if (not IsClassic) and IsFlying() then currentSpeed = flightSpeed elseif IsSwimming() then currentSpeed = swimSpeed diff --git a/Modules/Data/ItemSets.lua b/Modules/Data/ItemSets.lua index 7e07ffed..568c5058 100755 --- a/Modules/Data/ItemSets.lua +++ b/Modules/Data/ItemSets.lua @@ -1,3 +1,10 @@ +local ECSLoader = ECSLoader +local GetInventoryItemID = GetInventoryItemID +local IsClassic = ECS.IsClassic +local IsSoD = ECS.IsSoD +local IsWotlk = ECS.IsWotlk +local UnitClass = UnitClass + ---@class Data local Data = ECSLoader:ImportModule("Data") @@ -123,19 +130,19 @@ local itemSets = { ---@return number function Data:GetSetBonusModifierMP5() local mod = 0 - if (ECS.IsClassic and Data:IsSetBonusActive(setNames.GREEN_DRAGON_MAIL, 3)) then + if (IsClassic and Data:IsSetBonusActive(setNames.GREEN_DRAGON_MAIL, 3)) then mod = mod + 0.15 end - if (ECS.IsClassic and ( + if (IsClassic and ( (classId == Data.DRUID and Data:IsSetBonusActive(setNames.STORMRAGE_RAIMENT, 3)) or (classId == Data.PRIEST and Data:IsSetBonusActive(setNames.VESTMENTS_OF_TRANSCENDENCE, 3)) )) then mod = mod + 0.15 end - if (ECS.IsSoD and Data:IsSetBonusActive(setNames.LIVING_GREEN_DRAGON_MAIL, 3)) then + if (IsSoD and Data:IsSetBonusActive(setNames.LIVING_GREEN_DRAGON_MAIL, 3)) then mod = mod + 0.15 end - if (ECS.IsSoD and Data:IsSetBonusActive(setNames.DAWN_OF_TRANSCENDENCE, 2)) then + if (IsSoD and Data:IsSetBonusActive(setNames.DAWN_OF_TRANSCENDENCE, 2)) then mod = mod + 0.15 end if Data:IsSetBonusActive(setNames.PRIMAL_MOONCLOTH, 3) then @@ -151,32 +158,32 @@ function Data:GetSetBonusValueMP5() (classId == Data.SHAMAN and Data:IsSetBonusActive(setNames.AUGURS_REGALIA, 2)) or (classId == Data.PALADIN and Data:IsSetBonusActive(setNames.FREETHINKERS_ARMOR, 2) ) then - bonus = bonus + (ECS.IsWotlk and 5 or 4) + bonus = bonus + (IsWotlk and 5 or 4) end - if (ECS.IsSoD and Data:IsSetBonusActive(setNames.LIVING_GREEN_DRAGON_MAIL, 2)) then + if (IsSoD and Data:IsSetBonusActive(setNames.LIVING_GREEN_DRAGON_MAIL, 2)) then bonus = bonus + 3 end if Data:IsSetBonusActive(setNames.GREEN_DRAGON_MAIL, 2) then - bonus = bonus + (ECS.IsWotlk and 4 or 3) + bonus = bonus + (IsWotlk and 4 or 3) end - if (not ECS.IsClassic and Data:IsSetBonusActive(setNames.GREEN_DRAGON_MAIL, 3)) then - bonus = bonus + (ECS.IsWotlk and 25 or 20) + if (not IsClassic and Data:IsSetBonusActive(setNames.GREEN_DRAGON_MAIL, 3)) then + bonus = bonus + (IsWotlk and 25 or 20) end - if (not ECS.IsClassic and ( + if (not IsClassic and ( (classId == Data.DRUID and Data:IsSetBonusActive(setNames.STORMRAGE_RAIMENT, 3)) or (classId == Data.PRIEST and Data:IsSetBonusActive(setNames.VESTMENTS_OF_TRANSCENDENCE, 3)) ) ) then - bonus = bonus + (ECS.IsWotlk and 25 or 20) + bonus = bonus + (IsWotlk and 25 or 20) end if Data:IsSetBonusActive(setNames.BLOODSOUL_EMBRACE, 3) then - bonus = bonus + (ECS.IsWotlk and 15 or 12) + bonus = bonus + (IsWotlk and 15 or 12) end if Data:IsSetBonusActive(setNames.FEL_IRON_CHAIN, 4) then - bonus = bonus + (ECS.IsWotlk and 10 or 8) + bonus = bonus + (IsWotlk and 10 or 8) end if Data:IsSetBonusActive(setNames.WINDHAWK_ARMOR, 3) then - bonus = bonus + (ECS.IsWotlk and 10 or 8) + bonus = bonus + (IsWotlk and 10 or 8) end return bonus end diff --git a/Modules/Data/MP5.lua b/Modules/Data/MP5.lua index 5ea8de85..551751df 100755 --- a/Modules/Data/MP5.lua +++ b/Modules/Data/MP5.lua @@ -1,3 +1,18 @@ +local ECSLoader = ECSLoader +local GetBuffDataByIndex = C_UnitAuras.GetBuffDataByIndex +local GetDebuffDataByIndex = C_UnitAuras.GetDebuffDataByIndex +local GetInventoryItemLink = GetInventoryItemLink +local GetManaRegen = GetManaRegen +local GetWeaponEnchantInfo = GetWeaponEnchantInfo +local IsSoD = ECS.IsSoD +local IsTBC = ECS.IsTBC +local IsWotlk = ECS.IsWotlk +local match = string.match +local min = math.min +local tonumber = tonumber +local UnitClass = UnitClass +local UnitPowerMax = UnitPowerMax + ---@class Data local Data = ECSLoader:ImportModule("Data") ---@type DataUtils @@ -22,7 +37,7 @@ function Data:GetValueFromAuraTooltip(index,type) if region and region:GetObjectType() == "FontString" then local tooltip = region:GetText() if tooltip then - return tonumber(string.match(tooltip, '%d[%d,.]*')) + return tonumber(match(tooltip, '%d[%d,.]*')) end end return 0 @@ -122,7 +137,7 @@ function Data:GetMP5FromBuffs() local i = 1 repeat - local aura = C_UnitAuras.GetBuffDataByIndex("player", i) + local aura = GetBuffDataByIndex("player", i) if aura and aura.spellId then bonus = bonus + (Data.Aura.MP5[aura.spellId] or 0) bonus = bonus + (Data.Aura.PercentageMp5[aura.spellId] or 0) * maxmana @@ -137,7 +152,7 @@ function Data:GetMP5FromBuffs() if Data.Aura.PeriodicallyGiveManaTooltip[aura.spellId] then periodic = periodic + Data.Aura.PeriodicallyGiveManaTooltip[aura.spellId] * Data:GetValueFromAuraTooltip(i, "HELPFUL") end - if ECS.IsWotlk then + if IsWotlk then if aura.spellId == 64999 then bonus = bonus + 85 * aura.applications -- Meteoric Inspiration end @@ -147,7 +162,7 @@ function Data:GetMP5FromBuffs() until (not aura) i = 1 repeat - local aura = C_UnitAuras.GetDebuffDataByIndex("player", i) + local aura = GetDebuffDataByIndex("player", i) if aura and aura.spellId then bonus = bonus + (Data.Aura.PercentageMp5[aura.spellId] or 0) * maxmana end @@ -160,7 +175,7 @@ end function _MP5.GetMP5FromRunes() local mod = 0 - if (not ECS.IsSoD) then + if (not IsSoD) then return mod end @@ -179,17 +194,17 @@ function _MP5:GetTalentModifier() local mod = 0 if classId == Data.PRIEST then - local coeff = ECS.IsTBC and 0.1 or (ECS.IsWotlk and 0.5/3 or 0.05) + local coeff = IsTBC and 0.1 or (IsWotlk and 0.5/3 or 0.05) mod = mod + coeff * DataUtils:GetActiveTalentSpell({14521,14776,14777}) -- meditation elseif classId == Data.MAGE then - local coeff = ECS.IsTBC and 0.1 or (ECS.IsWotlk and 0.5/3 or 0.05) + local coeff = IsTBC and 0.1 or (IsWotlk and 0.5/3 or 0.05) mod = mod + coeff * DataUtils:GetActiveTalentSpell({14521,18463,18464}) -- arcane meditation - if ECS.IsWotlk then + if IsWotlk then mod = mod + 0.5/3 * DataUtils:GetActiveTalentSpell({34293,34295,34296}) -- pyromaniac end elseif classId == Data.DRUID then - local coeff = ECS.IsTBC and 0.1 or (ECS.IsWotlk and 0.5/3 or 0.05) + local coeff = IsTBC and 0.1 or (IsWotlk and 0.5/3 or 0.05) mod = mod + coeff * DataUtils:GetActiveTalentSpell({17106,17107,17108}) -- intensity/reflection end return mod diff --git a/Modules/Data/Melee.lua b/Modules/Data/Melee.lua index b10071c5..82480a8e 100755 --- a/Modules/Data/Melee.lua +++ b/Modules/Data/Melee.lua @@ -1,3 +1,19 @@ +local ECSLoader = ECSLoader +local GetCombatRating = GetCombatRating +local GetCombatRatingBonus = GetCombatRatingBonus +local GetCritChance = GetCritChance +local GetExpertise = GetExpertise +local GetHitModifier = GetHitModifier +local GetShapeshiftFormInfo = GetShapeshiftFormInfo +local IsClassic = ECS.IsClassic +local IsSoD = ECS.IsSoD +local IsWotlk = ECS.IsWotlk +local UnitAttackBothHands = UnitAttackBothHands +local UnitAttackPower = UnitAttackPower +local UnitAttackSpeed = UnitAttackSpeed +local UnitClass = UnitClass +local UnitLevel = UnitLevel + ---@class Data local Data = ECSLoader:ImportModule("Data") ---@type DataUtils @@ -7,6 +23,7 @@ local Utils = ECSLoader:ImportModule("Utils") local _Melee = {} local _, _, classId = UnitClass("player") +local playerLevel = UnitLevel("player") ---@return number function Data:GetMeleeAttackPower() @@ -62,27 +79,27 @@ function _Melee:GetHitTalentBonus() local mod = 0 if classId == Data.WARRIOR then - if ECS.IsWotlk then + if IsWotlk then -- precision mod = 1 * DataUtils:GetActiveTalentSpell({29590,29591,29592}) end elseif classId == Data.HUNTER then - if ECS.IsWotlk then + if IsWotlk then -- focused aim mod = 1 * DataUtils:GetActiveTalentSpell({53620,53621,53622}) end elseif classId == Data.SHAMAN then - if ECS.IsWotlk then + if IsWotlk then -- Dual Wield Specialization if Data:GetMeleeAttackSpeedOffHand() > 0 then mod = 2 * DataUtils:GetActiveTalentSpell({30816,30818,30819}) end - elseif ECS.IsClassic then + elseif IsClassic then -- Nature's Guidance mod = 1 * DataUtils:GetActiveTalentSpell({16180,16196,16198}) end elseif classId == Data.ROGUE then - if ECS.IsClassic then + if IsClassic then -- precision mod = 1 * DataUtils:GetActiveTalentSpell({13705,13832,13843,13844,13845}) end @@ -101,7 +118,7 @@ end function _Melee.GetHitFromRunes() local mod = 0 - if (not ECS.IsSoD) then + if (not IsSoD) then return mod end @@ -118,7 +135,6 @@ end ---@return string function Data:MeleeHitMissChanceSameLevel() local mainBase, mainMod, _, _ = UnitAttackBothHands("player") - local playerLevel = UnitLevel("player") local enemyDefenseValue = playerLevel * 5 local missChance @@ -147,12 +163,11 @@ end ---@return string function Data:MeleeHitMissChanceBossLevel() local mainBase, mainMod, _, _ = UnitAttackBothHands("player") - local playerLevel = UnitLevel("player") local enemyDefenseValue = (playerLevel + 3) * 5 local missChance if DataUtils:IsShapeshifted() then - missChance = ECS.IsWotlk and 8 or 9 + missChance = IsWotlk and 8 or 9 else missChance = DataUtils.GetMissChanceByDifference(mainBase + mainMod, enemyDefenseValue) end @@ -184,7 +199,6 @@ end ---@return string function Data:GlanceHitChanceByLevel(level) local mainBase, mainMod, _, _ = UnitAttackBothHands("player") - local playerLevel = UnitLevel("player") local enemyDefenseValue = (playerLevel + level) * 5 local glancingChance = DataUtils:GetGlancingChanceByDifference(playerLevel, mainBase + mainMod, enemyDefenseValue) @@ -204,7 +218,6 @@ end ---@return string function Data:GlanceDamageByLevel(level) local mainBase, mainMod, _, _ = UnitAttackBothHands("player") - local playerLevel = UnitLevel("player") local enemyDefenseValue = (playerLevel + level) * 5 local glancePenalty = DataUtils:GetGlancingDamage(mainBase + mainMod, enemyDefenseValue) @@ -231,7 +244,7 @@ end function Data:GetArmorPenetration() local armorPenetration = GetArmorPenetration() - if ECS.IsWotlk and classId == Data.WARRIOR then + if IsWotlk and classId == Data.WARRIOR then local _, isActive = GetShapeshiftFormInfo(1) if isActive then armorPenetration = armorPenetration + 10 -- 10% from Battle Stance diff --git a/Modules/Data/Ranged.lua b/Modules/Data/Ranged.lua index f53af9e1..010a28c9 100755 --- a/Modules/Data/Ranged.lua +++ b/Modules/Data/Ranged.lua @@ -1,3 +1,17 @@ +local ECSLoader = ECSLoader +local GetCombatRating = GetCombatRating +local GetCombatRatingBonus = GetCombatRatingBonus +local GetHitModifier = GetHitModifier +local GetRangedCritChance = GetRangedCritChance +local IsClassic = ECS.IsClassic +local IsWotlk = ECS.IsWotlk +local UnitClass = UnitClass +local UnitHasRelicSlot = UnitHasRelicSlot +local UnitLevel = UnitLevel +local UnitRangedAttack = UnitRangedAttack +local UnitRangedAttackPower = UnitRangedAttackPower +local UnitRangedDamage = UnitRangedDamage + ---@class Data local Data = ECSLoader:ImportModule("Data") ---@type Utils @@ -8,6 +22,7 @@ local DataUtils = ECSLoader:ImportModule("DataUtils") local _Ranged = {} local _, _, classId = UnitClass("player") +local playerLevel = UnitLevel("player") ---@return number function Data:GetRangeAttackPower() @@ -69,7 +84,7 @@ function _Ranged:GetHitBonus() local hitValue = 0 -- Biznick Scope awards Hit rating in TBC and is part of CR_HIT_RANGED - if ECS.IsClassic then + if IsClassic then local rangedEnchant = DataUtils:GetEnchantForEquipSlot(Utils.CHAR_EQUIP_SLOTS["Range"]) if rangedEnchant and rangedEnchant == Data.Enchant.Ids.BIZNICK_SCOPE then hitValue = hitValue + 3 @@ -89,7 +104,7 @@ end function _Ranged:GetHitTalentBonus() local bonus = 0 - if ECS.IsWotlk and classId == Data.HUNTER then + if IsWotlk and classId == Data.HUNTER then bonus = bonus + 1 * DataUtils:GetActiveTalentSpell({53620,53621,53622}) -- Focused Aim end @@ -99,7 +114,6 @@ end ---@return string function Data:RangeMissChanceSameLevel() local rangedAttackBase, rangedAttackMod = UnitRangedAttack("player") - local playerLevel = UnitLevel("player") local enemyDefenseValue = playerLevel * 5 local missChance = DataUtils.GetMissChanceByDifference(rangedAttackBase + rangedAttackMod, enemyDefenseValue) @@ -118,7 +132,6 @@ end function Data.RangeMissChanceBossLevel() local rangedAttackBase, rangedAttackMod = UnitRangedAttack("player") local rangedWeaponSkill = rangedAttackBase + rangedAttackMod - local playerLevel = UnitLevel("player") local enemyDefenseValue = (playerLevel + 3) * 5 local missChance = DataUtils.GetMissChanceByDifference(rangedWeaponSkill, enemyDefenseValue) diff --git a/Modules/Data/SpellCrit.lua b/Modules/Data/SpellCrit.lua index f787fdce..53ea0dc3 100755 --- a/Modules/Data/SpellCrit.lua +++ b/Modules/Data/SpellCrit.lua @@ -1,3 +1,10 @@ +local ECSLoader = ECSLoader +local GetBuffDataByIndex = C_UnitAuras.GetBuffDataByIndex +local GetInventoryItemID = GetInventoryItemID +local GetSpellCritChance = GetSpellCritChance +local IsClassic = ECS.IsClassic +local IsWotlk = ECS.IsWotlk + ---@class Data local Data = ECSLoader:ImportModule("Data") ---@type DataUtils @@ -24,7 +31,7 @@ function _SpellCrit:GetSpellCritFromBuffs(school) local mod = 0 local i = 1 repeat - local aura = C_UnitAuras.GetBuffDataByIndex("player", i) + local aura = GetBuffDataByIndex("player", i) i = i + 1 if aura and aura.spellId then mod = mod + (Data.Aura.SpellCrit[aura.spellId] or 0) @@ -54,26 +61,26 @@ function _SpellCrit:GetGeneralTalentModifier() local mod = 0 if classId == Data.MAGE then - if not ECS.IsClassic then + if not IsClassic then mod = mod + 1 * DataUtils:GetActiveTalentSpell({15058,15059,15060}) -- Arcane Instability end elseif classId == Data.DRUID then - if ECS.IsWotlk then + if IsWotlk then mod = mod + 1 * DataUtils:GetActiveTalentSpell({33881,33882,33883}) -- Natural Perfection end elseif classId == Data.WARLOCK then - if ECS.IsWotlk then + if IsWotlk then mod = mod + 2 * DataUtils:GetActiveTalentSpell({30242,30245,30246,30247,30248}) -- Demonic Tactics mod = mod + 1 * DataUtils:GetActiveTalentSpell({34935,34938,34939}) -- Backlash end mod = mod + 1 * DataUtils:GetActiveTalentSpell({18130,18131,18132,18133,18134}) -- Devastation elseif classId == Data.SHAMAN then - if ECS.IsWotlk then + if IsWotlk then mod = mod + 1 * DataUtils:GetActiveTalentSpell({16255,16302,16303,16304,16305}) -- Thundering Strikes end elseif classId == Data.PALADIN then - if ECS.IsWotlk then + if IsWotlk then mod = mod + 1 * DataUtils:GetActiveTalentSpell({20117,20118,20119,20120,20121}) -- Conviction mod = mod + 1 * DataUtils:GetActiveTalentSpell({32043,35396,35397}) -- Sanctity of Battle end @@ -115,11 +122,11 @@ function _SpellCrit:GetTalentModifierFireCrit() if classId == Data.MAGE then mod = mod + 2 * DataUtils:GetActiveTalentSpell({11115,11367,11368}) -- Critical Mass - if ECS.IsWotlk then + if IsWotlk then mod = mod + 1 * DataUtils:GetActiveTalentSpell({34293,34295,34296}) -- Pyromaniac end elseif classId == Data.WARLOCK then - if ECS.IsClassic then + if IsClassic then -- Devastation (while this increases the crit chance of "Destruction spells" there are no fire spells, which are not destruction spells) mod = mod + 1 * DataUtils:GetActiveTalentSpell({18130,18131,18132,18133,18134}) end @@ -140,7 +147,7 @@ end ---@return number function _SpellCrit:GetItemModifierHolyCrit() local mainHand, _ = GetInventoryItemID("player", 16) - if ECS.IsClassic and mainHand == 18608 then + if IsClassic and mainHand == 18608 then return 2 -- 2% Holy Crit from Benediction end return 0 @@ -155,9 +162,4 @@ function _SpellCrit:GetSetBonus(school) end return bonus -end - ----@return number -function Data:GetSpellPenetration() - return DataUtils:Round(GetSpellPenetration(), 2) -end +end \ No newline at end of file diff --git a/Modules/Data/SpellDamage.lua b/Modules/Data/SpellDamage.lua index 701ea5e6..750a34a2 100755 --- a/Modules/Data/SpellDamage.lua +++ b/Modules/Data/SpellDamage.lua @@ -1,3 +1,15 @@ +local ECSLoader = ECSLoader +local GetBuffDataByIndex = C_UnitAuras.GetBuffDataByIndex +local GetCombatRating = GetCombatRating +local GetDebuffDataByIndex = C_UnitAuras.GetDebuffDataByIndex +local GetHaste = GetHaste +local GetInventoryItemID = GetInventoryItemID +local GetPlayerAuraBySpellID = C_UnitAuras.GetPlayerAuraBySpellID +local GetSpellBonusDamage = GetSpellBonusDamage +local GetSpellBonusHealing = GetSpellBonusHealing +local GetSpellPenetration = GetSpellPenetration +local IsSoD = ECS.IsSoD + ---@class Data local Data = ECSLoader:ImportModule("Data") ---@type DataUtils @@ -35,7 +47,7 @@ function Data:GetSpellHasteBonus() local hasteBonus = GetHaste() -- items - if ECS.IsSoD then + if IsSoD then local timeworn = DataUtils:CountTimewornItems() for i = 1, 18 do local id, _ = GetInventoryItemID("player", i) @@ -47,7 +59,7 @@ function Data:GetSpellHasteBonus() -- buffs local i = 1 repeat - local aura = C_UnitAuras.GetBuffDataByIndex("player", i) + local aura = GetBuffDataByIndex("player", i) if aura and aura.spellId then hasteBonus = hasteBonus + (Data.Aura.SpellHaste[aura.spellId] or 0) end @@ -57,7 +69,7 @@ function Data:GetSpellHasteBonus() -- debuffs i = 1 repeat - local aura = C_UnitAuras.GetDebuffDataByIndex("player", i) + local aura = GetDebuffDataByIndex("player", i) if aura and aura.spellId then hasteBonus = hasteBonus + (Data.Aura.SpellHaste[aura.spellId] or 0) end @@ -65,8 +77,8 @@ function Data:GetSpellHasteBonus() until (not aura) -- not stacking buffs - if ECS.IsSoD then - local aura = C_UnitAuras.GetPlayerAuraBySpellID(1219557) -- Power of the Guardian + if IsSoD then + local aura = GetPlayerAuraBySpellID(1219557) -- Power of the Guardian if aura then hasteBonus = hasteBonus + 2 end diff --git a/Modules/Data/SpellHit.lua b/Modules/Data/SpellHit.lua index 084e7d82..4260affc 100755 --- a/Modules/Data/SpellHit.lua +++ b/Modules/Data/SpellHit.lua @@ -1,3 +1,14 @@ +local ECSLoader = ECSLoader +local GetCombatRating = GetCombatRating +local GetCombatRatingBonus = GetCombatRatingBonus +local GetSpellHitModifier = GetSpellHitModifier +local IsClassic = ECS.IsClassic +local IsSoD = ECS.IsSoD +local IsWotlk = ECS.IsWotlk +local max = math.max +local min = math.min +local UnitClass = UnitClass + ---@class Data local Data = ECSLoader:ImportModule("Data") ---@type DataUtils @@ -15,7 +26,7 @@ local _, _, classId = UnitClass("player") function Data:SpellMissChance(school,levelDifference,IsPvP) -- https://royalgiraffe.github.io/resist-guide local missChance = 0 - local minimumMissChance = ECS.IsWotlk and 0 or 1 + local minimumMissChance = IsWotlk and 0 or 1 local maximumMissChance = 90 -- uncertain, may be different for PvP if levelDifference >= -3 and levelDifference <= 2 then @@ -53,40 +64,40 @@ function _SpellHit:GetTalentSpellHitBonus(school) if classId == Data.DRUID then bonus = bonus + 2 * DataUtils:GetActiveTalentSpell({33592,33596}) -- Balance of Power elseif classId == Data.DEATHKNIGHT then - if ECS.IsWotlk then + if IsWotlk then bonus = bonus + 1 * DataUtils:GetActiveTalentSpell({48962,49567,49568}) -- Virulence end elseif classId == Data.MAGE then - if ECS.IsWotlk then + if IsWotlk then bonus = bonus + 1 * DataUtils:GetActiveTalentSpell({29438,29439,29440}) -- Elemental Precision bonus = bonus + 1 * DataUtils:GetActiveTalentSpell({11222,12839,12840}) -- Arcane Focus else if (school == Data.FIRE_SCHOOL or school == Data.FROST_SCHOOL) then - local coeff = ECS.IsClassic and 2 or 1 + local coeff = IsClassic and 2 or 1 bonus = bonus + coeff * DataUtils:GetActiveTalentSpell({29438,29439,29440}) -- Elemental Precision elseif school == Data.ARCANE_SCHOOL then bonus = bonus + 2 * DataUtils:GetActiveTalentSpell({11222,12839,12840,12841,12842}) -- Arcane Focus end end elseif classId == Data.PALADIN then - if ECS.IsWotlk then + if IsWotlk then bonus = bonus + 2 * DataUtils:GetActiveTalentSpell({53556,53557}) -- Enlightened Judgements end elseif classId == Data.PRIEST then if school == Data.SHADOW_SCHOOL then - local coeff = ECS.IsWotlk and 1 or 2 + local coeff = IsWotlk and 1 or 2 bonus = bonus + coeff * DataUtils:GetActiveTalentSpell({15260,15327,15328}) -- Shadow Focus end elseif classId == Data.SHAMAN then if (school == Data.FIRE_SCHOOL or school == Data.FROST_SCHOOL or school == Data.NATURE_SCHOOL) then - local coeff = ECS.IsWotlk and 1 or 2 + local coeff = IsWotlk and 1 or 2 bonus = bonus + coeff * DataUtils:GetActiveTalentSpell({30672,30673,30674}) -- Elemental Precision end - if ECS.IsClassic then + if IsClassic then bonus = bonus + 1 * DataUtils:GetActiveTalentSpell({16180,16196,16198}) -- Nature's Guidance end elseif classId == Data.WARLOCK then - if ECS.IsWotlk then + if IsWotlk then bonus = bonus + 1 * DataUtils:GetActiveTalentSpell({18174,18175,18176}) -- Suppression end end @@ -109,7 +120,7 @@ end function _SpellHit.GetSpellHitFromRunes(school) local mod = 0 - if (not ECS.IsSoD) then + if (not IsSoD) then return mod end diff --git a/Modules/EventHandler.lua b/Modules/EventHandler.lua index d6833a4d..fa57eded 100644 --- a/Modules/EventHandler.lua +++ b/Modules/EventHandler.lua @@ -1,3 +1,7 @@ +local After = C_Timer.After +local ECSLoader = ECSLoader +local UnitGUID = UnitGUID + ---@class EventHandler local EventHandler = ECSLoader:CreateModule("EventHandler") @@ -6,25 +10,27 @@ local Stats = ECSLoader:ImportModule("Stats") ---@type GearInfos local GearInfos = ECSLoader:ImportModule("GearInfos") +local playerGUID = UnitGUID("player") + local function DelayedUpdateInformation() local statsFrame = Stats:GetFrame() statsFrame:SetScript("OnUpdate", nil) -- update next frame - C_Timer.After(0, function () + After(0, function () Stats.UpdateInformation() end) end local function DelayedUpdateGearColorFrames() -- update next frame - C_Timer.After(0, function () + After(0, function () GearInfos.UpdateGearColorFrames() end) end local function DelayedUpdateInspectGearColorFrames() -- update next frame - C_Timer.After(0, function () + After(0, function () GearInfos:UpdateInspectGearColorFrames() end) end @@ -66,12 +72,12 @@ function EventHandler.HandleOnEvent(self,event, ...) event == "UNIT_RANGED_ATTACK_POWER" ) and args[1] == "player") then statsFrame:SetScript("OnUpdate", DelayedUpdateInformation) - elseif (event == "INSPECT_READY" and args[1] == UnitGUID("player")) or event == "PLAYER_EQUIPMENT_CHANGED" or event == "SOCKET_INFO_SUCCESS" then + elseif (event == "INSPECT_READY" and args[1] == playerGUID) or event == "PLAYER_EQUIPMENT_CHANGED" or event == "SOCKET_INFO_SUCCESS" then statsFrame:SetScript("OnUpdate", DelayedUpdateInformation) end end - if (event == "INSPECT_READY" and args[1] == UnitGUID("player")) or event == "PLAYER_EQUIPMENT_CHANGED" then + if (event == "INSPECT_READY" and args[1] == playerGUID) or event == "PLAYER_EQUIPMENT_CHANGED" then DelayedUpdateGearColorFrames() end if InspectPaperDollFrame and event == "INSPECT_READY" and args[1] == UnitGUID("target") then diff --git a/Modules/GearInfos.lua b/Modules/GearInfos.lua index 5522b795..51669cd6 100755 --- a/Modules/GearInfos.lua +++ b/Modules/GearInfos.lua @@ -1,9 +1,10 @@ - ----@class GearInfos -local GearInfos = ECSLoader:CreateModule("GearInfos") - --- Forward declaration -local _CreateGearColorFrames, _UpdateColorFrame, _GetInspectGearSlots +local After = C_Timer.After +local ECSLoader = ECSLoader +local GetInventoryItemLink = GetInventoryItemLink +local GetItemInfo = C_Item.GetItemInfo +local GetItemQualityByID = C_Item.GetItemQualityByID +local GetItemQualityColor = C_Item.GetItemQualityColor +local ipairs = ipairs local GEAR_SLOT_FRAMES = { CharacterHeadSlot, @@ -25,6 +26,12 @@ local GEAR_SLOT_FRAMES = { CharacterRangedSlot, } +---@class GearInfos +local GearInfos = ECSLoader:CreateModule("GearInfos") + +-- Forward declaration +local _CreateGearColorFrames, _UpdateColorFrame, _GetInspectGearSlots + function GearInfos.Init() _CreateGearColorFrames() end @@ -53,15 +60,15 @@ _UpdateColorFrame = function (gearFrame, unit) local itemLink = GetInventoryItemLink(unit, gearFrame:GetID()) if itemLink ~= nil then - local _, itemInfo = C_Item.GetItemInfo(itemLink) + local _, itemInfo = GetItemInfo(itemLink) if itemInfo ~= nil then - local itemQuality = C_Item.GetItemQualityByID(itemInfo) - local r, g, b, _ = C_Item.GetItemQualityColor(itemQuality) + local itemQuality = GetItemQualityByID(itemInfo) + local r, g, b, _ = GetItemQualityColor(itemQuality) gearFrame.qualityTexture:SetVertexColor(r, g, b, ExtendedCharacterStats.general.qualityColorsIntensity) end else -- next frame - C_Timer.After(0, function () + After(0, function () _UpdateColorFrame(gearFrame, unit) end) end diff --git a/Modules/Init.lua b/Modules/Init.lua index e59adaaa..63f7fa82 100644 --- a/Modules/Init.lua +++ b/Modules/Init.lua @@ -1,3 +1,9 @@ +local ECSLoader = ECSLoader +local IsClassic = ECS.IsClassic +local IsEventValid = C_EventUtils.IsEventValid +local IsSoD = ECS.IsSoD +local PaperDollItemsFrame = PaperDollItemsFrame + ---@class Init local Init = ECSLoader:CreateModule("Init") local _Init = {} @@ -15,8 +21,6 @@ local GearInfos = ECSLoader:ImportModule("GearInfos") ---@type Profile local Profile = ECSLoader:ImportModule("Profile") - - function Init:OnAddonLoaded() if (not ExtendedCharacterStats) then ExtendedCharacterStats = {} @@ -98,10 +102,11 @@ function _Init.RegisterEvents(eventFrame) eventFrame:RegisterUnitEvent("UNIT_RANGED_ATTACK_POWER", "player") eventFrame:RegisterUnitEvent("UNIT_RANGEDDAMAGE", "player") eventFrame:RegisterEvent("UPDATE_SHAPESHIFT_FORM") - if not ECS.IsClassic then + if not IsClassic then eventFrame:RegisterEvent("SOCKET_INFO_SUCCESS") -- Triggers whenever the player successfully sockets an item if GearManagerDialog then + local GearManagerDialog = GearManagerDialog GearManagerDialog:HookScript("OnShow", function() Stats:HideWindow() end) @@ -110,12 +115,12 @@ function _Init.RegisterEvents(eventFrame) end) end end - if (C_EventUtils.IsEventValid("GLYPH_ADDED")) then + if IsEventValid("GLYPH_ADDED") then eventFrame:RegisterEvent("GLYPH_ADDED") eventFrame:RegisterEvent("GLYPH_UPDATED") eventFrame:RegisterEvent("GLYPH_REMOVED") end - if ECS.IsSoD then + if IsSoD then eventFrame:RegisterEvent("RUNE_UPDATED") -- Triggers whenever the player changed a rune end end diff --git a/Modules/Migration.lua b/Modules/Migration.lua index 0f1bf19b..e3854a52 100644 --- a/Modules/Migration.lua +++ b/Modules/Migration.lua @@ -1,3 +1,6 @@ +local ECS = ECS +local ECSLoader = ECSLoader + ---@class Migration local Migration = ECSLoader:CreateModule("Migration") diff --git a/Modules/Profile.lua b/Modules/Profile.lua index 2a2152fe..640b16f8 100755 --- a/Modules/Profile.lua +++ b/Modules/Profile.lua @@ -1,3 +1,5 @@ +local ECSLoader = ECSLoader + ---@class Profile local Profile = ECSLoader:CreateModule("Profile") diff --git a/Modules/SlashCommands.lua b/Modules/SlashCommands.lua index ecf83f7d..2d151509 100644 --- a/Modules/SlashCommands.lua +++ b/Modules/SlashCommands.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local lower = string.lower + ---@type i18n local i18n = ECSLoader:ImportModule("i18n") ---@type Config @@ -6,7 +9,7 @@ local Config = ECSLoader:ImportModule("Config") local Stats = ECSLoader:ImportModule("Stats") local function _HandleSlash(msg) - local cmd = string.lower(msg) or "help" + local cmd = lower(msg) or "help" if cmd == "toggle" then Stats:ToggleWindow() diff --git a/Modules/Stats.lua b/Modules/Stats.lua index acac2a0b..eca5d2f1 100755 --- a/Modules/Stats.lua +++ b/Modules/Stats.lua @@ -1,3 +1,20 @@ +local After = C_Timer.After +local CanDualWield = CanDualWield +local CharacterModelFrame = CharacterModelFrame +local ECSLoader = ECSLoader +local error = error +local insert = table.insert +local IsClassic = ECS.IsClassic +local IsSoD = ECS.IsSoD +local IsWotlk = ECS.IsWotlk +local PaperDollItemsFrame = PaperDollItemsFrame +local pairs = pairs +local type = type +local remove = table.remove +local STANDARD_TEXT_FONT = STANDARD_TEXT_FONT +local UnitHasMana = UnitHasMana +local UnitHasRelicSlot = UnitHasRelicSlot + ------------------------------------------------------------------ -- Modules ------------------------------------------------------------------ @@ -72,14 +89,17 @@ function Stats.CreateWindow() toggleButton:SetText("< ECS") toggleButton:SetSize(44, 18) -- Move to old position if Leatrix Plus durability button is active. See #20 - if (LeaPlusDB and LeaPlusDB["DurabilityStatus"] == "On") or PawnInitialize then - if OutfitterButton then -- See #89 - toggleButton:SetPoint("TOPRIGHT", PaperDollItemsFrame, "TOPRIGHT", -55, -16) + if LeaPlusDB then + local LeaPlusDB = LeaPlusDB + if (LeaPlusDB["DurabilityStatus"] == "On") or PawnInitialize then + if OutfitterButton then -- See #89 + toggleButton:SetPoint("TOPRIGHT", PaperDollItemsFrame, "TOPRIGHT", -55, -16) + else + toggleButton:SetPoint("TOPRIGHT", PaperDollItemsFrame, "TOPRIGHT", -57, -16) + end else - toggleButton:SetPoint("TOPRIGHT", PaperDollItemsFrame, "TOPRIGHT", -57, -16) + toggleButton:SetPoint("BOTTOMRIGHT", PaperDollItemsFrame, "BOTTOMRIGHT", -38, 87) end - else - toggleButton:SetPoint("BOTTOMRIGHT", PaperDollItemsFrame, "BOTTOMRIGHT", -38, 87) end toggleButton:SetScript("OnClick", function () Stats:ToggleWindow() @@ -88,6 +108,8 @@ function Stats.CreateWindow() mainFrame:SetScript("OnShow", function () toggleButton:SetText("< ECS") if OutfitterFrame ~= nil and OutfitterButtonFrame ~= nil then + local OutfitterButtonFrame = OutfitterButtonFrame + local OutfitterFrame = OutfitterFrame OutfitterFrame:SetPoint("TOPLEFT", OutfitterButtonFrame , "TOPRIGHT", -34 + ExtendedCharacterStats.general.window.width, -38) end Stats.UpdateInformation() @@ -95,6 +117,8 @@ function Stats.CreateWindow() mainFrame:SetScript("OnHide", function () toggleButton:SetText("ECS >") if OutfitterFrame ~= nil and OutfitterButtonFrame ~= nil then + local OutfitterButtonFrame = OutfitterButtonFrame + local OutfitterFrame = OutfitterFrame OutfitterFrame:SetPoint("TOPLEFT", OutfitterButtonFrame , "TOPRIGHT", -34, -38) end end) @@ -104,10 +128,11 @@ function Stats.CreateWindow() Stats:HideWindow() end - if ECS.IsSoD then + if IsSoD then -- next frame - C_Timer.After(0, function () + After(0, function () if EngravingFrame then + local EngravingFrame = EngravingFrame if EngravingFrame:IsShown() then mainFrame:ClearAllPoints() mainFrame:SetPoint("LEFT", EngravingFrame, "RIGHT", 10, 19) @@ -217,24 +242,24 @@ _CreateStatInfos = function() category, category.attackPower, category.crit, - ECS.IsWotlk and category.penetrationRating or nil, - (not ECS.IsClassic) and category.penetration or nil, - (not ECS.IsClassic) and category.expertiseRating or nil, - (not ECS.IsClassic) and category.expertise or nil, - (not ECS.IsClassic) and category.hasteRating or nil, - (not ECS.IsClassic) and category.hasteBonus or nil + IsWotlk and category.penetrationRating or nil, + (not IsClassic) and category.penetration or nil, + (not IsClassic) and category.expertiseRating or nil, + (not IsClassic) and category.expertise or nil, + (not IsClassic) and category.hasteRating or nil, + (not IsClassic) and category.hasteBonus or nil ) if category.display then category = category.hit _CreateStatInfo( category, - (not ECS.IsClassic) and category.rating or nil, + (not IsClassic) and category.rating or nil, category.bonus, category.sameLevel, category.bossLevel ) - if (not ECS.IsWotlk) then + if (not IsWotlk) then category = profile.melee.glance _CreateStatInfo(category, category.sameLevel, category.damageSameLevel, category.bossLevel, category.damageBossLevel) end @@ -253,10 +278,10 @@ _CreateStatInfos = function() category, category.attackPower, category.crit, - ECS.IsWotlk and category.penetrationRating or nil, - (not ECS.IsClassic) and category.penetration or nil, - (not ECS.IsClassic) and category.hasteRating or nil, - (not ECS.IsClassic) and category.hasteBonus or nil, + IsWotlk and category.penetrationRating or nil, + (not IsClassic) and category.penetration or nil, + (not IsClassic) and category.hasteRating or nil, + (not IsClassic) and category.hasteBonus or nil, category.attackSpeed ) @@ -264,7 +289,7 @@ _CreateStatInfos = function() category = category.hit _CreateStatInfo( category, - (not ECS.IsClassic) and category.rating or nil, + (not IsClassic) and category.rating or nil, category.bonus, category.sameLevel, category.bossLevel @@ -281,16 +306,16 @@ _CreateStatInfos = function() category.spellCritReduction, category.avoidance, category.avoidanceBoss, - (not ECS.IsClassic) and category.defenseRating or nil, + (not IsClassic) and category.defenseRating or nil, category.defense, - (not ECS.IsClassic and DataUtils:CanBlock()) and category.blockRating or nil, + (not IsClassic and DataUtils:CanBlock()) and category.blockRating or nil, DataUtils:CanBlock() and category.blockChance or nil, DataUtils:CanBlock() and category.blockValue or nil, - (not ECS.IsClassic and DataUtils:CanParry()) and category.parryRating or nil, + (not IsClassic and DataUtils:CanParry()) and category.parryRating or nil, DataUtils:CanParry() and category.parry or nil, - (not ECS.IsClassic) and category.dodgeRating or nil, + (not IsClassic) and category.dodgeRating or nil, category.dodge or nil, - (not ECS.IsClassic) and category.resilienceRating or nil + (not IsClassic) and category.resilienceRating or nil ) if UnitHasMana("player") then @@ -305,12 +330,12 @@ _CreateStatInfos = function() local spellHit = spell.hit _CreateStatInfo( category, - (not ECS.IsClassic) and category.hasteRating or nil, + (not IsClassic) and category.hasteRating or nil, category.hasteBonus, - (not ECS.IsClassic) and category.penetrationRating or nil, - (not ECS.IsClassic) and category.penetration or nil, + (not IsClassic) and category.penetrationRating or nil, + (not IsClassic) and category.penetration or nil, spellBonus.bonusHealing, - (not ECS.IsClassic) and spellHit.rating or nil, + (not IsClassic) and spellHit.rating or nil, spell.arcane.display and spellBonus.arcaneDmg or nil, spell.arcane.display and spellCrit.display and spellCrit.arcane or nil, spell.arcane.display and spellHit.bonus.display and spellHit.arcaneHitBonus or nil, @@ -360,7 +385,7 @@ _CreateHeader = function(name, displayText, isSubHeader) end lastYOffset = lastYOffset - 20 ---@class StatsHeader - local header = table.remove(framePool) + local header = remove(framePool) if not header then header = _Stats.frame.ScrollChild:CreateFontString(name, "OVERLAY", headerFont) else @@ -385,7 +410,7 @@ _CreateText = function(name, displayText, isSubText) lastYOffset = lastYOffset - 15 ---@class StatsText - local stat = table.remove(framePool) + local stat = remove(framePool) if not stat then stat = _Stats.frame.ScrollChild:CreateFontString(name, "OVERLAY", statFont) else @@ -393,7 +418,7 @@ _CreateText = function(name, displayText, isSubText) end stat:SetPoint("TOPLEFT", xOffSet, lastYOffset) stat:SetText(displayText) - stat:SetFont(STANDARD_TEXT_FONT, ExtendedCharacterStats.general.statFontSize) + stat:SetFont(STANDARD_TEXT_FONT, ExtendedCharacterStats.general.statFontSize) stat:Show() _Stats.displayedLines[name] = stat end @@ -402,7 +427,7 @@ end ---@param frame StatsHeader|StatsText function Stats:RecycleFrame(frame) frame:Hide() - table.insert(framePool, frame) + insert(framePool, frame) end --- Resets the Y-Offset and rebuilds the displayed frames diff --git a/Modules/Utils.lua b/Modules/Utils.lua index ed2fca8f..135b7820 100755 --- a/Modules/Utils.lua +++ b/Modules/Utils.lua @@ -1,8 +1,12 @@ +local ECSLoader = ECSLoader +local tostring = tostring +local GetAddOnInfo = C_AddOns.GetAddOnInfo +local match = string.match +local tonumber = tonumber + ---@class Utils local Utils = ECSLoader:CreateModule("Utils") -local GetAddOnInfo = C_AddOns and C_AddOns.GetAddOnInfo or GetAddOnInfo - ---@class table Utils.CHAR_EQUIP_SLOTS = { ["Head"] = "HeadSlot", @@ -81,7 +85,7 @@ function Utils:GetAddonVersionInfo() cachedTitle = title end -- %d = digit, %p = punctuation character, %x = hexadecimal digits. - local major, minor, patch, _ = string.match(cachedTitle, "(%d+)%p(%d+)%p(%d+)") + local major, minor, patch, _ = match(cachedTitle, "(%d+)%p(%d+)%p(%d+)") return tonumber(major), tonumber(minor), tonumber(patch) end diff --git a/Modules/i18n/i18n.lua b/Modules/i18n/i18n.lua index a0948518..f4e0b330 100755 --- a/Modules/i18n/i18n.lua +++ b/Modules/i18n/i18n.lua @@ -1,3 +1,12 @@ +local ECS = ECS +local ECSLoader = ECSLoader +local format = string.format +local GetLocale = GetLocale +local ipairs = ipairs +local setmetatable = setmetatable +local tostring = tostring +local unpack = unpack + ---@class i18n local i18n = ECSLoader:CreateModule("i18n") i18n.translations = {} @@ -28,21 +37,21 @@ local function translate(key, ...) if translationEntry == nil then -- Translation for the key is missing completely ECS:Error("The translation for <".. tostring(key) .. "> is missing completely. Please report this!") - return string.format(key, unpack(args)) + return format(key, unpack(args)) end local translationValue = translationEntry[selectedLocale] if (not translationValue) then -- The translation for the selected locale is missing - return string.format(key, unpack(args)) + return format(key, unpack(args)) end if translationValue == true then -- Fallback to enUS which is the key - return string.format(key, unpack(args)) + return format(key, unpack(args)) end - return string.format(translationValue, unpack(args)) + return format(translationValue, unpack(args)) end setmetatable(i18n, {__call = function(_, ...) return translate(...) end}) diff --git a/Modules/i18n/translations/CommandTranslations.lua b/Modules/i18n/translations/CommandTranslations.lua index 45e8820a..c5afb7d8 100644 --- a/Modules/i18n/translations/CommandTranslations.lua +++ b/Modules/i18n/translations/CommandTranslations.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local pairs = pairs + ---@type i18n local i18n = ECSLoader:ImportModule("i18n") diff --git a/Modules/i18n/translations/ConfigTranslations/ConfigTranslations.lua b/Modules/i18n/translations/ConfigTranslations/ConfigTranslations.lua index a8b72073..bcb3d99f 100644 --- a/Modules/i18n/translations/ConfigTranslations/ConfigTranslations.lua +++ b/Modules/i18n/translations/ConfigTranslations/ConfigTranslations.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local pairs = pairs + ---@type i18n local i18n = ECSLoader:ImportModule("i18n") diff --git a/Modules/i18n/translations/ConfigTranslations/DefenseConfigTranslations.lua b/Modules/i18n/translations/ConfigTranslations/DefenseConfigTranslations.lua index 8d2a36cb..a9246b16 100644 --- a/Modules/i18n/translations/ConfigTranslations/DefenseConfigTranslations.lua +++ b/Modules/i18n/translations/ConfigTranslations/DefenseConfigTranslations.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local pairs = pairs + ---@type i18n local i18n = ECSLoader:ImportModule("i18n") diff --git a/Modules/i18n/translations/ConfigTranslations/GeneralConfigTranslations.lua b/Modules/i18n/translations/ConfigTranslations/GeneralConfigTranslations.lua index 88bb1158..d40c4e4b 100644 --- a/Modules/i18n/translations/ConfigTranslations/GeneralConfigTranslations.lua +++ b/Modules/i18n/translations/ConfigTranslations/GeneralConfigTranslations.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local pairs = pairs + ---@type i18n local i18n = ECSLoader:ImportModule("i18n") diff --git a/Modules/i18n/translations/ConfigTranslations/ManaConfigTranslations.lua b/Modules/i18n/translations/ConfigTranslations/ManaConfigTranslations.lua index 21443840..54b5a11a 100644 --- a/Modules/i18n/translations/ConfigTranslations/ManaConfigTranslations.lua +++ b/Modules/i18n/translations/ConfigTranslations/ManaConfigTranslations.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local pairs = pairs + ---@type i18n local i18n = ECSLoader:ImportModule("i18n") diff --git a/Modules/i18n/translations/ConfigTranslations/MeleeConfigTranslations.lua b/Modules/i18n/translations/ConfigTranslations/MeleeConfigTranslations.lua index 57db826a..d6451061 100644 --- a/Modules/i18n/translations/ConfigTranslations/MeleeConfigTranslations.lua +++ b/Modules/i18n/translations/ConfigTranslations/MeleeConfigTranslations.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local pairs = pairs + ---@type i18n local i18n = ECSLoader:ImportModule("i18n") diff --git a/Modules/i18n/translations/ConfigTranslations/RangedConfigTranslations.lua b/Modules/i18n/translations/ConfigTranslations/RangedConfigTranslations.lua index f8576871..9f5c0afe 100644 --- a/Modules/i18n/translations/ConfigTranslations/RangedConfigTranslations.lua +++ b/Modules/i18n/translations/ConfigTranslations/RangedConfigTranslations.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local pairs = pairs + ---@type i18n local i18n = ECSLoader:ImportModule("i18n") diff --git a/Modules/i18n/translations/ConfigTranslations/SpellConfigTranslations.lua b/Modules/i18n/translations/ConfigTranslations/SpellConfigTranslations.lua index 9fd59d06..10ac6331 100644 --- a/Modules/i18n/translations/ConfigTranslations/SpellConfigTranslations.lua +++ b/Modules/i18n/translations/ConfigTranslations/SpellConfigTranslations.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local pairs = pairs + ---@type i18n local i18n = ECSLoader:ImportModule("i18n") diff --git a/Modules/i18n/translations/ConfigTranslations/SpellSchoolsConfigTranslations.lua b/Modules/i18n/translations/ConfigTranslations/SpellSchoolsConfigTranslations.lua index 55c4a28c..92a5a399 100644 --- a/Modules/i18n/translations/ConfigTranslations/SpellSchoolsConfigTranslations.lua +++ b/Modules/i18n/translations/ConfigTranslations/SpellSchoolsConfigTranslations.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local pairs = pairs + ---@type i18n local i18n = ECSLoader:ImportModule("i18n") diff --git a/Modules/i18n/translations/StatTranslations.lua b/Modules/i18n/translations/StatTranslations.lua index 6bf9140e..b1d251bf 100644 --- a/Modules/i18n/translations/StatTranslations.lua +++ b/Modules/i18n/translations/StatTranslations.lua @@ -1,3 +1,6 @@ +local ECSLoader = ECSLoader +local pairs = pairs + ---@type i18n local i18n = ECSLoader:ImportModule("i18n")