Help on kelvintalph burgler

def commandTroops():
    chieftain = hero.findNearest(hero.findByType('chieftain'))
    for index, friend in enumerate(hero.findFriends()):
        if chieftain and friend.type != 'paladin':
            continue
        if witch and friend.type != 'paladin':
            continue
        if chieftain and chieftain.pos.x<57 and chieftain.pos.x> 43:
            hero.command(friend, "move", {'x':25, 'y':48})
        elif not chieftain and friend.pos.x<40:
            hero.command(friend, "move", {'x':51, 'y':51})
        elif friend.type == 'paladin':
            CommandPaladin(friend)
        elif friend.type == 'soldier':
            if friend.pos.y>30:
                CommandSoldier(friend)
            
        else:
            CommandArcher(friend)

def CommandPaladin(paladin):
    
    if(paladin.canCast("heal") and not chieftain):
        target = lowestHealthFriend()
        if target:
            hero.command(paladin, "cast", "heal", target)
    elif(paladin.health<100):
        hero.command(paladin, "shield")
    else:
        if witch:
            
                
            hero.command(paladin, "attack", witch)
        elif(chieftain):
            
                
            hero.command(paladin, "attack", chieftain)
        else:
            hero.command(paladin, "move", {"x":78, "y":40})

def CommandSoldier(soldier):
    if witch:
        hero.command(soldier, "attack", witch)
    else:
        hero.command(soldier, "move", {'x':78, 'y':40})

def CommandArcher(soldier):
    if witch:
        hero.command(soldier, "attack", witch)
    else:
        hero.command(soldier, "move", {'x':78, 'y':40})



def lowestHealthFriend():
    lowestHealth = 99999
    lowestFriend = None
    friends = hero.findFriends()
    for friend in friends:
        if friend.health < lowestHealth and friend.health < friend.maxHealth:
            lowestHealth = friend.health
            lowestFriend = friend
    return lowestFriend





while True:
    flag = hero.findFlag("green")
    nearest = hero.findNearest(hero.findByType("paladin"))
    witch = hero.findNearest(hero.findByType('witch'))
    chieftain = hero.findNearest(hero.findByType('chieftain'))
    if witch or chieftain:
        commandTroops()
        
    if flag:
        hero.blink(flag.pos)
        hero.pickUpFlag(flag)

my paladin is not moving to the white X and im using ritic

You copied that code from github, please use orrangial code

As I’ve mentioned before (more than I should have to), please don’t reply on old topics unless you’re looking for help yourself.
I’ve explained it plenty of times…

That sounds like an interesting type of code.

Don’t tell other people to follow the “rules” if you can’t follow them yourself.
Danny

1 Like