# The function defines a parameter called target def cleaveWhenClose(target): if hero.distanceTo(target) < 5 and hero.isReady("cleave"): pass # Put your attack code here # If cleave is ready, then cleave target hero.cleave(target) # else, just attack target! else: hero.attack(target) # 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)```
Your code is correct. Make sure you have the right equipment. (Good armor? Correct sword? etc.)
I have to spend gem buying equipment?
Some equipment can be obtained for free in certain levels (the Long Sword itself is one of those items), but most you have to get with gems.