Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Help on Kelvintaph Defiler

This is my code so far. But it all stops when step is made 2. What am I doing wrong?

# The ogres are trapping you with their dark rituals!
# Your hero can't do anything besides command and move without angering the warlocks.
# Beware ice, robots, traps, antigravity fields, and other dark magic.
# Somehow, you'll need to defeat Nalfar and save your paladin.
# The great treasure of Kelvintaph awaits your victory.
def commandPaladin(paladin):
    if hero.time >= 2:
        if paladin.canCast("heal") and < paladin.maxHealth * 0.7:
            hero.command(paladin, "cast", "heal", paladin)
            hero.command(paladin, "shield")

def commandArcher(friend):
    if step == 1:
        enemy = friend.findNearestEnemy()
        if enemy and enemy.type != "yeti":
            hero.command(friend, "attack", enemy)
    elif step == 2 and == "Mirana":
        hero.command(friend, "move", {"x":9, "y":77})
    elif step == 2:
        hero.command(friend, "move", {"x":28, "y":49})

def commandSolider(friend):
    if hero.time >= 3:
        if hero.time <= 7:
            hero.command(friend, "move", {"x":21, "y":73})
        elif hero.time <= 9:
            enemy = friend.findNearestEnemy()
            if enemy and enemy.type != "yeti":
                hero.command(friend, "attack", enemy)
        elif hero.time == 10:
            step = 2
    elif step == 2:
        hero.command(friend, "move", {"x":24, "y":66})

def commandAllies():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin":
        elif friend.type == "archer":
step = 0
hero.move({"x":32, "y":17})
#hero.cast("invisibility", hero)
while True:
    if hero.time == 2.2:
        step = 1

I would define the step variable in your while true loop. So have a series of ifs and then an elif checking hero.time then setting step to the appropriate number. You can then check step while commanding your friends without defining it each time.
I hope this helps,

1 Like

So if I do that, my code will work?

Think of it as a suggestion, not a solution…we’ll never know until you at least try it :wink:

1 Like

Ok. I will try it. :slight_smile:

Thanks for advice. I finished the level

Now I got the bonus. I am so happy! Thanks for help! :slight_smile: