Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Heroes 3.5 - WoG and Beyond > Thread: Script from James Vogan- -no more negative experience bug
Thread: Script from James Vogan- -no more negative experience bug
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted February 04, 2009 02:50 AM
Edited by Salamandre at 02:57, 04 Feb 2009.

Script from James Vogan- -no more negative experience bug

Jim Vogan just emailed me this script which will disable the negative experience bug, which is a dead end if occurs.

note from James Vogan:

"The bug you describe probably occurs when the experience exceeds the maximum positive value that its (internal) variable can store.  For example, one byte (8 bits) can store a number from 0 to 255 (11111111 in binary), but it is convenient to the value stored as from -128 to +127, by performing the "two's complement" (change all 0's to 1's and 1's to 0's, then add 1) to convert a positive number to a negative number, because any binary number and its two's-complement sum to zero (with a carry that overflows out of the byte).  This makes integer subtraction easy (just add the two's complement of the number to be subtracted), but it means that, for example, if you are using 1-byte storage, adding 2 to 127 (00000010 to 01111111 in binary) produces -127 instead of 129."

In readable words :P this bug will certainly occur when the experience received after a very big battle can't be handled by the game. Usually if you continue to play a map after the 12th month and the neutral creatures have an overgrowth. Your experience will go into the negative, all abilities will be lost and you will need certainly more than hundred battles to restore it. The script restore it automatically if lost.

Here it is:

ZVSE

** script to prevent creature experience reduction due to overflow. JHV,
2/3/2009

** uses v7090-v7103 to store troop ranks @ start of battle
** 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


!?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;

!?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

!?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)
!!IF&610:V616/1;



Jim used FU463 which is already claimed for the espionage script so I changed the functions to 459-462. Tested and no bugs so far.

For whom may be concerned.
____________
Era II mods and utilities

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Warmonger
Warmonger


Promising
Legendary Hero
fallen artist
posted February 04, 2009 08:16 AM

Does it work for creatures, hero or both?

Either way, I love this one already

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted February 04, 2009 08:33 AM

The negative experience bug concerns only creatures when stack experience is enabled.
____________
Era II mods and utilities

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
terranu1
terranu1

Tavern Dweller
posted December 15, 2011 06:21 AM

hello I don't know where to post this, here seems what i want but very old post; anyway so I hahve wog 3.58f the standard installation, i modded the growth of creatures so that now maps start with swarm/zounds fo l1 ,throngs for l2 l3 and so on...but as soon as month 4-5 i get the negative xp bug i tried ceating an erm file with erm editor, put all the text here in it and put it in "s" folder of my wog installation but it doesnt work so how do you do it right ??
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
terranu1
terranu1

Tavern Dweller
posted December 15, 2011 06:23 AM

I forgot to say, i'm playing rmg maps with my own made rmg and I also tried copying this script text for no negative xp inside other scripts that came with wog but doesnt work I would really appreciate someone tell me how to add this script so it works with rmg maps
____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted December 15, 2011 06:50 PM
Edited by JimV at 22:46, 15 Dec 2011.

The Negative Experience script has been updated to include Heroes as well as creatures, and to account for many special circumstances.  I will paste a copy of the latest version below.  See the map "The Dragon Slaughter" for more details (in the Help menu which opens when you right-click the System Options button in "The Dragon Slaughter" (TDS)).  TDS can be downloaded at another post on this site.  See the last comments of that post for a link to the latest version.

It was designed as a stand-alone script which is added to a map via the Map Editor/Tools/Map Specifications/Timed Events.  If you are using only wogification scripts, a simple way to get it would be to edit Data/s/script40.erm in the ERM Editor and paste this script at the end of the current script.  I have not used random maps or random-map templates much, but I assume they get their wogification scripts from Data/s.  When adding a new script number to Data\s, I think some text file has to be changed or else the new script will not be used - so adding the script to an existing WoG script is easier.

The script will prevent experience overflows as a result of a battle, but other things can cause experience overflows, such as combining two very large troops or splitting a very large troop.  Once a troop's experience overflows and becomes negative, it can be fixed by right-clicking the troop slot in the Hero screen.  (The troop will be restored to level 10 experience - but only if it has negative experience.)  Also, before trying to split a troop which has too much experience to split without overflow, right-clicking the troop slot will give it -100 experience (only if its total experience is over the limit of 2.147 billion), so that it can be split and then the split troops can be restored by right-clicking.

Large level jumps occur to Heroes after level 108, so such Heroes will be reduced back to level 100 after a promotion from 100 to 108.

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.)
** updated 2010.7.31 after Hero overflow, set exp. pts. & level to 100
** updated 2011.4.16 R-C troop stack which has too much exp to split, -->-100 exp.
** updated 2011.7.5 to account for 1st Aid Tent revivals and Pacification returns
** updated 2011.7.19 to prevent excessive leveling by dropping back to 100 at 108

* 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;
!!VRvv5:Sy3;

!#UN:P3/?v7106; v7106=0 if commanders enabled
!?BA53&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:E2073739175; set att. Hero L=100 if overflow
!!HEv1&v3>-1/v3<8/v5>2130000000:E2073739175; set att. Hero L=100 if almost overflow
!!COv1&v3>-1/v3<8:X1/?v5; get att. cmdr exp.after battle (Paladin learns 150%)
!!COv1&v7106=0/v3>-1/v3<8/v5<1:X1/1508362195; set att. comm. L=74
!!COv1&v7106=0/v3>-1/v3<8/v5>1910034207:X1/1508362195; set att. L=74
!!HEv2&v4>-1/v4<8:E?v6; get def. hero exp.after battle
!!HEv2&v4>-1/v4<8/v6<v7105:E2073739175; set def. Hero L=100 if overflow
!!HEv2&v4>-1/v4<8/v6>2130000000:E2073739175; set def. Hero L=100 if almost overflow
!!COv2&v4>-1/v4<8:X1/?v6; get def. hero exp.after battle
!!COv2&v7106=0/v4>-1/v4<8/v6<1:X1/1508362195; set def. comm. L=74
!!COv2&v7106=0/v4>-1/v4<8/v6>1910034207:X1/1508362195; set def. comm. L=74
**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:C0/x16/d/d/y3/2; reset to fool 1st Aid Tent revivals and Pacification returns
!!HEx1&y4>y3:C0/x16/d/d/10/12; set rank to 10 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:C0/x16/d/d/y3/2; reset to fool 1st Aid Tent revivals and Pacification returns
!!HEx1&y4>y3:C0/x16/d/d/10/12; set rank to 10 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)
!!HE-1:E?v1; chk for -exp.
!!HE-1&v1<0:E18975933; set Hero L=50 if negative (50 promotions is enuff)
!!CO-1&v1<0:X1/18975933; set comm. L=50

!?CM2; click on Hero screen
!!CM:F?v1 I?v2; get flag and clicked object values
!!FU|v1<>4/v2<68/v2>74:E; exit if not ctrl-left-click or not creature slot
!!VRv2:-68; now v2=slot # from 0 to 6
!!HE-1:C0/v2/d/?y2/?y3/2; y2=no., y3=experience
!!VRe-2:Sy2;
!!VRe-3:Sy3;
!!VRe-1:Se-2*e-3:1024;
!!VRv1:Se-1;
!!FU&v1<2097152:E;
!!HE-1:C0/v2/d/d/-100/2; set exp negative so it can be restored after a split
!!CM:R0;

** after L75, level jumps to 88, then 100, then 108, then 868
** to prevent the long sequence 109, 110, 111, ..., 868:
** drop from 108 back to 100 at next movement
!?HM-1&1000;
!!HE-1:Ed/?l;
!!FU&l<108:E;
!!HE-1:E2073739175/100;

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Salamandre
Salamandre


Admirable
Omnipresent Hero
Wog refugee
posted December 15, 2011 08:18 PM
Edited by Salamandre at 20:20, 15 Dec 2011.

Also use the slider bar to combine huge stacks, or there is a chance they simply vanish.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
terranu1
terranu1

Tavern Dweller
posted December 15, 2011 10:12 PM

wow, works now within script 40, thanks

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
terranu1
terranu1

Tavern Dweller
posted December 15, 2011 10:14 PM

is there any fix for the ballistas dissapearing after a few months?

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted December 15, 2011 10:44 PM

Quote:
is there any fix for the ballistas dissapearing after a few months?


I am not familiar with this bug.  Perhaps someone else who knows about it will comment.  If not, I would need a saved game where it is about to happen in order to study it and devise a fix.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
citron9999
citron9999

Tavern Dweller
posted May 27, 2012 03:40 PM

Quote:
Jim Vogan just emailed me this script which will disable the negative experience bug, which is a dead end if occurs.

note from James Vogan:

