[HELP] Kelvintaph Burgler

My archers and soldiers get killed by the ogre chieftain. My paladin kills the witch and forgets the ogre chieftain. I am trying to dodge the robot walkers. I don’t know how to make my allies kill both ogres and I don’t know how to kill the robot walkers without getting shot and killed. Here is my code:

# What eldritch artifacts are these? Don't let them blast you!
# The ice gate will open when both ogres are defeated.
# You can find friends through walls, but not enemies.
# Watch out for smooth, frictionless ice patches!
def commandfriend():
    for friend in hero.findFriends():
        enemy = friend.findNearestEnemy()
        w = friend.findNearest(hero.findByType("witch"))
        c = friend.findNearest(hero.findByType("chieftain"))
        if enemy and enemy.type != "yak":
            
            if w and friend.type == "archer":
                hero.command(friend, "attack", c)
                hero.command(friend, "attack", w)
            elif w and friend.type == "paladin":
                hero.command(friend, "attack", c)
                hero.command(friend, "attack", w)
            elif friend.type == "paladin" and friend.canCast("heal"):
                hero.command(friend, "cast", "heal", friend)
            elif friend.type == "soldier" and enemy:
                hero.command(friend, "attack", c)
                hero.command(friend, "attack", w)
            elif enemy:
                hero.command(friend, "attack", enemy)
        elif friend and friend.type == "soldier" or "archer" or "paladin":
            hero.command(friend, "move", {"x": 20, "y": 58})
            hero.command(friend, "move", {"x": 52,"y": 58})
            hero.command(friend, "move", {"x": 41,"y": 40})
            hero.command(friend, "move", {"x": 78,"y": 40})

while True:
    flag = hero.findFlag("green")
    black = hero.findFlag("black")
    archers = hero.findByType("archer")
    enemy = hero.findNearestEnemy()
    if flag:
        hero.pickUpFlag(flag)
    if black:
        if hero.gold >= hero.costOf("archer"):
            hero.summon("archer")
    if enemy:
        if enemy:
            hero.attack(enemy)
        elif hero.canCast("chain-lightning",enemy):
            hero.cast("chain-lightning", enemy)
    commandfriend()

1 Like

Now I make it through, but my paladin goes to the witch, and lets the witch kill her, and my paladin is my last ally alive. Here is my code:


def commandfriend():
    for friend in hero.findFriends():
        enemy = friend.findNearestEnemy()
        w = friend.findNearest(hero.findByType("witch"))
        c = friend.findNearest(hero.findByType("chieftain"))
        if enemy and enemy.type != "ice-yak":
            if w and friend.type == "archer":
                hero.command(friend, "attack", c)
                hero.command(friend, "attack", w)
            elif c and friend.type == "paladin":
                if w:
                    hero.command(friend, "move", [50,50])
                    hero.command(friend, "move", [30,50])
                    hero.command(friend, "attack", w)
                else:
                    hero.command(friend, "move", {"x": 78,"y": 40})
            elif friend.type == "paladin" and friend.canCast("heal"):
                hero.command(friend, "cast", "heal", friend)
            elif friend.type == "soldier" and enemy:
                if c:
                    hero.command(friend, "attack", c)
        elif friend and friend.type == "soldier" or "archer":
            hero.command(friend, "move", {"x": 78,"y": 40})

while True:
    flag = hero.findFlag("green")
    black = hero.findFlag("black")
    archers = hero.findByType("archer")
    enemy = hero.findNearestEnemy()
    targets = hero.findByType("griffin-rider")
    enemy = hero.findNearestEnemy()
    if flag:
        hero.pickUpFlag(flag)
    if black:
        if hero.gold >= hero.costOf("archer"):
            hero.summon("archer")
    if enemy:
        if enemy:
            hero.attack(enemy)
            if hero.gold >= hero.costOf("griffin-rider"):
                hero.summon("griffin-rider")
            for target in targets:
                hero.command(target, "attack", enemy)
        elif hero.canCast("chain-lightning",enemy):
            hero.cast("chain-lightning", enemy)
    commandfriend()

1 Like

It seems that my paladin only attacks the witch if I die.

1 Like

Firstly having consecutive move statements unfortunately does not work (@xython might be able to explain more :grin:). It seems to go for the last statement because a “move” statement doesn’t take any time, so you need a single move statement to be looped over and over again for it to actually work.
Also your move argument [50,50] is not in the correct format. You should put it like this, like you have it below in your code:

{"x": 78,"y": 40})

Or, if you’ve done Vector levels (which I think you probably may have at this point):

Vector(50, 50)

It’s very simple, just that is needed.
Danny

You can look at the Grim determination posts where i wrote how to command minions, as well as others where it is explained how to move with move(Vector (x, y))
Possible level strategy:


PS: Only now did I notice that the two baby yaks had been killed by the chieftain. I don’t like this solution anymore…

3 Likes

So if I shouldn’t use consecutive move statements, what should I do?

2 Likes

Also I learned that my paladin won’t kill anything unless I die, it just lures the chieftain to the ice yak and then goes to the witch, so I have to kill the witch, because my troops already died.

1 Like

I found a way to kill the witch, and now I completed the level.

4 Likes

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