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

Kelvintaph Crusader hlp plz

When I played the level it said that hero.findEnemies() doesn’t work. It says it on that comment. But maybe it does, I don’t know now. I’ll have to check…

1 Like

My solution was time-depending. As I mentioned it included two basic functions. First (and easiest) for the hero: where to go at the certain period of time (using hero.move(moveToPos)). Hero should stay alive while catapults kill brawlers and themselves (I added chain-lightning, but it’s optional). The second defines actions for allies. Again their tactics depended on the time and type as primary conditions and then other things like or shield.ability. Also I used enemies names (as far as they are hardcoded) to indicate targets.
Thanks to you I managed to complete all the goals (when I passed the level for the first time not all of my allies stayed alive). Now I figured out missed piece of puzzle)
You code is a bit in another manner. I can try your current code but it seems to me that if your allies don’t wanna obey it’s good idea to go back to previous levels with practicing of units management.


For the start I would recommend to move this part


            if friend.type == 'paladin':

And then try to set up other things.

1 Like

They move not to the end but to 50,39. It’s because of line:
hero.command(friend, "move", {'x': 50, 'y': 39})
And this is because of mistakes in the whole commandTroops() function :confused:
Plus I suppose function findWorstEnemy() is also a little irrelevant(

F.e. look what happens if edit function like this:

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':
                if friend.canCast("heal"):
                    hero.command(friend, "cast", "heal", friend)
                    hero.command(friend, "move", {'x': 31, 'y': 40})
                hero.command(friend, "move", {'x': 7, 'y': 40})
            worst = findWorstEnemy()
            if (worst and friend.pos.x - worst.pos.x < 10):
                hero.command(friend, "move", {'x': 50, 'y': 58})
                hero.command(friend, "move", {'x': 6, 'y': 58})
                hero.command(friend, "move", {'x': 49, 'y': 58})
                hero.command(friend, "move", {'x': 50, 'y': 39})
                hero.command(friend, "move", {'x': 78, 'y': 40})

Where do all the allies go?

1 Like

what do you mean by where do the allies go @Alexbrand?

I mean that with your last version of code

And after editing a little they go not to the (50,39) point, but to the left upper corner of the level. Why? Because there is hero.command(friend, "move", {'x': 6, 'y': 58}) line in your code.
I’m sorry but I think that looks like you don’t understand basic principles of how to make your troops move and attack or shield depending on different circumstances and conditions. Frankly speaking I’m not a good programmer at all but with a bit of work it’s possible to write simple code by oneself without copying solutions.

1 Like

why can’t i load the level now?

like i load it and it stops half way through

It loads and works on my machine. Maybe you have some errors in code? Try to comment it out maybe?