diff --git a/common/combat/vulnerable.trait.js b/common/combat/vulnerable.trait.js index 56af30c..cffb1e3 100644 --- a/common/combat/vulnerable.trait.js +++ b/common/combat/vulnerable.trait.js @@ -31,6 +31,7 @@ export class Vulnerable extends Trait { playDamagingSound, ], }, + vulnerabilities: undefined, } } @@ -178,16 +179,23 @@ export class Vulnerable extends Trait { const damageSpecs = entity.damageSpecs; for (let i = 0; i < damageSpecs.length; ++i) { const damageSpec = damageSpecs[i]; + let power = damageSpec.power; + // Check if vulnerable to this affinity. + if (this.params.vulnerabilities) { + if (damageSpec.affinity in this.params.vulnerabilities) { + power *= this.params.vulnerabilities[damageSpec.affinity]; + } + } if (this.locks.has(damageSpec)) { continue; } this.locks.set(damageSpec, damageSpec.lock); const variance = Math.random() * damageSpec.variance * 2 - damageSpec.variance; - const difference = damageSpec.power * variance; + const difference = power * variance; // Account for variance past 0, so track if it's damage or not. - let amount = Math.round(damageSpec.power + difference); + let amount = Math.round(power + difference); let isDamage; - if (damageSpec.power < 0) { + if (power < 0) { isDamage = false; if (amount > 0) { amount = 0;