"The bug you describe probably occurs when the experience exceeds the maximum positive value that its (internal) variable can store.  For example, one byte (8 bits) can store a number from 0 to 255 (11111111 in binary), but it is convenient to the value stored as from -128 to +127, by performing the "two's complement" (change all 0's to 1's and 1's to 0's, then add 1) to convert a positive number to a negative number, because any binary number and its two's-complement sum to zero (with a carry that overflows out of the byte).  This makes integer subtraction easy (just add the two's complement of the number to be subtracted), but it means that, for example, if you are using 1-byte storage, adding 2 to 127 (00000010 to 01111111 in binary) produces -127 instead of 129."

In readable words :P this bug will certainly occur when the experience received after a very big battle can't be handled by the game. Usually if you continue to play a map after the 12th month and the neutral creatures have an overgrowth. Your experience will go into the negative, all abilities will be lost and you will need certainly more than hundred battles to restore it. The script restore it automatically if lost.

Here it is:

ZVSE

** script to prevent creature experience reduction due to overflow. JHV,
2/3/2009

** uses v7090-v7103 to store troop ranks @ start of battle
** 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


!?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;

!?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

!?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)
!!IF&610:V616/1;



Jim used FU463 which is already claimed for the espionage script so I changed the functions to 459-462. Tested and no bugs so far.

For whom may be concerned.


I’m playing h3 and my problem is that I have negative experience for my troops is there way to fix this bug (I mean my save) I don’t want to start this game over again could somebody help me with that Thanks.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted May 27, 2012 04:54 PM

Your saved game can be fixed by hex-editing the game file to reset the negative experience.  Also it might be possible to add the latest negative-experience script (from "The Dragon Slaughter") to the saved game, using one of Bersy's tools.  The first step is to upload the saved game somewhere online (box.net, wikisend, etc.) where it can be downloaded to be worked on, or else email it via the forum's User Profile tool.

To reply, please just click the "Post Reply" icon at the the bottom of the screen, rather than quoting a long post which the original author already knows and no one else wants to read (even the the original author).  The "quote" function is useful to extract (by editing) just a small portion of a long post which the commenter wants to focus on.  In my opinion it should almost never be used to quote a whole post.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
citron9999
citron9999

Tavern Dweller
posted May 27, 2012 07:45 PM

Hi Thanks for Quick replay I have uploaded my saved game file to http://wikisend.com/download/429886/sec4.GM1
It possible to send me detailed instructions what you did to this saved game file?
I want to try to fix something like that next time on my own &#61514;
| appreciate your help.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
JimV
JimV


Responsible
Supreme Hero
posted May 27, 2012 09:24 PM
Edited by JimV at 21:25, 27 May 2012.

I have uploaded saved-game sec5.gm1 to the TDS folder at box.net:

https://www.box.com/shared/bj1eh6b50e

First I re-read Bersy's instructions for using the DEE program:

"For Era 1.9+ F12 will upload updated scripts from Data\s and apply. For earlier versions russian GUI tool "DEE" (wog era 1.81\Tools\DEE v0.6 alpha\) allows to load script from memory, edit and upload to memory. CTRL+L to load, CTRL+U to upload (for english-readers). After uploading, the gamer should save game and load.

DEE also supports 3.58f but one needs to edit "dee.ini" changing Heroes=3.59 to Heroes=3.58."

Then I started h3wog.exe, loaded sec4.gm1, and tried to use the DEE program (after editing dee.ini) to upload my latest experience-checker script into it.  I got the "success" beep, but the script did not seem to be active in the game (after saving as sec5 and reloading).

Next I decompressed the sec5.gm1 file using WinRAR, and examined it with a hex editor.  The map does not appear to have any scripts (wog or otherwise).  That is, it appears to be an un-wogified map with no internal scripts.  Perhaps this is why DEE did not add my script.  It also rules out my other method, of editing existing scripts (comments and instructions) to add ERM code - since there are no scripts to edit.

