# Modelling_Bleeds - Icytroll/bleedFAQ GitHub Wiki

## Predicting stacked bleed amount and tick damage on a target as a function of time

If we assume that we're continuously applying the same bleed to a target at some amount of attacks per second, then the expected total bleed `bleedTotal`

on a target as a function of time in seconds can be expressed via:

$$\text{bleedTotal}(t) = \text{bleedMax} - (\text{bleedMax}-\text{bleedAtk}) * e^{-t\dfrac{\text{bleedAtk * atks/second}}{\text{bleedMax}}}$$

where `bleedMax`

is the value at which the total bleed amount will stop growing, and `bleedAtk`

is the bleed amount applied with each attack:

```
bleedAtk = baseDmg * (1 + extraDotDuration)
bleedMax = baseDmg * (1 + extraDotDuration)^2 * 5 * atks/second
```

with `baseDmg`

being the bleed amount an attack applies **before** extra dot durations are taken into account. The formula for `bleedMax`

is how we came to the result of 16.667 tick damage at the end of the last section, where `100 * (1 + 0)^2 * 5 * 1/3 = 166.67`

gives the max that we could stack the total bleed to, and dividing this result by 10 for a 5s bleed gives us the ticking damage of 16.667.

### Example

Okay lets look at a short example using the above $\text{bleedTotal}(t)$ formula. Lets say we have the following setup using Flay:

```
baseDmg = 100
extraDotDuration = 50%
atks/second = 3
```

and our other variables become:

```
bleedAtk = 150
bleedMax = 3375
```

If we then simulate how a bleed evolves using the above, we get the below image where we see the bleed growing rapidly at the start and then taporing off as the bleed ticks start to approach the applied bleeds and the total bleed thus can't grow any bigger at the value of `bleedMax = 3375`

. The $\text{bleedTotal}(t)$ formula seems to predict the overall behaviour quite well.

In the above we assumed no variance at all, however in game that's rarely the case as most bleeds are subject to weapon variance. This variance means that if the tooltip of your bleed skill shows some bleed value, the game multiplies that value with a random number in the range `[0.8,1.2]`

when attacking (if the bleed is also subject to skill variance this range is increased to `[0.72,1.32]`

).
If we include this variance in a bleed simulation we see that even though there are ups and downs we're still able to predict the total bleed quite reliably.

The number of attacks per second results in smoothing out the total bleed, with higher attacks per second smoothing things out more. In this simulation we've used 1 attack per second instead of 3 and the bleed thus only stacks up to `bleedMax = 1125`

.

In the case of barbarians where Gushing Wounds exists (bleeds can crit) we add even more variance to the bleed, here we've used the worst case of variance with 50% crit chance, but even with this we can still see that the bleed tends to follow our prediction.

### Where does this solution come from

I won't go through the derivation here, but for those interested the $\text{bleedTotal}(t)$ formula is the result of solving the 1st order linear differential equation

$$ \frac{d \text{bleedTotal(t)}}{d t} + \frac{\text{bleedAtk} * \text{atks/second}}{\text{bleedMax}} * \text{bleedTotal}(t) = \text{bleedAtk} * \text{atks/second} $$

with the initial condition

$$ \text{bleedTotal(0)} = \text{bleedAtk} $$

We can check the solution by plugging the $\text{bleedTotal}(t)$ formula into the left-hand-side of the differential equation, after evaluating the derivative and simplifying a bunch we get a result of: $\text{bleedAtk} * \text{atks/second}$, which matches the right-hand-side of the equation meaning our solution is valid.

### Bleed tick damage

In order to convert the total bleed `bleedTotal(t)`

on the target into ticking damage we simply divide the whole expression by the amount of ticks for a bleed:

$$\text{tickDamage}(t) = \dfrac{\text{bleedMax} - (\text{bleedMax}-\text{bleedAtk}) * e^{-t\dfrac{\text{bleedAtk * atks/second}}{\text{bleedMax}}}}{10*(1+\text{extraDotDuration})}$$

and we can convert this to damage per second (dps) by replacing the 10 with a 5 in the denominator (2 ticks per second):

$$\text{tickDps}(t) = \dfrac{\text{bleedMax} - (\text{bleedMax}-\text{bleedAtk}) * e^{-t\dfrac{\text{bleedAtk * atks/second}}{\text{bleedMax}}}}{5*(1+\text{extraDotDuration})}$$

If we want the total damage done by ticks up to some time $t$, we have to integrate the $\text{tickDps}(t)$ formula which gives us:

$$\text{tickTotalDamage}(t) = \dfrac{\text{bleedMax} * t + \dfrac{\text{bleedMax}}{\text{atks/second}} * \left(e^{-t\dfrac{\text{bleedAtk * atks/second}}{\text{bleedMax}}}-1\right) * \left(\dfrac{\text{bleedMax}}{\text{bleedAtk}}-1\right)}{5 * (1+\text{extraDotDuration})}$$

and if we want the averaged damage per second done by the bleed ticks up to some time t, we simply divide the $\text{tickTotalDamage}(t)$ formula by $t$:

$$\text{tickTotalDps}(t) = \dfrac{\text{bleedMax} * t + \dfrac{\text{bleedMax}}{\text{atks/second}} * \left(e^{-t\dfrac{\text{bleedAtk * atks/second}}{\text{bleedMax}}}-1\right) * \left(\dfrac{\text{bleedMax}}{\text{bleedAtk}}-1\right)}{5 * (1+\text{extraDotDuration}) * t}$$

I should note that all of the above should apply to dots in general, though I haven't looked into mixing different schools of dot effects, I've only looked at bleeds so far (physical dots).

### Time before some total bleed amount is attained

To calculate the elapsed time before `bleedTotal(t)`

reaches a percentage `pct`

of `bleedMax`

, we can set `bleedTotal(t)`

for the above equation equal to `pct*bleedMax`

and solve for the time $t_{value}$:

$$t_{value}(pct) = - \text{ln}\left(\frac{\text{bleedMax} - \text{bleedMax}*pct}{\text{bleedAtk} - \text{bleedMax}}\right) * \frac{\text{bleedMax}}{\text{bleedAtk * atks/second}}$$

with `ln`

denoting the natural logarithm and `pct`

having the range `bleedAtk/bleedMax <= pct < 1`

(1 not allowed). If we're interested in how long it takes for the bleed to reach a generic value we can also just replace `bleedMax*pct`

in the nominator inside the logarithm with that value, with the permissable range then being `bleedAtk <= value < bleedMax`

:

$$t_{value}(value) = - \text{ln}\left(\frac{\text{bleedMax} - value}{\text{bleedAtk} - \text{bleedMax}}\right) * \frac{\text{bleedMax}}{\text{bleedAtk * atks/second}}$$

Go to next page Modelling a DoT (WIP)