Jump to content

IE Engine and basic script running question


erebusant

Recommended Posts

I recently came across a CTD in my install that was caused by a corrupted .cre file that was corrupted by the code I came across that Nythrun posted to enforce .cre order, and to make certain that they use v2 effects. How and why certain cre files get corrupted by this, I haven't a clue, however so far I've only run across approx 6 instances of this occuring out of 10,270 .cre files. That aside, what I'd really like to learn is how and why this particular corrupted .cre would cause a CTD when it is in an entirely different area of my game than the one I'm in when the CTD occurs. Following is order of events in my game:

1. Party enters F_8888.are which has the are script that includes the following block:

IF
Global("F_finalfight","GLOBAL",1)
!Exists("F_ROBED")
THEN
RESPONSE #100
	CreateCreature("F_ROBED",[660.850],8) // Robed Figure
	SetGlobal("F_finalfight","GLOBAL",2)
END

Global("F_finalfight","GLOBAL",X) is non-existant at this point.

2. Party travels to F_8889.are with no problems.

3. Party travels to F_9999.are with no problems.

4. Party travels to F_9595.are with no problems.

5. Party enters F_9797.are in which there is Catti-Brie and Jarlaxle (among others).

6. Catti-Brie dialogs with party and the action associated with her last dialog state does SetGlobal("F_finalfight","GLOBAL",1).

7. Immediately before anything can occur Jarlaxle's dialog with the party kicks in and in his dialog once again the last dialog state before exiting to battle has DO SetGlobal("F_finalfight","GLOBAL",1).

8. Both of these dialogs occur with Tweaks set to "Pause on all dialogs" so you don't notice the crash right away until both dialogs end.

9. If you delete the SetGlobal from 1 or the other dialog, but not both the CTD still occurs as soon as they both end as I'd expect.

10. If you delete the SetGlobal from both dialogs the CTD no longer occurs.

11. If you delete the F_8888.bcs from override and leave the dialogs alone, the CTD does not occur.

12. If you leave both dialogs and the bcs file alone and copy the original .cre file from the installation folder, the CTD does not occur.

 

So in essence, it would seem that all area scripts are continuously running in the game, regardless of whether you are in the area or not. Or is this only true for areas that you have actually visited? Along that line, if you are completed with an area and will never be returning to it, is there a way to turn those scripts off so they are not continuously running?

Link to comment

Master areas.

 

Child areas may or may not be running their scripts at the same time as the last loaded master area. I believe ToB makes this behavior worse (more can happen in an inactive but loaded area), but it's always worked this way.

Link to comment

Yeah, once the master area is loaded its script continues running after you transition to child areas.

 

Do you remember, offhand, which creatures that ancient bedragged unsupported patch screwed up? I knew of two from Cliffette's mods (where the Bhaalspawn innates had been removed by deleting part of the memorized spells table rather than just removing the list entries) and the mysterious bub3.cre that can't reasonably be fixed by automation, but if there's more I'd like to make sure that newer versions aren't exacerbating errors :cool:

Link to comment
Yeah, once the master area is loaded its script continues running after you transition to child areas.

 

Do you remember, offhand, which creatures that ancient bedragged unsupported patch screwed up? I knew of two from Cliffette's mods (where the Bhaalspawn innates had been removed by deleting part of the memorized spells table rather than just removing the list entries) and the mysterious bub3.cre that can't reasonably be fixed by automation, but if there's more I'd like to make sure that newer versions aren't exacerbating errors :cool:

I'll post my list when I get home tonite, along with the original .cre files.

Link to comment
Yeah, once the master area is loaded its script continues running after you transition to child areas.

 

Do you remember, offhand, which creatures that ancient bedragged unsupported patch screwed up? I knew of two from Cliffette's mods (where the Bhaalspawn innates had been removed by deleting part of the memorized spells table rather than just removing the list entries) and the mysterious bub3.cre that can't reasonably be fixed by automation, but if there's more I'd like to make sure that newer versions aren't exacerbating errors :cool:

