How do you determine what type of enemies is an array


#1

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


#2

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

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

#3

I mean within an array


#4

Try self.findByType("shaman").


#5

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


#6

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").


#7

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


#8

Chronist’s example is in JS.


#9

So it is. Is there something I am missing?


#10

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