I ran into an interesting problem while trying to figure out the average time a hero would spend stunned if they were attacked continuously with a bash item or ability.

For example, if I was playing Slardar, and had a 25% chance bash for 1 second, and could attack twice a second, then what percentage of time can I expect my opponent to be bashed for? I want to know what the increments are, so that I can figure out when it's worth it to level that skill.

I came up with the following state diagram to help me through it. The states represent a half-second period after each attack.

State Diagram

Note that new stuns will refresh old ones (not stack). For example:

=STUNNED (for this round and next)... HIT
=STUNNED (for this round and next)... MISS
=RECOVERING (for this round)... HIT
=STUNNED (for this round and next)... MISS
=RECOVERING (for this round)... MISS

Is there a formula which would fit any number of seconds, and any percent chance of stunning?

  • 5
    I'm voting to close this question as off-topic because this is a math problem wrapped in some game terms.
    – Elva
    Sep 5, 2017 at 6:01
  • 2
    Knowing the damage output decrease from stunning your opponent is highly relevant for games like Dota, that implement stun-on-hit.
    – Addison
    Sep 5, 2017 at 6:04
  • 11
    Theorycrafting questions like this are not off-topic... In quite a few games you need to do the math (damage, timing, etc) in order to be more than an average player.
    – dly
    Sep 5, 2017 at 6:25
  • 1
    This question is more complicated than it originally seems due to bashes being pseudo-random. I'm also not sure if it's possible to bash someone during a bash.
    – Haibo Li
    Sep 5, 2017 at 10:54
  • 1
    How about now @Frank? This is now a question about how the lockdown potential of Slardar, a hero in Dota, changes with attackspeed and ability levels.
    – Addison
    Sep 5, 2017 at 12:19

2 Answers 2



As it was commented the 25% isn't a constant in each attack but more an average of times it will proc from a bigger pool of attacks.

How does it work, the real chance to stun is 8% per attack at full level, every time it doesn't proc this chance is increased another 8.5% until stuns the target and then it resets to the base of 8%.

P(T): The chance for the skill to proc 25%

P(A): The average for the skill to proc 24.90%

C: Contant value from the Pseudo Random distribution 0.08475

Max N: The minimum number of hits that would occur until the next one is a sure proc: 12

Most Probable N: The amount of hits to get a proc: 3

Average N: The average hits until get a proc 4.02


If you hit every 0.5 seconds and the average proc it's at the 4.02 hit then the target could be stunned every two seconds.



There is no such general closed form solution available due to the Abel-Ruffini Theorem, since solving for the pseudorandom value C involves a polynomial in degree N, where N > 4 for all P < ~46%.

First, given your proc chance P, determine the PRG value C using one of the methods detalied in the answers to the question Calculating the constant C in Dota 2 pseudo-random distribution.

Next, define N = ceil(1/P)

Then, we define a series of functions:

p(n) = min(Cn, 1)
inv(n) = 1 - p(n); inv(0) = 1.
cml(n) = cml(n-1) * inv(n); cml(0) = 1.
nfr(n) = cml(n-1) - cml(n); nfr(0) = 1. 
wgn(n) = nfr(n) * n
tf(n) = wgn(n) / SUM(wgn(n in 1..N))

The logic goes as follows: p(n) is the chance of bashing on the nth successive hit in a chain of non-crits. inv(n) inverts this, so we have the chance of missing (the bash) on each hit. From this, by using the multiplication rule, obtain cml(n), the cumulative chance of getting to n misses. E.g. if cum(6) = x that means there's a chance of x that any chain of attacks is 6 or longer. Then by differencing this function obtain nfr(n) which is the fraction of chains that is n long. Next, weigh this function by the length of the chain to obtain tf(n), the "fraction of time spent in a chain of length n".

Next, we need to adjust for something: As you observed, with high attack speed, bashes can overlap. Therefore, with a given input attack speed a, construct the formula

b(n,a) = min(DUR / (100 * BAT / a), n) / n

Which is the fraction of time spent bashed in a chain of attacks where it takes n attacks until the next bash. Here BAT is your base attack time. For slardar this is BAT = 1.7, and DUR is the stun duration. In the example, DUR = 1, or one second. Some example figures:

ATK      N=1    N=2    N=3
100    58.9%  29.4%  19.6%
200     100%  58.9%  39.2%
300     100%  88.2%  58.9%
600     100%   100%   100%

Next, compute:

ws(n,a) = b(n,a) * tf(n). 

Which is the time spent bashed in a chain of attacks, weighted by the total spent fraction of time in a chain of such length. Sum over all ws, or

SUM(ws(n in 1..N,a)) = sf(a).

Where sf(a) is the fraction of time the target spends stunned, as a function of the attack speed. Figures for slardar are below:

|     100 | 14.7% |
|     125 | 18.4% |
|     150 | 22.1% |
|     175 | 25.7% |
|     200 | 29.0% |
|     225 | 32.4% |
|     250 | 35.8% |
|     275 | 39.1% |
|     300 | 42.5% |
|     325 | 45.9% |
|     350 | 49.0% |
|     375 | 51.8% |
|     400 | 54.6% |
|     425 | 57.4% |
|     450 | 60.2% |
|     475 | 63.0% |
|     500 | 65.8% |
|     525 | 68.1% |
|     550 | 70.2% |
|     575 | 72.3% |
|     600 | 74.4% |

Note that this algorithm assumes that the game is perfectly timed. In reality, durations are rounded to integer numbers of frames: the game is a discrete system, not a continuous one. Thus in the actual game the real figures will be somewhat rounded compared to these estimates.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .