List of Enemy Types?


#1

I’m having trouble targeting enemies by type in the level i’m working on, because i don’t know the names of the enemy types, and the specific type i’m trying to kill I can’t target to learn its type with self:say(enemy.type).

Specifically i’m working on clash of clones and would like to target the archers.
i’ve tried “archer”, “ranger”, and “thrower”, and none of them work.

However, is there a handy reference where one can look up what each type of enemy is? If not, can someone provide a list of enemies and their types?


#2

You could click on an enemy to see it’s type (basically you click on a unit, then at the bottom it shows that unit’s portrait, name, and type like this):

Just make sure to lowercase the name when you check with unit.type or findByType(type).


#3

I figured it would be something simple like this. thank you


#4

On the level Clash of Clones the enemy has the same type of units as you, so you would first need to find your enemies, and then identify the different types:

enemyArchers = self.findByType("archer", self.findEnemies())

If you don’t have the findByType() method, you can do it this way:

enemies = self.findEnemies()
enemyArchers = []
for enemy in enemies:
    if enemy.type == "archer":
        # append it to the list
        enemyArchers.append(enemy)

Or with list comprehension (warning! advanced trickery! :smile:)

enemyArchers = [enemy for enemy in self.findEnemies() if enemy.type == "archer"]

#5

this is helpful, thank you, but what if you do not know the enemy unit type? Like for example a yak, which type would that be?


#6

it would be a yak. that’s the enemy type. The name is the enemy type itself.


#7

If you don’t know the enemy type, just click on it, as explained about 3 comments above


it would be a yak. that’s the enemy type. The name is the enemy type itself.
[/quote]
Wrong. The enemy type for yaks is “sand-yak”.


#8

Yeah that’s what I meant, thanks for clearing that up! :+1: