[SOLVED] Seek-and-hide: Battle with the brawler

I really need some help. My code is failing. My character is accidentally going the wrong way and getting attacked by headhunters. Here is my code. Can you please help me?

# Gather 4 lightstones to defeat the Brawler.
# If you find a lightstone, hide.

def checkTakeHide(item):
    if item:
        # The item is here, so take it.
        hero.moveXY(item.pos.x, item.pos.y)
        # Then move to the center of the camp (40, 34)
        hero.moveXY(40, 34)

while True:
    # Move to the top right X mark.
    hero.moveXY(54, 50)
    hero.moveXY(68, 56)
    # Search for a lightstone there.
    lightstone = hero.findNearestItem()
    # Call checkTakeHide with the argument: lightstone
    checkTakeHide(lightstone)
    hero.moveXY(12, 56)
    lightstone = hero.findNearestItem()
    checkTakeHide(lightstone)
    # Move to the top left mark.
    
    # Search for a lightstone.
    
    # Call the checkTakeHide function.
    # Pass in the result of your search as an argument.
    
    

I just ran your code and it worked fine after commenting out the line, hero.moveXY(54, 50). I think that little extra movement in the while True: loop is causing a delay.

I tried that. Is there any other code which can work? For me this code failed! My character still goes and runs into a headhunter who kills him.

It worked fine for me so it could be an equipment problem. Can you post a screenshot of the gear you’re using? What boots are you using? Maybe your hero is too slow.

Here is the image:

try using the softened leather boots. they’re a little faster and may give you what you need.

Still failing miserably, with the same issue as before. Is there any other code that I can use? This code is failing!!!

No, it isn’t failing. It works fine. We don’t give code out on this board so please don’t ask. We’re here to help you solve any issues, not just give answers.

@Anastasia do you want to join my clan? Pls do cuz i want to get at least 100 people in my clan. The link is in my profile

Alright. But let’s make a deal. I have my own clan, but no-one has joined it apart from me. If I join yours, can you please join mine? Just search “Artemis Coders” to find mine. Deal?

Ok (200000000) Can you give me the link cuz there is no search button for clans @Anastasia

are you using okar stompfoot? He’s waaay too slow. Try using a faster hero. I’m passing the level with your code using Tharin.

Our bargain is complete! I joined your one!

Finally working! Thankyou!

K Great! (20 charsss)

I’m also struggling on this level. I keep being killed by the big ogre that spawns out of the tent.
I only have 1 or 2 lightstones at the time he arrives. When I re-enter the camp, for some reason the hero loops back towards the ogre rather than leaving.

Below is my current code re simplified, but I have tried multiple variations including creating variables to have him recognise the enemy prescience (hero.findNearestEnemy), and used (hero.distanceTo) to trigger an if/else. My thinking was that if the “if” told him to move away from the enemy every time it was within a certain distance, he wouldn’t get killed and that might count as hiding if he was out of sight. But I kept getting a null target from that, so eventually deleted it because “if there’s no enemy, there’s no distance to enemy”. I tried including an else statement as well but it still wouldn’t run.

I know it must be missing something simple, and probably overcomplicating it as a newcomer, but I’ve been at it for over an hour and I’m just getting frustrated…








So I took a break and reset the code, and did it in 2 minutes… Lesson learnt, if in doubt or frustration, sometimes just take a break and hit reset.