generalize buff damage multipliers
This commit is contained in:
@@ -5,6 +5,7 @@ export default class Buff {
|
|||||||
|
|
||||||
name = 'Buff'
|
name = 'Buff'
|
||||||
|
|
||||||
|
damageMultiplier = null
|
||||||
duration = 0
|
duration = 0
|
||||||
|
|
||||||
#effect = null
|
#effect = null
|
||||||
@@ -22,5 +23,6 @@ export default class Buff {
|
|||||||
id: 'exposed',
|
id: 'exposed',
|
||||||
name: 'Exposed',
|
name: 'Exposed',
|
||||||
duration: 4,
|
duration: 4,
|
||||||
|
onHitMultiplier: 3,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-2
@@ -324,15 +324,21 @@ export default class Entity {
|
|||||||
damage(amount, source = null) {
|
damage(amount, source = null) {
|
||||||
if (this.dead) { return }
|
if (this.dead) { return }
|
||||||
|
|
||||||
let damage = amount
|
let customMultipliers = 0
|
||||||
if (this.hasBuff(Buff.exposed.id)) {
|
if (this.hasBuff(Buff.exposed.id)) {
|
||||||
const buff = this.getBuff(Buff.exposed.id)
|
const buff = this.getBuff(Buff.exposed.id)
|
||||||
if (buff.source == source.id) {
|
if (buff.source == source.id) {
|
||||||
damage *= 3 // TODO: move to Buff class to make generic
|
customMultipliers += (buff.onHitMultiplier - 1)
|
||||||
this.removeBuff(Buff.exposed.id)
|
this.removeBuff(Buff.exposed.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const damageMultiplerBuffs = source.buffs.map((it) => it.getBuff).filter((it) => it != null && it.damageMultiplier != null)
|
||||||
|
const buffPassiveDamageMultiplier = damageMultiplerBuffs.reduce((it) => it.damageMultiplier - 1, 0)
|
||||||
|
|
||||||
|
const damageMultipler = 1 + buffPassiveDamageMultiplier + customMultipliers
|
||||||
|
const damage = amount * damageMultipler
|
||||||
|
|
||||||
this.health = Math.min(Math.max(0, this.health - damage), this.maxHealth)
|
this.health = Math.min(Math.max(0, this.health - damage), this.maxHealth)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user