When i tested it, my soldiers spawned, but they didnt attack the ogres.
Here is my code
{
var item = hero.findNearestItem();
if (item) {
while (true) {
var item = hero.findNearestItem();
var gold = hero.gold;
hero.moveXY(item.pos.x, item.pos.y);
if (gold >= 15) {
hero.summon("soldier");
}
}
}
var friends = hero.findFriends();
for (var friendIndex = 0; friendIndex < friends.length; friendIndex++) {
var friend = friends[friendIndex];
if (friend.type == "soldier") {
var enemy = friend.findNearestEnemy();
if (enemy) {
hero.command(friend, "attack", enemy);
}
else {
hero.command(friend, "move", {x: 43, y: 43});
}
}
}
}