123456789101112131415161718192021 |
- /// <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);
- });
- if (hostiles.length > 0) {
- hostiles.sort((a, b) => {
- return person.AI.getHostilityTo(b) - person.AI.getHostilityTo(a);
- });
- return new ActionAttack(person, hostiles[0]);
- }
- }
- });
- }
|