Help: I can't beat Grim Determination

Mod edit: solution removed

I managed to beat the level with this code above. I get the sense that the relation between hero.attack(enemy) and hero.command(someone, ‘attack’, enemy) is like the one between hero.move(pos) and hero.moveXY(x,y). Only the one time attack code and one step forward code go well together with while loop. So the griffin riders worked as I intended.

And my paladins did their job perfectly. But still, I don’t get the exact idea behind the paladin part. Please if you could give any advice I’d be very happy.