I’m attempting to develop my human battle plan with Hushbaum the librarian. I’m trying to get him to heal his allies if they are hurting, but I get an error: “Only the last action set in chooseAction() will be applied.” This is wonderful, makes me happy, I was assuming that I could only set one action and my code should only ever evaluate to one chooseAction(), but it won’t update and run my new code, or if it does, my friends are still never healed.
Any help?
var regen;
regen = False;
var friends = this.getFriends();
for (var f in friends) {
friend = friends[f];
if (friend.health < friend.maxHealth * 0.5) {
this.say("Regenerate, " + friend.id + "!");
this.castRegen(friend);
this.say("hi");
regen = True;
}
}
if (!regen) {
var enemies = this.getEnemies();
if (enemies.length === 0)
return;
// Do nothing if all enemies are dead.
var enemy = this.getNearest(enemies);
this.say("Attack!", { target: enemy });
if (this.canCast('slow', enemy)) {
this.castSlow(enemy);
// Slow the enemy, or chase if out of range (30m).
if (this.distance(enemy) <= 30) {
this.say("Not so fast, " + enemy.type + " " + enemy.id);
}
} else {
this.attack(enemy);
}
}