Sacred:Damage
Damage is any diminution of an entity's health as the result of a successful attack.
As such, it is a fundamental combat mechanic. Entities fight each other by attempting attacks, eventually inflicting damage, until their opponents' or their own health is fully depleted and they die. To win a fight, one has to kill the opponent before the opponent kills oneself.
In Sacred, there are four distinct damage types and corresponding resistances:
- Physical
- Fire
- Magic
- Poison
The net damage of an attack is calculated through several steps:
- On attack, the attacker's attack value is rolled against the defender's defense value, determining whether the attack hits or misses. Only successful hits inflict any damage.
- If the attack is successful, for each damage type individually, a gross damage value is drawn from the discrete uniform probability distribution of attainable values.
- Each of these gross damage values gets mitigated by the defender's resistances, by being divided by ( 1 + Resistance / Gross Damage ).
- The resulting net damages get summed up and subtracted together from the defender's health. Damage over Time (DoT) effects may be applied. Hit reactions may be triggered.
Hence, the net damage on successful attack is given by the formula:
N = Σ((G_i)^2/(G_i+R_i))
Where N is the net damage, i from 1 to 4 are the indices of the four damage types, G_i is the gross damage rolled for damage type i, and R_i is the defender's resistance against damage type i. For any damage type, if the gross damage is very large compared to the resistance, the net damage gets close to the gross damage. Conversely, if the resistance is very large compared to the gross damage, the net damage gets close to 0. If resistance and gross damage are equal, net damage is equal to half the gross damage.
The interaction of resistance and damage for one damage type is illustrated to the right.
To evaluate the effect of increases in damage for the attacker or resistance for the defender at a certain regime of values, the total derivative is helpful. For one damage type:
dN = δN/δG dG + δN/δR dR = ( 1 - (R/(R+G))^2 ) dG - (G/(G+R))^2 dR
It reveals that for both the attacker and the defender, it is crucial to boost the stats on the damage types where the incoming damage is large compared to the adverse resistance.
There is no cross interaction between the damage calculations on different damage types.