Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Armour.js
Show All 37 Lines | |||||
* @param {number} multiplier - the damage multiplier. | * @param {number} multiplier - the damage multiplier. | ||||
* Returns object of the form { "killed": false, "change": -12 }. | * Returns object of the form { "killed": false, "change": -12 }. | ||||
*/ | */ | ||||
Armour.prototype.TakeDamage = function(strengths, multiplier = 1) | Armour.prototype.TakeDamage = function(strengths, multiplier = 1) | ||||
{ | { | ||||
if (this.invulnerable) | if (this.invulnerable) | ||||
return { "killed": false, "change": 0 }; | return { "killed": false, "change": 0 }; | ||||
if (strengths == "InstantKill") | |||||
{ | |||||
// Special damage to instantly kill entities. | |||||
let cmpTargetHealth = Engine.QueryInterface(this.entity, IID_Health); | |||||
if (cmpTargetHealth) | |||||
return cmpTargetHealth.Reduce(cmpTargetHealth.GetHitpoints()); | |||||
} | |||||
// Adjust damage values based on armour; exponential armour: damage = attack * 0.9^armour | // Adjust damage values based on armour; exponential armour: damage = attack * 0.9^armour | ||||
var armourStrengths = this.GetArmourStrengths(); | var armourStrengths = this.GetArmourStrengths(); | ||||
// Total is sum of individual damages | // Total is sum of individual damages | ||||
// Don't bother rounding, since HP is no longer integral. | // Don't bother rounding, since HP is no longer integral. | ||||
var total = 0; | var total = 0; | ||||
for (let type in strengths) | for (let type in strengths) | ||||
total += strengths[type] * multiplier * Math.pow(0.9, armourStrengths[type] || 0); | total += strengths[type] * multiplier * Math.pow(0.9, armourStrengths[type] || 0); | ||||
Show All 32 Lines |
Wildfire Games · Phabricator