Finally, I started a memory editor, searched for the negative values of experience which I saw in the game (Gandalf's Sharpshooters, at -96588 and -90045), and changed those values to 70,000 (level 10 experience).  Then I re-saved the game and uploaded it to Box.net.

I recommend adding the experience-checker script as a Timed Event to the map for future play.  I will list the latest version below.

For more information on hex-editing (aka cheating) do a Google search.  There are a number of free programs and tutorials online.


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.)
** updated 2010.7.31 after Hero overflow, set exp. pts. & level to 100
** updated 2011.4.16 R-C troop stack which has too much exp to split, -->-100 exp.
** updated 2011.6.23 to prevent excessive leveling using UN:J1 [Doesn't Work]
** updated 2011.7.5 to account for 1st Aid Tent revivals and Pacification returns
** updated 2011.7.19 to prevent excessive leveling by dropping back to 100 at 108

* 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
!!UN:P3/?v7106; v7106=0 if commanders enabled
!!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;
!!VRvv5:Sy3;

!?BA53&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:E2073739175; set att. Hero L=100 if overflow
!!HEv1&v3>-1/v3<8/v5>2130000000:E2073739175; set att. Hero L=100 if almost overflow
!!COv1&v3>-1/v3<8:X1/?v5; get att. cmdr exp.after battle (Paladin learns 150%)
!!COv1&v7106=0/v3>-1/v3<8/v5<1:X1/1508362195; set att. comm. L=74
!!COv1&v7106=0/v3>-1/v3<8/v5>1910034207:X1/1508362195; set att. L=74
!!HEv2&v4>-1/v4<8:E?v6; get def. hero exp.after battle
!!HEv2&v4>-1/v4<8/v6<v7105:E2073739175; set def. Hero L=100 if overflow
!!HEv2&v4>-1/v4<8/v6>2130000000:E2073739175; set def. Hero L=100 if almost overflow
!!COv2&v4>-1/v4<8:X1/?v6; get def. hero exp.after battle
!!COv2&v7106=0/v4>-1/v4<8/v6<1:X1/1508362195; set def. comm. L=74
!!COv2&v7106=0/v4>-1/v4<8/v6>1910034207:X1/1508362195; set def. comm. L=74
**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:C0/x16/d/d/y3/2; reset to fool 1st Aid Tent revivals and Pacification returns
!!HEx1&y4>y3:C0/x16/d/d/10/12; set rank to 10 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:C0/x16/d/d/y3/2; reset to fool 1st Aid Tent revivals and Pacification returns
!!HEx1&y4>y3:C0/x16/d/d/10/12; set rank to 10 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)
!!HE-1:E?v1; chk for -exp.
!!HE-1&v1<0:E18975933; set Hero L=50 if negative (50 promotions is enuff)
!!CO-1&v1<0:X1/18975933; set comm. L=50

!?CM2; click on Hero screen
!!CM:F?v1 I?v2; get flag and clicked object values
!!FU|v1<>4/v2<68/v2>74:E; exit if not ctrl-left-click or not creature slot
!!VRv2:-68; now v2=slot # from 0 to 6
!!HE-1:C0/v2/d/?y2/?y3/2; y2=no., y3=experience
!!VRe-2:Sy2;
!!VRe-3:Sy3;
!!VRe-1:Se-2*e-3:1024;
!!VRv1:Se-1;
!!FU&v1<2097152:E;
!!HE-1:C0/v2/d/d/-100/2; set exp negative so it can be restored after a split
!!CM:R0;

** after L74, level jumps to 88, then 100, then 108, then 868
** to prevent the long sequence 109, 110, 111, ..., 868:
** drop from 108 back to 100 at next movement
!?HM-1&1000;
!!HE-1:Ed/?l/1;
!!HE-1&l>100:E2073739175/100;
!!HE-1:F?y1/?y2/?y3/?y4;
!!VRy1|y1>125/y1<0:S125; [1-byte storage, -127 to +127, -A/D shows as 0, -P/K shows as 1]
!!VRy2|y2>125/y2<0:S125;
!!VRy3|y3>125/y3<1:S125;
!!VRy4|y4>125/y4<1:S125;
!!HE-1:Fy1/y2/y3/y4;
!!FU&l<100:E;
!!VRy1&y1<1:S125;
!!VRy2&y2<1:S125;
!!VRy3&y3<2:S125;
!!VRy4&y4<2:S125;
!!HE-1:Fy1/y2/y3/y4;

!?HL-1; Hero gets a level promotion [prevent long promotion sequences]
!!HE-1:E?v2/?v1/1;
!!FU&v1<109:E;
!!HE-1:Ed/868;
!!HE-1&v2>=2146553679:Ed/3732;
!!HE-1&v2>=2146733313:Ed/5920;
!!HE-1&v2>=2147293156:Ed/6424;

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Bersy
Bersy


Honorable
Supreme Hero
posted May 27, 2012 11:06 PM

Right. Dee uploads script actually, but only if it already presented in saved game (script with the same number 00..99).

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
citron9999
citron9999

Tavern Dweller
posted May 28, 2012 08:39 AM

Thank you very much you save my day again

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread »
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0879 seconds