Stranded in the Dunes freezes

This is my code:

while True:
    
    flag = hero.findFlag()
    enemy = hero.findNearestEnemy()
    friend = hero.findFriends()
    
    if flag:
        hero.moveXY(flag.pos.x, flag.pos.y)
        hero.pickUpFlag(flag)
        
    if hero.canCast("summon-burl"):
        hero.cast("summon-burl")
    if hero.canCast("summon-undead"):
        hero.cast("summon-undead")
    if hero.canCast("raise-dead"):
        hero.cast("raise-dead")
    
    if enemy:
        if enemy.type != "yak":
            
            if hero.canCast("summon-burl", enemy):
                hero.cast("summon-burl")
            if hero.canCast("summon-undead", enemy):
                hero.cast("summon-undead")
            if hero.canCast("raise-dead", enemy):
                hero.cast("raise-dead")
            if hero.canCast("poison-cloud", enemy):
                hero.cast("poison-cloud", enemy)
            if hero.canCast("mana-blast", enemy):
                hero.manaBlast()
            if hero.canCast("reset-cooldown", enemy):
                hero.resetCooldown("mana-blast")
                
            else:
                hero.attack(enemy)
   

I get to the skeleton - king every time and on the first potion the raven drops the game freezes.

Please help

That is formal. Try reloading the page.

@Chaboi_3000 thanks but it doesn’t work. If I reload the page it reloads the level. Sometimes when it freezes it kicks me out of the game.

Hmm. did you try looking into the javascript console and reload the cache.

Just tried it, it got me a little further along but on the third potion the raven dropped it froze once again.

You have too many skeletons maybe?

Yeah it could be, not sure how to keep the number low though. Any suggestions?

Try using different flags so maybe black ones to summon skeletons and green for attacking.