123456789101112131415161718192021222324 |
- /// <reference path="../AI.ts" />
- module AIRules {
- export var attackInRange = AI.combatRules.createAndAddRule({
- name : "Attack highest aggro",
- firstPriority : AIRules.PRIORITY_ACTING_ON_SITUATION,
- code : (runner : RulebookRunner<Person>) => {
- let person = runner.noun;
- let hostiles = [...person.AI.hostileTargets].filter(value => {
- return person.AI.newNoticed.includes(value) &&
- (
- !(value instanceof Person) || value.stance != PersonStance.KNOCKEDOUT
- ); // by default, stop hitting unconscious people.
- });
- if (hostiles.length > 0) {
- hostiles.sort((a, b) => {
- return person.AI.getHostilityTo(b) - person.AI.getHostilityTo(a);
- });
- return new ActionAttack(person, hostiles[0]);
- }
- }
- });
- }
|