can someone give me the details on how to do this? i am so lost
// Ogre Witches have some unpleasant surprises ready for you.
// Define a chooseTarget function which takes a friend argument
// Returns the a target to attack, depending on the type of friend.
// Soldiers should attack the witches, archers should attack nearest enemy.
function chooseTarget(friend){
var nearestWitch = friend.findNearest(hero.findByType("witch"));
if(friend && friend.type == "soldier") {
hero.command(friend, "attack", nearestWitch);
}
}
while(true) {
var friends = hero.findFriends();
for(var i=0; i < friends.length; i++) {
var friend = friends[i];
// Use your chooseTarget function to decide what to attack.
chooseTarget();
}
}