Restless dead codecombat help

Rider not moving or attack

`summonTypes = ['paladin']


def attack(enemy):
    if enemy:
        while (enemy.health > 0):
            if (hero.distanceTo(enemy) > 10):
                hero.move(enemy.pos)
            elif (hero.isReady("bash")):
                hero.bash(enemy)
            elif (hero.canCast('chain-lightning', enemy)):
                hero.cast('chain-lightning', enemy)
            else:
                hero.attack(enemy)


def summonTroops():
    type = summonTypes[len(hero.built) % len(summonTypes)]
    if hero.gold > hero.costOf(type):
        hero.summon(type)


def commandTroops():
    for index, friend in enumerate(hero.findFriends()):
        if friend.type == 'paladin':
            CommandPaladin(friend)


def CommandPaladin(paladin):
    if (paladin.canCast("heal") and hero.health < hero.maxHealth * 0.6):
        hero.command(paladin, "cast", "heal", hero)
    else:
        hero.command(paladin, "defend", hero)


def collectItems():
    item = hero.findNearestItem()
    while item:
        hero.move(item.pos)
        item = hero.findNearestItem()


hero.moveXY(55, 10)
hero.wait(2)
attack(hero.findNearestEnemy())
collectItems()
hero.moveXY(55, 33)
hero.moveXY(49, 37)
hero.moveXY(19, 40)
for i in range(1, 20):
    summonTroops()
commandTroops()
hero.moveXY(55, 48)
while True:
    attack(hero.findNearestEnemy())
    commandTroops()
    collectItems()`

need help quickly 20 characters

its because you do not have a commanding line for griffins

there is also a apostrophy at the start—> image

2 Likes
def attack(enemy):
    if enemy:
        while (enemy.health > 0):
            if (hero.distanceTo(enemy) > 10):
                hero.move(enemy.pos)
            elif (hero.isReady("bash")):
                hero.bash(enemy)
            elif (hero.canCast('chain-lightning', enemy)):
                hero.cast('chain-lightning', enemy)
            else:
                hero.attack(enemy)

summonTypes = ['griffin-rider']
def summonTroops():
    type = summonTypes[len(hero.built)%len(summonTypes)]
    if hero.gold >= hero.costOf(type):
        hero.summon(type)

    
def collectItems():
    item = hero.findNearestItem()
    while item:
        hero.move(item.pos)
        item = hero.findNearestItem()
def comGrif(griff):
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.command(griff, "attack", enemy)
    else:
        hero.move(hero.pos)

def commandTroops():
    for index, friend in enumerate(hero.findFriends()):
        if friend.type == 'griffin-rider':
            comGrif(friend)


hero.moveXY(53, 14)
hero.wait(2)
attack(hero.findNearestEnemy())
collectItems()
hero.moveXY(55, 33)
hero.moveXY(49, 37)
hero.moveXY(19, 40)
for i in range(1, 20):
    summonTroops()
commandTroops()
hero.moveXY(23, 38)
while True:
    commandTroops()
    
    collectItems()    



still not working…

you’ve defined the function to command your griffins but you aren’t running the function in the while True loop

i already put it in command troops and it already in while true

1 Like