-While, if loop-

enemy = hero.findNearestEnemy()
while True:
    if hero.attackRange > 30:
        hero.attack(enemy)

hi there,
I am in a dungeon and there are waves of mobs. If I try this :arrow_upper_left:, then my hero don’t attack. Does anybody know why?
I am doing this in python and I want to do it with while and if loop.

What level is this? I do not reconcnize it

Put instead of that the variabile enemy.
Oh, and put this

Before the if in the while True loop.
I think those are the problems. Does it work now?

thanks, I see range 30 is quite a lot :smiley:

Instead of using attackRange, how about trying distanceTo? Your attackRange will be constant…the distanceTo will be totally variable.

ok, I will try if I have a better wand :wink:

a sword can only strike 3 meters, the hero will never attack because it’s attackRange is always 3 meters

The last job I had, a customer gave me some tips so I have the premium version now and can use a magic person :smiley: If I play Games where there are wizards, I always use them :smiley: a mix between slow down and necro is very mighty :smiley: and blood heal tricks let you stay alive. Now I have to save 6300 gems for my favorite char in this game :wink:

1 Like