findEnemies function


Hi, I’m a bit new here, and new to programming in general. I wanted to know what information the findEnemies function returns, specifically if I can get the enemy’s type/class from it.



The function returns an array (a list) of all enemies the hero can see. Each entry of the list will be addressed by a number, (called index) it contains information about the enemy,as id/name, pos /position, type etc.
Go through the sarven desert levels and look at the HINTS (blue button) thoroughly to learn more.


@user1, I’m still pretty far from the desert, but I already have the glasses that let me findEnemies. I’m still figuring out how the functions work, but if I wanted to code my hero into attacking by class in a loop, how would I do it with that? It’s start off with:


and then would probably need to set a variable, maybe:

longRangeAttacker = enemy.type(Thrower)

Then, finally


I strongly suspect that I’m setting up the middle code wrong, though. Help much appreciated.


Well, you would need to understand the concept of array if you really wanted to use that.
But here some examples (not tested, hope they work)

Some examples:

hero.attack(e[0]) #attacks first enemy (has index 0)

#Now do some stuff with all enemies in list:
while i<len(e): # do the following for all enemies from e[0] up to the last one
    hero.say(e[i].id) #greet your enemy
    hero.moveXY(e[i].pos.x, e[i].pos.y) #pay him a visit
    if e[i].type="thrower":
        hero.say("there is a thrower on the loose...")
    i=i+1  #increment your index, to get the next enemy in the next iteration of the while-loop

But as said before - I would really recommend to go through the main path in sarven desert to get a full tutorial on how to uses arrays and while loops…


I’ve sharpened my skills a bit, and think I have an easier way of doing what I wanted, not that I articulated that so clearly. What I wanted was a way to code in how to have my hero prioritize attacking a particular type of enemy. If you have glasses good enough, then this works:

while True:
    thrower = hero.findByType("thrower", hero.findEnemies())
    enemy = hero.findNearestEnemy()
    if thrower:
    elif enemy:


also the array if you do not know already starts at 0 not 1 like in some block coding programs.