Nythrun - Here is the link to the download for my corrupted file so far. http://www.shsforums.net/index.php?showtop...id=396974

I've encrypted the .rar and PM'ed you the password since I don't wan't to be spreading the .tp2 I've been running and have others corrupting any .cre's in their games as well, however few they are.

Link to comment

f_robed.cre is missing spell memorization table entries for wizard levels 8 and 9, and for innates - a little too much mess for old versions of that patch to smooth over. Changing "crash only with HaveSpellInnate()" to "crash always" wasn't much of an improvement though. I'll check the rest too - if this is the only error that was unaccounted for on a mega - install, it ought to be smooth sailing from here on out :cool:

Link to comment
f_robed.cre is missing spell memorization table entries for wizard levels 8 and 9, and for innates - a little too much mess for old versions of that patch to smooth over. Changing "crash only with HaveSpellInnate()" to "crash always" wasn't much of an improvement though. I'll check the rest too - if this is the only error that was unaccounted for on a mega - install, it ought to be smooth sailing from here on out :cool:

How would you code a COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~ to read offsets 2d4 through 3d4 and then have it spit out a list of any .cre's that are missing any of those spell memorization table entries? That way I would be able to know which .cre files would possibly cause these problems before I reach them in the game. I guess they could be patched to insert the spell memorization table entries that are missing as well.

Link to comment
COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ nowhere
 READ_LONG 0x2ac m ELSE 0
 PATCH_IF m != 17 BEGIN
TO_LOWER SOURCE_FILE
SET $m(~%SOURCE_FILE%~) = 0
 END
BUT_ONLY
ACTION_PHP_EACH m AS i => s BEGIN
 PRINT ~%i_0% has an issue~
END

Link to comment
COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ nowhere
 READ_LONG 0x2ac m ELSE 0
 PATCH_IF m != 17 BEGIN
TO_LOWER SOURCE_FILE
SET $m(~%SOURCE_FILE%~) = 0
 END
BUT_ONLY
ACTION_PHP_EACH m AS i => s BEGIN
 PRINT ~%i_0% has an issue~
END

Very Cool. The following from my mega-install:

[./override/ZOMBX1.CRE] loaded, 1116 bytes
[./override/ZORDRA.CRE] loaded, 1456 bytes
[./override/ZORL.CRE] loaded, 1116 bytes
[./override/ZPRIZE1.CRE] loaded, 1356 bytes
[./override/ZPRIZE2.CRE] loaded, 1356 bytes
[./override/ZPRIZE3.CRE] loaded, 1356 bytes
[./override/ZPRIZE4.CRE] loaded, 1356 bytes

bart9.cre has an issue

charbase.cre has an issue

f_robed.cre has an issue

j#pirat4.cre has an issue

nthasten.cre has an issue

ntmonkd2.cre has an issue

ntmonkde.cre has an issue


Saving This Log:
BG2FIXPACK/SETUP-BG2FIXPACK.TP2  0  0 Installed 
BG2FIXPACK/SETUP-BG2FIXPACK.TP2  0  1 Installed

Most of these were already identified, with the exception of NTPIQUE, but all in all, this error is fairly minimal and can be fixed easily.

Link to comment
f_robed.cre is missing spell memorization table entries for wizard levels 8 and 9, and for innates - a little too much mess for old versions of that patch to smooth over. Changing "crash only with HaveSpellInnate()" to "crash always" wasn't much of an improvement though. I'll check the rest too - if this is the only error that was unaccounted for on a mega - install, it ought to be smooth sailing from here on out ;)

For Nythrun - Here is another occurence of a .cre broken in a different way.

http://www.shsforums.net/index.php?showtop...id=397153

