Kelvintaph Defiler Step Variable Help

yea, but the main problem right now is that I somehow have to kill the shamans? so that I don’t just do nothing except have the paladin survive? I still need to kill all of the ogres

oopsie just noticed this wasn’t in the level help category. Just added it in

1 Like

As for ogre killing, to make it easier stay in starting spot for a bit then move down so the 2 robot walkers kill each other

no even with what I do they still kill each other. That was my first goal

1 Like

hmmm, i’ve tweaked my code a little bit (fixed a couple of errors) and ended with this, my troops don’t get flung, but they don’t attack either.

# 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.
hero.move({'x': 35, 'y': 14})
hero.move({'x': 34, 'y': 7})
def commandSoldiers():
    soldiers = hero.findByType("soldiers")
    for soldier in soldiers:
        enemies = hero.findByType("shaman")
        for enemy in enemies:
            if enemy:
                hero.command(soldier, "attack", enemy)
def commandArchers():
    archers = hero.findByType("archer")
    for archer in archers:
        enemies = hero.findByType("shaman")
        for enemy in enemies:
            if enemy:
                hero.command(archer, "attack", enemy)
def commandPaladins():
    paladin = hero.findNearest(hero.findByType("paladin"))
    enemy = hero.findNearest(hero.findByType("shaman"))
    if enemy:
        hero.command(paladin, "attack", enemy)
    elif hero.time > 1.3 and paladin:
        hero.command(paladin, "shield", paladin)
while True:
    commandSoldiers()
    commandPaladins()
    commandArchers()

could someone help?

Go to the other post where you put your first post. I solved your problem there

No, it’s not with an s.
Replace it with:

soldiers = hero.findByType("soldier")
1 Like

Yes, that’s the problem.

Just saying, are you expecting your archers to attack every shaman at once? Their arrows can’t reach past high walls.

1 Like

we don’t talk about not putting hero.findNearest() shush

# 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.
hero.move({'x': 35, 'y': 14})
hero.move({'x': 34, 'y': 7})
def commandSoldiers():
    soldiers = hero.findByType("soldier")
    for soldier in soldiers:
        enemies = soldier.findNearest(hero.findByType("shaman"))
        if enemies:
            hero.command(soldier, "attack", enemy)
def commandArchers():
    archers = hero.findByType("archer")
    for archer in archers:
        enemies = archer.findNearest(hero.findByType("shaman"))
        if enemies:
            hero.command(archer, "attack", enemy)
def commandPaladins():
    paladin = hero.findNearest(hero.findByType("paladin"))
    enemy = hero.findNearest(hero.findByType("shaman"))
    if enemy:
        hero.command(paladin, "attack", enemy)
    elif hero.time > 1.3 and paladin:
        hero.command(paladin, "shield", paladin)
while True:
    commandSoldiers()
    commandPaladins()
    commandArchers()

Now, (I actually added findNearest) but they still don’t attack? I’m very confused…

Umm… you won’t find the shamans if you aren’t wearing see-through-walls glasses.
Maybe say

def commandSoldiers():
    soldiers = hero.findByType("soldier")
    for soldier in soldiers:
        enemies = soldier.findNearest(soldier.findByType("shaman"))
        if enemies:
            hero.command(soldier, "attack", enemy)
def commandArchers():
    archers = hero.findByType("archer")
    for archer in archers:
        enemies = archer.findNearest(archer.findByType("shaman"))
        if enemies:
            hero.command(archer, "attack", enemy)

Make them find enemies from their point of view.

1 Like

You have a problem with these codes. You have defined enemies but not enemy.

1 Like

Oh. Thanks! (stupid character limit)

2 Likes

oops! just noticed that the see through walls glasses are restricted. I thought i had equipped them.

1 Like

Ok, I hadn’t noticed those errors. Thanks! But, I’m only killing the first shaman, because that’s the only one that can be seen. How would I get them to move to a certain shaman/location and kill it?

