Reporting townspeople should send the guard to the player's last known location

This commit is contained in:
2014-06-22 14:03:43 -07:00
parent 22cbd2849a
commit 97b0b89dce
2 changed files with 26 additions and 6 deletions

View File

@@ -377,12 +377,27 @@ var AISprite = function(game, x, y, key, frame) {
this.action_chaseplayer = function() this.action_chaseplayer = function()
{ {
this.chasetarget(player, if ( this.path.length > 1 &&
STATE_ALERTED, this.path_index >= this.path.length &&
STATE_MOVING | STATE_RUNNING, hasState(this, STATE_RUNNINGTOREPORT) ) {
true, delState(this, STATE_RUNNINGTOREPORT);
undefined, this.target = player;
false); }
if ( hasState(this, STATE_RUNNINGTOREPORT) ) {
this.chasetarget(this.target,
STATE_ALERTED,
STATE_MOVING | STATE_RUNNING,
true,
1000,
false);
} else {
this.chasetarget(player,
STATE_ALERTED,
STATE_MOVING | STATE_RUNNING,
true,
undefined,
false);
}
return; return;
} }
@@ -394,6 +409,10 @@ var AISprite = function(game, x, y, key, frame) {
var aiSprites = game.state.states.game.aiSprites; var aiSprites = game.state.states.game.aiSprites;
this.target = nearestInGroup(this, aiSprites, "townsfolk-guard"); this.target = nearestInGroup(this, aiSprites, "townsfolk-guard");
} else if ( hasState(this, STATE_RUNNINGTOLIGHT) == false ) { } else if ( hasState(this, STATE_RUNNINGTOLIGHT) == false ) {
this.target.setAwarenessState(STATE_ALERTED);
this.target.target = this.lastSawPlayerAt
addState(this.target, STATE_RUNNINGTOREPORT);
this.path_tween_stop(); this.path_tween_stop();
this.path_purge(); this.path_purge();
var staticLights = game.state.states.game.staticLights; var staticLights = game.state.states.game.staticLights;

View File

@@ -21,6 +21,7 @@ STATE_FACE_DOWN = 1 << 9;
STATE_MOVING = 1 << 10; STATE_MOVING = 1 << 10;
STATE_RUNNINGTOLIGHT = 1 << 11; STATE_RUNNINGTOLIGHT = 1 << 11;
STATE_RUNNINGTOREPORT = 1 << 12;
STATES_AWARENESS = (STATE_UNAWARE | STATE_CONCERNED | STATE_ALERTED | STATE_LOSTHIM); STATES_AWARENESS = (STATE_UNAWARE | STATE_CONCERNED | STATE_ALERTED | STATE_LOSTHIM);
STATES_MOVEMENT = (STATE_MOVING | STATE_RUNNING); STATES_MOVEMENT = (STATE_MOVING | STATE_RUNNING);