hello, plz help me
I know this was solved but I tried all the solutions and it didn’t work.
Utilise ton nouveau pouvoir pour choisir ce que tu dois faire : hero.time
while True:
# Durant les 10 premières secondes : se battre.
if hero.time < 10:
if enemy:
enemy = hero.findNearestEnemy()
hero.moveXY(enemy.pos.x, enemy.pos.y)
hero.attack(enemy)
pass
# Sinon, si on est toujours dans les 35 premières secondes, ramasser des Pièces.
elif hero.time < 35:
coin = hero.findNearestItem()
if coin :
hero.moveXY(coin.pos.x, coin.pos.y)
pass
# Après 35 secondes, rejoindre le raid !
else:
enemy = hero.findNearestEnemy()
if enemy:
enemy = hero.findNearestEnemy()
hero.moveXY(enemy.pos.x, enemy.pos.y)
hero.attack(enemy)
if hero.isReady("cleave"):
hero.cleave(enemy)
pass
You don’t need to move to the enemy’s position as calling hero.attack() will move you in range of attacking the enemy.
In the start of your code, you never define enemy, so you are checking if there is something that hasn’t been defined yet. You need to find the nearest enemy before you check if it exists and after you check if your hero’s time is less than the value 10. The next thing you need to fix is within your if loops checking for enemy, don’t define enemy again inside of the if loops. you only need to define enemy once within each fighting time period before checking if an enemy exists.
In this part above, you want to check if the hero is ready to cleave first, if he is ready, then cleave. Otherwise (else statement), you need to just attack an enemy.