// caught(EVENT1, EVENT2)
// -----------------------------------
// Checks if EVENT1 has caught EVENT2.
// I.e., whether EVENT1 is right next to EVENT2, facing EVENT2, and the map
// is passable from EVENT1's square to EVENT2's square.
//
Game_Interpreter.prototype.caught = function(event1_id, event2_id){
// Not even close.
if (!this.eventInRange(event1_id, event2_id, 1)){
return false;
}
// EVENT1 not facing EVENT2.
var e1_xy = Kron.AI_base.getXY(event1_id, this.eventId());
var e2_xy = Kron.AI_base.getXY(event2_id, this.eventId());
var e1_dir = Kron.AI_base.getDirection(event1_id, this.eventId());
if ((e1_dir === 2 && !(e1_xy.Y < e2_xy.Y))
||
(e1_dir === 4 && !(e1_xy.X > e2_xy.X))
||
(e1_dir === 8 && !(e1_xy.Y > e2_xy.Y))
||
(e1_dir === 6 && !(e1_xy.X < e2_xy.X))){
return false;
}
// EVENT1 can't pass to the square of EVENT2.
if (!this.isMapPassable(e1_xy.X, e1_xy.Y, e1_dir)){
return false;
}
// All checks are a pass.
return true;
}