I decided to refactor my attack speed calculations. I say that but it’s more of an add-on instead of a refactoring.
I’m designing this while thinking about the possibility of adding additional player characters with different stats. For instance, one that shoots a beam but fires very slowly. Or one that just fires slowly lol. Or one that shoots pellets very quickly.
This is what I came up with
I had base cooldown (e.g. 3) which represent
attackSpeed = (baseAttackSpeed + (attackSpeedRatio * bonusAttackSpeed / 100)) * modifier
buffs are additive (bonusAttackSpeed += percentage)
debuffs are multiplicative (modifier *= (1 - percentage))
I also decided to make debuffs piecewise so that higher debuff percentages are less effective. My current function has modifiers at 0.2 and 0.6
newModifier = {