I’m not sure if this is a bug, or I just have issues with my code.
On the level tutorial, and the regular Dungeon Arena level, playing as a human, I have some problems:
The first is that the code: self.distance(enemy) allways gives me this error message:
time 0.1: Find the distance to a target unit.
I can see that the “enemy” object is initalized, and has the type munchkin, it was created with this method:
enemy = self.getNearest(enemies)
My second problem is with the librarian unit, I can’t cast spells on other units, because this code:
if self.canCast(“slow”, enemy): self.castSlow(enemy) Gives me this error:
time 0.1: Target must be a unit
This is my full code:
friends = self.getFriends() enemies = self.getEnemies() if enemies.length is 0: return # Chill if all enemies are dead. enemy = self.getNearest(enemies) friend = self.getNearest(friends) distanceFromFriend = friend.pos.x - self.pos.x distanceFromEnemy = enemy.pos.x - self.pos.x if distanceFromFriend < distanceFromEnemy and friend.type != "base": if self.canCast("haste", self.getNearest(friends)): self.castHaste(self.getNearest(friends)) return elif friend.health < friend.maxHealth: if self.canCast("regen", friend): self.castRegen(friend) return return else: if self.canCast("slow", enemy): self.castSlow(enemy) return else: self.attack(enemy) return return
Also I couldn’t use the beneficial spells, my nearest “friend” is my base, is that expected?
Thanks for the help!