Help me i can not beat this level
here is my code
enemies = hero.findEnemies()
def cleaveWhenClose(target):
if hero.distanceTo(target) < 5:
hero.attack(enemy)
hero.attack(enemy)
if hero.isReady(“cleave”):
hero.cleave(enemy)
else:
hero.attack(enemy)
hero.attack(enemy)
This code is not part of the function.
while True:
enemy = hero.findNearestEnemy()
if enemy:
# Note that inside cleaveWhenClose, we refer to the enemy
as target
.
cleaveWhenClose(enemy)
help me @discobot here is my code enemies = hero.findEnemies()
def cleaveWhenClose(target):
if hero.distanceTo(target) < 5:
hero.attack(enemy)
hero.attack(enemy)
if hero.isReady(“cleave”):
hero.cleave(enemy)
else:
hero.attack(enemy)
hero.attack(enemy)
This code is not part of the function.
while True:
enemy = hero.findNearestEnemy()
if enemy:
# Note that inside cleaveWhenClose, we refer to the enemy
as target
.
cleaveWhenClose(enemy)
Could you format your code property using the button </> so we can help you?
``enemies = hero.findEnemies()
def cleaveWhenClose(target):
if hero.distanceTo(target) < 5:
hero.attack(enemy)
hero.attack(enemy)
if hero.isReady(“cleave”):
hero.cleave(enemy)
else:
hero.attack(enemy)
hero.attack(enemy)
This code is not part of the function.
while True:
enemy = hero.findNearestEnemy()
if enemy:
# Note that inside cleaveWhenClose, we refer to the enemy
as target
.
cleaveWhenClose(enemy)
`
enemies = hero.findEnemies()
def cleaveWhenClose(target):
if hero.distanceTo(target) < 5:
hero.attack(enemy)
hero.attack(enemy)
if hero.isReady("cleave"):
hero.cleave(enemy)
else:
hero.attack(enemy)
hero.attack(enemy)
# This code is not part of the function.
while True:
enemy = hero.findNearestEnemy()
if enemy:
# Note that inside cleaveWhenClose, we refer to the `enemy` as `target`.
cleaveWhenClose(enemy)
there i did it corectly
Here and here
Put enemy instead of target and it should work fine.
what do you mean?
did i get the wrong code?
it says i have a problem with this line
if hero.isReady("cleave"):
No. Try to change what I just told you to + this:
In the place of
put
if hero.isReady("cleave"):
hero.cleave(enemy)
else:
hero.attack(enemy)
Can you show me your equipment?
THANK YOU SO MUCH. Would you like to join my clans?
Do not worry i only have 2 clans
What clan are you talking about? Please respond me in this topic