Paladins not healing on summits gate


#1
# Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
archers=hero.findByType("archer")
soldiers = hero.findByType("soldier")
paladins = hero.findByType("paladin")
catapults=hero.findByType("catapult")
hero.command(soldiers.pop(0), "attack", catapults[0])
hero.command(soldiers.pop(1), "attack", catapults[1])
stage=1
def findLowestHealth(units):
    lowHealth=999
    lowUnit=None
    for unit in units:
        if unit.health>0 and unit.health<lowHealth:
            lowUnit=unit
            lowHealth=unit.health
            #hero.say(lowUnit)
def allIn():
    while stage==1:
        for soldier in soldiers+archers:
            enemy=soldier.findNearest(soldier.findEnemies())
            #hero.say(enemy)
            if enemy:
                hero.command(soldier, "attack", enemy)
        for paladin in paladins:
            unit1=findLowestHealth(soldiers+archers)
            if unit1:
                hero.command(paladin, "cast", "heal",unit1)
                hero.say('healers!')
        #hero.command(paladin, "move", {"x":paladin.pos.x+1,"y":paladin.pos.y})
        enemy1=hero.findNearestEnemy()
        if enemy1:
            hero.attack(enemy1)
        if enemy1.type=="door":
            stage+=1
    
allIn()

This code runs, but the paladins will not heal anything. Why is that?


#2

you have to first see if the paladin is ready to heal.


#3

the paladins will auto-heal nearby troops
what you should do, instead, is to command the paladins to heal your hero while hero.healht < hero.maxHealth
also,
you should have a function to choose the best target
(ex choose ranged enemies first, catapults and witches and chieftains ahead of ranged enemies, etc. etc.)