Zero Sum: Raise dead will cause errors on enemies = findEnemies()


#1

raising deads on zero sum with commands like

hero.command(friend, "attack", friend.findNearest(enemies))

will result in errors saying

command's argument minion should have type unit, but got object: Acoldan. Hero Placeholder 1 (team ogres) can't command Acoldan (team humans)

removing the raise dead functions will make the codes run perfectly. This errors only shows when a raise dead was accomplished beforehand (as far as i know). The Acoldan is always different with every run, its most likely the name of the enemy units.

Here’s my code snip

while True:
    enemies = hero.findEnemies()
    nearestEnemy = hero.findNearest(enemies)    
    enemyHero = hero.findNearest(hero.findByType("sorcerer",enemies))
    
    friends = hero.findFriends()
    # In case theres a python error from codecombat
    friends.remove(hero.findByType("cage"))
    friends.remove(hero.findByType("yeti"))
    while True:
        if nearestEnemy:
            if hero.distanceTo(nearestEnemy) < 20 and hero.isReady("mana-blast"):
                hero.manaBlast()
                summon("soldier",5)
            elif len(hero.findByType("griffin-rider")) < 3:
                if summon("griffin-rider") == False:
                    break
            else:
                break
        else:
            break
    
    if len(hero.findByType("artillery")) < 1:
        summon("artillery")

    for friend in friends:
        cage = hero.findByType("cage")
        # Please don't mess with the cage
        if cage:
            enemies.remove(cage[0])
        nearest_to_friends = friend.findNearest(enemies)
        hero.command(friend, "attack", nearest_to_friends)
    
    # Raise Dead Corpses
    if hero.isReady("raise-dead"):
        corpses = hero.findCorpses()
        if len(corpses) >= 1:
            undead_army = []
            for corpse in corpses:
                if hero.distanceTo(corpse) < 20:
                    undead_army.append(corpse)
                if len(undead_army) >= 5:
                    hero.cast("raise-dead")
                    break

#2
  1. Try to just take one blocking action each iteration during the loop (moving, casting a spell, attacking etc.), after you command your troops. You don’t want to be trying to command a stale friend variable that used to be on your team but is now on the enemy team because in between when you got the reference and tried to command it, it died and was brought back as an enemy.

  2. Check the types of your friends and don’t command ones that you shouldn’t be able to command.

Hope this helps!