This class calculates all damage related calculations
More...
This class calculates all damage related calculations
§ finalDamage()
static int Model.DamageCalculations.finalDamage |
( |
Unit |
attacker, |
|
|
Unit |
defender, |
|
|
bool |
physOrMagic |
|
) |
| |
|
static |
This method factors in damage dealt, hit rate, crit rate, and number of attacks (as in how above functions were calculated) to calculate actual damage dealt. Hit and crit is factored in by creating a random number between 0-100, and see if that random number is within the range of the crit or hit rate. If it is, then the unit hits with the attack and/or crits.
If an attack misses, damage dealt is 0, otherwise damage is dealt normally.
If an attack crits, damage dealt is x2 regular normal damage.
If numOfAttacks is 1, damage is dealt once. Else if 2, damage is dealt twice.
- Parameters
-
attacker | The unit performing the attack. |
defender | The unit defending against the attack. |
physOrMagic | The boolean that tells the controller if it's physical or magical damage to be calculated. |
§ getCritRate()
static int Model.DamageCalculations.getCritRate |
( |
Unit |
attacker, |
|
|
Unit |
defender |
|
) |
| |
|
static |
This method takes in the 2 units, and returns the crit rate as a percentage out of 100 by taking into account both unit's skill.
This calculation is found according to the equation [((attackerSkill/10) - (defenderSkill/10) +1) *0.1] *100.
A negative hitrate will be changed to 0.
- Parameters
-
attacker | The unit performing the attack. |
defender | The unit defending against the attack. |
§ getDamageDealt()
static int Model.DamageCalculations.getDamageDealt |
( |
Unit |
attacker, |
|
|
Unit |
defender, |
|
|
bool |
physOrMagic |
|
) |
| |
|
static |
This method takes in the 2 units, and a boolean on whether attack is physical (false). Damage is then calculated by taking attacker's Str/int, and defender's def/res (where str-def is for physical, and int-res is for magic). If the defending stat is higher, final damage is 0 as an attack cannot heal.
- Parameters
-
attacker | The unit performing the attack. |
defender | The unit defending against the attack. |
physOrMagic | Boolean that tells the controller if it's physical or magical damage to be calculated. |
§ getHitCount()
static int Model.DamageCalculations.getHitCount |
( |
Unit |
attacker, |
|
|
Unit |
defender |
|
) |
| |
|
static |
This method takes in the 2 units, and determines how many attacks the attacker makes by factoring in both unit's relative speed. If one unit's speed is 4 or more higher then the other unit, hitCount will return 2.
- Parameters
-
attacker | The unit performing the attack. |
defender | The unit defending against the attack. |
§ getHitRate()
static int Model.DamageCalculations.getHitRate |
( |
Unit |
attacker, |
|
|
Unit |
defender |
|
) |
| |
|
static |
This method takes in the 2 units, and returns the hit rate as a percentage out of 100 by taking into account both unit's skill.
This calculation is found according to the equation [((attackerSkill/10) - (defenderSkill/10) +1) *0.8] *100.
A negative hitrate will be changed to 0.
- Parameters
-
attacker | The unit performing the attack. |
defender | The unit defending against the attack. |
The documentation for this class was generated from the following file:
- C:/Users/Thien Trandinh/Documents/Blaze-Brigade/src/Blaze-Brigade/Blaze_Brigade/DamageCalculations.cs