[SOLVED] HELP Kelvintaph Defiler level help

Hi,
I managed to get to kithgard defiler, however I cannot get past. My troops just stand by the enemies saying “EEEK” or something and the only person to make it to Nalfar are the Paladin and a soldier when the Paladin is at low health
Here is my code:

step = 0


def choiseTarget(enemies):
    hero.say(enemies)
    for enemy in enemies:
        for att in attack:
            if att[0] == enemy.pos.x and att[1] == enemy.pos.y:
                return enemy
    return None


def commandTroops():
    for index, friend in enumerate(hero.findFriends()):
        if (step == 0 and friend.pos.y > 60 and (friend.type != 'archer' or hero.now() > 3.7)):
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
        elif step == 4:
            hero.command(friend, "move", {'x': 42, 'y': 67})
        elif friend.type == 'archer':
            CommandArcher(friend)
        elif friend.type == 'paladin':
            CommandPaladin(friend)
        else:
            CommandSoldier(friend)


def CommandPaladin(soldier):
    if step < 4:
        if (soldier.canCast("heal") and hero.now() > 3):
            hero.command(soldier, "cast", "heal", soldier)
        elif hero.now() > 3 and soldier.health < soldier.maxHealth * 0.7:
            hero.command(soldier, "shield")


def CommandSoldier(soldier):
    if step < 4:
        if soldier.pos.x < 74:
            hero.command(soldier, "move", {'x': 76, 'y': 76})
        else:
            enemy = soldier.findNearestEnemy()
            if enemy:
                hero.command(soldier, "attack", enemy)


def CommandArcher(soldier):
    if step == 1:
        if soldier.pos.y > 60:
            hero.command(soldier, "move", {'x': 22, 'y': 55})
        else:
            enemies = soldier.findEnemies()
            for enemy in enemies:
                if enemy.type != 'yeti':
                    hero.command(soldier, "attack", enemy)
    elif step == 2:
        if soldier.pos.x > 14:
            hero.command(soldier, "move", {'x': 8, 'y': 77})
        else:
            enemy = soldier.findNearestEnemy()
            if enemy:
                hero.command(soldier, "attack", enemy)
    elif step == 3:
        if soldier.pos.x < 74:
            hero.command(soldier, "move", {'x': 76, 'y': 76})
        else:
            enemy = soldier.findNearestEnemy()
            if enemy:
                hero.command(soldier, "attack", enemy)


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


index = 0
route = [[33, 12, False], [34, 9, False], [32, 6, False]]


def moveHero():
    if len(route) > index:
        moveTo({'x': route[index][0], 'y': route[index][1]}, route[index][2])
        if (hero.pos.x == route[index][0] and hero.pos.y == route[index][1]):
            return True
        else:
            return False


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:
    if (hero.now() > 6 and hero.now() < 12):
        step = 1
    elif (hero.now() > 10 and hero.now() < 17):
        step = 2
    elif (hero.now() > 15 and hero.now() < 30):
        step = 3
    elif (hero.now() > 28 and hero.now() < 600):
        step = 4
    commandTroops()
    if step < 4:
        if moveHero():
            index = index + 1
    else:
        enemy = hero.findNearestEnemy()
        if enemy:
            attack(enemy)
        else:
            moveTo({'x': 74, 'y': 44})

any help will be greatly appreciated
Thanks,
Mumbo_6

Use the soldier to kill the shamans and all the troops will be free after all of the shamans are dead.

Andrei

You are using again a code you didn’t created yourself as in [SOLVED] Help with Kelvintaph Crusader?

no, i wrote this one myself
i took some commands from previous levels

this is also kelvintaph defiler and not crusader

fine I wrote a compete new code then if you insist I stole it @xython!
Here it is:

hero.moveXY(34, 15)
hero.moveXY(34, 7)
friend = hero.findFriends()
if friend.type == "soldier":
    enemy = soldier.findNearestEnemy()
    if enemy:
        hero.command(soldier, "attack", enemy)
    else:
        hero.command(soldier, "moveXY", (80, 74))
elif friend.type == "archer":
    archer = hero.findFriends()
    enemy = archer.findNearestEnemy()
    if enemy:
        hero.command(archer, "attack", enemy)
    else:
        hero.command(archer, "moveXY", (74, 75))
elif friend.type == "paladin":
    paladin = hero.findFriends()
    if enemy:
        hero.command(paladin, "moveXY", (54, 82))

Do you think you can help me now?
My soldiers and archers dont do anything

The summonable units have the “move”, not “moveXY”.

Andrei

but then dont they just move one step towards that position?

plus my paladin does not even move, it just stands there and gets rekt by Nalfar

and nothing else happens the same results appear

Because they have to move to a position. Like here

You should move to the {“x”:80 ,“y”:74} instead of (80, 74).

Andrei

OHHHHHHHH it all makes sense now :smile:

The paladin should heal when she can and she will not waste any point of heal (the heal spell heals for 150 health) and shield as much as she can (the shield makes the spell weaker).

Andrei

ok i didnt know that

Then try to read the hints. They help you a bunch. :wink:

Andrei

ok ill try
(the hints are always super confusing for me, since i am not mother language english)

how are the soldiers meant to kill the shamans when they cast spells that disable them?

From Hints:
Screenshot 2020-07-13 at 11.08.30

my paladin is just getting its health drained even though i commanded it to shield and heal itself

hero.moveXY(34, 15)
hero.moveXY(34, 7)
friend = hero.findFriends()
if friend.type == "soldier":
    enemy = soldier.findNearestEnemy()
    if enemy:
        hero.command(soldier, "attack", enemy)
    else:
        hero.command(soldier, "move", ("x", 80, "y", 74))
elif friend.type == "archer":
    archer = hero.findFriends()
    enemy = archer.findNearestEnemy()
    if enemy:
        hero.command(archer, "attack", enemy)
    else:
        hero.command(archer, "move", ("x", 74, "y", 75))
elif friend.type == "paladin":
    paladin = hero.findFriends()
    if enemy:
        if paladin.health == paladin.maxhealth - 10:
            while True:
                hero.command(paladin, "shield")
                hero.command(paladin, "heal", paladin)


After you defeat the shamans, the troops will not have fear anymore.

Andrei

i know, but how? My soldiers just stand there doing nothing