///
module AIRules {
export var Grudge = AI.rules.createAndAddRule({
name : "Grudge",
firstPriority : AIRules.PRIORITY_ACTING_ON_SITUATION,
conditions : (runner : RulebookRunner) => {
let person = runner.noun;
return person.AI.hostileTo.length > 0 && (Math.random() * 100) <= person.AI.grudgeRate;
},
code : (runner : RulebookRunner) => {
let person = runner.noun;
let hostileTo = person.AI.hostileTo;
for (let i = 0; i < hostileTo.length; i++) {
if (ActionFollow.isCloseEnough(person, hostileTo[i])) {
return new ActionFollow(person, hostileTo[i]);
}
}
}
});
}