From 24ffb87af9695cc88deb4da34d12b6b5f348dd92 Mon Sep 17 00:00:00 2001 From: kts of kettek Date: Sun, 30 Jan 2022 12:10:34 -0800 Subject: [PATCH] Adjust attack sound logic --- Engine/src/live/AnimalEntity.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Engine/src/live/AnimalEntity.ts b/Engine/src/live/AnimalEntity.ts index 82886f5..21bf097 100644 --- a/Engine/src/live/AnimalEntity.ts +++ b/Engine/src/live/AnimalEntity.ts @@ -288,10 +288,7 @@ export class AnimalEntity extends Entity { } } attack(ctx: WorldContext) { - this.yell(1) if (this.isMonster) { - let v = 1 + Math.floor(Math.random() * 4) - playSound(`action/hit-v${v}`, 1.0) this.sprite.animate = true this.sprite.loop = false this.sprite.setKey = 'attack' @@ -321,14 +318,22 @@ export class AnimalEntity extends Entity { box[1][1] += 20 } - let entities: AnimalEntity[] = ctx.queryEntities([box[0][0], box[1][0]], [box[0][1], box[1][1]]).filter(v=>v instanceof AnimalEntity && v !== this && !v.isMonster) as AnimalEntity[] + let entities: AnimalEntity[] = ctx.queryEntities([box[0][0], box[1][0]], [box[0][1], box[1][1]]).filter(v=>v instanceof AnimalEntity && v !== this && !v.isMonster && !v.dead) as AnimalEntity[] if (entities.length > 0) { + let v = 1 + Math.floor(Math.random() * 4) + playSound(`action/hit-v${v}`, 1.0) entities[0].dead = true entities[0].shouldGib = true + if (Math.random() > 0.5) { + this.yell(1) + } + } else { + // growl if there are no targets. + this.yell(1) } } } else { - + this.yell(1) } } yell(volume: number) {