will do thanks for that to.
Glad I could help you!
how? they don’t have programmation 4 yet!
What do you mean by that?
and? is something wrong with that @EpicCoder999
if you don’t have a for loop i think you have to use while…
@AnSeDra i will try for lloop without equipping programmation 4
for enemy in hero.findEnemies(): for i in range(4): hero.attack(enemy)
Well, I belive you can, so try it out!
oh it woked!!! nice…
for, i, num in enumerate(len(enemies)):
Mine isn’t working. My hero never says attack and in the end the ogres kill them all. What’s the problem here?
# Attack when your soldiers' total health is greater # than the ogres' total health # This function return the sum of all the units' health. def sumHealth(units): totalHealth = 0 # Complete this function: #enemies = hero.findEnemies() enemyIndex = 0 while enemyIndex < len(enemies): totalHealth += enemies[enemyIndex].health enemyIndex += 1 return totalHealth while True: friends = hero.findFriends() enemies = hero.findEnemies() # Get the total health of your soldiers and the ogres. if sumHealth(friends) <= sumHealth(enemies): hero.say("Wait") # Say "Attack" when your side has more total health. else: hero.say("ATTACK!!!")
can you post the link to the level so i can help u
Replace enemies with units.
I tried this and it worked. Thanks for the help!
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.