diff --git a/common/combat/vulnerable.trait.js b/common/combat/vulnerable.trait.js index b19f7bb..d50a586 100644 --- a/common/combat/vulnerable.trait.js +++ b/common/combat/vulnerable.trait.js @@ -14,7 +14,6 @@ export class Vulnerable extends Trait { static defaultParams() { const emitDamage = buildInvoke(['entity', 'emitDamageParticle'], [ - buildTraversal(['entity', 'position']), buildTraversal(['damage']), ]); const playDamagingSound = buildInvoke(['damage', 'from', 'playSound'], [ @@ -116,6 +115,61 @@ export class Vulnerable extends Trait { } } + hooks() { + return { + + particles: () => { + return { + damage: { + traits: { + darkened: { + params: { + isDarkened: false, + }, + }, + emitted: { + params: { + alpha: { + start: 1, + end: 0, + }, + force: [0, 1], + velocity: [ + randomNumber(-0.5, 0.5), + randomNumber(-1.25, -0.75) + ], + rotation: { + start: 0, + add: { + min: -0.5, + max: 0.5, + }, + }, + scale: { + start: 1, + end: 1.25, + }, + }, + }, + existent: {}, + layered: {}, + listed: {}, + positioned: {}, + roomed: {}, + visible: { + state: { + zIndex: 65535, + } + }, + }, + }, + } + + }, + + } + } + listeners() { return { @@ -136,47 +190,11 @@ export class Vulnerable extends Trait { methods() { return { - emitDamageParticle: (position, damage) => { - const {amount, damageSpec, isDamage} = damage; + emitDamageParticle: (damage) => { + const {amount, isDamage} = damage; const fill = isDamage ? '#FF0000' : '#00FF77'; - - this.entity.emitParticleJson({ + this.entity.emitParticle('damage', { traits: { - darkened: { - params: { - isDarkened: false, - }, - }, - emitted: { - params: { - alpha: { - start: 1, - end: 0, - }, - force: [0, 1], - velocity: [ - randomNumber(-0.5, 0.5), - randomNumber(-1.25, -0.75) - ], - position, - rotation: { - start: 0, - add: { - min: -0.5, - max: 0.5, - }, - }, - scale: { - start: 1, - end: 1.25, - }, - }, - }, - existent: {}, - layered: {}, - listed: {}, - positioned: {}, - roomed: {}, textual: { state: { text: amount, @@ -188,14 +206,7 @@ export class Vulnerable extends Trait { }, }, }, - visible: { - state: { - zIndex: 65535, - } - }, }, - }).then((particle) => { - this.entity.list.addEntity(particle); }); },