Nice work with +res% and +crit%, seeing this i would never make it functional
It pretty simple looking it this way, but i only wonder why you after function body have 3 times :
end
end
end ?
You have 2 if start:
if defenseb > 0 then
if Attack.act_ally(a) then.
So i ask why closing 3 functions, when only 2 started ?
It works, and it`s great but every 5 points of att/def . . . seems a bit much. But with you already making string, it`s easy to alter it (to something every point of attack gives 10% crit

And about editor, i checked it and found in your mod sessions/items/medals you placed 4/5 line there, and in original campaign it`s only 1/2/3 lvl medals. How did you add those lines ? My editor crashes when ever i try to change something in that area.
Beside changing those lines, also medals.txt and eng_rewards should be changed to match settings in editor but i think this should work. You mentioned couple posts above that almost everything can be modded except medal requirements. But you already added 2 new lines in editor to make your 4/5th medal lvls work. So how come spell required itself cant be changed ?