Is there a Bug in the Leave It to the Cleaver level?


#1

I’ve tried everything, but no mater what I do when the hero gets to the top two enemy’s spawn and she does nothing, I thought ah i might just be to fast, so i put a move back to the middle and let them come to her. but to no avail she just sits there and lets them attack her when shes attacked the rest. I can’t find much online on this level so im not sure if im doing it correct.

# This shows how to define a function called cleaveWhenClose
# The function defines a parameter called target
def cleaveWhenClose(enemy):
    if hero.distanceTo(enemy) <5:
        pass
        # Put your attack code here
        # If cleave is ready, then cleave target
        hero.isReady("cleave")
        hero.cleave(enemy)
        # else, just attack target!
    else:
        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)

Note it doesn’t work with or without the hero.moveXY in there she will run to the top killing everything and then stop on the last two


#2

also remembered that I changed all the Targets to Enemy but it still does the same even on targets


#4

if hero.distanceTo(enemy) <5:, you have to move the bigger symbol


#5

You have structural issues as well as improper use of the cleave method. After using the cleave method, it has a cool down period and is not always available. Therefore, you must check to see IF your hero is ready to use it. If you click on any of the methods in the middle of the screen, you can see how to use them.

Once you have done this correctly, you will have to tab the else conditional over.


#6

When you check is the hero is ready to cleave, you use hero.isReady("cleave") in a if statement. In the current case, the hero just checks if it is ready to cleave or not, and it attempts to cleave. You also placed the else statement in the area which ignores the distance to enemy


#7

thanks guys, I actually figured it out about an hour after posted this! but i thought i would leave it up due to the lack of information on this level for someone else like me. thanks for the help