I want to provide additional information on !!EA receiver bugs, for debugging purpose.
First, there is the EA override bug. Meaning if you add spells or attributes to battle stacks and after that use !!EA receiver on that stack the additional spell buffs or attributes are removed.
Second, when giving stacks a stack experience ability with !!EA and they have changed stats through !!BMx1:H500 (or whatever) and you then lose or retreat from battle the next combat the units will have these old manipulated stats, plus the new ones, resulting in insane stats. By the way, even RELOADING the game wont fix this. You actually need a complete restart to clear/reset EA stacks.
Now I tried several things to avoid these.
And my best solution was to use one bug to solve the other bug
When the battle ends (retreat or loose), you make a check !!BU:C and apply new abilities on stacks, because this resets the !!EA stacks. Then the next combat this problem is solved.
Test script to work on Arrogance map:
https://dropmefiles.com/W3Ack
How to use this test script:
Start arrogance map and attack the nearest stack and lose combat. Buy a new Hero and attack again. Now defender stack 21 and 22 will have the bug.
Later you can play with enabling/disabling the check at battle end, to solve the bug.
!?BG1;
*Reset HP by applying EA to stacks at battle end
!!FU:E; TEST HERE BY ENABLING/DISABLING
Ofc theres always the chance that I produced complete BS and the problem is only for me
Also I dont want to put pressure on solving this bug, it wont happen often, this post is just to provide additional information for the future, and I was just playing around.