From f619134b64ef0090db8e0929bb1e39e7ebae94bc Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sun, 22 Jun 2014 13:50:50 -0700 Subject: [PATCH] Face a random direction when you stop at a light --- moonlight/src/AISprite.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/moonlight/src/AISprite.js b/moonlight/src/AISprite.js index 5c88146..3e39d5b 100644 --- a/moonlight/src/AISprite.js +++ b/moonlight/src/AISprite.js @@ -313,6 +313,15 @@ var AISprite = function(game, x, y, key, frame) { }, this); } + this.turnRandomDirection = function() { + var directions = [STATE_FACE_DOWN, STATE_FACE_LEFT, + STATE_FACE_RIGHT, STATE_FACE_UP]; + setMovingState(this, game.rnd.integerInRange(0, 3]); + this.animations.stop(); + this.animations.play("bipedrun" + spriteFacing(this)); + this.animations.stop(); + } + this.turnUnseenDirection = function() { if ( this.seen_directions.length >= 4 ) this.seen_directions = []; @@ -396,6 +405,7 @@ var AISprite = function(game, x, y, key, frame) { this.awareness_timer.stop(); this.awareness_change_enabled = true; this.setAwarenessEffect(STATE_LOSTHIM); + this.turnRandomDirection(); this.target = null; delState(this, STATE_RUNNINGTOLIGHT); return;