I am just stuck on this level everything works fine until the ogre gets the item and my Peon gets it as well, then the hero says there is a enemy at the same position and fires and kills the ogre and the peon as well so that makes me fail the mission.
thank you for your help in advance
here is the code:
while True:
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
if enemy:
enemyPos = enemy.pos.x + " " + enemy.pos.y
hero.say("Enemy at " + enemyPos)
if item:
itemPos = item.pos.x + " " + item.pos.y
hero.say("Gem at " + itemPos)
the cannon shooting the enemy is fine but when the last enemy comes the cannon does not shoot the enemy.
it also shot the fourth enemy twice. Please, can someone help me?
I used your code and it worked fine for me. The only suggestion I can make for improvement would be to carefully compare line 17 with line 8. But even that doesn’t really change/modify the behavior because it’s just a string.
Also, I don’t know if it will make a difference, but I was using the Rough Sense Stone and regular wooden glasses.
while True:
enemy = hero.findNearestEnemy()
if enemy:
enemyPos = enemy.pos.x + " " + enemy.pos.y
hero.say("Enemy at " + enemyPos)
pass
# Now that you have sweet revenge,
# why not have your cake and eat it, too?
# Find the item's position and
# say it for your artillery to target.
item = hero.findNearestItem()
if item:
hero.say("Gem is at " + item.pos.x + ", " + item.pos.y + "!")
pass
The cannon doesn’t shoot the last enemy when its position is mentioned. I believe there’s a bug.
Also, use of the word “peon” in this thread/level is confusing. It means the ogres/enemies, right? OP is calling the peasants who get the gems for us the peons, but on the other hand, they’re the once we should defeat in this level - so the ogres, right?