Code
# 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 commandSoldiers():
    soldiers = hero.findByType("soldier")
    for soldier in soldiers:
        enemies = soldier.findNearest(soldier.findByType("shaman"))
        if enemies and enemies.health > 0:
            hero.command(soldier, "attack", enemies)
def commandArchers():
    archers = hero.findByType("archer")
    for archer in archers:
        enemies = archer.findNearest(archer.findByType("shaman"))
        if enemies and enemies.health > 0:
            hero.command(archer, "attack", enemies)
def commandPaladins():
    paladin = hero.findNearest(hero.findByType("paladin"))
    if hero.time > 2 and paladin:
        hero.command(paladin, "shield", paladin)
hero.move({'x': 35, 'y': 14})
hero.move({'x': 34, 'y': 7})
while True:
    commandSoldiers()
    commandPaladins()
    commandArchers()

I’ve been trying to use a step variable, like this

def commandArchers(step):
    archers = hero.findByType("archer")
    for archer in archers:
        enemies = archer.findNearest(archer.findByType("shaman"))
        if enemies and enemies.health > 0 and step == 0:
            hero.command(archer, "attack", enemies)
            step = 1
        elif step == 1:
            hero.command(archer, "move", {'x': 23, 'y': 62})
            hero.command(archer, "attack", enemies)
            step = 2
        elif step == 2:
            hero.command(archer, "move", {'x': 9, 'y': 75})
            hero.command(archer, "attack", enemies)
            step = 3
        elif step == 3:
            hero.command(archer, "move", {'x': 38, 'y': 65})
            hero.command(archer, "attack", enemies)
            step = 4
        elif step == 4:
            hero.command(archer, "move", {'x': 75, 'y': 73})

but it doesn’t seem to do anything different. What am i doing wrong?

This post hasn’t been used in a bit, but I don’t want to make another one.

So I’ve been tinkering around with a step variable in my archer function, yet it only kills the first shaman. yes I also made the post “Kelvintaph Defiler Error But No Error Message.”

# 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 commandSoldiers():
    soldiers = hero.findByType("soldier")
    for soldier in soldiers:
        enemies = soldier.findNearest(soldier.findByType("shaman"))
        if enemies and enemies.health > 0:
            hero.command(soldier, "attack", enemies)
def commandArchers():
    step = 0
    archers = hero.findByType("archer")
    for archer in archers:
        enemies = archer.findNearest(archer.findByType("shaman"))
        if enemies and enemies.health > 0 and step == 0:
            hero.command(archer, "attack", enemies)
            step = 1
        elif step == 1:
            hero.command(archer, "move", {'x': 23, 'y': 62})
            enemies = archer.findNearest(archer.findByType("shaman"))
            hero.command(archer, "attack", enemies)
            step = 2
        elif step == 2:
            enemies = archer.findNearest(archer.findByType("shaman"))
            hero.command(archer, "move", {'x': 9, 'y': 75})
            hero.command(archer, "attack", enemies)
            step = 3
        elif step == 3:
            hero.command(archer, "move", {'x': 38, 'y': 65})
            enemies = archer.findNearest(archer.findByType("shaman"))
            hero.command(archer, "attack", enemies)
            step = 4
        elif step == 4:
            hero.command(archer, "move", {'x': 75, 'y': 73})
def commandPaladins():
    paladin = hero.findNearest(hero.findByType("paladin"))
    if hero.time > 2 and paladin:
        hero.command(paladin, "shield", paladin)
        if paladin.canCast('heal'):
            hero.command(paladin, "cast", "heal", paladin)
hero.move({'x': 35, 'y': 14})
hero.move({'x': 34, 'y': 7})
while True:
    commandSoldiers()
    commandPaladins()
    commandArchers()

Could anyone explain if I’m using the step variable wrong, or something else? Thanks

First thing: your archers can’t move. They are in the air flung by shamans. You should kill the second shaman, not the first. Make them target the second shaman when they are close enough.

Also, you can equip see-through-walls glasses if you play another level with them then use the link to the level and you will have the glasses.