Page 1 of 1

Improved duration stacking (code included)

Posted: Fri May 24, 2013 3:23 am
by Umbrall
In short:
replace all instances of:

Code: Select all

local dur = math.ceil((old_eff.dur + new_eff.dur) / 2)
in timed effects with

Code: Select all

local dur = math.floor((old_dam + new_dam) / (old_eff.power + new_effect.power))
What this does is weight the duration such that the dps of any given effect will never decrease from the sum of the two parts (alternatively you can do it as the max of their dps's instead of the sum, but this has the weird situation where without capping it would just stack duration instead of damage, and is therefore wrong)

Re: Improved duration stacking (code included)

Posted: Fri May 24, 2013 6:02 pm
by darkgod
>Hum you second formula doesnt use duration at all I'm not sure I understand

Re: Improved duration stacking (code included)

Posted: Fri May 24, 2013 9:52 pm
by Umbrall
It does actually, the old_dam and new_dam values have the durations multiplied into them already (as they're already used by other stuff)

So in short where T is duration and D is damage per turn it's
(D1T1 + D2T2) / (D1 + D2)