In this case the original .cre file was missing Priest Spell Memorization table 6, Wizard Spell Memorization table 8 and Innate Spell Memorization table 0. It looks like the patch code inserted the missing Spell Memorization Tables properly, however the .cre file still crashed the game. As it turned out, what I needed to do to repair the .cre file was to go through the Spell Memorization Tables and manually index the memorized spells. After this was completed, the .cre no longer crashes the game. Now the damned guy is just kicking my ass all over the place, so basically the same result,,, :cool: .

 

I guess I need to run the "Find the F*'ed Up CRE" Code prior to running the patch code in order to better see how many .cre files may be effected. Edit** I ran it on my test install with only 5700 or .cres and before the patch code and sure enough there are several more probable problem cre files. I attached the debug at the above link as well.

Link to comment

Here, if you're looking for problem files to troubleshoot, you might as well have the code from the latest unreleasable version of Level1NPCs - which has been safe as houses on everything I've checked thus far. Syntax is

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ override
 LAUNCH_PATCH_MACRO fj_cre_validity
 PATCH_IF valid BEGIN
LAUNCH_PATCH_MACRO fj_enforce_cre_order
LAUNCH_PATCH_MACRO fj_use_v2_eff
 END
BUT_ONLY

 

where macros are

DEFINE_PATCH_MACRO fj_cre_validity BEGIN
 LOCAL_SET temp_0 = 0x02d4
 LOCAL_SET temp_1 = 0x02d4
 LOCAL_SET temp_2 = 0x02d4
 LOCAL_SET temp_3 = 0x0000
 LOCAL_SPRINT signature ~CRE V1.0~
 SET valid = 0x01
 PATCH_IF ~%SOURCE_RES%~ STRING_EQUAL_CASE charbase BEGIN
SET valid = 0x00
PATCH_PRINT ~We do not tamper with charbase.cre lightly.~
 END ELSE BEGIN
PATCH_IF SOURCE_SIZE < 0x2d4 BEGIN
  SET valid = 0x00
  PATCH_PRINT ~%SOURCE_FILE% is corrupt: below minium length.~
END ELSE BEGIN
  READ_ASCII 0x000 signature
  PATCH_IF ~%signature%~ STR_CMP ~CRE V1.0~ BEGIN
	SET valid = 0x00
	PATCH_PRINT ~%SOURCE_FILE% is corrupt: header misplaced.~
  END ELSE BEGIN
	DEFINE_ASSOCIATIVE_ARRAY cre_offset BEGIN
	  0x02a0 => 0x02a4
	  0x02a8 => 0x02ac
	  0x02b0 => 0x02b4
	  0x02b8 => 0x02c0
	  0x02bc => 0x02c0
	  0x02c4 => 0x02c8
	END
	PHP_EACH cre_offset AS temp => temp_1 BEGIN
	  READ_LONG temp_0 temp_2
	  READ_LONG temp_1 temp_3
	  PATCH_IF temp_3 = 0x00 && temp_2 < 0x2d4 BEGIN
		WRITE_LONG temp_0 0x2d4
	  END
	  PATCH_IF temp_3 != 0x00 && temp_2 < 0x2d4 BEGIN
		SET valid = 0x00
		PATCH_PRINT ~%SOURCE_FILE% is corrupt: extended structures pointed to header.~
	  END
	END
  END
END
 END
