I’m gonna keep it short. Please help.
# If the peasant is damaged, the flowers will shrink!
def summonSoldiers():
if hero.gold >= hero.costOf("soldier"):
hero.summon("soldier")
# Define the function: commandSoldiers
def commandSoldiers():
enemy = hero.findNearestEnemy()
soldiers = hero.findFriends()
for soldier in soldiers:
hero.command(soldier, "attack", enemy)
pass
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
hero.move(hero.findNearestItem().pos)
peasant = hero.findByType("peasant")[0]
while True:
summonSoldiers()
# commandSoldiers()
commandSoldiers()
# pickUpNearestCoin()
pickUpNearestCoin()
The peasant is also your friend.
@GraySkayl007 Can you send me the link to this level?
Lydia
Replace soldiers = hero.findFriends()
(line 10) with soldiers = hero.findByType("soldier")
, the peasant can’t kill ogres with his flowers. Also in line 16, I think you should define the nearest item as a variable, then you move to its position, else I don’t think it would work.
I got it to work, but now there are too many ogres. My soldiers can’t take them and they end up targeting Hector (the peasant) anyway.
1 Like
Thanks, I will try to help you as soon as I can.
Lydia
1 Like
Nevermind! I just completed it by helping the soldiers attack once in a while.
4 Likes
system
Closed
September 12, 2020, 2:35am
10
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.