Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Help, im new and my code wont work


hey there im new to code combat, smashing through the levels and ive hit a brick wall and cant work out what im doing wrong. its in regards to tagerting enemies…i put up this simple code that ive used loads but now it work work:

    enemy = self.findEnemies()
    if enemy:
        if self.isReady("cleave") and self.distanceTo(enemy) < 5:

i just want to target and attack enemis but it keeps coming up with “fix code: find distance to target unit” if tried replacing self.distanceTo(enemy.pos) and that doesnt work either. help! the level im on is sarven treasure btw and im using python.


self.findEnemies() returns an array of all enemies the hero can see. You need one enemy to attack. Try self.findNearest(self.findEnemies()).

Thank you for formatting your code correctly!