Repository: PathOfBuildingCommunity/PathOfBuilding
File: src/Modules/CalcOffence.lua (Lua)

Code before:
			globalOutput.BleedStackPotential = overrideStackPotential or (bleedStacks / maxStacks)

			if globalBreakdown then
				globalBreakdown.BleedStackPotential = {"Ratio of bleed stacks to maximum active bleeds:"}
				if overrideStackPotential then
					t_insert(globalBreakdown.BleedStackPotential, s_format("= %g ^8(stack potential override)", overrideStackPotential))
				else
					t_insert(globalBreakdown.BleedStackPotential, s_format("%.2f ^8(chance to hit)", output.HitChance / 100))
					t_insert(globalBreakdown.BleedStackPotential, s_format("* %.2f ^8(chance to bleed)", output.BleedChanceOnHit / 100))
					t_insert(globalBreakdown.BleedStackPotential, s_format("* (%.2f / %.2f) ^8(Bleed duration / Attack Time)", globalOutput.BleedDuration, (output.HitTime or output.Time)))
					if skillData.dpsMultiplier ~= 1 then
						t_insert(globalBreakdown.BleedStackPotential, s_format("* %g ^8(DPS multiplier for this skill)", skillData.dpsMultiplier))
					end
					if skillFlags.totem then
						t_insert(globalBreakdown.BleedStackPotential, s_format("* %d ^8(active number of Totems)", activeTotems))
					end
					t_insert(globalBreakdown.BleedStackPotential,s_format("/ %d ^8(max number of stacks)", maxStacks))
					t_insert(globalBreakdown.BleedStackPotential,s_format("= %.2f", globalOutput.BleedStackPotential))
				end
			end

			-- the amount of damage each bleed does as % maximum
			local bleedRollAverage
			if globalOutput.BleedStackPotential > 1 then
				-- shift damage towards top of range as only top bleeds apply
				bleedRollAverage = globalOutput.BleedStackPotential / (globalOutput.BleedStackPotential + 1) * 100
			else
				-- assume middle of range for hit damage
				bleedRollAverage = 50
			end
			globalOutput.BleedRollAverage = bleedRollAverage
			if globalBreakdown then
				globalBreakdown.BleedRollAverage = {
					s_format(colorCodes.CUSTOM.."This is the average roll of a Bleed affecting the enemy if you are constantly attacking"),
					s_format(colorCodes.CUSTOM.."If attacking constantly, your average strongest bleed currently achieves ^7%.2f%%"..colorCodes.CUSTOM.." of its max damage", bleedRollAverage),
					s_format(""),
					s_format("Average Bleed Roll:"),
				}
				if(bleedStacks >= maxStacks) then
					t_insert(globalBreakdown.BleedRollAverage, s_format("%.2f / %.2f ^8Stack Potential / (Stack Potential + 1)", globalOutput.BleedStackPotential, globalOutput.BleedStackPotential + 1))
					t_insert(globalBreakdown.BleedRollAverage, s_format("= %.2f%%", bleedRollAverage))
				else
					t_insert(globalBreakdown.BleedRollAverage, "50% (averaging <= 1 bleed)")
				end
			end

			for sub_pass = 1, 2 do
				if skillModList:Flag(dotCfg, "AilmentsAreNeverFromCrit") or sub_pass == 1 then
					dotCfg.skillCond["CriticalStrike"] = false
				else
					dotCfg.skillCond["CriticalStrike"] = true

Review comment (suggestion):
this could be improved. my thought process is the following:

the question is, when you apply bleed n (=bleedStacks) times, what are the m (=maxStacks) highest bleeds in average?
for m==1 it is n / (n + 1). for m==2, it is slightly less. the general formula is: (n - (m - 1)/2) / (n + 1).

e.g. for n==m==8 this gives 1/2 which is as expected, and pretty different to 8/9.

Code after:
			if (globalOutput.HitSpeed or globalOutput.Speed) > 0 then
				--assume skills with no cast, attack, or cooldown time are single cast
				bleedStacks = bleedStacks * globalOutput.BleedDuration * (globalOutput.HitSpeed or globalOutput.Speed)
			end
			local activeTotems = env.modDB:Override(nil, "TotemsSummoned") or skillModList:Sum("BASE", skillCfg, "ActiveTotemLimit", "ActiveBallistaLimit")
			if skillFlags.totem then
				bleedStacks = bleedStacks * activeTotems
			end
			if configStacks > 0 then
				bleedStacks =  configStacks
			end

			if bleedStacks < 1 and (overrideStackPotential or 0) <= 1 then
				skillModList:NewMod("Condition:SingleBleed", "FLAG", true, "bleed")
			end

			-- ratio of bleeds applied : max effective bleeds
			globalOutput.BleedStackPotential = overrideStackPotential or (bleedStacks / maxStacks)

			if globalBreakdown then
				globalBreakdown.BleedStackPotential = {"Ratio of bleed stacks to maximum active bleeds:"}
				if overrideStackPotential then
					t_insert(globalBreakdown.BleedStackPotential, s_format("= %g ^8(stack potential override)", overrideStackPotential))
				else
					t_insert(globalBreakdown.BleedStackPotential, s_format("%.2f ^8(chance to hit)", output.HitChance / 100))
					t_insert(globalBreakdown.BleedStackPotential, s_format("* %.2f ^8(chance to bleed)", bleedChance))
					if (globalOutput.HitSpeed or globalOutput.Speed) > 0 then
						t_insert(globalBreakdown.BleedStackPotential, s_format("* (%.2f / %.2f) ^8(Bleed duration / Attack Time)", globalOutput.BleedDuration, (output.HitTime or output.Time)))
					end
					if skillData.dpsMultiplier ~= 1 then
						t_insert(globalBreakdown.BleedStackPotential, s_format("* %g ^8(DPS multiplier for this skill)", skillData.dpsMultiplier))
					end
					if skillFlags.totem then
						t_insert(globalBreakdown.BleedStackPotential, s_format("* %d ^8(active number of Totems)", activeTotems))
					end
					t_insert(globalBreakdown.BleedStackPotential,s_format("/ %d ^8(max number of stacks)", maxStacks))
					t_insert(globalBreakdown.BleedStackPotential,s_format("= %.2f", globalOutput.BleedStackPotential))
				end
			end

			-- the amount of damage each bleed does as % maximum
			local bleedRollAverage
			if globalOutput.BleedStackPotential > 1 then
				-- shift damage towards top of range as only top bleeds apply
				bleedRollAverage = (bleedStacks - (maxStacks - 1)/2) / (bleedStacks + 1) * 100
			else
				-- assume middle of range for hit damage
				bleedRollAverage = 50
			end
			globalOutput.BleedRollAverage = bleedRollAverage
			if globalBreakdown then