diff --git a/.luacheckrc b/.luacheckrc index a2e64414..f6af8d1a 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1182,6 +1182,7 @@ stds.ecs = { "GetMirrorTimerProgress", "GetModifiedClick", "GetModifiedClickAction", + "GetModResilienceDamageReduction", "GetMoney", "GetMonitorAspectRatio", "GetMonitorCount", @@ -2542,6 +2543,8 @@ stds.ecs = { "CR_HIT_RANGED", "CR_HIT_SPELL", "CR_PARRY", + "CR_RESILIENCE_CRIT_TAKEN", + "CR_RESILIENCE_PLAYER_DAMAGE_TAKEN", "CR_WEAPON_SKILL", "CraftFrame", "CreateChannelPopup", diff --git a/Modules/Config/DefenseSection.lua b/Modules/Config/DefenseSection.lua index 0e1cadaa..83182771 100755 --- a/Modules/Config/DefenseSection.lua +++ b/Modules/Config/DefenseSection.lua @@ -1,3 +1,7 @@ +-- keep-sorted start case=no +local IsClassic = ECS.IsClassic +-- keep-sorted end + ---@class Config local Config = ECSLoader:ImportModule("Config") local _Config = Config.private @@ -215,9 +219,23 @@ function _Config:LoadDefenseSection() Stats.RebuildStatInfos() end, }, - resilience = { + resilienceRating = { type = "toggle", order = 7, + name = function() return i18n("Resilience Rating") end, + desc = function() return i18n("Shows/Hides the resilience rating.") end, + width = 1.5, + 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) + ExtendedCharacterStats.profile.defense.resilienceRating.display = value + Stats.RebuildStatInfos() + end, + }, + resilience = { + type = "toggle", + order = 8, name = function() return i18n("Resilience") end, desc = function() return i18n("Shows/Hides the resilience value.") end, width = 1.5, diff --git a/Modules/Data/Data.lua b/Modules/Data/Data.lua index 1786b0c9..1200c084 100755 --- a/Modules/Data/Data.lua +++ b/Modules/Data/Data.lua @@ -1,3 +1,7 @@ +-- keep-sorted start case=no +local IsClassic = ECS.IsClassic +-- keep-sorted end + ---@class Data local Data = ECSLoader:CreateModule("Data") @@ -68,7 +72,8 @@ dataFunctionRefs = { ["ParryChance"] = function() return Data:GetParryChance(playerLevel) end, ["BlockChance"] = function() return Data:GetBlockChance(playerLevel) end, ["BlockValue"] = function() return Data:GetBlockValue() end, - ["ResilienceValue"] = function() return ECS.IsClassic and 0 or Data:GetResilienceRating() end, + ["ResilienceRating"] = function() return IsClassic and 0 or Data:GetResilienceRating() end, + ["Resilience"] = function() return IsClassic and 0 or Data:GetResilience() end, -- Spell ["SpellHitRating"] = function() return ECS.IsClassic and 0 or Data:SpellHitRating() end, ["SpellHitBonus"] = function() return Data.SpellHitBonus(Data.HOLY_SCHOOL) end, diff --git a/Modules/Data/Defense.lua b/Modules/Data/Defense.lua index 2a1a785b..8f851fad 100755 --- a/Modules/Data/Defense.lua +++ b/Modules/Data/Defense.lua @@ -1,3 +1,9 @@ +-- keep-sorted start case=no +local GetCombatRating = GetCombatRating +local GetCombatRatingBonus = GetCombatRatingBonus +local GetModResilienceDamageReduction = GetModResilienceDamageReduction +-- keep-sorted end + ---@class Data local Data = ECSLoader:ImportModule("Data") ---@type DataUtils @@ -31,6 +37,7 @@ function _Defense:GetCritReduction() local meleeCritReduction = 0 local rangedCritReduction = 0 local spellCritReduction = 0 + local critReducingFromResilience = 0 local i = 1 repeat local aura = C_UnitAuras.GetAuraDataByIndex("player", i, "HELPFUL") @@ -64,7 +71,9 @@ function _Defense:GetCritReduction() if critReductionFromDefense < 0 then critReductionFromDefense = 0 end - local critReducingFromResilience = GetCombatRatingBonus(15) + if CR_RESILIENCE_CRIT_TAKEN then + critReducingFromResilience = GetCombatRatingBonus(CR_RESILIENCE_CRIT_TAKEN) + end if classId == DRUID then local coeff = ECS.IsWotlk and 2 or 1 @@ -240,7 +249,16 @@ end ---@return number function Data:GetResilienceRating() - return DataUtils:Round(GetCombatRating(15), 2) + local rating = 0 + if CR_RESILIENCE_PLAYER_DAMAGE_TAKEN then + rating = GetCombatRating(CR_RESILIENCE_PLAYER_DAMAGE_TAKEN) + end + return DataUtils:Round(rating, 2) +end + +---@return number +function Data:GetResilience() + return DataUtils:Round(GetModResilienceDamageReduction(), 2) end ---@return number diff --git a/Modules/Migration.lua b/Modules/Migration.lua index ba65b3bc..fb7c8ae0 100644 --- a/Modules/Migration.lua +++ b/Modules/Migration.lua @@ -17,16 +17,13 @@ function Migration:ToLatestProfileVersion(profileVersion) local defaultProfile = Profile:GetDefaultProfile() - if profileVersion < 24 then - ExtendedCharacterStats.profile.defense.resilienceRating = ExtendedCharacterStats.profile.defense.resilience - ExtendedCharacterStats.profile.defense.resilience = nil - end - if profileVersion < 25 then - ExtendedCharacterStats.profile.defense.resilience = nil - end if profileVersion < 26 then ExtendedCharacterStats.profile.spellBonus.baseSpellDmg = defaultProfile.profile.spellBonus.baseSpellDmg ExtendedCharacterStats.profile.defense.enemyMissChance = defaultProfile.profile.defense.enemyMissChance ExtendedCharacterStats.profile.defense.enemyMissChanceBoss = defaultProfile.profile.defense.enemyMissChanceBoss end + if profileVersion < 27 then + ExtendedCharacterStats.profile.defense.resilience = defaultProfile.profile.defense.resilience + ExtendedCharacterStats.profile.defense.resilienceRating = defaultProfile.profile.defense.resilienceRating + end end diff --git a/Modules/Profile.lua b/Modules/Profile.lua index 742b6e4b..a73a543c 100755 --- a/Modules/Profile.lua +++ b/Modules/Profile.lua @@ -6,7 +6,7 @@ local Utils = ECSLoader:ImportModule("Utils") ---@return number function Profile.GetProfileVersion() - return 26 + return 27 end ---@return ECSProfile @@ -288,7 +288,12 @@ local function GetDefaultStatsProfile() dodge = { display = true, refName = "DodgeChance", text = "Dodge Chance" }, resilienceRating = { display = true, - refName = "ResilienceValue", + refName = "ResilienceRating", + text = "Resilience Rating" + }, + resilience = { + display = true, + refName = "Resilience", text = "Resilience" }, }, diff --git a/Modules/Stats.lua b/Modules/Stats.lua index 9432cffd..0dc99a2d 100755 --- a/Modules/Stats.lua +++ b/Modules/Stats.lua @@ -1,3 +1,7 @@ +-- keep-sorted start case=no +local IsClassic = ECS.IsClassic +-- keep-sorted end + ------------------------------------------------------------------ -- Modules ------------------------------------------------------------------ @@ -319,7 +323,8 @@ _CreateStatInfos = function() DataUtils:CanParry() and category.parry or nil, (not ECS.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, + (not IsClassic) and category.resilience or nil ) if UnitHasMana("player") then diff --git a/Modules/i18n/translations/ConfigTranslations/DefenseConfigTranslations.lua b/Modules/i18n/translations/ConfigTranslations/DefenseConfigTranslations.lua index 5dbea0c9..713ebdd1 100644 --- a/Modules/i18n/translations/ConfigTranslations/DefenseConfigTranslations.lua +++ b/Modules/i18n/translations/ConfigTranslations/DefenseConfigTranslations.lua @@ -182,6 +182,16 @@ local defenseConfigTranslations = { ["esMX"] = false, ["ptBR"] = false }, + ["Shows/Hides the resilience rating."] = { + ["enUS"] = true, + ["deDE"] = false, + ["frFR"] = false, + ["zhCN"] = false, + ["ruRU"] = false, + ["esES"] = false, + ["esMX"] = false, + ["ptBR"] = false, + }, ["Shows/Hides the enemy miss chance."] = { ["enUS"] = true, ["deDE"] = "Zeigt/Versteckt die Verfehlen-Chance des Gegners.", @@ -190,7 +200,7 @@ local defenseConfigTranslations = { ["ruRU"] = false, ["esES"] = false, ["esMX"] = false, - ["ptBR"] = false + ["ptBR"] = false, }, ["Shows/Hides the enemy miss chance (Lvl +3)."] = { ["enUS"] = true, diff --git a/Modules/i18n/translations/StatTranslations.lua b/Modules/i18n/translations/StatTranslations.lua index ce312a41..5fe600a9 100644 --- a/Modules/i18n/translations/StatTranslations.lua +++ b/Modules/i18n/translations/StatTranslations.lua @@ -382,6 +382,16 @@ local statTranslations = { ["esMX"] = "Probabilidad de esquivar", ["ptBR"] = "Chance de esquivar" }, + ["Resilience Rating"] = { + ["enUS"] = true, + ["deDE"] = false, + ["frFR"] = false, + ["zhCN"] = false, + ["ruRU"] = false, + ["esES"] = false, + ["esMX"] = false, + ["ptBR"] = false, + }, ["Resilience"] = { ["enUS"] = true, ["deDE"] = "Abhärtung",