HI, I’, having trouble with Mind the Trap. I hit RUN and instead of attacking the ogres on my side of the mines, Tharin ran toward the mines and died.
Here’s my code:
loop:
flag = self.findFlag()
enemy = self.findNearestEnemy()
if flag:
# Pick up the flag.
self.pickUpFlag(flag)
elif enemy:
if self.isReady("cleave"):
self.cleave(enemy)
# Only attack if the enemy distance is < 10 meters
if enemy and self.distanceTo(enemy) < 10:
if self.isReady("cleave"):
self.cleave(enemy)
else:
self.attack(enemy)
It doesn’t describe what is wrong. It just says at the top where the goals are: FAILING. I don`t know what is wrong.
I would appreciate it very much if someone would help
EDIT: I fixed by:
loop:
flag = self.findFlag()
enemy = self.findNearestEnemy()
if flag:
# Pick up the flag.
self.pickUpFlag(flag)
self.say("I should pick up the flag.")
elif enemy:
# Only attack if the enemy distance is < 10 meters
if self.distanceTo(enemy) < 10:
if self.isReady("cleave"):
self.cleave(enemy)
else:
self.attack(enemy)