loop: enemy = self.findNearestEnemy() distance = self.distanceTo(enemy.pos) flag = self.findFlag() if flag: self.pickUpFlag(flag) elif enemy == True: if distance < 30: if self.isReady("bash"): self.bash(enemy) else: self.attack(enemy) else: item = self.findNearestItem() position = item.pos x = position.x y = position.y self.moveXY(x, y)
Basically, my knight just ignores the enemy no matter what. Without some sort of “enemy == True” clause though, the code bottoms out after the only enemy dies, and doesn’t pick back up even after the respawn. He chases coins unless there’s a flag down, and even then, the responsiveness to the flag is low (I’m not sure how to break the “else” statement once it’s begun to go for a coin, or if that’s possible).
Note: in the distance variable, enemy needs the .pos or else it bugs, supposedly that’s a known issue.