[SOLVED] Kelvintaph Crusader HELP! Really Stuck!

Help!! My friends don’t escape the enemy prison!

Please help!

Here is my code:

def moveTo(position, fast=True):
    if (hero.isReady("jump") and fast):
        hero.jumpTo(position)
    else:
        hero.move(position)

def commandTroops():
    for index, friend in enumerate(hero.findFriends()):
        enemies = hero.findEnemies()
        witch = hero.findNearest(hero.findByType('witch'))
        if len(enemies) > 0 and witch:
            if friend.type == 'paladin':
                CommandPaladin(friend)
            else:
                CommandSoldier(friend)
        elif hero.now() < 10 and hero.now() > 5 and friend.type == 'paladin':
            if (friend.canCast("heal")):
                hero.command(friend, "cast", "heal", friend)
            elif hero.now() < 7:
                hero.command(friend, "move", {'x': 31, 'y': 40})
            elif hero.now() < 12:
                hero.command(friend, "move", {'x': 7, 'y': 40})
        elif hero.now() < 15 and friend.type != 'archer':
            worst = findWorstEnemy()
            if (worst and friend.pos.x - worst.pos.x < 10):
                hero.command(friend, "move", {'x': 50, 'y': 58})
        elif friend.type == 'archer' and hero.now() < 15:
            if hero.now() < 7:
                hero.command(friend, "move", {'x': 6, 'y': 58})
            else:
                hero.command(friend, "move", {'x': 49, 'y': 58})
        elif hero.now() < 17:
            hero.command(friend, "move", {'x': 50, 'y': 39})
        else:
            hero.command(friend, "move", {'x': 78, 'y': 40})


def CommandPaladin(paladin):
    if (paladin.canCast("heal")):
        target = lowestHealthFriend()
        if target:
            hero.command(paladin, "cast", "heal", target)
    elif (paladin.health < 100):
        hero.command(paladin, "shield")
    else:
        target = findWorstEnemy()
        if (target):
            hero.command(paladin, "attack", target)

def CommandSoldier(soldier):
    target = findWorstEnemy()
    if (target):
        hero.command(soldier, "attack", target)

def findWorstEnemy():
    witch = hero.findNearest(hero.findByType('witch'))
    ogre = hero.findNearest(hero.findByType('ogre'))
    skeleton = hero.findNearest(hero.findByType('skeleton'))
    if witch:
        return witch
    elif ogre:
        return ogre
    elif skeleton:
        return skeleton
    else:
        return None

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

def attack(target):
    if target:
        if (hero.distanceTo(target) > 10):
            moveTo(target.pos)
        elif (hero.isReady("bash")):
            hero.bash(target)
        else:
            hero.attack(target)

while True:
    commandTroops()
    brawler = hero.findNearest(hero.findByType('brawler'))
    catapult = hero.findNearest(hero.findByType('catapult'))
    if brawler and hero.distanceTo(brawler) > 15:
        moveTo(brawler.pos, False)
    elif brawler:
        runaway = Vector.subtract(hero.pos, brawler.pos)
        runaway = Vector.normalize(runaway)
        runaway = Vector.multiply(runaway, 15)
        direction = Vector.add(runaway, hero.pos)
        moveTo(direction, False)
    elif catapult:
        attack(catapult)
    else:
        hero.move({'x': 78, 'y': 15})


1 Like

You copy pasted that code from github.
Please don’t cheat.
It was vadim job py at master right?
Come on, please don’t cheat.
:joy:

1 Like

Remove that code, if you know it is pasted from github, why did you post it again

1 Like

It doesnt work.
20 chars.

Sorry, I thought that level for HOURS and I still didn’t complete it.

So I copied the code from GitHub.

But… It didn’t work…
:joy:

Can you become invisible? (the precious) ring . It is gold in color

1 Like

Alright I’ll try to help you.
Kill the witch first.
She can heal her allies, and does a lot of damage.
You really only need to kill the witch, then command your friends to get the heck out of there.
Just move forward your hero, the catapults will kill those brawlers.
Then walk up, then run. The catapults will destroy themselves.
Then get out.

Yes I have this ring in my equipment:)

Most copied codes don’t work…

Thank you!! I will try this! I made the topic solved

If you have solved this level, mark it solved, if not please un mark it, because the topic will close in 12 hours

Okay! Thanks, now done.

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