Damage calculation
For my damage calculation, I wanted to use something that forces players to get closer to enemies to do more damage. This creates high risk, high reward combat which compliments the speedrunning part of the game. It also makes it so players will have to get used to the damage calculation to be able to make the right choices on when and when not to get closer to enemies.
I came up with a fitting algorithm with inspiration of some other fps games.
Damage * [RangeModifier ^ (Distance(u)/500)]
Damage = base damage of gun.
RangeModifier = Damage dropoff multiplier of gun between 0 (no range) and 1 (infinite range).
u = Distance between damaging object (gun or fireball) and target.
His will determine the damage done depending on the distance to the target. The RangeModifier is basically the amount of damage the gun will do less every 500 units. I changed this to 10 units. Which means if a gun has a RangeModifier of 0.85, the gun will do 0.85 of its max damage if the target is 10 meters away. In code it looks like this:


This is used for 2 things:
- Damage the player gun does to an enemy.
- Damage an exploding fireball will do to the player.
By doing this it will force the player to get closer to the enemy to do more damage, but it will be a lot harder for the player to dodge the fireball and the fireball does incredible damage on a direct hit.