END
DEFINE_PATCH_MACRO fj_enforce_cre_order BEGIN
 LOCAL_SET eff	= 0x00
 LOCAL_SET kso	= 0x2d4
 LOCAL_SET ksc	= 0x00
 LOCAL_SET smo	= 0x2d4
 LOCAL_SET smc	= 0x00
 LOCAL_SET mso	= 0x2d4
 LOCAL_SET msc	= 0x00
 LOCAL_SET iso	= 0x2d4
 LOCAL_SET ilo	= 0x2d4
 LOCAL_SET ilc	= 0x00
 LOCAL_SET elo	= 0x2d4
 LOCAL_SET elc	= 0x00
 LOCAL_SET i_0	= 0x00
 LOCAL_SET off_0  = 0x00
 LOCAL_SET off_1  = 0x00
 LOCAL_SET temp_0 = 0x00
 LOCAL_SET temp_1 = 0x00
 LOCAL_SPRINT ks   fail
 LOCAL_SPRINT sm   fail
 LOCAL_SPRINT ms   fail
 LOCAL_SPRINT is   fail
 LOCAL_SPRINT il   fail
 LOCAL_SPRINT el   fail
 READ_BYTE	0x0033 eff
 READ_LONG	0x02a0 kso
 READ_LONG	0x02a4 ksc
 READ_LONG	0x02a8 smo
 READ_LONG	0x02ac smc
 READ_LONG	0x02b0 mso
 READ_LONG	0x02b4 msc
 READ_LONG	0x02b8 iso
 READ_LONG	0x02bc ilo
 READ_LONG	0x02c0 ilc
 READ_LONG	0x02c4 elo
 READ_LONG	0x02c8 elc
 READ_ASCII   kso ks ELSE fail (0x0c * ksc)
 READ_ASCII   smo sm ELSE fail (0x10 * smc)
 READ_ASCII   mso ms ELSE fail (0x0c * msc)
 READ_ASCII   iso is ELSE fail (0x50)
 READ_ASCII   ilo il ELSE fail (0x14 * ilc)
 READ_ASCII   elo el ELSE fail (elc * (0x30 + ((eff & 0x01) = 0x01 ? 0xd8 : 0x00)))
 DELETE_BYTES	  0x02d4 SOURCE_SIZE - 0x02d4
 SET			   off_0 = 0x02d4
 WRITE_LONG		0x02a0 off_0
 PATCH_IF ~%ks%~ STR_CMP fail BEGIN
INSERT_BYTES	off_0 0x0c * ksc
WRITE_ASCIIE	off_0 ~%ks%~
 END ELSE BEGIN
SET			 ksc = 0x00
WRITE_LONG	  0x02a4 ksc
 END
 SET			   off_0 += 0x0c * ksc
 WRITE_LONG		0x02a8 off_0
 INSERT_BYTES	  off_0 0x10 * 0x11
 PATCH_IF ~%sm%~ STR_CMP fail && smc = 0x11 BEGIN
WRITE_ASCIIE	off_0 ~%sm%~
 END ELSE BEGIN
FOR (i_0 = 0x00; i_0 < 0x07; i_0 += 0x01) BEGIN
  WRITE_SHORT   off_0 + i_0 * 0x10 i_0
END
FOR (i_0 = 0x00; i_0 < 0x09; i_0 += 0x01) BEGIN
  WRITE_SHORT   off_0 + i_0 * 0x10 + 0x070 i_0
  WRITE_SHORT   off_0 + i_0 * 0x10 + 0x076 0x01
END
WRITE_SHORT	 off_0 + 0x106 0x02
PATCH_IF ~%sm%~ STR_CMP fail BEGIN
  PATCH_IF smc > 0x11 BEGIN
	SET msc = 0x00
	SPRINT ms fail
  END ELSE PATCH_IF smc < 0x11 && smc > 0x00 BEGIN
	PATCH_IF STRING_LENGTH EVALUATE_BUFFER ~%sm%~ = 0x10 * smc BEGIN
	  SET smc = 0x11
	  WHILE STRING_LENGTH EVALUATE_BUFFER ~%sm%~ > 0x00 BEGIN
		SET off_1 = 0x00
		INNER_PATCH_SAVE sm ~%sm%~ BEGIN
		  READ_SHORT   0x00 temp_0
		  SET off_1 += temp_0 * 0x10
		  READ_SHORT   0x06 temp_0
		  SET off_1 += 0x70 * temp_0 + (temp_0 = 0x02 ? 0x10 : 0x00)
		  READ_SHORT   0x08 temp_0
		  READ_ASCII   0x00 temp_1 (0x10)
		  DELETE_BYTES 0x00 0x10
		END
		WRITE_ASCIIE off_0 + off_1 ~%temp_1%~
		FOR (off_1 += 0x10; off_1 < 0x110; off_1 += 0x10) BEGIN
		  WRITE_SHORT off_0 + off_1 + 0x08 temp_0
		END
	  END
	END ELSE BEGIN
	  SET smc = 0x11
	  SET msc = 0x00
	  SPRINT ms fail
	END
  END
