From 10bd3d1d1b63e007bc37063f813f256e7356e09c Mon Sep 17 00:00:00 2001
From: Regisle <Regisle.godform@gmail.com>
Date: Fri, 30 Aug 2024 18:16:38 +0930
Subject: [PATCH] Change Passes to only always, never or average crit chance

---
 src/Modules/CalcOffence.lua  | 26 +++++++++++++++++++-------
 src/Modules/CalcSections.lua | 22 +++++++++++-----------
 2 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/src/Modules/CalcOffence.lua b/src/Modules/CalcOffence.lua
index fc430b091d..d772ba247b 100644
--- a/src/Modules/CalcOffence.lua
+++ b/src/Modules/CalcOffence.lua
@@ -2907,8 +2907,8 @@ function calcs.offence(env, actor, activeSkill)
 		output.EnergyShieldLeechInstant = 0
 		output.ManaLeech = 0
 		output.ManaLeechInstant = 0
-		output.impaleStoredHitAvg = 0
-		for pass = 1, 2 do
+		output.impaleStoredHitAvg = 0 
+		for _, pass in ipairs(output.CritChance == 100 and { 1 } or output.CritChance == 0 and { 2 } or { 1, 2 }) do
 			-- Pass 1 is critical strike damage, pass 2 is non-critical strike
 			cfg.skillCond["CriticalStrike"] = (pass == 1)
 			local lifeLeechTotal = 0
@@ -3077,15 +3077,15 @@ function calcs.offence(env, actor, activeSkill)
 						if env.mode == "CALCS" then
 							output[damageType.."EffMult"] = effMult
 						end
-						if pass == 2 and breakdown and (effMult ~= 1 or sourceRes ~= damageType) and skillModList:Flag(cfg, isElemental[damageType] and "CannotElePenIgnore" or nil) then
+						if breakdown and (pass == 2 or output.CritChance == 100) and (effMult ~= 1 or sourceRes ~= damageType) and skillModList:Flag(cfg, isElemental[damageType] and "CannotElePenIgnore" or nil) then
 							t_insert(breakdown[damageType], s_format("x %.3f ^8(effective DPS modifier)", effMult))
 							breakdown[damageType.."EffMult"] = breakdown.effMult(damageType, resist, 0, takenInc, effMult, takenMore, sourceRes, useRes, invertChance)
-						elseif pass == 2 and breakdown and (effMult ~= 1 or sourceRes ~= damageType) then
+						elseif breakdown and (pass == 2 or output.CritChance == 100) and (effMult ~= 1 or sourceRes ~= damageType) then
 							t_insert(breakdown[damageType], s_format("x %.3f ^8(effective DPS modifier)", effMult))
 							breakdown[damageType.."EffMult"] = breakdown.effMult(damageType, resist, pen, takenInc, effMult, takenMore, sourceRes, useRes, invertChance)
 						end
 					end
-					if pass == 2 and breakdown then
+					if breakdown and (pass == 2 or output.CritChance == 100) then
 						t_insert(breakdown[damageType], s_format("= %d to %d", damageTypeHitMin, damageTypeHitMax))
 					end
 
@@ -3128,12 +3128,13 @@ function calcs.offence(env, actor, activeSkill)
 						}
 					end
 				end
-				if pass == 1 then
+				if pass == 1 or output.CritChance == 0 then
 					output[damageType.."CritAverage"] = damageTypeHitAvg
 					totalCritAvg = totalCritAvg + damageTypeHitAvg
 					totalCritMin = totalCritMin + damageTypeHitMin
 					totalCritMax = totalCritMax + damageTypeHitMax
-				else
+				end
+				if pass == 2 or output.CritChance == 100 then
 					if env.mode == "CALCS" then
 						output[damageType.."Min"] = damageTypeHitMin
 						output[damageType.."Max"] = damageTypeHitMax
@@ -5527,4 +5528,15 @@ function calcs.offence(env, actor, activeSkill)
 	output.CullingDPS = output.CombinedDPS * (bestCull - 1)
 	output.ReservationDPS = output.CombinedDPS * (output.ReservationDpsMultiplier - 1)
 	output.CombinedDPS = output.CombinedDPS * bestCull * output.ReservationDpsMultiplier
+	
+	
+	if output.CritChance == 100 then
+		skillCfg.skillCond["CriticalStrike"] = true
+	end
+	if output.MainHand and output.MainHand.CritChance == 100 then
+		activeSkill.weapon1Cfg.skillCond["CriticalStrike"] = true
+	end
+	if output.OffHand and output.OffHand.CritChance == 100 then
+		activeSkill.weapon2Cfg.skillCond["CriticalStrike"] = true
+	end
 end
