while True: enemy = hero.findNearestEnemy() flag = hero.findFlag() item = hero.findNearestItem() #this will follow the flag if flag: hero.moveXY(flag.pos.x, flag.pos.y) #this will find and attack an enemy if enemy: hero.attack(enemy) #this will find and pickup item item = hero.findNearestItem() if item == "mushroom": hero.moveXY(item.pos.x,item.pos.y)
i got this issue with my code. although technically it works i get a problem collecting the mushrooms.
having the code structured like this, the hero ping-pongs between killing an enemy and picking up a mushroom.
Thanks in advance for any tips.
My tip for you is to turn this:
into this so the flag is prioritized.
elif enemy: hero.attack(enemy)
I recommend removing the
if item part because you can use flags to handle the mushroom collecting.
thanks for the reply, will do that
can i get some help here i have looked for answers forever and now im just doing this
# This level is intended to be for advanced players. The solution should be pretty complex with a lot of moving parts. It might also be a bit of a gear check unless you use "creative" methods. # You need to make your way to the first trial (Oasis of Marr) defeating enemies along the way. When you reach it, pick all the mushrooms to trigger the trial to begin. If you survive the onslaught, make your way to the next Oasis for the second trial, then the Temple. When all trials are complete you will have to face the final boss. Good luck! # HINT: Glasses with a high visual range help tremendously on this level so buy the best you can get. # HINT: the unit 'type' for the oasis guardians is 'oasis-guardian' while True: friends = hero.findFriends() for friend in friends: hero.command(friend, "defend", hero) item = hero.findNearestItem() enemy = hero.findNearestEnemy() if item: hero.moveXY(item.pos.x, item.pos.y) if enemy: if enemy.type == "oasis-guardian": if hero.isReady("bash"): hero.bash(enemy) else: hero.attack(enemy) else: hero.attack(enemy)
and what would be good strategy?
my hero finishes the first trial and then he just stands there after defeating the mini boss of the first trial
Well done on completing the first trial. Now you need to tell your hero to move to the next oasis. There’s more mushrooms there to collect…
i used the twlight glasses and beat it like no problem
press here to see what my result was
I tried not to show the code so if anyone sees it OOPS but if it shows i am just saying it was an accident
you should put a code that collects the items by themselves