Damage calculation

Got three weapon prototypes up and working: Knife (light/pierce), Sword (medium/slash), and Hammer (heavy/bash). Still playing with the timing and properties of each, but it’s a good start. Now to decide where to go next: combat, map/environment mechanics, or further fleshing out the GameObject class (which, realistically, should probably be first).

For combat, I’ve been doing some thinking on what equations to use. Attack is easy – (weapon base + strength) * modifiers – but defense threw me for a bit more of a loop. How much should armor affect damage taken? I don’t like the thought of a linear design (ATK – DEF = DMG) – a low-level character is overwhelmed too easily (especially if DEF > ATK), and if ATK and DEF scale at a similar rate, then you’re stuck doing a constant amount of damage no matter what level you’re at. I’ve decided instead to use exponential decay, something like:

DMG = ATK * e ^ (d * -DEF / ATK)

..where ATK and DEF are self-explanatory, e is Euler’s Constant, and d is a configurable rate of decay. This method tends to skew things toward the underdog – if ATK is much higher than DEF, then small increases in DEF will show a large payoff in the amount of damage mitigated, and if DEF is higher than ATK, the character will still do a small but decent amount of damage. A few examples:

d = .9, ATK = 80, DEF = 20: 64 dmg

d = .9, ATK = 80, DEF = 30: 57 dmg

d = .9, ATK = 40, DEF = 70: 8 dmg

d = .9, ATK = 50, DEF = 50: 20 dmg

Playing with different values of d will change the effectiveness of armor – the lower higher d is, the more heavily DEF is weighted. My hope is to have a combat system where magic users don’t get unconditionally bulldozed, and the player doesn’t get stuck in too many situations where they constantly do 1 or zero damage.

One Response to Damage calculation

Ive used pretty much the same formula , only if the damage is higher and takes the health past 0 (another class “overkill”) an alternative animation to the player or NPC happens (if an NPC drops a special item) , will keep you posted with my findings :)