Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

HALP!: The Agrippa Defense!


Hi All, So I can see that there are other posts and people have clearly come up with more ocmplex solutions than me, but I’d like to not risk having the answer HANDED to me by virtue of reading someone else’s post. So if you’re willing to check out my code and give me some insight I’d be incredibly appreciative!

enemy = self.findNearestEnemy()

if enemy:
    pass  # Replace this with your own code.
    enemy = self.findNearestEnemy()
    distance = self.distanceTo(enemy)
if distance < 5:
    if self.isReady("cleave"):

The result is that My toon successfully takes out the first two waves but does nothing for the 3rd.


First things first:

#Whitespace is everything!

The loop only activates if you use the proper indentation.

What happens when there is no enemy? You place the if-statement on distance outside of the if enemy:, so if there is no enemy, the distance is null, which I believe throws an error.

What about throwers? If you only attack when the distance is less than five, and the throwers are more than five meters away, then they can hit you all they want while you do nothing in return.

Lastly, self.shield() takes no arguments. If you want to shield, then cleave, do self.shield(), then self.cleave().


To quote @J_F_B_M

Indentations save lives!

You have to have to proper amount of indentations in python
In JS it is just benificial

1 Like