Help with targeting specific enemies

I am in the Sarven Brawl, and I have been having trouble targeting specific types of enemies. I want to set up an if statement to target everything but throwers and sand yaks. However, my hero just stands there and doesn’t do anything. Here is an excerpt from my code:

if enemy.type == "thrower":
            hero.attack(enemy)
        elif distance < 15:
            if enemy.type == enemy not "thrower" or "sand-yak":
                hero.attack(enemy)
            else:
                pass
        elif enemy.type == "sand-yak":
            pass

I get an error message at this line

if enemy.type == enemy not "thrower" or "sand-yak":

that says, “Unexpected token: expected expr but found T_NAME while parsing comparison”

Does anyone know what this means or how to fix it? I feel like it’s something really silly that I’m just missing, LMAO.

Hi.
If you just want to do this, you can use a much simpler and error free version (You can’t say if enemy.type == enemy not “x” or “y”):

#something like:
if enemy and enemy.type != "thrower" and enemy.type != "sand-yak":
    #do something
    pass

I understand you may want to do something more confusing with you code, but this is a basic starting point using != (doesn’t equal). You can incorporate distance, elifs, health etc… Whatever you want.
I hope this helps,
Danny

1 Like

Wow, okay. I didn’t even know you could do that, but that certainly makes it much easier. Thank you so much!

My pleasure. :grin: (20 chars)