• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Attack Speed Calculation

Status
Not open for further replies.
Level 4
Joined
Nov 17, 2007
Messages
57
Hi :) Sorry if this has been asked before, but i tried to google, and search for it on this site :)
the problem is, i got a hero which has an attack speed of 2.0 seconds, i've made an item that decreases attack speed by 1.2. (in world editor, guess that means 120% :)) How much attack speed would the hero have after that? I really need to know this as im making a map where theres alot of modern weapons in, and you can attack quite fast with those in real :)

ps. please give me an easy formula, as im not very good at maths :p
 
Level 3
Joined
Dec 26, 2007
Messages
30
A. spd. - Percentage
2.0 - 100%
X - 120%

X=2.0*120/100=2.4
2.0-2.4=-0.4

I doubt there's any way for a unit to have negative cooldown on its attack, so... I'm not sure what the result would be.
 
Level 4
Joined
Nov 17, 2007
Messages
57
Can it be like this?
2.0 attack speed of unit, decreased by 120% = 0.8 attack speed?
100% halfs the 2.0, so its 1.0, and then theres 20% left - which makes it to 0.8? :/
 
No. 120% of 2.0 is:
- 2*1.2 = 2.4

Thus, 120% attack speed would be 2.4.

So 2.-2.4 would be -.4

If you have taken, probably at least Pre-Algebra :p you should know that 120% is more than 2.0. Because it is 2.0+20% of 2.0.

If you want it to have 0.8 attack speed, you must decrease the attack speed by 40% if I calculated correctly.

.8/2 = 0.4
.40 = 40%

WE takes the values like actual math. So 120% wouldn't be 1.2, unless 1 is the 100% value.
 
Level 4
Joined
Jan 17, 2008
Messages
65
NO! YOU'RE ALL WRONG! :) Including me, actually! This is the master update fixing EVERYTHING!

j/k! well i'm not, but i meant it in a joking manner.... my building's fire alarm just went off i'll be right back to edit my post....

MASTER EDIT: I wrong about a lot of this, i need to solve an equation with a limit i think... and i hate calculus... so i'm not going to do it right now. And there's always the distinctly ominous possibility that i'm wrong about all of this and my beautiful wall of colored text is nothing but falsehoods... GAH!

Ok, i was wrong about attack speed reduction. Well i was right, but somewhere in there i got myself confused and after some more testing i've got my answer! ONLY READ WORDS IN PURPLE FOR THE FINAL JUDGEMENT ON DECREASING ATTACK SPEED! Everything else about DECREASING attack speed is wrong, 'cept the math below, but that doesn't matter because the math is basically useless. My official answer is as follows:

Just like the math shows, a 50% attack speed reduction makes you attack half as fast, it does, in fact, function also like the explanation in between this and the math shows also, except that instead of increasing the delay/animation time you need to look at the attack speed as the difference between the actual attack speed and the minimum! Like this:

Let's assume the fastest attack speed is a 1.0 delay (+animation time, but we'll leave animation time out :p)
Let's assume that the slowest attack speed is a 10.0 delay
Let's assume that your unit has a delay of 2.0

All of the writing below works perfectly for attack speed increases but for decreases you must treat the unit's speed as the difference between its base speed (2.0) and the minimum speed (10.0). That's 10-2, or 8.

When you find the difference then you can plug in that 8.0 to the formulas below and it will work for DECREASING. The way to find your final answer is to find the difference between the minimum and the base speed again.

so to reduce a 2.0 delay by 50% we flip 2.0 into an 8.0 (10 - 2 = 8), then reduce it by 50% to get a 4 (8*0.5 = 4), and then flip it back to a 6 (10-4 = 6) for our new delay.

That's basically how it works, but the low cap is a percentage based cap, which means that any given unit's minimum attack speed is something like 20% of its original attack speed. So that 10.0 that i used earlier is a different number based off of the unit's base delay. So:


INCOMPLETE: ok, i was wrong about the curve for slowed attacks, it doesn't even make sense. Intuitively a 50% slow makes your delay twice as long, and that IS the case. a 2.0 delay slowed by 50% becomes a 4.0 delay. I'm going to do some testing now to see if i can't figure out exactly what % the slowing cap is at....

EUREKA! I know how it works now!

your attacks per second can be represented like this:

1 attack per 2 units of delay time, or 1/2

the amount of decrease of speed is the difference between 1 and the percent that you're slowing, so:

75% slow = 1/4
50% slow = 1/2
25% slow = 3/4

then you just multiply your attacks per second by the slow speed, so if you're slowing by 50% you multiply like this:

(1/2)*(1/2) = 1/4 which means you attack once every 4 units of delay time!

-------------------------------------------------------------------------------------------------------------------------------------------

EDIT: Ok so i did a lot of math down there to prove absolutely nothing. Read it if you want, it was fun to do, but i'll explain everything right here!

The one part of below that is actually necessary to understand is that when you slow an attack speed you're actually slowing the attack ANIMATION as well as the time spent in the "neutral" position (in cooldown) before your next attack.

The second thing you must understand is how attack delays work. Animation length aside (let's pretend it's instantaneous, 'cause it really doesn't matter...)

A delay of 1.0 is faster than a delay of 2.0! (twice as fast, in fact! :p) therefore when you increase attack speed you reduce the cooldown. This makes the unit wait in the "neutral" position less time before his next attack (thus increasing his attack rate)


IGNORE THIS (I'm just leaving it in there for anyone who wants to see the thought process, it doesn't work though):

therefore, to decrease attack speed you are increasing the delay. a 120% slowed unit with an attack delay of 2.0 will have that delay increased to 4.4 <---(2 + 2*1.2), and a unit with a haste of 120% and an attack delay of 2.0 will have that delay decreased to 0.8.

