[SOLVED] Sarven brawl help

what would I do with that?

Not quite, you are still using boss now for both variables. The variable used in the for loop is a temporary variable just for that loop. You can use whatever you want, just a long as it is not a variable used somewhere else in your code. The temporary variable does not have to be defined before the loop.

for temporaryVariable in enemies:

Also, you don’t need the two lines if you are focusing on the array (list) of enemies. And to explain what ducky was suggesting, you can check if the enemy is a sand-yak to skip over it, or you may accidentally attack it. See Below.

while True:
    enemies = hero.findEnemies
    for boss in enemies:
        if boss.type == "sand-yak":  # if it is a sand-yak, it will skip over and not attack
            continue
        elif hero.distanceTo(boss) < 5:
            hero.attack(boss)
        elif enemy.type == "thrower" or enemy.type == "ogre":
            hero.attack(boss)

If you want to use the other method too, assign a different variable name.

nearEnemy = hero.findNearestEnemy()

This is my final code that worked so this topic is solved.(I can’t solve it I don’t think

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        if enemy.type == "sand-yak": 
            hero.moveXY(25, 75)
            continue
        elif hero.distanceTo(enemy) < 5:
            hero.attack(enemy)
        elif enemy.type == "thrower" or enemy.type == "ogre":
            hero.attack(enemy)

Now replay the level and see how you do with the increased challenge. :thinking:

hi can someone help me

What do you need help with? :slight_smile: (summon me to your topic using @Rachel699)