AIHitBack.ts 585 B

1234567891011121314151617
  1. /// <reference path="../AI.ts" />
  2. module AIRules {
  3. export var attackInRange = AI.combatRules.createAndAddRule({
  4. name : "Attack in range",
  5. firstPriority : AIRules.PRIORITY_ACTING_ON_SITUATION,
  6. code : (runner : RulebookRunner<Person>) => {
  7. let person = runner.noun;
  8. let hostileTo = person.AI.hostileTo;
  9. for (let i = 0; i < hostileTo.length; i++) {
  10. if (hostileTo[i].isVisibleTo(person)) {
  11. return new ActionAttack(person, hostileTo[i]);
  12. }
  13. }
  14. }
  15. });
  16. }