# Wait for ogres, defeat them and collect gold.
while True:
enemies = hero.findEnemies()
# That variable is used to iterate "enemies" array.
enemyIndex = 0
# While it less than the array length:
while enemyIndex < len(enemies):
# Get an enemy from the array.
enemy = enemies[enemyIndex]
hero.attack(enemy)
# Increase "enemyIndex" by one.
enemyIndex += 1
coins = hero.findItems()
# That variable is used to iterate "coins" array.
coinIndex = 0
while coinIndex < len(coins):
# Get a coin from the "coins" array at coinIndex.
coin = coins[coinIndex]
# Collect that coin.
hero.moveXY(coin.pos.x, coin.pos.y)
# Increase "coinIndex" by one.
coinIndex = coinIndex + 1
pass
But for some reason my hero just sits there and doesn’t collet the coins.
my solution (in spanish, i translate all text i can to my native language, including comments and variables) was using the warrior :
# Espera por los ogros, derrotales y recoge oro.
while True:
Enemigos = hero.findEnemies()
# IndiceDeEnemigos es usado para iterar el arreglo Enemigos
IndiceDeEnemigos = 0
# Mientas IndiceDeEnemigos es menor que len(Enemigos)
while IndiceDeEnemigos < len(Enemigos):
# Atacar a los enemigos en IndiceDeEnemigos
Enemigo = Enemigos[IndiceDeEnemigos]
hero.isReady("cleave") and hero.cleave(Enemigo)
# Incrementar IndiceDeEnemigos en uno.
IndiceDeEnemigos += 1
Monedas = hero.findItems()
#DILO#hero.say("Monedas= " + Monedas.length)
# Monedero es usado para iterar el arreglo Monedas
Monedero = 0
while Monedero < len(Monedas):
# Recoge una moneda de las monedas usando el arreglo Monedero
Moneda = Monedas[Monedero]
# Recoge esa moneda
hero.moveXY(Moneda.pos.x, Moneda.pos.y)
# Incrementa el Monedero en 1
Monedero += 1
For some strange reason, if i try to use hero.attack instead hero.isReady(“cleave”) and hero.attack(“cleave”)
When the hero defeat the enemies and the coins appears, the warrior, don’t move to pick up coins.
but when i change attack method for cleave, the hero yes pick up the cleave, but i don’t understand why.