Kelvintaph Burgler helpp[SOLVED]

hero not moving at flag pos bug???





def lowHp():
    friends = hero.findFriends()
    for friend in friends:
        if friend.health <= friend.maxHealth / 2:
            pass


def comPal(paladin):
    lH = lowHp()
    friend = hero.findFriends()
    enemy = paladin.findNearestEnemy()
    if friend.health <= lH:
        if paladin.canCast("heal", friend):
            hero.command(paladin, "cast", "heal", friend)
        elif enemy.health > 0:
            hero.command(paladin, "attack", enemy)

def comGriff():
    if hero.gold >= hero.costOf("griffin-rider"):
        # lesgoo command giffin-rider
        hero.summon("griffin-rider")
        friends = hero.findFriends()
        enemy = hero.findNearestEnemy()
    for friend in friends:
        if enemy.health > 0:
            hero.command(friend, "attack", enemy)

while True:
    flag = hero.findFlag()
    friends = hero.findFriends()
    enemy = hero.findNearestEnemy()
    if flag:
        hero.move(flag.pos)
        
    for friend in friends:
        if friend.type == "griffin-rider":
            if enemy.type == "robot-walker":
                comGriff()
        elif friend.type == "paladin":
            comPal()
        elif friend.type == "archer" and friend.type == "soldier":
            if enemy.type == "chieftain":
                hero.command(friend, "attack", enemy)
        
    hero.command(friend, "move", {'x': 32, 'y': 57})
    hero.command(friend, "move", {'x': 26, 'y': 57})
    hero.command(friend, "move", {'x': 30, 'y': 52})
    hero.command(friend, "move", {'x': 54, 'y': 59})
    hero.command(friend, "move", {'x': 76, 'y': 57})
    hero.command(friend, "move", {'x': 78, 'y': 40})
    if enemy.type == "robot-walker" and enemy.health == 0:
        hero.moveXY(76, 14)
    
    
        


I think you should specify the flag’s colour. I think, not sure tho

2 Likes

Yes, you’re right.It should be

hero.findFlag('[flag color]')
2 Likes

ok (20charsaqwadwf) 20(chars

and one more thing. i get error Try use "hero.findNearestEnemy()"

def comPal(paladin):
    lH = lowHp()
    friend = hero.findFriends()
    enemy = paladin.findNearestEnemy()
    if friend.health <= lH:
        if paladin.canCast("heal", friend):
            hero.command(paladin, "cast", "heal", friend)
        elif enemy.health > 0:
            hero.command(paladin, "attack", enemy)

@Aya @Anonym

It is possible paladin doesn’t have property findNearestEnemy()

Also, there is another problem,

this returns a list, so what you should do is either make a for-loop or get a certain index like this friend = hero.findFriends()[number]

like this eh? friend = hero.findFriends()[1]??

Hint: from which number do indexes start in Python?

i don’t know what do you mean

Do they start from 1 or a different number 0

0 (200000 charsssssss)

1 Like

bruh still get error (20chars)

Can you please post your new code? And the error

1 Like
def comPal(paladin):
    lH = lowHp()
    friend = hero.findFriends()[0]
    enemy = paladin.findNearestEnemy()
    if friend.health <= lH:
        if paladin.canCast("heal", friend):
            hero.command(paladin, "cast", "heal", friend)
        elif enemy.health > 0:
            hero.command(paladin, "attack", enemy)

Sorry, I was offline.
friend = hero.findFriends()[number] do like this

and i get the same errorr

ah, i see.Ok, have you tried for loop?

oh ok i try (20chars)

still.

def comPal(paladin):
    lH = lowHp()
    friends = hero.findFriends()[0]
    enemy = paladin.findNearestEnemy()
    for friend in friends:
        if friend.health <= lH:
            if paladin.canCast("heal", friend):
                hero.command(paladin, "cast", "heal", friend)
            elif enemy.health > 0:
                hero.command(paladin, "attack", enemy)