Stuff is broken on backwoods treasure 7

on backwoods brawl, I use these:
image
and my code does nothing

#Commented out to stop infinite loop.
# Stay alive for one minute.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.
def wait(boba):
    for bob in range(boba):
        hero.moveXY(hero.pos.x,hero.pos.y)
while True:
    enemy = hero.findNearestEnemy()
    if hero.isReady("summon-burl"):
        hero.cast("summon-burl")
    if hero.isReady("summon-yeti"):
        hero.cast("summon-yeti")
    if hero.isReady("summon-undead"):
        hero.cast("summon-undead")
    
    if hero.gold > 20:
        soldier = hero.summon("archer")
    b = hero.findFriends()
    for a in b:
        if a.type == "archer":
            if hero.findNearestEnemy():
                hero.command(a, "defend", hero)
    
    if enemy:
        if hero.isReady("magnet-field") and hero.isReady("poison-cloud"):
            
            hero.cast("magnet-field", enemy.pos)
            hero.cast("poison-cloud", enemy.pos)
        if hero.canCast("chain-lightning"):
            hero.cast("chain-lightning", hero.findNearestEnemy())
            continue
        if hero.canCast("raise-dead"):
            hero.cast("raise-dead")
            
        elif hero. canCast("drain-life") and hero.distanceTo(enemy) <15:
            hero.cast("drain-life", enemy)
 

What is the def wait(boba) function for? There is already a wait function, that might be causing a bug. Otherwise I see nothing else that would cause a glitch, except maybe the space in
hero. canCast("drain-life")

ok sorry for off-topic but what is that helmet?

viking helmet, it gives 50 health but triples bash knockback

where do you get it?

A deleted level it’s not that good

That level was deleted?
It was called viking something right

ya i forgor though (20 chars)

I dont have wait gear so I just made one for myself XD

Oh then I dunno why else your code would’nt work besides that space in hero. canCast("drain-life")

yeah i fixed it. thanks a bunch

I run it but hero does nothing
:face_with_raised_eyebrow:

Yay it got deleted cuz it was too hard but you can still get it by going to the link but I don’t know what it was called

i tried checking history but not work. daggggg

I looked it up, its called “Lost Viking.”

Back on topic, maybe try removing the continue, and the soldier = in
soldier = hero.summon("archer")?

sorry, new updated code:

# Collect 100 gold from two or three groves.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
hero.moveXY(27, 25)
def function(enemy):
    #if hero.isready("warcry"):
    #    hero.warcry()
    friends = hero.findFriends()
    enemy = hero.findNearestEnemy()
    if enemy:
        if enemy.health > 140:
            hero.attack(enemy)
    for friend in friends:
        if friend.type == 'yeti' or friend.type == 'skeleton':
            if hero.findNearestEnemy():
                hero.command(friend, 'attack', hero.findNearestEnemy())
            else:
                hero.command(friend, 'move', hero.pos)
    
    if hero.isReady("summon-burl"):
        hero.cast("summon-burl")
    if hero.isReady("summon-undead"):
        hero.cast("summon-undead")
    if hero.isReady("raise-dead") and enemy:
        hero.cast("raise-dead")
    if hero.isReady("summon-yeti"):
        hero.cast("summon-yeti")
        
#    if hero.isReady("chain-lightning"):
#        if hero.findNearestEnemy() and hero.distanceTo(hero.findNearestEnemy()) < 45:
#            hero.cast("chain-lightning", hero.findNearestEnemy())


def optimalCoin():
    items = hero.findItems()
    optimalItem = items[0]
    for item in items:
        if (item.value)/hero.distanceTo(item.pos) > optimalItem.value/hero.distanceTo(optimalItem.pos) and not (item.pos.x > 40 and item.pos.y > 34):
            optimalItem = item
    
    for friend in hero.findFriends():
        if friend.type == 'yeti':
            hero.command(friend, 'move', optimalItem.pos)
    hero.moveXY(optimalItem.pos.x, optimalItem.pos.y)

while True:
    enemy = hero.findNearestEnemy()
    item = hero.findNearestItem()
    coin =  function(enemy)
    
    if enemy:
        function()
    if item:
        if item.pos.x < 39:
            optimalCoin()
        else:
            optimalCoin()
            #hero.moveXY(22, 21)
    else:
        hero.moveXY(22, 25)
        hero.moveXY(18, 26)

No problem. There are two possibilities from what I’ve seen.
Below, the hero kept going between the two points and then stopping when I tested it on a level without coins. So it might be the case when there are no items currently spawned in the level.

if enemy:
        function()
    elif item:
        if item.pos.x < 39:
            optimalCoin()
        else:
            optimalCoin()
            #hero.moveXY(22, 21)
    else:
        hero.moveXY(22, 25)
        hero.moveXY(18, 26)

However, when I put it in the backwoods brawl, the hero just dies to ogres so it might be something else that is causing it.
The other is that the coin = function(enemy) may be causing issues when the hero is trying to do something else.

wait whoops. I did a smolbrain. The level is actuallly backwoods treasure

Oh lol no problem, I didn’t even notice; I still went to Backwoods Treasure when I saw the # Collect 100 gold from two or three groves. My backwoods treasure is advanced enough that I die before being able to do very much.