From 9f9b986f9ae3f94fbfd711dd7b69054e8e9a2f0d Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Tue, 17 Jun 2014 22:41:28 -0700 Subject: [PATCH] Stop chasing me if you can't see me at the end of your path --- moonlight/js/moonlight-skulk.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/moonlight/js/moonlight-skulk.js b/moonlight/js/moonlight-skulk.js index db0154a..fc8d62e 100644 --- a/moonlight/js/moonlight-skulk.js +++ b/moonlight/js/moonlight-skulk.js @@ -988,9 +988,11 @@ 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 ) { + console.log("I am at the end of my path and can see the player"); this.path_set(player, true); this.path_tween_start(); } else { + console.log("I am at the end of my path but can't see the player"); if ( hasState(this, STATE_FACE_DOWN) ) { setMovingState(this, STATE_FACE_LEFT); } else if ( hasState(this, STATE_FACE_LEFT) ) { @@ -1002,12 +1004,13 @@ var AISprite = function(game, x, y, key, frame) { } } } else { - if ( this.path_set(player, this.blocked(true)) == true ) + if ( this.path_set(player, this.blocked(true)) == true ) { if ( this.canSeeSprite(player, false) == false ) { this.path_tween_stop(); } else { this.path_tween_start(); } + } } return; }