AI returns to their origin when they cant move and are in wandering state. AI gets their facing state from the map. Guards can re-encounter you while traveling back to the origin.

This commit is contained in:
2014-06-27 18:04:34 -07:00
parent 6873a1ba53
commit 9709a87fb0
4 changed files with 26 additions and 14 deletions

View File

@@ -101,6 +101,9 @@ function nearestWalkableTile(spr)
return null;
}
if ( grid.nodes[spr.y/32][spr.x/32].walkable == true )
return [spr.x/32, spr.y/32];
for ( var i = 1 ; i < 100 ; i++ ) {
var rv = _walkable_inner(i);
if ( isSet(rv) ) {
@@ -109,11 +112,7 @@ function nearestWalkableTile(spr)
return rv
}
}
//if ( multiplier >= 10 )
console.log("Couldn't find a near walkable tile");
console.log([spr.x / 32, spr.y / 32]);
return [parseInt(spr.x / 32), parseInt(spr.y / 32)];
//return nearestWalkableTile(spr, multiplier + 1);
}
function addAnimation(obj, anim)
@@ -134,6 +133,15 @@ function getAwarenessState(spr)
return STATE_LOSTHIM;
}
function faceStateFromString(face)
{
var states = { "up": STATE_FACE_UP,
"down": STATE_FACE_DOWN,
"left": STATE_FACE_LEFT,
"right": STATE_FACE_RIGHT };
return states[face.toLowerCase()];
}
function getFaceState(spr)
{
if ( hasState(spr, STATE_FACE_LEFT) )