123456789101112131415161718192021 |
- /// <reference path="../AI.ts" />
- module AIRules {
- export var Grudge = AI.rules.createAndAddRule({
- name : "Grudge",
- firstPriority : AIRules.PRIORITY_ACTING_ON_SITUATION,
- conditions : (runner : RulebookRunner<Person>) => {
- let person = runner.noun;
- return person.AI.hostileTo.length > 0 && (Math.random() * 100) <= person.AI.grudgeRate;
- },
- code : (runner : RulebookRunner<Person>) => {
- 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]);
- }
- }
- }
- });
- }
|