HELP Kelvintaph Crusader

def move():
    hero.moveXY(hero.pos.x + 40, hero.pos.y)
    hero.moveXY(hero.pos.x - 40, hero.pos.y)
    safe = commandfriend()
    if safe:
        catapult = hero.findNearest(hero.findByType("catapult"))
        if catapult:
            hero.attack(catapult)

def commandfriend():
    friends = hero.findByType("paladin")
    solds = hero.findByType("soldier")
    arches = hero.findByType("archer")
    for friend in friends:
        target = {'x': 78, 'y': 40}
        if friend.distanceTo({'x': 16, 'y': 58}) > 2:
            hero.command(friend, "move", {'x': 16, 'y': 58})
        elif friend.distanceTo({'x': 50, 'y': 58}) > 2:
            hero.command(friend, "move", {'x': 50, 'y': 58})
        elif friend.distanceTo({'x': 50, 'y': 40}) > 2:
            hero.command(friend, "move", {'x': 50, 'y': 40})
        elif friend.distanceTo({'x': 78, 'y': 40}) > 2:
            hero.command(friend, "move", {'x': 78, 'y': 40})
    for sold in solds:
        target = hero.findByType("witch")
        for tar in target:
            hero.command(sold, "attack", tar)
    for arch in arches:
        targ = hero.findByType("witch")
        for ta in targ:
            hero.command(arch, "attack", ta)
    return target
hero.move({'x': hero.pos.x, 'y': hero.pos.y + 2})
while True:
    commandfriend()
    move()

it almost worked - The devil is in the details :slight_smile:

thank you for helping me though. :grinning:

the paladin goes backwards :rofl:

image

Can you please help me kelvintaph cursader

while True:
    
    friends = hero.findFriends()
    paladins = hero.findByType("paladin")
    enemies = hero.findEnemies()
    witches = hero.findByType("witch")
    enemies = hero.findEnemies()
    if hero.canCast("chain-lightning", "Trogdor"):
        hero.cast("chain-lightning", "Trogdor")
    for friend in friends:
        if friend.type != 'paladin':
            if 'Oni'.health > 0:
                hero.command(friend, "attack", "Oni")
            elif 'Oni'.health <= 0:
                if friend.type != 'paladin':
                    hero.command(friend, "shield")
                elif 'Rusty':
                    hero.command(friend, "attack", "Rusty")
                elif 'Skully':
                    hero.command(friend, "attack", "Skully")
        if hero.canCast("chain-lightning", "Trogdor"):
            hero.cast("chain-lightning", "Trogdor")
        
        elif friend.type == 'paladin':
            if 'Yzzrith':
                witch = 'Yzzrith'
                hero.command(friend, "attack", witch)
            elif enemy.type == 'skeleton':
                hero.command(friend, "shield")
    for enemy in enemies:
        if enemy.type is "catapult":
            while enemy.health > 0:
                hero.attack(enemy) 
            hero.moveXY(78, 14)

This is my code, my paladin does not shield when asked too, I have a problem of the moving part too, I ask him to move and he goes the the last destination

example:
move 10, 10
move 20,20

paladin moves to 20,20 without moving to 10,10

Please help
Goutham 123

Do you think this is OK?
‘’’

            if 'Oni'.health > 0:
            elif 'Oni'.health <= 0:
                elif 'Rusty':
                elif 'Skully':

Possible way to command and fight by name, no strings used:
Run this code:

friends = hero.findFriends()
myFriends = []
for i in range(len(friends)):
    myFriends.append("\n" + friends[i].id + " = friends[" + i + "]")
console.log("\nmyFriends = \n" + myFriends)

enemies = hero.findEnemies()
myEnemies = []
for i in range(len(enemies)):
    myEnemies.append("\n" + enemies[i].id + " = enemies[" + i + "]")
console.log("\nmyEnemies = \n" + myEnemies)

Go to the console output:


Copy the code you want to use and format it as needed.

Why did you keep me in your ignore list @xython you have been in many discussions and specialize in python. I need your help I have been trying for months (2 months) for the level and I didn’t get any where :rage:. I am sorry if I sound mad and arrogant, but I’ve tried everything and I can’t pass, I have been fed up with the level.
goutham123

Hi I tried your code and you die from the catapults so I suggest making your hero wait for one second before moving to point2. But I have no chain-lighting so my troops die and I lose. Can someone help me get the emperors gloves?

I find this code works rather well just delete the “and hero.distanceTo(catapult) < 3”