In Sarven Siege I am trying to command my newly created soldier (at the tower where he’s created) to defend the tower instead of running off to distant enemies. However, I’m struggling with getting the defend command to work.
I get the error "Hero Placeholder can’t command type arrow-tower (only types: soldier, archer).
Since I’m not commanding the tower but a newly minted soldier, I’m stumped.
‘’’
// Defend your towers in this replayable challenge level!
// Step on an X if you have 20 gold to build a soldier.
loop{
var enemy = this.findNearest(this.findEnemies());
var closestGold = null;
var minGoldDistance = Infinity;
var coinIndex = 0;
var coins = this.findItems();
var friend = this.findNearest(this.findFriends());
while (this.gold < 21){
var coin = this.findNearest(this.findItems());
this.move(coin.pos);
}
if (this.gold > 21){
if (this.pos.y < 36){
this.moveXY(84, 22);
this.command(friend, "defend", this.pos);
}else{
this.moveXY(84, 51);
}
}
}
’’’