END
 END
 SET			   off_0 += 0x110
 WRITE_LONG		0x02b0 off_0
 PATCH_IF ~%ms%~ STR_CMP fail && ~%sm%~ STR_CMP fail && smc = 0x11 BEGIN
INSERT_BYTES	off_0 0x0c * msc
WRITE_ASCIIE	off_0 ~%ms%~
 END ELSE BEGIN
SET			 msc = 0x00
WRITE_LONG	  0x02b4 msc
 END
 SET			   smc = 0x11
 WRITE_LONG		0x2ac smc
 SET			   off_0 += 0x0c * msc
 WRITE_LONG		0x02c4 off_0
 PATCH_IF ~%el%~ STR_CMP fail BEGIN
INSERT_BYTES	off_0 (elc * (0x30 + (((eff & 0x01) = 0x01) ? 0xd8 : 0x00)))
WRITE_ASCIIE	off_0 ~%el%~
 END ELSE BEGIN
SET			 elc = 0x00
WRITE_LONG	  0x02c8 elc
 END
 SET			   off_0 += (elc * (0x30 + (((eff & 0x01) = 0x01) ? 0xd8 : 0x00)))
 WRITE_LONG		0x02bc off_0
 PATCH_IF ~%il%~ STR_CMP fail BEGIN
INSERT_BYTES	off_0 (0x14 * ilc)
WRITE_ASCIIE	off_0 ~%il%~
 END ELSE BEGIN
 SET			ilc = 0x00
 WRITE_LONG	 0x02c0 ilc
 END
 SET			   off_0 += 0x14 * ilc
 WRITE_LONG		0x02b8 off_0
 INSERT_BYTES	  off_0 0x50
 PATCH_IF ~%is%~ STR_CMP fail BEGIN
WRITE_ASCIIE	off_0 ~%is%~
 END ELSE BEGIN
FOR (i_0 = 0x00; i_0 < 0x4c; i_0 += 0x02) BEGIN
  WRITE_SHORT   off_0 + i1 0xffff
END
 END
 SET SOURCE_SIZE = off_0 + 0x50
END
DEFINE_PATCH_MACRO fj_use_v2_eff BEGIN
 LOCAL_SET elo			= 0x2d4
 LOCAL_SET elc			= 0x00
 LOCAL_SET i_0			= 0x00
 LOCAL_SET off_0		  = 0x00
 LOCAL_SET off_1		  = 0x2d4
 LOCAL_SET eff_type	   = 0x01
 LOCAL_SET opcode		 = 0x00
 LOCAL_SET target		 = 0x00
 LOCAL_SET power		  = 0x00
 LOCAL_SET parameter1	 = 0x00
 LOCAL_SET parameter2	 = 0x00
 LOCAL_SET timing_mode	= 0x00
 LOCAL_SET dispellability = 0x00
 LOCAL_SET duration	   = 0x00
 LOCAL_SET probability1   = 0x00
 LOCAL_SET probability2   = 0x00
 LOCAL_SPRINT resref		~~
 LOCAL_SPRINT efx		   ~~
 LOCAL_SPRINT rfx		   ~~
 READ_BYTE  0x33 eff_type
 WRITE_BYTE 0x33 0x1
 PATCH_IF (eff_type & 0x1) = 0x0 BEGIN
