Woodland Cleaver Target Issue


#1

I’m attempting to complete “Woodland Cleaver”, but it continues to call my target “enemy” null, despite the fact that the enemy is identified at the beginning of the loop and the code runs properly for half the level before locking down and failing because of this issue.

The code I have is as follows, including the sample code and text.

# Use your new "cleave" skill as often as you can.

self.moveXY(23, 23)
loop:
    enemy = self.findNearestEnemy()
    if self.isReady("cleave"):
        # Cleave the enemy!
        self.cleave(enemy)

    else:
        # Else (if cleave isn't ready), do your normal attack.
        self.attack(enemy)

I’ve looked around and based on the posts in the main topic for Woodland Cleaver, and the sample text of the level, this seems like it should be the proper solution.

EDIT: I’ve managed to bypass this by creating a larger “if” and putting it around the if/else statements already in place so that it only performs them if an enemy is present.


#2

I, too, was having this same issue. My solution was to remove the self.moveXY at the beginning of the code. Hope this helps someone else.


#3

Thanks for the heads up on this one, guys. I’ve tuned the visibility and spawn rates a bit such that you’re less likely to kill all the enemies early and then error out on a null target. In general, surrounding things like this in an if to make sure there is an enemy there is a great tactic! We just wanted this one to be easier, so hopefully now it is.


#4

Another thing is happening because it keeps saying there is a problem with the the beginning code, it keeps saying please put in 4 spaces and also puts in error invalid token. I have checked everything but nothing is working. Please help.


#5

The sample code has the problem because there is an empty if statement in it. You need to fill in the if statement body on like 8 and the else statement body on line 11, and then it will be complete and stop giving a warning.


#6

Ran into this issue today, below is my code, received the null target error and was able to successfully complete by running the code a second time:

 # Use your new "cleave" skill as often as you can.

 self.moveXY(23, 23)
 loop:
     enemy = self.findNearestEnemy()
     if self.isReady("cleave"):
         # Cleave the enemy!
         self.cleave(enemy)
    
     else:
         # Else (if cleave isn't ready), do your normal attack.
         self.attack(enemy)

#7

Hey Michael, what hero/weapon/boots were you using?