How do you determine what type of enemies is an array

I am trying to find a shaman in an array of enemies and I forgot how to do could someone please tell me how to do this

I believe you can use enemy.type. For example:

if enemy.type == "shaman":
    # do stuff
1 Like

I mean within an array

Try self.findByType("shaman").

I know that, for my strategy to work in need to find the shamens(shamen?) in the array

I’m interpreting your question in a couple different ways:

1: You want to find shamans inside an array of enemies:


var enemies = this.findEnemies();
for (enemyIndex = 1;,enemyIndex < enemies.length;,enemyIndex++) {
    if (enemies[enemyIndex].type == "shaman") {
        // do stuff

2: You want to make an array of shamans from an array of enemies:

Simply use this.findByType("shaman").

I was intending to do the first one and I need this in Js please

Chronist’s example is in JS.

So it is. Is there something I am missing?

hmm ithough it had no semi colons so i though it was python but it appears that i was mistaken