diff --git a/.luacheckrc b/.luacheckrc index 2e903fee..14a6d71e 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -819,6 +819,8 @@ stds.ecs = { "CR_HIT_RANGED", "CR_HIT_SPELL", "CR_PARRY", + "CR_RESILIENCE_CRIT_TAKEN", + "CR_RESILIENCE_PLAYER_DAMAGE_TAKEN", "CR_WEAPON_SKILL", "CreateFont", "CreateFrame", @@ -1196,6 +1198,7 @@ stds.ecs = { "GetMirrorTimerProgress", "GetModifiedClick", "GetModifiedClickAction", + "GetModResilienceDamageReduction", "GetMoney", "GetMonitorAspectRatio", "GetMonitorCount", diff --git a/Modules/Config/DefenseSection.lua b/Modules/Config/DefenseSection.lua index 202a3a54..d02a4c7c 100755 --- a/Modules/Config/DefenseSection.lua +++ b/Modules/Config/DefenseSection.lua @@ -189,9 +189,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 ECS.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 4d1f3fe1..3b2970f3 100755 --- a/Modules/Data/Data.lua +++ b/Modules/Data/Data.lua @@ -1,3 +1,5 @@ +local IsClassic = ECS.IsClassic + ---@class Data local Data = ECSLoader:CreateModule("Data") @@ -66,7 +68,8 @@ dataFunctionRefs = { ["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, + ["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 f9511d57..cdd15976 100755 --- a/Modules/Data/Defense.lua +++ b/Modules/Data/Defense.lua @@ -27,6 +27,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") @@ -60,7 +61,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 == Data.DRUID then local coeff = ECS.IsWotlk and 2 or 1 @@ -219,7 +222,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 0f1bf19b..31e1329a 100644 --- a/Modules/Migration.lua +++ b/Modules/Migration.lua @@ -15,11 +15,10 @@ function Migration:ToLatestProfileVersion(profileVersion) return end - 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 + local defaultProfile = Profile:GetDefaultProfile() + + if profileVersion < 26 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 2a2152fe..affcc521 100755 --- a/Modules/Profile.lua +++ b/Modules/Profile.lua @@ -6,7 +6,7 @@ local Utils = ECSLoader:ImportModule("Utils") ---@return number function Profile.GetProfileVersion() - return 25 + return 26 end ---@return ECSProfile @@ -286,7 +286,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 acac2a0b..3546a637 100755 --- a/Modules/Stats.lua +++ b/Modules/Stats.lua @@ -1,3 +1,5 @@ +local IsClassic = ECS.IsClassic + ------------------------------------------------------------------ -- Modules ------------------------------------------------------------------ @@ -290,7 +292,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 8d2a36cb..44b5bb2a 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, + }, } for k, v in pairs(defenseConfigTranslations) do diff --git a/Modules/i18n/translations/StatTranslations.lua b/Modules/i18n/translations/StatTranslations.lua index 6bf9140e..c8cdfe39 100644 --- a/Modules/i18n/translations/StatTranslations.lua +++ b/Modules/i18n/translations/StatTranslations.lua @@ -362,6 +362,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",