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

Hero doesn't attack - kithgard Brawl


Hello all. I am playing kithgard Brawl. My code seems to work fine at the beginning, but after 15 seconds, my hero stop attacking enemies for a while. Importantly, this happens before the medicine appears. Any ideas?

        enemy = self.findNearestEnemy()
        item = self.findNearestItem()
        if item:
            position = item.pos
            x = position.x
            y = position.y
            if < 200:
                self.moveXY(x, y)    
        elif enemy:
            distance = self.distanceTo(enemy)
            if distance < 5 and self.isReady("cleave"):  
            elif enemy.type is "ogre" and self.isReady("bash"):


What’s happening is your code runs correctly from the start because there are no items on the field.
It checks items and finds none, so your hero goes about killing.
Once an item appears, your loop constantly goes into your “if item:” loop and checks for your health being below 200
Until it gets below 200, your hero just stands there.
To fix this, try moving the health check up to the if statement.
You can check more than one statement at a time using “and”.


Thanks a lot for your reply!