How often will an opponent be bashed?

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:

  ACTIVE... MISS
=ACTIVE... HIT
=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
=ACTIVE...


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


Solution 1:

Pseudo-Random

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

Answer:

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.

https://webcache.googleusercontent.com/search?q=cache:wu6BspkLHVwJ:https://dota2.gamepedia.com/Random_distribution+&cd=1&hl=es&ct=clnk&gl=ec