Stop chasing me if you can't see me at the end of your path
This commit is contained in:
@@ -725,8 +725,8 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
yd = -(yd);
|
yd = -(yd);
|
||||||
|
|
||||||
var hyp = Math.sqrt(Number(xd * xd) + Number(yd * yd));
|
var hyp = Math.sqrt(Number(xd * xd) + Number(yd * yd));
|
||||||
if ( hyp > this.view_distance ) {
|
if ( hyp > vd ) {
|
||||||
console.log("Player is outside my view distance");
|
console.log("Target is outside my view distance");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -739,7 +739,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
if ( viewrect.intersects(sprrect) || viewrect.containsRect(sprrect) ) {
|
if ( viewrect.intersects(sprrect) || viewrect.containsRect(sprrect) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
console.log("I have a view rectangle but it does not intersect or contain the player");
|
console.log("I have a view rectangle but it does not intersect or contain the target");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1002,7 +1002,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
this.path_set(player, true);
|
this.path_set(player, true);
|
||||||
this.path_tween_start();
|
this.path_tween_start();
|
||||||
} else {
|
} else {
|
||||||
console.log("I can't see the player");
|
console.log("I can't see the player - turning so I can");
|
||||||
if ( hasState(this, STATE_FACE_DOWN) ) {
|
if ( hasState(this, STATE_FACE_DOWN) ) {
|
||||||
setMovingState(this, STATE_FACE_LEFT);
|
setMovingState(this, STATE_FACE_LEFT);
|
||||||
} else if ( hasState(this, STATE_FACE_LEFT) ) {
|
} else if ( hasState(this, STATE_FACE_LEFT) ) {
|
||||||
@@ -1015,6 +1015,7 @@ var AISprite = function(game, x, y, key, frame) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( this.path_set(player, this.blocked(true)) == true ) {
|
if ( this.path_set(player, this.blocked(true)) == true ) {
|
||||||
|
console.log("I just got a new path");
|
||||||
if ( this.canSeeSprite(player, false) == false ) {
|
if ( this.canSeeSprite(player, false) == false ) {
|
||||||
this.path_tween_stop();
|
this.path_tween_stop();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user