diff --git a/src/Modules/CalcSections.lua b/src/Modules/CalcSections.lua
index af359bcb5e..41f15736cb 100644
--- a/src/Modules/CalcSections.lua
+++ b/src/Modules/CalcSections.lua
@@ -126,17 +126,17 @@ return {
 		},
 		{ format = "x {3:output:LightningEffMult}",
 			{ breakdown = "LightningEffMult" },
-			{ label = "Player modifiers", modName = { "LightningPenetration", "ElementalPenetration", "IgnoreLightningResistance" }, cfg = "skill" },
+			{ label = "Player modifiers", modName = { "LightningPenetration", "ElementalPenetration", "IgnoreLightningResistance", "IgnoreElementalResistances" }, cfg = "skill" },
 			{ label = "Enemy modifiers", modName = lightningHitTaken, enemy = true, cfg = "skill" },
 		},
 		{ format = "x {3:output:ColdEffMult}",
 			{ breakdown = "ColdEffMult" },
-			{ label = "Player modifiers", modName = { "ColdPenetration", "ElementalPenetration", "IgnoreColdResistance" }, cfg = "skill" },
+			{ label = "Player modifiers", modName = { "ColdPenetration", "ElementalPenetration", "IgnoreColdResistance", "IgnoreElementalResistances" }, cfg = "skill" },
 			{ label = "Enemy modifiers", modName = coldHitTaken, enemy = true, cfg = "skill" },
 		},
 		{ format = "x {3:output:FireEffMult}",
 			{ breakdown = "FireEffMult" },
-			{ label = "Player modifiers", modName = { "FirePenetration", "ElementalPenetration", "IgnoreFireResistance" }, cfg = "skill" },
+			{ label = "Player modifiers", modName = { "FirePenetration", "ElementalPenetration", "IgnoreFireResistance", "IgnoreElementalResistances" }, cfg = "skill" },
 			{ label = "Enemy modifiers", modName = fireHitTaken, enemy = true, cfg = "skill" },
 		},
 		{ format = "x {3:output:ChaosEffMult}",
@@ -197,22 +197,22 @@ return {
 		},
 		{ format = "x {3:output:MainHand.LightningEffMult}",
 			{ breakdown = "MainHand.LightningEffMult" },
-			{ label = "Player modifiers", modName = { "LightningPenetration", "ElementalPenetration" }, cfg = "weapon1" },
+			{ label = "Player modifiers", modName = { "LightningPenetration", "ElementalPenetration", "IgnoreLightningResistance", "IgnoreElementalResistances" }, cfg = "weapon1" },
 			{ label = "Enemy modifiers", modName = lightningHitTaken, enemy = true, cfg = "weapon1" },
 		},
 		{ format = "x {3:output:MainHand.ColdEffMult}",
 			{ breakdown = "MainHand.ColdEffMult" },
-			{ label = "Player modifiers", modName = { "ColdPenetration", "ElementalPenetration" }, cfg = "weapon1" },
+			{ label = "Player modifiers", modName = { "ColdPenetration", "ElementalPenetration", "IgnoreColdResistance", "IgnoreElementalResistances" }, cfg = "weapon1" },
 			{ label = "Enemy modifiers", modName = coldHitTaken, enemy = true, cfg = "weapon1" },
 		},
 		{ format = "x {3:output:MainHand.FireEffMult}",
 			{ breakdown = "MainHand.FireEffMult" },
-			{ label = "Player modifiers", modName = { "FirePenetration", "ElementalPenetration" }, cfg = "weapon1" },
+			{ label = "Player modifiers", modName = { "FirePenetration", "ElementalPenetration", "IgnoreFireResistance", "IgnoreElementalResistances" }, cfg = "weapon1" },
 			{ label = "Enemy modifiers", modName = fireHitTaken, enemy = true, cfg = "weapon1" },
 		},
 		{ format = "x {3:output:MainHand.ChaosEffMult}",
 			{ breakdown = "MainHand.ChaosEffMult" },
-			{ label = "Player modifiers", modName = "ChaosPenetration", cfg = "weapon1" },
+			{ label = "Player modifiers", modName = {"ChaosPenetration", "IgnoreChaosResistance"}, cfg = "weapon1" },
 			{ label = "Enemy modifiers", modName = chaosHitTaken, enemy = true, cfg = "weapon1" },
 		},
 	},
@@ -268,22 +268,22 @@ return {
 		},
 		{ format = "x {3:output:OffHand.LightningEffMult}",
 			{ breakdown = "OffHand.LightningEffMult" },
-			{ label = "Player modifiers", modName = { "LightningPenetration", "ElementalPenetration" }, cfg = "weapon2" },
+			{ label = "Player modifiers", modName = { "LightningPenetration", "ElementalPenetration", "IgnoreLightningResistance", "IgnoreElementalResistances" }, cfg = "weapon2" },
 			{ label = "Enemy modifiers", modName = lightningHitTaken, enemy = true, cfg = "weapon2" },
 		},
 		{ format = "x {3:output:OffHand.ColdEffMult}",
 			{ breakdown = "OffHand.ColdEffMult" },
-			{ label = "Player modifiers", modName = { "ColdPenetration", "ElementalPenetration" }, cfg = "weapon2" },
+			{ label = "Player modifiers", modName = { "ColdPenetration", "ElementalPenetration", "IgnoreColdResistance", "IgnoreElementalResistances" }, cfg = "weapon2" },
 			{ label = "Enemy modifiers", modName = coldHitTaken, enemy = true, cfg = "weapon2" },
 		},
 		{ format = "x {3:output:OffHand.FireEffMult}",
 			{ breakdown = "OffHand.FireEffMult" },
-			{ label = "Player modifiers", modName = { "FirePenetration", "ElementalPenetration" }, cfg = "weapon2" },
+			{ label = "Player modifiers", modName = { "FirePenetration", "ElementalPenetration", "IgnoreFireResistance", "IgnoreElementalResistances" }, cfg = "weapon2" },
 			{ label = "Enemy modifiers", modName = fireHitTaken, enemy = true, cfg = "weapon2" },
 		},
 		{ format = "x {3:output:OffHand.ChaosEffMult}",
 			{ breakdown = "OffHand.ChaosEffMult" },
-			{ label = "Player modifiers", modName = "ChaosPenetration", cfg = "weapon2" },
+			{ label = "Player modifiers", modName = {"ChaosPenetration", "IgnoreChaosResistance"}, cfg = "weapon2" },
 			{ label = "Enemy modifiers", modName = chaosHitTaken, enemy = true, cfg = "weapon2" },
 		},
 	},