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) {