From f83ddcd81d6c1060b96681beeb06bb3c238b9f66 Mon Sep 17 00:00:00 2001 From: kts of kettek Date: Sun, 30 Jan 2022 02:27:17 -0800 Subject: [PATCH] Adjust random logic --- Engine/src/live/AnimalEntity.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Engine/src/live/AnimalEntity.ts b/Engine/src/live/AnimalEntity.ts index 9cf9e7c..4b9be2a 100644 --- a/Engine/src/live/AnimalEntity.ts +++ b/Engine/src/live/AnimalEntity.ts @@ -129,7 +129,7 @@ export class AnimalEntity extends Entity { this.sprite.setCtor(`${this.sprite.spriteKey}.${this.sprite.animationKey}.${this.sprite.setKey}.${cardinal}.${this.sprite.frameIndex}`) } if (this.stepSoundElapsed >= 200) { - let v = 1+Math.round(Math.random()*3) + let v = 1 + Math.floor(Math.random() * 3) playSound('action/footstep-tiny-v'+v, 0.5) this.stepSoundElapsed = 0 } @@ -165,7 +165,7 @@ export class AnimalEntity extends Entity { while (this.thinkTimer >= 100) { if (!this.isMonster) { if (this.seenTarget) { - let r = Math.atan2(this.y-this.seenTarget.y, this.x-this.seenTarget.x) + let r = Math.atan2(this.y-(this.seenTarget.y+10), this.x-this.seenTarget.x) // FIXME: 10 ain't right son let a = r * (180 / Math.PI) if (a < 0) { a += 360 @@ -176,6 +176,9 @@ export class AnimalEntity extends Entity { } this.desiredActions = adjustAction([], this.getCardinal(a), 0.85) this.desiredActions = adjustAction(this.desiredActions, this.getCardinal(Math.random()*360), Math.random()) + if (Math.random() > 1 - this.mode.erratic) { + this.desiredActions = adjustAction(this.desiredActions, this.getCardinal(Math.random()*360), 1) + } this.yell(1) } else if (this.smelledTarget) { let r = Math.atan2(this.y-this.smelledTarget.y, this.x-this.smelledTarget.x) @@ -251,7 +254,7 @@ export class AnimalEntity extends Entity { if (this.lastYellElapsed > this.nextYell) { this.nextYell = 500 + Math.random()*3000 this.lastYellElapsed = 0 - let v = 1+Math.round(Math.random()*2) + let v = 1 + Math.floor(Math.random() * 2) if (this.isMonster) { playSound(`monsters/evil-${this.def.name}-v${v}`, volume) } else {