Stop chasing me if you can't see me at the end of your path

This commit is contained in:
2014-06-18 09:09:56 -07:00
parent 69da8831ec
commit 134c6e8e29

View File

@@ -714,6 +714,13 @@ var AISprite = function(game, x, y, key, frame) {
this.canSeeSprite = function(spr, debug) { this.canSeeSprite = function(spr, debug) {
var vd = this.view_distance; var vd = this.view_distance;
if ( hasState(this, STATE_FACE_LEFT) ||
hasState(this, STATE_FACE_UP) ) {
// Without this the player can stand in our view distance
// but as long as their left edge is 1 px out we won't see them,
// with this we see their near edge
vd = vd + 32;
}
if ( hasState(this, STATE_ALERTED) ) if ( hasState(this, STATE_ALERTED) )
vd = vd * 2; vd = vd * 2;