can i have help with this definition?
is arch.pos.x not a thing?
def commandArchers():
archer = hero.findByType("archer")
enemy = hero.findNearest(hero.findEnemies())
if archer:
if enemy:
if enemy.pos.x + 25 <= 50 :
hero.command(archers, "attack", enemy)
else:
x = archer.pos.x
y = archer.pos.y
hero.command(archer, "move", { 'x': x, 'y': y})
thx in advance
and if i use,
def commandArchers():
archer = hero.findByType("archer")
enemy = hero.findNearest(hero.findEnemies())
if archer:
if enemy:
if enemy.pos.x + 25 <= 50 :
hero.command(archers, "attack", enemy)
else:
hero.command(archer, "move", archer.pos)
I get a array error on archer in
archer.pos
even though it worked for
if archer:
Bryukh
3
archerS <=> archer
Maybe that’s the problem
1 Like
archer
in this case is an array. So it should be called archers as that is more descriptive of what is being returned.
therefore archer.pos.x
is undefined. however archer[0].pos.x
should be defined if there are archers in game.
2 Likes
ok thanks
funny what you miss sometimes