From 25a91e6e24764c6eac7aac240827064d92e72e74 Mon Sep 17 00:00:00 2001 From: Casey Raethke Date: Thu, 27 Jul 2023 09:25:56 -0500 Subject: [PATCH] Account for weapon skill in crit conversion --- RatingBuster.lua | 5 ++++- libs/StatLogic/StatLogic.lua | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/RatingBuster.lua b/RatingBuster.lua index 2f4d358..05be7ed 100644 --- a/RatingBuster.lua +++ b/RatingBuster.lua @@ -1511,11 +1511,14 @@ do end end - -- Ignore Stat Mods that mostly exist for Tank Points + -- Ignore Stat Mods that are only used for Diminishing Returns + -- and agi/int conversion rates local ignoredStatMods = { ["MOD_DMG_TAKEN"] = true, ["ADD_DODGE"] = true, ["ADD_HIT_TAKEN"] = true, + ["ADD_MELEE_CRIT"] = true, + ["ADD_SPELL_CRIT"] = true, } local function GenerateAuraOptions() for modType, modList in pairs(StatLogic.StatModTable) do diff --git a/libs/StatLogic/StatLogic.lua b/libs/StatLogic/StatLogic.lua index 3559a88..83d4e0c 100644 --- a/libs/StatLogic/StatLogic.lua +++ b/libs/StatLogic/StatLogic.lua @@ -481,6 +481,10 @@ local function GetTotalDefense(unit) return base + modifier end +local function GetTotalWeaponSkill(unit) + local base, modifier = UnitAttackBothHands(unit); + return base + modifier +end --============-- -- Base Stats -- @@ -1562,14 +1566,21 @@ end function StatLogic:GetEffectFromDefense(defense, attackerLevel) self:argCheck(defense, 2, "nil", "number") self:argCheck(attackerLevel, 3, "nil", "number") - if not defense then - local base, add = UnitDefense("player") - defense = base + add - end + defense = defense or GetTotalDefense("player") if not attackerLevel then attackerLevel = UnitLevel("player") end - return (defense - attackerLevel * 5) * 0.04 + return (defense - attackerLevel * 5) * DODGE_PARRY_BLOCK_PERCENT_PER_DEFENSE +end + +function StatLogic:GetCritChanceFromWeaponSkill(skill, targetLevel) + self:argCheck(skill, 2, "nil", "number") + self:argCheck(targetLevel, 3, "nil", "number") + skill = skill or GetTotalWeaponSkill("player") + if not targetLevel then + targetLevel = UnitLevel("player") + end + return (skill - targetLevel * 5) * 0.04 end function StatLogic:RatingExists(id) @@ -2048,6 +2059,7 @@ function StatLogic:GetCritPerAgi(class, level) local _, agility = UnitStat("player", 2) local critFromAgi = GetCritChance() - self:GetStatMod("ADD_MELEE_CRIT") + - self:GetCritChanceFromWeaponSkill() - self:GetTotalEquippedStat(StatLogic.Stats.MeleeCrit) return (critFromAgi - addon.BaseMeleeCrit[class]) / agility end