while True:
enemy = hero.findNearestEnemy(enemy)
# If there is an enemy, then…
if enemy:
# Create a distance variable with distanceTo.
distance = hero.distanceTo(enemy) <5
# If the distance is less than 5 meters, then attack.
hero.attack(enemy)
# Else (the enemy is far away), then shield.
else:
distance = hero.distanceTo(enemy)
hero.moveXY(40, 34)
pass
# Else (there is no enemy)…
Seems like you are missing the call to shield for one. I’m using Lua so my code looks a little different. Aren’t you also supposed to cleave? You might want to try resetting the map and filling in the instructions the comments give. I would just paste my code but I’m not sure that’d really be helping you.