# Stillness in motion Help ME Somebodey

**URL:** <https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713>\
**Category:** Adventurer\
**Created:** [November 22, 2016, 10:31pm UTC](https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713 "2016-11-22T22:31:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![KareemT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kareemt/32/5228_2.png) [@KareemT](https://discourse.codecombat.com/u/KareemT)\
**Post date:** [November 22, 2016, 10:31pm UTC](https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713/1 "2016-11-22T22:31:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TheReaperKing](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thereaperking/32/5206_2.png) [@TheReaperKing](https://discourse.codecombat.com/u/TheReaperKing)\
**Post date:** [November 22, 2016, 11:36pm UTC](https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713/2 "2016-11-22T23:36:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![KareemT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kareemt/32/5228_2.png) [@KareemT](https://discourse.codecombat.com/u/KareemT)\
**Post date:** [November 22, 2016, 11:38pm UTC](https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713/3 "2016-11-22T23:38:41Z")

</div>

Okay thanks you I will go and check.

---

<div class="post-metadata">

**Author:** ![KareemT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kareemt/32/5228_2.png) [@KareemT](https://discourse.codecombat.com/u/KareemT)\
**Post date:** [November 22, 2016, 11:40pm UTC](https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713/4 "2016-11-22T23:40:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TheReaperKing](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thereaperking/32/5206_2.png) [@TheReaperKing](https://discourse.codecombat.com/u/TheReaperKing)\
**Post date:** [November 22, 2016, 11:42pm UTC](https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713/5 "2016-11-22T23:42:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KareemT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kareemt/32/5228_2.png) [@KareemT](https://discourse.codecombat.com/u/KareemT)\
**Post date:** [November 22, 2016, 11:43pm UTC](https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713/6 "2016-11-22T23:43:52Z")

</div>

Okay that was what I was missing in my code.

---

<div class="post-metadata">

**Author:** ![KareemT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kareemt/32/5228_2.png) [@KareemT](https://discourse.codecombat.com/u/KareemT)\
**Post date:** [November 22, 2016, 11:50pm UTC](https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713/7 "2016-11-22T23:50:44Z")

</div>

Thank you so much your a great friend

---

<div class="post-metadata">

**Author:** ![TheReaperKing](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thereaperking/32/5206_2.png) [@TheReaperKing](https://discourse.codecombat.com/u/TheReaperKing)\
**Post date:** [November 22, 2016, 11:51pm UTC](https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713/8 "2016-11-22T23:51:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KareemT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kareemt/32/5228_2.png) [@KareemT](https://discourse.codecombat.com/u/KareemT)\
**Post date:** [November 22, 2016, 11:52pm UTC](https://discourse.codecombat.com/t/stillness-in-motion-help-me-somebodey/9713/9 "2016-11-22T23:52:35Z")

</div>

Thank you and to you too.
