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: ERA scripts debugging and fixing
Thread: ERA scripts debugging and fixing This thread is 5 pages long: 1 2 3 4 5 · NEXT»
majaczek
majaczek


Supreme Hero
Work at Magic Dimmension
posted May 04, 2012 03:11 PM
Edited by majaczek at 15:26, 04 May 2012.

ERA scripts debugging and fixing

The topic is mainly for getting merged_SU enough stable, but any ERA script-related bugs fits here. That mean if you have problem with merged_SU, original ERA scripts, or perhaps any ERA mod scripts - post savegame before and after error and we both can try fix your savegame and try fixing the original scripts so it hopefully won't happen again.

The ultimate aim: make central place for fixing bugs in ERM and savegames (ERA dependent). The near aim: make merged_SU enough stable to satisfy Bersy (from my point of view it's very stable now, but Bersy have higher standards on it).

I have not enough manpower myself for the job so JimV, Bersy, Fnord and any Scipter authorities are highly welcome here. Still if you are not yet an authority in scripting but you can feel that fixing anything/something from spectrum of mentioned problems is possible for you = you are welcome as resolver. We want to keep community atmosphere like in ERA thread - so anybody can help and anybody can ask for help. Don't demand work done but simply gently ask for help.

==========================================================
current subjects to inspect:
1) merged_SU http://mir.cr/0GWDM7KK - Hybrid between ERA official scripts and Script Update (put on top of latest ERA - same files as in ERA not included) - state: sources merged, major incompabilities solved - search for: any incompabilities between two components, functions which returns via global variables (mostly negative indexes), fragments of code resulting in rare bugs

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


Responsible
Supreme Hero
posted May 04, 2012 05:58 PM

I thank Majaczek for posting this topic as I think it will benefit the user community.

Besides bug reports, this could also be a venue to request changes or additions to script features.

Even without the language barriers people have, it is difficult to envision the exact problem or feature which someone is trying to report, so the more information (screenshots, etc.) which can be provided the better.  As Majaczek indicates, the most complete source of information would be a saved game which exhibits the problem.  For example, the problem might be system-related, which would be suspected if the saved game did not have the problem on another system.  Saved-game files can be uploaded to some site such as wikisend or box.net, or emailed via the membership list.

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


Honorable
Supreme Hero
posted May 04, 2012 07:07 PM

Bug Report #1
5_Red_Adventure_Cave_Bug - WoG 3.58f bug. You can fight in Adventure Cave with troglodytes endlessly.
3_Red_Hell_Barons_Bug - [unchecked] Hell Barons have huge speed.
3_Red_Tavern_Bug - [unchecked] Bugs in Thieves Guild report.
3_Red_Art_Bug - Era 2.1- HE:A3 bug. Fixed in Era 2.2.

/Reported by SyDr

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


Honorable
Supreme Hero
posted May 04, 2012 07:18 PM

Bug report #2
Saved game cannot be loaded. Reason: garrisons script kills the game. Observations: multiple.

/Reported by SyDr.

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


Honorable
Supreme Hero
posted May 04, 2012 07:22 PM
Edited by Bersy at 19:37, 04 May 2012.

Bug report #3
Press "M" and choose "normal battle". Random Hero script produces ERM errors message.

/Reported by SyDr.

Bug report #4
Dan of Thieves bugs:
1_Tan - dead red player exists in the statistics.
5_Tan - crash on visiting Dan of Thieves.

/Reported by SyDr.

Bug report #5
External halflings dwelling cannot be upgraded if Neutrals Town is on.

/Reported by SyDr.

Bug report #6
Dead war machines are displayed as stroked pikeman in post-battle info.

/Reported by SyDr.

Bug report #7
Scouting script with random events generates them REALLY rarely (once per several weeks)

/Reported by SyDr.

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


Responsible
Supreme Hero
posted May 04, 2012 10:28 PM
Edited by JimV at 22:38, 04 May 2012.

Bersy, thanks for the information, which must have taken a lot of time to compile.

Starting at the top, Bug Report #1, Adventure Cave:

Debug Report:

I downloaded the game file, ran it under Era 2.1, and verified that the Trogs will attack the same Hero every time the Hero searches the cave.  The Trog Attack is produced by this script segment:

...
!!IF&v602=1:M1/z130021; [Trog Attack message--JV]

!!IF&v602=0/y1=1:M1/z130022;
!!VRv547&v602=0/y1=1:S1; [use battlefield #1 for this fight]
!!HE-1&v602=0/y1=1:Tv998/v999/v1000/71/70; [provoke battle w/ 70 infernal trogs]
!!HE-1:O?y3; [check owner in y3 to see if hero died]
!!VRv609:|4; [set split-cave-monster-killed bit]
!!FU769&v602=0/y1=1/y3<>-1:Pv609/998; [store modified bits if monster and it's beaten]

...

So the attack is supposed to be recorded by setting bit-value 4 in v609 and then calling FU769 which stores this value in PO:O at the cave location.  At the beginning of the function which contains the above code, PO:O is read and tested and y1 is set to zero if PO:O has the bit whose value is 4 set.  This "should" work.

I added the following IF:M statements to the Adventure Cave script (easy to do under Era with F12):

...
!!IF&v602=1:M1/z130021;

!!IF&v602=0/y1=1:M1/z130022;
!!VRv547&v602=0/y1=1:S1; [use battlefield #1 for this fight]

!!IF:M^v609=%V609, v602=%V602, y1=%Y1, v998=%V998, v999=%V999^; <--JV

!!HE-1&v602=0/y1=1:Tv998/v999/v1000/71/70; [provoke battle w/ 70 infernal trogs]
!!HE-1:O?y3; [check owner in y3 to see if hero died]
!!VRv609:|4; [set split-cave-monster-killed bit]

!!IF:M^v609=%V609, v602=%V602, y1=%Y1, y3=%Y3, v998=%V998, v999=%V999^; <--JV

!!FU769&v602=0/y1=1/y3<>-1:Pv609/998; [store modified bits if monster and it's beaten]

and got these results (before and after the combat):





That is, the value of y1 has changed from 1 to 0 unexpectedly during the combat, which negates the conditions used to record the combat.

As far as I can see, this script should work - it occurs within a function (FU732), and local y-variables should not be able to be changed by another trigger section (HE:T) called from within a function - at least, that is what my experience with WoG 3.58f indicates.

It could be fixed by using an (unclaimed) permanent variable instead of y1, in this instance, but first I must ask whether I am mistaken in my conclusion, since if I am not, many WoG 3.58f scripts will probably need revision.

P.S. It occurred to me that perhaps FU732 which contains the above code is being interfered with by some other script, but I searched the game file and did not find another references to it in other scripts.

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


Honorable
Supreme Hero
posted May 04, 2012 11:39 PM

Thanks Jim for analyzing. It seems that there is at least one bug in my implementation of saving/restoring y-vars in triggers. I will try to investigate it deeper tomorrow and fix in the upcoming Era 2.2 release. If Adventure Cave works correctly after fixing, I'll post here about the results and we will close this case. Sorry for the bug.

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


Responsible
Supreme Hero
posted May 05, 2012 12:27 AM
Edited by JimV at 00:38, 05 May 2012.

Debug Report:  3_Red_Hell_Barons_Bug - [unchecked] Hell Barons have huge speed.

True.  Before the end of Tactics, they have speed 19, and after 49:





However, this seems to be what the Enhanced Monsters script is intended to do:
...
!?BA0&v7183=1/-998;                 [continue if enabled]
...
!!VRv7011|y-1>0/y-2>0:S1;                [set v7011 to 1 if anyone has tactics] <--so before end of Tactics, v7011=1--JV
...

** start of battle turn trigger **
!?BR&v7183=1/-998;                         [continue if enabled]

!!FU7066&v7001=54/v7011=0:P0/v7010;        [restore speed - devils]
!!FU7066&v7001=55/v7011=0:P0/v7010;        [restore speed - arch devils]
!!FU7066&v7001=153/v7011=0:P0/v7010;       [restore speed - hell barons]

!!VRv7006:S-1;                             [reset fastest speed]
!!DO7060/0/41/1:P;                         [prepare to give spells/abilities/check for fastest monster]
!!BMv7004:T?y-5;                            [get fastest monster's type]

!!VRv7011&v997=0:S0;                       [enable speed boost after tactics is done] <--note: at round 0 v7011=0--JV
!!FU7066&y-5=54/v7011=0:P1/v7004;           [boost speed - devils]
!!FU7066&y-5=55/v7011=0:P7/v7004;           [boost speed - arch devils]
!!FU7066&y-5=153/v7011=0:P8/v7004;          [boost speed - hell barons]
...

** function to boost speed      x1=offset  x2=target
!?FU7066;
!!BMx2:S?y1;                          [get speed]
!!VRy1:-x1;                           [speed offset]
!!BMx2&y1<1:Sd30;                     [boost speed if <1]
!!BMx2&y1>30:Sd-30;                   [restore speed if >30]
!!BMx2&x1>0:Sd30;                     [boost speed]<--19+30=49--JV

+30 speed does seem like a lot, but that seems to be what the WoG Team wanted.  It can easily be changed by editing the "30" values in FU7066 to some other number, if users would prefer some other number.

(I have never used this script myself, and maybe I am missing something or don't understand the issue.)

P.S. (I didn't see Bersy's reply above as I was writing this.)  Thanks  for the quick reply, but I wouldn't be totally surprised if I missed something and it is not a Era problem.  Even if so, as a great man once pointed out, code errors are inevitable.  I take great comfort in this quotation by Einstein:  "All coders make mistakes; good coders find them." (Once their existence is pointed out.)  Actually he said that about mathematicians, but coders and mathematicians are pretty much the same thing.

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


Supreme Hero
Work at Magic Dimmension
posted May 05, 2012 02:14 AM

Heh - thanks for Replying. It seems this topic was really needed. Most credits for idea of starting such thread goes to JimV. About what is ontopic and what is offtopic: WoG Scripts Bugs not fixed in ERA nor SU is definately ontopic. The relation to ERA mentioned was just to make sure we move on ERA world so we don't need to avoid ERM commands availible in ERA but not in 3.58f nor should we matter about ERM interpreter bugs already fixed in ERA until fix is not entirely correct.

Even beeing "a bit" offtopic seems to be allowed if it has good enough link with rest of the thread (I couldn't avoid tangents in discussion, so I see no reason to not allow it to other speaking in the thread - even if they would be a bit more than usual).

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


Responsible
Supreme Hero
posted May 05, 2012 05:38 AM
Edited by JimV at 06:14, 05 May 2012.

Re:

Bug Report #1
3_Red_Tavern_Bug - [unchecked] Bugs in Thieves Guild report

I loaded the saved game.  I couldn't see any outside Thieves Guilds so I used a (Red) Tavern:



So far as I could check it (I could find some of the Heroes shown, but not all), it looks correct to me.  I suppose one could argue whether Sanya's Rust Dragons or Supreme Arch Angels are the most powerful Blue creatures, but I guess Heroes 3 is going by hit points.

I think I have seen instances where the Thieves Guilds did not update immediately when a top Hero is eliminated, but I think that goes back to SoD and before.

Anyway, I am missing the bug here, sorry.

Re:
Bug report #2
Saved game cannot be loaded. Reason: garrisons script kills the game.

This one does not look easy to resolve either.  The saved game crashes early in its loading process, apparently before any ERM commands are executed.  I tried disabling all GM0 triggers in the saved game, and that had no effect.  I also tried disabling the instruction at the EIP address of the crash, but that only moved the crash to a different EIP.  There may be some more information which I can find in the saved game.  Maybe I can eliminate all the Garrisons, but I have a hunch that the damage is already done.

[Update - I changed all the Garrison DEF names in the game file, e.g., AVCgar10.def --> JVCgar10.def, and after giving error messages for all the missing DEF's, I got the same crash as before.  Having missing DEF's is non-fatal, in my experience, so I think the cause of the crash is somewhere downstream of loading the Garrison DEF's.  Maybe I will try removing more DEF's - tomorrow.]

I tried creating a random map with the Garrisons script enabled, and played it for a couple of weeks of game-time, so far, with no problems yet (saving and re-loading every couple days).

A quick look at the script (which is another one which I have never used before) did not uncover anything obvious.  The Garrison creatures grow by 5% a week, but in a year of game-time that would only multiply initial numbers by about 10.  There are some special battle features.  Unfortunately, I started my test game at Impossible level out of habit, and it will be a long time before I have an army which can compete with any of the Garrisons on the map.  (I will probably start over with a better starting army.)

This is all negative information, but maybe it will give someone else an idea.

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


Honorable
Supreme Hero
posted May 05, 2012 10:12 AM
Edited by Bersy at 12:07, 05 May 2012.

3_Red_Hell_Barons_Bug - approved, a feature.

3_Red_Tavern_Bug - Teal player is dead, but exists in the Artifacts statistics (3-d place). I suspect Random Hero bug. Dead hero could suddenly obtain an owner. To see the scripts, used in the game, press F11 and look at Data\Extracted Scripts.

Quote:
Saved game cannot be loaded.

I faced this problem a few times from 2009 year. When garrisons script is on, some day the game refuses to load. The same problem as with passable terrain script (this one is the major save killer). I should recheck the placing algorithm, also ERM UN:I with 7 parameters could be buggy. We could make an empty test map and fill it fully with garrisons to test the limitation on garrisons quantity. Then we could try placing garrisons a bit out-of-the map.

Thanks for help.

[EDIT] Fixed the bug with y-vars. Now adventure cave seems to be ok.

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


Responsible
Supreme Hero
posted May 05, 2012 02:33 PM

Quote:
3_Red_Tavern_Bug - Teal player is dead, but exists in the Artifacts statistics (3-d place).


This did not occur when I loaded the saved game (3_Red_Tavern_Bug) - see the screen-capture above - there is no Teal.  The Hell Baron saved-game seems to be an earlier save from the same random map, and in that save Teal still exists and is about to be eliminated in the Hell Baron battle.  As I noted, I think I have seen the Thieves Guild be slow to update even in SoD, but it appeared to be updated when I reloaded.  (Or else I am misunderstanding what you are saying.)

Garrisons - I appreciate the suggestions for testing Garrisons in a test map, and I have a similar hunch about the bugginess of object placement, but first I plan to play with the saved game data some more.  It uses a total of 1321 different DEF's (that is, not the total number of objects but the total number of DEF's which objects use), and I am tempted to reduce that count to below where the Garrison DEF's are listed and see what happens.  In principle, I should be able to remove objects from the map by manipulating the saved-game data, but I have never tried to do this and will have to learn as I experiment.  If the map data has been badly corrupted, this might not turn out to be useful, but it could be interesting.

In my random test map, the Garrisons seemed to be well-placed and an interesting addition to the map, so it would be good to save this script if possible.

Thanks for your work and suggestions.  The y1 fix was almost instantaneous, and could fix some other script problems also.


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


Honorable
Supreme Hero
posted May 05, 2012 02:53 PM

Quote:
there is no Teal.

On your screen [Artifacts - 3rd] is Teal. The green is to the left side. The orange is absent in that line at all!

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


Responsible
Supreme Hero
posted May 05, 2012 03:21 PM

Now I understand, thank you for your patience.

When I fought Teal in the Hell Barons saved game and eliminated him, my Red Hero got a humungous amount of artifacts - three or more full screens of them, which made me wonder if the Red Hero's backpack would hold so many, but I didn't check.  However, now I suspect that there was a backpack overflow, and that this may have caused data corruption which leads to the TG glitch.  If so, I think a Backpack Overflow Script could be developed, similar to the Experience Overflow script used in The Dragon Slaughter map.  I will investigate this further.

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


Honorable
Supreme Hero
posted May 05, 2012 03:30 PM

Got advice from SyDr. Possibly this bug was produced by HE:A3 command, which was badly fixed in Era 2.1-. Original WoG had no code for decreasing number of artifacts in hero bag after HE:A3 artifacts deletion. I inserted the code, but it did not take into account that artifacts can also be on hero's body and thus no decrement was necessary. You see: 0 arts - 1 = 255 arts(!) which corrupts the whole bag.

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


Responsible
Supreme Hero
posted May 05, 2012 03:58 PM
Edited by JimV at 16:02, 05 May 2012.

My reading of the HE:A3 description in ERM Help told me that it should never be used - that HE:A, HE:A-, and HE:A4 should be used instead, so I have never used HE:A3 in any script and am surprised if the WoG scripts use it.  (In my Dress Code script, I count numbers of artifacts with HE:A2, remove all of one type with HE:A-, then add back some with HE:A, as necessary to achieve a specific number.)

More information from the Hell Baron battle save (in which Xarfax/Teal is eliminated):  Kalt gets 67 artifacts from Xarfax at the end of that battle.  If I give Kalt six more artifacts (from the other Red hero) before the battle, then Kalt wins 57 artifacts from Xarfax (unless I have miscounted - I will double-check).  While this is not conclusive, the mismatch in numbers (67-6 <> 57) seems to indicate some sort of data corruption.  My next act will be to try to remove most artifacts from Xarfax before the battle and see what happens.

It would be a massive coincidence if a previous save explains the TG glitch, so I am probably wrong, but it seems worth investigating.

Update - I see HE:A3 is used in the Artifact Boost script, to my surprise.

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


Honorable
Supreme Hero
posted May 05, 2012 04:08 PM
Edited by Bersy at 16:10, 05 May 2012.

These files use (+Phoenix Mod):

1 wog - cheat menu.erm
5 wog - enhanced war machines 3.erm
6 wog - random hero.erm
48 wog - adventure cave.erm
50 wog - school of wizardry.erm
51 wog - spell book.erm
53 wog - map options.erm
65 wog - tavern gambling game.erm
70 wog - junk merchant.erm
72 wog - hourglass of asmodeus.erm
76 wog - artifact boost.erm

grepWin utility, regular expression search: !!HE[^:]*:A3

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


Responsible
Supreme Hero
posted May 05, 2012 05:02 PM

Then if HE:A3 can be fixed in the executable code, that would be the best solution.

This is disappointing (from the Tavern Card Game):

[Display message that other players take hero's winnings - remove winnings]
!!IF&v419>40/-408:Q1/36/$stake$/8/$prize$/1/z113042;
!!VR$stake$:*-1;
!!OW&v419>40/-408:R-1/6/d$stake$;
!!HE-1&v419>40/-408:A3/$prize$/1/1;

ERM Help states:

A3/$1/$2/$3 - Remove several copies of artifact
  $1 - Number of artifact. (see Format A1).
  $2 - Numbers of copy to delete
  $3 - Flag to delete first equipped (1) or in backpack (0) _
Notes:
- If you remove an artifact that has added a spell to a hero's book with ERM (HE:A- or HE:A3), the spell remains in the hero's book permanently.
- If you remove an artifact with HE:A- it will correctly remove the added bonuses but if you remove it with HE:A3 it won't remove the bonuses.
- If you remove a combo artifact with HE:A- it will correctly remove the locked slots and added bonuses too, but if you remove it with HE:A3 it won't remove either!

So HE:A3 should only be used to delete items from a Hero's backpack, but the script above will (deliberately) remove an equipped item first.  This seems strange to me.

In practice, I suspect most people who win a prize in the Tavern Card Game and lose it will reload their last save, without noticing that they still had the bonuses of the lost prize (if non-primary-skill bonuses apply - probably they don't though).

All of those scripts could be corrected using HE:A- and HE:A, but if you can fix HE:A3 itself that would be a more elegant solution.  On the other hand, how much can one person do?  Let me know if you would rather have the individual scripts corrected.



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


Honorable
Supreme Hero
posted May 05, 2012 05:47 PM
Edited by Bersy at 17:57, 05 May 2012.

Thanks, I've already fixed it, so I hope it will eliminate many problems.

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


Promising
Famous Hero
posted May 06, 2012 02:25 PM

Old scripts are unloaded from memory too late after starting new map and some triggers from previous map may get executed and have unintended effects. The following example shows how AE trigger works where it shouldn't.

Steps:
1. download and start this map: test.h3m
2. exit map
3. start any other map and choose an artifact as starting bonus.


____________

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 5 pages long: 1 2 3 4 5 · NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.1134 seconds