Sarven outpost python hero ignores enemies because of glasses?


#1

problem:
hero ignores enemy
do I need special glasses to detect enemy health?

Here is the code that does not work:

(need to add four spaces and two blank lines to get the code to format properly!)

    # Check for ogres and defeat them!
    enemy = hero.findNearestEnemy()
    if enemy:
        if enemy.health <= 0:
            hero.attack(enemy)
    # Make sure to attack the ogres while their health is above 0.

If I comment out it works… again, is this a ‘glasses’ issue?

if enemy.health <= 0:

    if enemy:
        #if enemy.health <= 0:
        hero.attack(enemy)
    # Make sure to attack the ogres while their health is above 0.

#2

it means: Attack the enemy if it’s dead :wink:


#3

Doh!

Thanks for the tip. Many eyes make for shallow bugs or in this case many eyes makes it clear that I am not thinking clearly! :slight_smile: