I can’t seem to figure out how to command my troops to attack this is my code:def commandSoldiers():
enemies = hero.findEnemies()
enemy = hero.findNearest(enemies)
soldiers = hero.findFriends()
soldier = soldiers
for soldier in soldiers:
I agree with @riticmaster9087 on this one. The findByType() method works very well if you have the correct glasses that include this method. One note for this method, you need to understand that this is going to return an array list of all the soldiers. So using a for loop to command them individually works very well.
You can also include an additional parameter that ensures you are only finding friendly soldiers or whatever type you search for. This is important when you fight against warlocks since they can raise your soldiers from the dead to fight against you. If you don’t include the friends limitation, you will try to command the raised soldiers that are now enemies and you can’t, you will get an error.
Otherwise, using a for loop with your friends like @Lydia_Song suggested with the type check included like @abc mentioned is another great way to isolate the type of friends you want to command.
Extra note for those that are new to commanding friends: you have the right Boss Star that allows you command the different friends.