From 3077648386997294d01ed6ee204caa59a68539c3 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Tue, 17 Jun 2014 21:06:56 -0700 Subject: [PATCH] Stop chasing me if you can't see me at the end of your path --- moonlight/js/moonlight-skulk.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/moonlight/js/moonlight-skulk.js b/moonlight/js/moonlight-skulk.js index 99901a3..dc73dc5 100644 --- a/moonlight/js/moonlight-skulk.js +++ b/moonlight/js/moonlight-skulk.js @@ -987,13 +987,23 @@ var AISprite = function(game, x, y, key, frame) { if ( this.path_index >= this.path.length ) { this.path_tween_stop(); - if ( this.canSeeSprite(player, false) == true ) { + if ( this.canSeeSprite(player, false) == true ) { this.path_set(player, true); this.path_tween_start(); + } else { + if ( hasState(this, STATE_FACE_DOWN) ) { + setMovingState(this, STATE_FACE_LEFT); + } else if ( hasState(this, STATE_FACE_LEFT) ) { + setMovingState(this, STATE_FACE_UP); + } else if ( hasState(this, STATE_FACE_UP) ) { + setMovingState(this, STATE_FACE_RIGHT) ); + } else if ( haState(this, STATE_FACE_RIGHT) ) { + setMovingState(this, STATE_FACE_DOWN); + } } } else { if ( this.path_set(player, this.blocked(true)) == true ) - if ( this.canSeeSprite(player, false) == false ) { + if ( this.canSeeSprite(player, false) == false ) { this.path_tween_stop(); } else { this.path_tween_start();