Attack speed: Difference between revisions

Bloons TD 6: It seems we have an attack speed limit in BTD6 after all
Line 64: Line 64:
<math display="block">\text{Increase} = \left ( \frac{0.33}{1-0.33 } \right ) \times 100\% \approx 49.3 \% </math>
<math display="block">\text{Increase} = \left ( \frac{0.33}{1-0.33 } \right ) \times 100\% \approx 49.3 \% </math>


The attack cooldown has no correlation with the frame rate of the game, as it is possible to have [[Elite Defender (BTD6)|attacks]] that are faster than a single frame, in this case the animations can be visually skipped, show inconsistencies, or produce multiple projectiles per animation, but the damage dealt is properly applied on average. This will also be the case with high game lag, with the only difference being that in-game time might run slower than real time producing visual slow motion.
Attack animations do not have a correlation with the visual frame rate of the game, however the internal calculation of the game engine is performed 60 times per second, because of this, when the cooldown timer expires, the attack will be performed in the next calculation frame, and if the attack cooldown does not align with these frame rate, the next attack can be performed a frame early or late to compensate. For example if a tower has a cooldown of 0.22s, its first attack would happen at frame 14 (0.2333s), then at frame 27 (0.45s), frame 40 (0.6667s), frame 53 (0.8833) and frame 66 (1.1s), doing a cycle of 14-13-13-13-13 calculation frames between attacks.
 
In cases of very fast cooldowns, the animations can be visually skipped or show inconsistencies, but they don't have impact on the actual attack speed. With high game lag, each visual frame will be the same than a calculation frame, representing 1/60 of a second.
 
When the attack cooldown is lower than 0.1s, the game engine change will start to perform the attack in the nearest calculation frame and not in the next one, this can cause a Tower to fire two projectiles on the same frame. In this case each projectile will behave like normal in terms of damage, pierce and any buff, if present. Each frame can only fire one extra attack, so a Monkey is limited to 120 attacks per second, starting two every 1/60 of  a second (0.0167s). For example, if the attack cooldown of a tower is 0.01s (equivalent to 100 attacks per second), it would still only fire 60 times per second, but 40 out of those 60 attacks would launch two projectiles instead of one.
 
If the cooldown of a tower is still lower than 0.0833s (equivalent to 120 attacks per second), the tower will no longer fire additional projectiles, instead the damage of each projectile does will be increased to compensate so the damage is properly applied on average. For example if a tower has an attack that deals 2 damage and a cooldown of 0.005s (equivalent to 200 attacks / 400 damage per second), it will still attack every 1/60 of a second, launching two projectiles per attack, and each projectile damage would be increased to 3.3333 damage so it averages to 400 damage per second.
 
To handle fractional damage, the game rounds down the damage and the remainder is added to the next projectile. In the previous case the 3.3333 damage means that for every three projectiles that the tower launches, two will deal 3 damage and one will deal 4 so they average 3.3333 damage.
 
The cooldown limit of the game is 0.001s (equivalent to 1000 attacks per second) and cannot be further decreased. A tower with 2 damage per attack and this cooldown, would still only attack every 1/60 of a second with two projectiles at the same time, and each projectile would deal 16.6667 damage to have an average of 2,000 damage per second.
 
There are specific interactions of towers with such high cooldowns that are not intuitive due to the limit of 120 attacks per second, for example if the tower of the previous example (2 damage, 0.001s cooldown, 1 projectile per attack, 1 pierce) would attack an arbitrary large amount of Red Bloons, it would only be able to pop a maximum of 120 of them per second. In another scenario If the same Tower attacks Bloons under the effect of an [[Embrittlement (BTD6)|Embrittlement]], each projectile would deal 17.6667 damage, increasing the total damage per second against a single target to only 2,120 because the +1 damage bonus is applied per projectile.


===''Bloons Adventure Time TD''===
===''Bloons Adventure Time TD''===