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.
I’m not sure if you’ve already completed this level, but start by attacking the enemies in your corridor. After you’ve defeated all of them, command your hero to stand on the white X.
Next, you need to command your soldiers in the upper corridor to defeat their enemies, then move them to their white X.