|
@@ -16,6 +16,8 @@ class AI {
|
|
|
public wandersOn : Region;
|
|
|
public wanderChance = 50;
|
|
|
public picksShinies = true;
|
|
|
+ public hostileTo : Array<Thing> = [];
|
|
|
+ public grudgeRate = 50;
|
|
|
|
|
|
public constructor (options : AIOptions) {
|
|
|
for (let key in options) {
|
|
@@ -29,7 +31,18 @@ class AI {
|
|
|
*/
|
|
|
public async execute () : Promise<Action> {
|
|
|
let promise : Promise<Action>;
|
|
|
- if (promise != undefined) {
|
|
|
+ let inCombat = false;
|
|
|
+
|
|
|
+ if (this.hostileTo.length > 0) {
|
|
|
+ for (let i = this.hostileTo.length - 1; i >= 0; i--) {
|
|
|
+ if (this.actor.getRoom() == this.hostileTo[i].getRoom()) {
|
|
|
+ inCombat = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (inCombat) {
|
|
|
promise = AI.combatRules.execute({
|
|
|
noun : this.actor
|
|
|
}, ...this.extraCombatRules);
|