Library tactition/ python/ help [SOLVED]

I can’t keep my units alive and i can’t get them to run away when at low health

# Hushbaum has been ambushed by ogres!
# She is busy healing her soldiers, you should command them to fight!
# The ogres will send more troops if they think they can get to Hushbaum or your archers, so keep them inside the circle!

# Soldiers spread out in a circle and defend.
def commandSoldier(soldier, soldierIndex, numSoldiers):
    angle = Math.PI * 2 * soldierIndex/numSoldiers
    defendPos = {"x": 41, "y": 40}
    defendPos.x += 10 * Math.cos(angle)
    defendPos.y += 10 * Math.sin(angle)
    HealthLowPos = {"x": 42, "y": 41}
    if friend.heatlh < 100:
        hero.command(soldier, "move", HealthLowPos);
        hero.command(soldier, "defend", defendPos);
def findStrongestTarget():
    mostHealth = 0
    bestTarget = None
    enemies = hero.findEnemies()
    enemyIndex = 0
    while len(enemies) > enemyIndex:
        enemy = enemies[enemyIndex]
        if enemy:
            enemyIndex += 1
            for enemy in enemies:
                if > mostHealth:
                    mostHealth =
                    bestTarget = enemy
    if bestTarget and > 15:
        return bestTarget
        return None
archerTarget = None
def commandArcher(archer):
    if bestTarget:
        archerTarget = bestTarget
    nearest = archer.findNearestEnemy()
    if archerTarget:
        hero.command(archer, "attack", archerTarget)
    elif nearest:
        hero.command(archer, "attack", nearest)
while True:
    if > hero.costOf("soldier"):
    if not archerTarget or <= 0:
        archerTarget = findStrongestTarget()
    friends = hero.findFriends()
    soldiers = hero.findByType("soldier")
    archers = hero.findByType("archers")
    for i, soldier in enumerate(soldiers):
        commandSoldier(soldier, i, len(soldiers));
    for i in range(len(archers)):
        archer = archers[i]

found what was wrong and i fixed it the healthlow pos to 42 40 and the health number to 60. I changed friend in

    if friend.heatlh < 100:
        hero.command(soldier, "move", HealthLowPos);

to soldier and that fixed it

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.