READ_LONG  0x2c8 elc
PATCH_IF elc > 0x0 BEGIN
  READ_LONG  0x2c4 elo
  READ_ASCII   elo efx (0x30 * elc)
  PATCH_FOR_EACH off_0 IN 0x2a0 0x2a8 0x2b0 0x2b8 0x2bc BEGIN
	READ_LONG  off_0 off_1
	WRITE_LONG off_0 off_1 >= elo ? off_1 + elc * 0xd8 : off_1 < 0x2d4 ? 0x2d4 : off_1
  END
  DELETE_BYTES elo 0x030 * elc
  INSERT_BYTES elo 0x108 * elc
  SET SOURCE_SIZE += 0xd8 * elc
  SPRINT rfx ~~
  INNER_PATCH ~%efx%~ BEGIN
	FOR (i_0 = 0x0; i_0 < elc; i_0 += 0x1) BEGIN
	  READ_SHORT   i_0 * 0x30 + 0x00 opcode
	  READ_BYTE	i_0 * 0x30 + 0x02 target
	  READ_BYTE	i_0 * 0x30 + 0x03 power
	  READ_LONG	i_0 * 0x30 + 0x04 parameter1
	  READ_LONG	i_0 * 0x30 + 0x08 parameter2
	  READ_BYTE	i_0 * 0x30 + 0x0c timing_mode
	  READ_BYTE	i_0 * 0x30 + 0x0d dispellability
	  READ_LONG	i_0 * 0x30 + 0x0e duration
	  READ_BYTE	i_0 * 0x30 + 0x12 probability1
	  READ_BYTE	i_0 * 0x30 + 0x13 probability2
	  READ_ASCII   i_0 * 0x30 + 0x14 resref
	  INNER_PATCH_SAVE rfx ~%rfx%~ BEGIN
		INSERT_BYTES  i_0 * 0x108 + 0x00 0x110
		WRITE_LONG	i_0 * 0x108 + 0x10 opcode
		WRITE_LONG	i_0 * 0x108 + 0x14 target
		WRITE_LONG	i_0 * 0x108 + 0x18 power
		WRITE_LONG	i_0 * 0x108 + 0x1c parameter1
		WRITE_LONG	i_0 * 0x108 + 0x20 parameter2
		WRITE_BYTE	i_0 * 0x108 + 0x24 timing_mode
		WRITE_LONG	i_0 * 0x108 + 0x28 duration
		WRITE_SHORT   i_0 * 0x108 + 0x2c probability1
		WRITE_SHORT   i_0 * 0x108 + 0x2e probability2
		WRITE_ASCIIE  i_0 * 0x108 + 0x30 ~%resref%~
		WRITE_BYTE	i_0 * 0x108 + 0x5c dispellability
		WRITE_LONG	i_0 * 0x108 + 0x80 ` 0x0
		WRITE_LONG	i_0 * 0x108 + 0x84 ` 0x0
		WRITE_LONG	i_0 * 0x108 + 0x88 ` 0x0
		WRITE_LONG	i_0 * 0x108 + 0x8c ` 0x0
		WRITE_LONG	i_0 * 0x108 + 0xa4 ` 0x0
		DELETE_BYTES  i_0 * 0x108 + 0x08 0x8
	  END
	END
  END
  WRITE_ASCIIE elo ~%rfx%~
END
 END
END

Link to comment
Here...
...~^.+\...

Pinched.

 

Say, whatever happened to fj_cre_check anyway? I'm still using some ancient version of it from L1 alpha -1 or so. Or is this an updated version of it? Doesn't look like it, but I never claimed to be able to read Linear A. Just trying to fix some eh... inconsistencies... in one of our older mods with a couple hundred CREs to run through.

Link to comment
Here...
...~^.+\...

Pinched.

 

Say, whatever happened to fj_cre_check anyway? I'm still using some ancient version of it from L1 alpha -1 or so. Or is this an updated version of it? Doesn't look like it, but I never claimed to be able to read Linear A. Just trying to fix some eh... inconsistencies... in one of our older mods with a couple hundred CREs to run through.

I just ran the code on my Test Install folder and it worked perfectly as far as re-ordering and indexing the spell memorization tables. The 1st set of code I was using fixed the cre's as far as the spell memorization tables, but didn't re-index the memorized spells in the tables. The 2nd set of code only works if the 1st set hasn't been previously run.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...