///
module AIRules {
export var attackInRange = AI.combatRules.createAndAddRule({
name : "Attack in range",
firstPriority : AIRules.PRIORITY_ACTING_ON_SITUATION,
code : (runner : RulebookRunner) => {
let person = runner.noun;
let hostileTo = person.AI.hostileTo;
for (let i = 0; i < hostileTo.length; i++) {
if (hostileTo[i].isVisibleTo(person)) {
return new ActionAttack(person, hostileTo[i]);
}
}
}
});
}