James Vogan sent me his updated version of the fixing experience overflow bug, you may want to use it in 3.59 or ERA or anything, as it fixes a very annoying bug. Here it is:
Code:
ZVSE
** script to prevent creature experience reduction due to overflow. JHV, 2/3/2009
** updated Dec. 1,2009 to correct experience overflow when creatures are
** combined (right-click on creatures in Hero screen to restore their exp.)
* uses v7090-v7105 to store troop & hero ranks @ start of battle
* uses v7106 to store commander status
* uses FU459-FU462
!?BA0&1000; start of (human) battle
!!BA:H0/?v1; get attacker hero #
!!BA:H1/?v2; get defender hero # (if any)
!!DO459/0/6/1&v1>-1/v1<156:Pv1; check stacks 0-6 for attacker
!!DO460/0/6/1&v2>-1/v2<156:Pv2; check stacks 0-6 for defender
!!HEv1&v1>-1/v1<156:E?v7104; get att. hero exp.
!!HEv2&v2>-1/v2<156:E?v7105; get def. hero exp.
**IF:M^attacker = %V1 defender = %V2^;
!?FU459; get exp. rank of troop in slot x16 of hero x1, store in v[7090+x16)
!!HEx1:C0/x16/?y1/?y2/?y3/2; y1=type, y2=no., y3=experience
!!VRv5:S7090+x16;
!!VRvv5:Sy3;
!?FU460; get exp. rank of troop in slot x16 of hero x1, store in v[7097+x16)
!!HEx1:C0/x16/?y1/?y2/?y3/2; y1=type, y2=no., y3=experience
!!VRv5:S7097+x16;
!!VRv5:Sy3;
!#UN:P3/?v7106; v7106=0 if commanders enabled
!?BA1&1000; end of (human) battle
!!BA:H0/?v1; get attacker hero #
!!BA:H1/?v2; get defender hero # (if any)
!!VRv3:C-1/-1; set v3 & v4 to -1
!!HEv1&v1>-1/v1<156:O?v3; get attacker's Owner - will be 0-7 if attacker won
!!HEv2&v2>-1/v2<156:O?v4; get defender's Owner - will be 0-7 if defender won
!!DO461/0/6/1&v3>-1/v3<8:Pv1; check stacks 0-6 for attacker
!!DO462/0/6/1&v4>-1/v4<8:Pv2; check stacks 0-6 for defender
!!HEv1&v3>-1/v3<8:E?v5; get att. hero exp.after battle
!!HEv1&v3>-1/v3<8/v5<v7104:E18975933/50; set att. hero to level 50 if overflow
!!COv1&v7106=0/v3>-1/v3<8/v5<v7104:X1/18975933 X2/50; set att. commander to level 50 if overflow
!!HEv2&v4>-1/v4<8:E?v6; get def. hero exp.after battle
!!HEv2&v4>-1/v4<8/v6<v7105:E18975933/50; set def. hero to level 50 if overflow
!!COv2&v7106=0/v4>-1/v4<8/v6<v7105:X1/18975933 X2/50; set def. commander to level 50 if overflow
**IF:M^attacker = %V1 defender = %V2 OwnerA = %V3 OwnerD = %V4^;
!?FU461; get exp. rank of troop in slot x16 of hero x1, vs. v[7090+x16)
!!HEx1:C0/x16/?y1/?y2/?y3/2; y1=type, y2=no., y3=experience
!!FU&y2<1:E; quit if no troops left in slot
!!VRv5:S7090+x16;
!!VRy4:Svv5;
!!HEx1&y4>y3:C0/x16/d/d/11/12; set rank to 11 if negative experience was gained (overflow occurred)
!?FU462; get exp. rank of troop in slot x16 of hero x1, vs. v[7097+x16)
!!HEx1:C0/x16/?y1/?y2/?y3/2; y1=type, y2=no., y3=experience
!!FU&y2<1:E; quit if no troops left in slot
!!VRv5:S7097+x16;
!!VRy4:Svv5;
!!HEx1&y4>y3:C0/x16/d/d/11/12; set rank to 11 if negative experience was gained (overflow occurred)
!?CM2; click on Hero screen
!!CM:F?v1 I?v2; get flag and clicked object values
!!FU|v1<>512/v2<68/v2>74:E; exit if not right-click or not creature slot
!!VRv2:-68; now v2=slot # from 0 to 6
!!HE-1:C0/v2/?y1/?y2/?y3/2; y1=type, y2=no., y3=experience
!!HE-1&y3<0:C0/v2/d/d/11/12; set rank to 11 if negative experience was gained (overflow occurred)