From 35cd16f14b7be80119a870645ebc17a5b3144408 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Tue, 17 Jun 2014 21:02:19 -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, 10 insertions(+), 4 deletions(-) diff --git a/moonlight/js/moonlight-skulk.js b/moonlight/js/moonlight-skulk.js index b025202..d594f45 100644 --- a/moonlight/js/moonlight-skulk.js +++ b/moonlight/js/moonlight-skulk.js @@ -987,11 +987,17 @@ var AISprite = function(game, x, y, key, frame) { if ( this.path_index >= this.path.length ) { this.path_tween_stop(); - this.path_set(player, true); - this.path_tween_start(); - } else { - if ( this.path_set(player, this.blocked(true)) ) + if ( x.canSeeSprite(player, false) == true ) { + this.path_set(player, true); this.path_tween_start(); + } + } else { + if ( this.path_set(player, this.blocked(true)) == true ) + if ( x.canSeeSprite(player, false) == true ) { + this.path_tween_stop(); + } else { + this.path_tween_start(); + } } return; }