Kelvintaph crusader help!


#1

my code doesn’t work, I survive but my friends don’t

exit = Vector(78, 40)
ogre = self.findNearest(self.findByType("ogre"))
self.canCast("chain-lightning", ogre)
def commandFriends():
    friends = self.findFriends()
    enemies = self.findEnemies()
    greatestEnemyHealth = 0
    enemy = None
    for Lenemy in enemies:
        if Lenemy.health > greatestEnemyHealth and Lenemy.type != "witch" and Lenemy.pos.y > 35:
            greatestEnemyHealth = Lenemy.health
            enemy = Lenemy
    for friend in friends:
        witch = friend.findNearest(self.findByType("witch"))
        if friend.type == "paladin":
            if witch:
                self.command(friend, "attack", witch)
            elif enemy:
                self.command(friend, "attack", enemy)
        elif enemy:
            self.command(friend, "attack", enemy)
        else:
            self.command(friend, "move", exit)
def helpFriends():
    ogre = self.findNearest(self.findByType("ogre"))
    self.moveXY(25, 22)
    if ogre:
            
        self.cast("chain-lightning", ogre)
        
commandFriends()
self.moveXY(48, 15)
commandFriends()
helpFriends()
commandFriends()
while self.findNearest(self.findByType("catapult")):
    self.moveXY(69, 16)
    commandFriends()
    helpFriends()
    commandFriends()
self.moveXY(78, 14)
loop:
    ogre = self.findNearest(self.findByType("ogre"))
    commandFriends()
    self.canCast("chain-lightning", ogre)


#2

This does nothing. Look at the playback. You didn’t cast a lightning bolt.

use

if ogre and self.cancast("chain-lightning", ogre):
    self.cast("chainlightning", ogre) 

In general, this is a very messy piece of code. I suggest you clean it up a bit.
Also, here’s a fun fact: you don’t have to kill all the ogres.
Just kill the witch, open the gate, manage not to have all your allies die, and walk out.
Also create an array tracking the missiles the catapults are throwing, as well as their positions.
Then you should move away ONLY after the catapults have fired, so they can kill themselves.


#3

I beat the level 20 seconds later when I was posting that.