I’m trying to get behind the tower, just to know it is being recognized, but my === tower doesn’t work. Besides, when I still have 900 health Tharin gets frozen and does no longer attack the second tower. He stays still close to the second opened gate till life is taken from him. Please Help!!
// Fight your way into the Inner Sanctum of the ogre chieftain, and kill her.
this.commandPaladin = function(paladin) {
var nearestEnemy = paladin.findNearest(this.findEnemies());
if (paladin.canCast("heal")) {
this.command(paladin, "cast", "heal", this);
}
else if (paladin.health < paladin.maxHealth /3) {
this.command(paladin, "shield");
}
else if (nearestEnemy) {
this.command(paladin, "attack", nearestEnemy);
}
else {
this.command(paladin, "move", this.pos);
}
};
this.commandFighter = function(friend) {
var enemy = friend.findNearestEnemy();
if (enemy) {
this.command(friend, "attack", enemy);
}
};
this.summonGriffin = function(){
if (this.gold >= this.costOf("griffin-rider")) {
this.summon("griffin-rider");
}
};
this.commandFriends = function() {
// Command your friends.
var friends = this.findFriends();
for(var i=0; i < friends.length; i++) {
var friend = friends[i];
if (friend.type === "soldier" || friend.type === "archer" || friend.type === "griffin-rider") {
this.commandFighter(friend);
} else if (friend.type === "paladin") {
this.commandPaladin(friend);
}
}
};
loop {
this.commandFriends();
this.summonGriffin();
var enemy = this.findNearest(this.findEnemies());
var tower = this.findByType("tower");
if (enemy && enemy != tower) {
if (this.isReady("chain-lightning")) {
this.cast("chain-lightning", enemy);
}
else if (this.isReady("cleave")) {
this.cleave(enemy);
}
else {
this.attack(enemy);
this.bash(enemy);
}
}
else if (enemy && enemy === tower){
this.moveXY(110, 4);
}
}