Hi again all,
I’m creating a (very simple) roguelike dungeon crawler, and had a couple of questions regarding the way damage can be calculated when fighting an enemy.
I’ve got a rough idea of how I want it to work, but I know there are fairly well-set conventions for this sort of thing, so I want to see if I’m on the right track.
Every entity (player and enemy alike) has the following stats:
- Health (how many hit points it has)
- Damage (how much damage it deals as a maximum)
- Defense (how much defense it has against taking damage)
So, for example, the player starts with 100 health, 4 damage, and 5 defense. A weak enemy of equal level may have perhaps 30% or less weaker stats; so a weak enemy might have: 30 health, 1 damage, 2 defense.
When I’m writing in my calculations for attacking, I’m using the following assumptions:
- Player attacks, so we start by first assuming the attack will initially cause maximum damage of 4.
- The enemy’s defense is used as a mitigating factor for this damage, and is converted to a percentage
- The weak enemy’s defense, as shown above, can now mitigate 2% of the player’s maximum damage
- Because defense isn’t guaranteed, a randomisation is run to calculate how much of that defense to use (0 - 2%, in this case)
- The player’s maximum damage value is reduced by this defense value - so if reduced by 2% defense, it results in a damage of 3.92.
Obviously, these numbers are pretty small. But compare this to perhaps later in the game where a player’s weapon can deal a maximum of, say, 300 damage. Fighting an enemy with health of 500 and a defense of 40 could potentially have a worst case scenario of your weapon only doing a total of 180 damage (40% of 300).
What I want to know is whether or not this method is sound? It sounds right in my head, and obviously gives me some degree of flexibility to add further damage types if I want to get clever:
- Player’s main weapon deals max. of 200 melee damage
- Main weapon also deals 80 fire damage
- Enemy has 0 defense, but 100 fire resist
- Player’s main weapon hits for the full 200 damage, but fire resist can reduce that additional damage down to as little as zero.
And so on.
I’d appreciate any thoughts from veterans of these types of game systems.
Thanks!