So I am having trouble doing the code can I get some help

then the hero will know that he/she can cleave so then the hero can cleave if the hero cannot cleave then it will attack

2 Likes

tell me if it works @kayden4444

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

no but I changed the code i was using.

sorry I could only text a certain amount of texts so ya

in my opinion, you should restart the level

I did (20Characters)

and I’ll help you build the code

def cleaveWhenClose(target):
    if hero.distanceTo(target) < 5:
        pass
        # Put your attack code here
        # If cleave is ready, then cleave target
        if enemy:
            hero.cleave(enemy)
        # else, just attack `target`!
        else:
            hero.attack(enemy)

he does not attack!

so first put a
while true loop at the top

def cleaveWhenClose(target):
    if hero.distanceTo(target) < 5:
        pass
        # Put your attack code here
    while True:
        # If cleave is ready, then cleave target
        if enemy:
            
            hero.cleave(enemy)
        # else, just attack `target`!
        else:
            
            
            hero.attack(enemy)

I mean at the very top above the

1 Like
cleaveWhenClose
while True:
    # The function defines a parameter called `target`
    def cleaveWhenClose(target):
        if hero.distanceTo(target) < 5:
            pass
        # Put your attack code here
    
        # If cleave is ready, then cleave target
    if enemy:
            
            hero.cleave(enemy)
        # else, just attack `target`!
    else:
            
            
            hero.attack(enemy)

delete

at the very top

1 Like
while True:
    # The function defines a parameter called `target`
    if hero.distanceTo(target) < 5:
            pass
        # Put your attack code here
    
        # If cleave is ready, then cleave target
    if enemy:
            
        hero.cleave(enemy)
        # else, just attack `target`!
    else:
            
            
        hero.attack(enemy)

under

put enemy = hero.findNearestEnemy()

1 Like
while True:
    enemy = hero.findNearestEnemy()
    # The function defines a parameter called `target`
    if hero.distanceTo(target) < 5:
            pass
        # Put your attack code here
    
        # If cleave is ready, then cleave target
    if enemy:
            
        hero.cleave(enemy)
        # else, just attack `target`!
    else:
            
            
        hero.attack(enemy)
if hero.distanceTo(target) < 5:
            pass

It is giving me trouble.

your not finished yet

1 Like

replace 200000000000000

with

1 Like