Stillness in motion Help ME Somebodey


#1

This is my code I don’t know whats wrong with it?

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)…


#2

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.


#3

Okay thanks you I will go and check.


#4

It says you should shield[, but I will see if cleaving works and allows me to win.


#5

You’re supposed to set it to do both depending on the conditions.


#6

Okay that was what I was missing in my code.


#7

Thank you so much your a great friend


#8

I’m really glad I could help! I wish you the best with your future coding adventures :slight_smile:


#9

Thank you and to you too.