Hello fellow code combatants,
I’m using Python, and have reached the Backwoods Standoff level. After several unsuccessful tries I present the unknown problem to you.
Thank you in advance.
Here is my code:
while True:
enemy = hero.findNearestEnemy()
# Use an if-statement with isReady to check “cleave”:
if enemy:
# Cleave!
ready = hero.isReady("cleave")
hero.isReady("cleave")
# Else, if cleave is not ready:
else:
# Attack the nearest ogre!
hero.attack(enemy)
Carefully read the comments -
This is the proper format for cleave:
if enemy:
if hero.isReady("cleave"):
hero.cleave(enemy)
else:
hero.attack(enemy)
Memorize it. You’re going to be seeing this A LOT!
@MunkeyShynes Thank you for replying so promptly!
I used your suggestion. Cleave works, and my character runs to the enemy, but unless cleave is ready, does no harm to them.
How come my hero.attack(enemy) doesn’t work, do you know?
~Toskaduende
Can you post a screenshot of your code? It sounds like the else statement isn’t tabbed over properly. It’s probably a structure problem.
I’ve tried moving hero.cleave(enemy) down for spaces, as another post suggests, but that didn’t work.
~Toskaduende
That’s what I thought. The else statement should line up under the if hero.isReady statement.