From ea504785dc4c341a35014d3589f0c1f6acd4ff11 Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 6 Nov 2019 00:25:30 -0600 Subject: [PATCH] fun: blood --- common/combat/vulnerable.trait.js | 60 +++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/common/combat/vulnerable.trait.js b/common/combat/vulnerable.trait.js index d50a586..0642fda 100644 --- a/common/combat/vulnerable.trait.js +++ b/common/combat/vulnerable.trait.js @@ -13,7 +13,7 @@ import {DamagePacket} from './damage.packet'; export class Vulnerable extends Trait { static defaultParams() { - const emitDamage = buildInvoke(['entity', 'emitDamageParticle'], [ + const emitDamage = buildInvoke(['entity', 'emitDamageParticles'], [ buildTraversal(['damage']), ]); const playDamagingSound = buildInvoke(['damage', 'from', 'playSound'], [ @@ -163,7 +163,57 @@ export class Vulnerable extends Trait { }, }, }, - } + blood: { + traits: { + emitted: { + params: { + alpha: { + start: 1, + end: 0.4, + }, + force: [0, 4], + velocity: { + min: [-0.5, -1.25], + max: [0.5, -0.75], + }, + scale: { + start: 1, + end: 1.25, + }, + transient: false, + ttl: 0.5, + }, + }, + existent: {}, + layered: {}, + listed: {}, + perishable: { + params: { + ttl: 10, + }, + }, + positioned: {}, + primitive: { + params: { + primitives: [ + { + type: 'circle', + radius: 0.5, + line: { + rgba: [255, 0, 0], + }, + fill: { + rgba: [255, 0, 0], + }, + }, + ], + }, + }, + roomed: {}, + visible: {}, + }, + }, + }; }, @@ -190,7 +240,7 @@ export class Vulnerable extends Trait { methods() { return { - emitDamageParticle: (damage) => { + emitDamageParticles: (damage) => { const {amount, isDamage} = damage; const fill = isDamage ? '#FF0000' : '#00FF77'; this.entity.emitParticle('damage', { @@ -208,6 +258,10 @@ export class Vulnerable extends Trait { }, }, }); + this.entity.emitParticle('blood', { + rate: 0.0125, + count: 10, + }); }, takeDamageFrom: (entity) => {