Here are mu codes. It throw but it wont shoot arrows once enemy get close
loop:
enemy = self.findNearestEnemy()
if enemy:
if self.isReady("throw"):
distance = self.distanceTo(enemy)
# Only throw if the ogres are more than 15m away.
# Use "if" to compare distance to 15.
if distance > 15:
self.throw(enemy)
# Use "else" to attack if you're not throwing.
else:
self.attack(enemy)
Hard to be sure what the issue might be - is it possible to get all the code into the code format?
Its possible everything is inside the isReady if block?
The codes are properly indented. It just wont show up here. Now everything works fine using the same code, The arrows are firing when the enemies get close. However, by the time the third group of ogres arrived, I keep dying because it only fire once and just stood there doing nothing waiting for the ogre club me to death. Why is it not going through the loop progression and fire again?
This is what I did and it seems to work for a while but (spolier alert ) my character dies at the end still…just can’t think what I’d need to do to fix it. Any help appreciated pls. (i have tried to emulate the expected Indentation.
while True:
enemy = hero.findNearestEnemy()
if enemy:
if hero.isReady("Throw"):
distance = hero.distanceTo(enemy)
if distance > 15:
hero.throw(enemy)
else:
if distance < 15:
hero.attack(enemy)