I really need help with the level "Operation: Killdeer"[SOLVED]

It is confusing and difficult. Please help.

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

Please post your code so we can help you.

here is my code:

type or paste code here
```# Lure the ogres into a trap. These ogres are careful.
# They will only follow if the hero is injured.
enemy = hero.findNearestEnemy()
# This function checks the hero's health 
# and returns a Boolean value.
def shouldRun():
    if hero.health < hero.maxHealth / 2:
        return True
    else:
        return False

while True:
    # Move to the X only if shouldRun() returns True
    if shouldRun = true:
    x = hero.pos.x + 10
    hero.moveXY(x, 37)
    hero.moveXY(75, 37)
    # Else, attack!
    hero.attack(enemy)

This level is in the Sarven Desert

Change that to

    # Move to the X only if shouldRun() returns True
    if shouldRun():
        hero.moveXY(75, 37)
    # Else, attack!
    else:
        enemy = hero.findNearestEnemy()
        hero.attack(enemy)
1 Like

It worked! Thank you so much Eric_Tang. Your the best.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.