with a slow of 120% your hero would have attack rate 220% of the normal (100% normally + the 120% additional) which ends up being a delay of 4.4 and his attack animation would also take 120% longer. The duration of the attack taking longer, as i mention below, scales perfectly with the delay time so that with a 120% slow rate the time in between hits will take 120% longer. That's important because if the decreased attack speed only affected the delay in between attacks then it would actually NOT slow the time in between hits by 120%, but by a little less. That's a lot of complicated math and no one cares/wants to see it since the WE takes care of everything and makes it perfect! :D enjoy!


WARNING: There are caps to maximum and minimum attack speeds. I do not know what they are, but if you try to haste/slow too much then you could reach the cap. It might end up being like this:

300% haste is the cap, so 300% attack speed bonus is the exact same a a 2000% attack speed bonus.

I do not know wether the haste cap is related to your attack delay (so higher delay units could be hasted to the same attack speed as lower delay units) or if it is a percent cap (so no unit could be hasted more than, say 500% regardless of initial attack speed) I also do not know if you can change this. I believe movement speed max/min can be changed in the Gameplay Constants menu, but i couldn't find an attack speed one. GOOD LUCK! :)


-------------------------------------------------------------------------------------------------------------------------------------------
Ok after some basic (and as i started to write this MUCH more thourough) testing i have deduced some things:

changing attack speed (increasing OR decreasing) scales perfectly a combination of your cooldown time and the animation for your attack together. <---that means that with a unit with cooldown time 5.0 will attack normally every 5 units of time of passed, but the attack itself will still take time to execute, resulting in a duration of MORE than the delay (5.0 units of time) between each hit.

First we must note that 100% decrease in attack speed means that attacks will take 200% of the normal time to execute, NOT that the unit will actually attack 50% slower (I think! If i'm wrong then none of this is correct! So ignore it)

let 'x' = the time it take for the unit to go through the entire attack animation
let 't' = cooldown time
let 'A' = attack speed


A(t,x) means that A is a function of t and x, which it is.

your actual attack speed can be seen this way:

A(t,x) = t + x


so your attack speed is A units. now t might be a constant and therefore be the same for every unit, which would make a difference (in that it would make this all MUCH easier), but i don't want to explain that and i don't think anyone wants to hear it! But i digress....

so every 't' units of time you attack taking 'x' long totaling an attack time of A.


therefore when you increase attack speed by 100% it's doing this:


let 'N' = our new enhance (or decreased) attack time
let 'm' = our percentage modifier
(The game has a minimum attack speed, so reducing attack speed by 100000% will NOT reduce your attack speed to '0' and make you stop attacking. I do not know what the real number is, so i will use minimum to represent the lowest possible attack speed reduction)----(I will also use maximum to represent the maximum attack speed reduction)


m =100% = 1 <---changing the % into a real number [from here on out all percents will be automatically changed to "digit" form because that's how the WE deals with movement speed changes (as far as i know...)]

N(m, [A(t,x)] ) <----that's what it really looks like but i'll make it simple by saying that it looks like this: N(m,A)


N(m,A) = A + A*m [while A*m > (1 - minimum)] and [while A*m < (1 - maximum)]



All of the above goes to say that when you change a units attack speed (resulting in an attack speed of 'N') by adding or removing a percent 'm' you change the old attack speed 'A' and add it to itself, which results in this:

use simple substitution and remember this:
A(t,x) = A

N(m,A) = (t + x) + (t + x)*(m) [while A*m > (1 - minimum)] and [while A*m < (1 - maximum)]
therefore
N(m,A) = t + x + tm + tx [while A*m > (1 - minimum)] and [while A*m < (1 - maximum)]


All that goes to show that when you increase or decrease attack speed you are changing the time between hits, or 'A' not just the cooldown; attacks will also take longer to execute.

And quite frankly now i don't see how that's important at all, or even how it APPLIES to this question... I'll leave it up since i color-coded it all so nicely, but it isn't necessary to understand anything except out of pure curiosity. BACK TO THE TOP! to actually explain this simply!
 
Last edited:
Purge, you can't have negative attack speed..
The formula might be
FinalSpeed=StartingSpeed/((100+%increase)/100)
Therefore, a 120% increase from 2.00 seconds would be:
2.00/2.20=0.91
Although I'm not entirely sure. I also believe there is a minimum attack speed (the unit's backswing point or something..)
--donut3.5--

Yeah, I know that you can't have a negative attack speed. That's what I was trying to disprove.

And it seems like the actual thing is just retarded.

You can also edit the backswing though.

And I'm too lazy to read Gloryblade's post because of the colors. :ugly:
 
Level 4
Joined
Jan 17, 2008
Messages
65
hehe i sent you a pm, i confused myself, and i tried to take 80% of infinity in my problem... there's a way to find it somehow... but basically there is a cap and any amount of slow that you apply OVER that cap is meaningless because the attack speed can only be slowed down to that cap's %

the confusing thing is that the cap is % based, not a number, so a 1.0 dly unit and a 5.0 dly unit can be slowed as much as possible, but the 1.0 dly unit will still attack 5 times as fast if i'm right, which i believe i am.

sorry about the colors! i was trying to stay organized! ><

Attack speed bonuses are pretty much screwed in wc3, you cannot really assign them well. For example, 1 + 60% would turn into 1.85 instead of 1.6 .

i don't believe so, because i had a 5.0 delay knight hasted 500% and he hit the 1.0 delay footman the same time the footman hit him (he just completed his attack animation 5 times faster ^^)
 
Status
Not open for further replies.
Top