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.
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.
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.
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?
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…