Bank Raid code not working

# Wait for ogres, defeat them and collect gold.

while True:
    enemies = hero.findEnemies()
    # enemyIndex is used to iterate the enemies array.
    enemyIndex = 0
    # While enemyIndex is less than len(enemies)
    while enemyIndex < len(enemies):
        # Attack the enemy at enemyIndex
        enemy = enemies[enemyIndex]
        # Increase enemyIndex by one.
        enemyIndex += 1
    coins = hero.findItems()
    # coinIndex is used to iterate the coins array.
    coinIndex = 0
    while coinIndex < len(coins):
        # Get a coin from the coins array using coinIndex
        coin = coins[coinIndex]
        # Collect that coin.
        hero.moveXY(coin.pos.x, coin.pos.y)
        # Increase coinIndex by one.
        coinIndex += 1

I’ve tried copying and pasting online solutions to this level and the same thing happens. The hero would kill the enemies but not collect coins. Please help.

Use your own solution please @cakepuke.

I did use my own solution, and the code posted is my own. I’m just saying that I tried searching up answers before asking and they didn’t work either.

@cakepuke Your code looks perfectly fine. There are no problems when I run it.
Are you wearing glasses that can use the findItems() function?

Yes .-.
I’m using the crude telephoto glasses (the level made me buy them)

@cakepuke what is not working for you? is it coin collecting, killing enemies, or is your hero dying?

The coin collecting isn’t working

is your hero getting an error message? or is it just not collecting the coins? videos would be nice :slight_smile:

Sorry for terrible quality, I had to edit out the loading part cause imgur wouldn’t let you upload gifs over 30 seconds. I rendered using internet settings for the quality lol

It’s not collecting the coins but the hero does say “But it’s already dead!”

it’s already dead means your hero is attempting to attack an enemy you have already killed. I’m trying to form the same conditions you have and see what’s wrong.

Oh. Thanks for the help and effort you’re putting into this

No problem! :slight_smile:

I understand now.
It’s because you equipped the thornprick ring does the damage reflection thing and kills your enemies.
Because of the ring, your hero can’t attack them since they are already dead.
Just unequip the ring and u’ll beat the level.

1 Like

What -_- Okay, thanks I’m going to take it off.

It definitely worked. Thanks SuperSmacker!

No Problem! You’re welcome :slight_smile:

u have to add break after enemyIndex
break the loop

my hero wont collect coins
(working code, had to delete).