Bank Raid code not working


#1
# 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]
        hero.attack(enemy)
        # 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.


#2

Use your own solution please @cakepuke.


#3

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.


#4

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


#5

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


#6

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


#7

The coin collecting isn’t working


#8

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


#9

#10

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


#11

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


#12

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.


#13

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


#14

No problem! :slight_smile:


#15

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.


#16

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


#17

It definitely worked. Thanks SuperSmacker!


#18

No Problem! You’re welcome :slight_smile:


#19

u have to add break after enemyIndex
break the loop