Jump to content

Detectable Spells error


Miloch

Recommended Posts

As reported here:

ERROR: illegal 2-byte read from offset 2634 of 2634-byte file SPWI696.SPL

ERROR: [sPWI696.SPL] -> [override/SPWI696.SPL] Patching Failed (COPY) (Failure("SPWI696.SPL: read out of bounds"))

Yes, it's from NEJ2, but other than that, I don't know what the problem is... AFAICT the spell is just a clone of sppr717 Creeping Doom.
Link to comment
I may have to do that myself. Back in two hours or so.
Yeah... well I skipped that first step and went straight to the second. Maybe I'll get around to the first sometime, but that'd mean I'd actually have to install NEJ2. Think I'll stick with installing .iap mods for now.
Link to comment

I have failed you as a colleague if you were even considering it :help:

ACTION_FOR_EACH ~dir~ IN ~nejo/NeJ/cre~ ~nejo/NeJ2/cre~ ~nejo/NeJ2/Dar/cre~ ~nejo/NeJ2/Leina/cre~ ~nejo/NeJ2/Melora/cre~ ~nejo/NeJ3/cre~ ~nejo/NeJ3/fixes~ ~nejo/NeJ3/sharteel/cre~ ~nejo/NeJ3/cre_copy~ BEGIN
 ACTION_BASH_FOR ~%dir%~ ~^.+\.cre$~ BEGIN
COPY - ~%dir%/%BASH_FOR_FILE%~ ~override~
  DEBUGGING_GOES_HERE

 

List of files to skip coming shortly.

 

/edit

 

My god. Some of the index errors.

 

//edit

 

But wait there's more!

 

///edit

 

Okay that's enough

Link to comment

Ought to be sufficient for my nefarious purposes.

DEFINE_PATCH_MACRO ~enforce_cre_order~ BEGIN
 PATCH_IF ((SOURCE_SIZE > 0x02d3) AND !(~%SOURCE_RES%~ STRING_EQUAL_CASE ~charbase~)) THEN BEGIN
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" = 0x02d4
WRITE_LONG		0x02a0 "off"
PATCH_IF !(~%ks%~ STRING_EQUAL ~fail~) THEN BEGIN
  INSERT_BYTES	"off" (0x0c * "ksc")
  WRITE_ASCIIE	"off" ~%ks%~
END ELSE BEGIN
  SET			 "ksc" = 0x00
  WRITE_LONG	  0x02a4 "ksc"
END
SET			   "off" += (0x0c * "ksc")
WRITE_LONG		0x02a8 "off"
INSERT_BYTES	  "off" (0x10 * 0x11)
PATCH_IF ((~%sm%~ STR_CMP ~fail~) AND (smc = 0x11)) THEN BEGIN
  WRITE_ASCIIE	"off" ~%sm%~
END ELSE BEGIN
  SET			 "smc" = 0x11
  WRITE_LONG	  0x2ac "smc"
  FOR ("i1" = 0x00; "i1" < 0x07; "i1" += 0x01) BEGIN
	WRITE_SHORT   ("off" + (i1 * 0x10)) "i1"
  END
  FOR ("i1" = 0x00; "i1" < 0x09; "i1" += 0x01) BEGIN
	WRITE_SHORT   ("off" + ("i1" * 0x10) + 0x070) "i1"
	WRITE_SHORT   ("off" + ("i1" * 0x10) + 0x076) 0x01
  END
  WRITE_SHORT	 ("off" + 0x106) 0x02
END
SET			   "off" += (0x10 * "smc")
WRITE_LONG		0x02b0 "off"
PATCH_IF !(~%ms%~ STRING_EQUAL ~fail~) THEN BEGIN
  INSERT_BYTES	"off" (0x0c * "msc")
  WRITE_ASCIIE	"off" ~%ms%~
END ELSE BEGIN
  SET			 "msc" = 0x00
  WRITE_LONG	  0x02b4 "msc"
END
SET			   "off" += (0x0c * "msc")
WRITE_LONG		0x02c4 "off"
PATCH_IF !(~%el%~ STRING_EQUAL ~fail~) THEN BEGIN
  INSERT_BYTES	"off" ("elc" * (0x30 + ((("eff" & 0x01) = 0x01) ? 0xd8 : 0x00)))
  WRITE_ASCIIE	"off" ~%el%~
END ELSE BEGIN
  SET			 "elc" = 0x00
  WRITE_LONG	  0x02c8 "elc"
END
SET			   "off" += ("elc" * (0x30 + ((("eff" & 0x01) = 0x01) ? 0xd8 : 0x00)))
WRITE_LONG		0x02bc "off"
PATCH_IF !(~%il%~ STRING_EQUAL ~fail~) THEN BEGIN
  INSERT_BYTES	"off" (0x14 * "ilc")
  WRITE_ASCIIE	"off" ~%il%~
END ELSE BEGIN
   SET			"ilc" = 0x00
   WRITE_LONG	 0x02c0 "ilc"
END
SET			   "off" += (0x14 * "ilc")
WRITE_LONG		0x02b8 "off"
INSERT_BYTES	  "off" 0x50
PATCH_IF !(~%is%~ STRING_EQUAL ~fail~) THEN BEGIN
  WRITE_ASCIIE	"off" ~%is%~
END ELSE BEGIN
  FOR ("i1" = 0x00; "i1" < 0x4c; "i1" += 0x02) BEGIN
	WRITE_SHORT   ("off" + "i1") 0xffff
  END
END
SET SOURCE_SIZE = ("off" + 0x50)
 END
END
DEFINE_PATCH_MACRO ~use_v2_eff~ BEGIN
 PATCH_IF ((SOURCE_SIZE > 0x02d3) AND !(~%SOURCE_RES%~ STRING_EQUAL_CASE ~charbase~)) THEN BEGIN
READ_BYTE	0x0033 "eff_type"
WRITE_BYTE 0x0033 0x1
PATCH_IF (("eff_type" & 0x1) = 0x0) THEN BEGIN
  READ_LONG  0x02c8 "elc"
  PATCH_IF ("elc" > 0x0) THEN BEGIN
	READ_LONG  0x02c4 "elo"
	READ_ASCII   "elo" ~efx~ (0x30 * "elc")
	PATCH_FOR_EACH "off1" IN 0x02a0 0x02a8 0x02b0 0x02b8 0x02bc BEGIN
	  READ_LONG  "off1" "off2"
	  WRITE_LONG "off1" (("off2" > "elo") ? ("off2" + ("elc" * (0x108 - 0x30))) : ("off2" < 0x2d4 ? 0x2d4 : "off2"))
	END
	DELETE_BYTES "elo" (0x030 * "elc")
	INSERT_BYTES "elo" (0x108 * "elc")
	SPRINT ~rfx~ ~~
	INNER_PATCH ~%efx%~ BEGIN
	  FOR ("i1" = 0x0; "i1" < "elc"; "i1" += 0x1) BEGIN
		SET SOURCE_SIZE += 0xd8
		READ_SHORT   (("i1" * 0x30) + 0x00) "opcode"
		READ_BYTE	(("i1" * 0x30) + 0x02) "target"
		READ_BYTE	(("i1" * 0x30) + 0x03) "power"
		READ_LONG	(("i1" * 0x30) + 0x04) "parameter1"
		READ_LONG	(("i1" * 0x30) + 0x08) "parameter2"
		READ_BYTE	(("i1" * 0x30) + 0x0c) "timing_mode"
		READ_BYTE	(("i1" * 0x30) + 0x0d) "dispellability"
		READ_LONG	(("i1" * 0x30) + 0x0e) "duration"
		READ_BYTE	(("i1" * 0x30) + 0x12) "probability1"
		READ_BYTE	(("i1" * 0x30) + 0x13) "probability2"
		READ_ASCII   (("i1" * 0x30) + 0x14) ~resref~
		INNER_PATCH_SAVE ~rfx~ ~%rfx%~ BEGIN
		  INSERT_BYTES  (("i1" * 0x108) + 0x00) 0x110
		  WRITE_LONG	(("i1" * 0x108) + 0x10) "opcode"
		  WRITE_LONG	(("i1" * 0x108) + 0x14) "target"
		  WRITE_LONG	(("i1" * 0x108) + 0x18) "power"
		  WRITE_LONG	(("i1" * 0x108) + 0x1c) "parameter1"
		  WRITE_LONG	(("i1" * 0x108) + 0x20) "parameter2"
		  WRITE_BYTE	(("i1" * 0x108) + 0x24) "timing_mode"
		  WRITE_LONG	(("i1" * 0x108) + 0x28) "duration"
		  WRITE_SHORT   (("i1" * 0x108) + 0x2c) "probability1"
		  WRITE_SHORT   (("i1" * 0x108) + 0x2e) "probability2"
		  WRITE_ASCIIE  (("i1" * 0x108) + 0x30) ~%resref%~
		  WRITE_BYTE	(("i1" * 0x108) + 0x5c) "dispellability"
		  WRITE_LONG	(("i1" * 0x108) + 0x80) (` 0x0)
		  WRITE_LONG	(("i1" * 0x108) + 0x84) (` 0x0)
		  WRITE_LONG	(("i1" * 0x108) + 0x88) (` 0x0)
		  WRITE_LONG	(("i1" * 0x108) + 0x8c) (` 0x0)
		  WRITE_LONG	(("i1" * 0x108) + 0xa4) (` 0x0)
		  DELETE_BYTES  (("i1" * 0x108) + 0x08) 0x8
		END
	  END
	END
	WRITE_ASCIIE "elo" ~%rfx%~
  END
END
 END
END
DEFINE_PATCH_MACRO ~reindex_spell_or_item_extra_effects~ BEGIN
 PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN
PATCH_IF		  !(~%SOURCE_FILE%~ STRING_MATCHES_REGEXP ~^.+\.spl~) THEN BEGIN
  SET "hs" = 0x28
END ELSE PATCH_IF !(~%SOURCE_FILE%~ STRING_MATCHES_REGEXP ~^.+\.itm~) THEN BEGIN
  SET "hs" = 0x38
END
READ_LONG  0x64 "ho"
READ_SHORT 0x68 "hc"
READ_LONG  0x6a "eo"
READ_SHORT 0x70 "ei"
PATCH_IF (("ho" > "eo") AND ("hc" > 0x01)) THEN BEGIN
  READ_ASCII "ho" ~eh~ ELSE ~fail~ ("hs" * "hc")
  PATCH_IF (~%eh%~ STRING_EQUAL ~fail~) THEN BEGIN
	WHILE ((~%eh%~ STRING_EQUAL ~fail~) AND ("hc" > 0x00)) BEGIN
	  READ_ASCII "ho" ~eh~ ELSE ~fail~ ("hs" * "hc")
	  SET "hc" -= 0x01
	END
  END
  DELETE_BYTES "ho" ("hs" * "hc")
  SET "ho" = 0x72
  WRITE_LONG   0x64 "ho"
  WRITE_SHORT  0x68 "hc"
  SET "eo" = (0x72 + ("hs" * "hc"))
  WRITE_LONG   0x6a "eo"
  PATCH_IF !(~%eh%~ STRING_EQUAL ~fail~) THEN BEGIN
	INSERT_BYTES "ho" ("hs" * "hc")
	WRITE_ASCIIE "ho" ~%eh%~
  END
END ELSE PATCH_IF (("ho" != 0x72) AND ("hc" = 0x00)) THEN BEGIN
  SET "ho" = 0x72
  WRITE_LONG   0x64 "ho"
END
FOR ("i1" = 0x00; "i1" < ("hs" * "hc"); "i1" += "hs") BEGIN
  WRITE_SHORT ("ho" + "i1" + 0x20) "ei"
  READ_SHORT  ("ho" + "i1" + 0x1e) "ec"
  SET "ei" += "ec"
END
PATCH_IF (SOURCE_SIZE > (0x72 + ("hs" * "hc") + (0x30 * "ei"))) THEN BEGIN
  DELETE_BYTES (0x72 + ("hs" * "hc") + (0x30 * "ei")) (SOURCE_SIZE - (0x72 + ("hs" * "hc") + (0x30 * "ei")))
END
 END
END

ACTION_IF (MOD_IS_INSTALLED ~Setup-NeJ2v691.tp2~ "0") THEN BEGIN
 ACTION_FOR_EACH ~crefile~ IN  ~xangiber.cre~
							~xan.cre~
							~whitcomb.cre~ 
							~vrielle.cre~  
							~vpguard.cre~  
							~urnst.cre~	
							~tumatej.cre~  
							~tujiri.cre~   
							~tuguard.cre~  
							~tualert.cre~  
							~trolca02.cre~ 
							~trolca01.cre~ 
							~towniem5.cre~ 
							~towniem4.cre~ 
							~towniem3.cre~ 
							~towniem2.cre~ 
							~towniem1.cre~ 
							~townief5.cre~ 
							~townief4.cre~ 
							~townief3.cre~ 
							~townief2.cre~ 
							~townief1.cre~ 
							~tomegol4.cre~ 
							~tilornn.cre~  
							~tilorn2.cre~  
							~tilorn.cre~   
							~tertia.cre~   
							~tazok.cre~	
							~taffic91.cre~ 
							~taffic12.cre~ 
							~taffic11.cre~ 
							~stoolm3.cre~  
							~stoolm2.cre~  
							~stoolm1.cre~  
							~squirel.cre~  
							~soth.cre~	 
							~slavem6.cre~  
							~slavem5.cre~  
							~slavem4.cre~  
							~slavem3.cre~  
							~slavem2.cre~  
							~slavem1.cre~  
							~slavef7.cre~  
							~slavef6.cre~  
							~slavef5.cre~  
							~slavef4.cre~  
							~slavef3.cre~  
							~slavef2.cre~  
							~slavef1.cre~  
							~skie78.cre~   
							~skie77.cre~   
							~shdelfpt.cre~ 
							~serrhya.cre~  
							~sebast.cre~   
							~sdelfpr.cre~  
							~read3.cre~	
							~rdundead.cre~ 
							~rdundea4.cre~ 
							~rdundea3.cre~ 
							~rdundea2.cre~ 
							~pressapp.cre~ 
							~presio.cre~   
							~pomab.cre~	
							~oldjed.cre~   
							~nate.cre~	 
							~minsc9.cre~   
							~minsc7.cre~   
							~minsc12.cre~  
							~minsc8.cre~   
							~minsc10.cre~  
							~mcapvil.cre~  
							~lysan.cre~	
							~lizking.cre~  
							~lhillias.cre~ 
							~leinamum.cre~ 
							~leina14.cre~  
							~leina13.cre~  
							~leina12.cre~  
							~leina11.cre~  
							~laria.cre~	
							~kumirek.cre~  
							~kontik.cre~   
							~kharesse.cre~ 
							~kaylessa.cre~ 
							~kalabac.cre~  
							~jhonen.cre~   
							~jermsy.cre~   
							~innkpr.cre~   
							~imoen6.cre~   
							~imoen10.cre~  
							~icgob05.cre~  
							~icgob05.cre~  
							~icgob05.cre~  
							~icgob05.cre~  
							~icgob05.cre~  
							~hroth9.cre~   
							~hroth8.cre~   
							~hjollder.cre~ 
							~hildreth.cre~ 
							~hightort.cre~ 
							~hermit.cre~   
							~gerth.cre~	
							~gaspar.cre~   
							~gareth.cre~   
							~fmcapvil.cre~ 
							~firorc01.cre~ 
							~ffcapvil.cre~ 
							~fcapvil.cre~  
							~everard.cre~  
							~eurich.cre~   
							~elisia.cre~   
							~egirl2.cre~   
							~egirl1.cre~   
							~egequest.cre~ 
							~egeques2.cre~ 
							~eboy2.cre~	
							~eboy1.cre~	
							~dver.cre~	 
							~duvguard.cre~ 
							~davin.cre~	
							~damien.cre~   
							~cmcapvil.cre~ 
							~churin.cre~   
							~chairm4.cre~  
							~chairm3.cre~  
							~chairm2.cre~  
							~chairm1.cre~  
							~cfcapvil.cre~ 
							~calliana.cre~ 
							~brial.cre~	
							~bjorn.cre~	
							~biknight.cre~ 
							~bart2.cre~	
							~barkeep.cre~  
							~bandoth.cre~  
							~apsel.cre~	
							~amelia.cre~   
							~albion.cre~   
							~accali8.cre~ BEGIN
ACTION_IF (FILE_EXISTS_IN_GAME ~%crefile%~) THEN BEGIN
  COPY_EXISTING ~%crefile%~ ~override~
	LAUNCH_PATCH_MACRO ~enforce_cre_order~
	LAUNCH_PATCH_MACRO ~use_v2_eff~
  BUT_ONLY
END
 END
 ACTION_FOR_EACH ~spellitm~ IN ~spwi724.spl~
							~spwi696.spl~
							~spwi524.spl~
							~spwi388.spl~
							~spin506.spl~
							~spin502.spl~
							~j2haxe.itm~
							~helmla.itm~
							~celebra.itm~
							~auril.itm~
							~accshld.itm~ BEGIN
ACTION_IF (FILE_EXISTS_IN_GAME ~%spellitm%~) THEN BEGIN
  COPY_EXISTING ~%spellitm%~ ~override~
	LAUNCH_PATCH_MACRO ~reindex_spell_or_item_extra_effects~
  BUT_ONLY
END
 END
END

 

/edit

 

Typo :help:

Link to comment

I am beginning to think it might be a good idea to do this with a regexp on all .cre, .spl, .itm... on most mods. Not that many folks are smashing up up spell and item index, but because the methodology for .cre creation varies widely, and not all editors get everything tidiesd up, I think.

 

I think I should try a trial run on Tutu/EasyTutu and see what gets changed, too. the spells and items are likely fine, but I know we found soem serious effv1 usage... so it might be good just to run these at the end of BG1NPC just to make sure. I would do it at the beginning, in core fixes, but would need to make sure none of our stuff has the misordered .cres!

Link to comment

Am I understanding it correctly, that the big batch of code is something you want to run on all your various mod files before packaging them up for distribution in your mod to make sure you haven't corrupted anything? Is this another tool to be used in the development process?

Link to comment
Am I understanding it correctly, that the big batch of code is something you want to run on all your various mod files before packaging them up for distribution in your mod to make sure you haven't corrupted anything? Is this another tool to be used in the development process?

I'd suggest G3DS instead, and use Nythrun's code for dealing with mods that won't be updated any time soon. Briefly looking at the code, it looks like it'll attempt to fix many of the errors that G3DS will bitch about--myself, I'd rather have a warning and have a go at it personally.

Link to comment
it'll attempt to fix many of the errors that G3DS will bitch about

 

Just index errors (and not all of those of course) for three file types, so yeah - not much.

 

If it's enough to get something installed without bug reports due to someone else's scrambled files, I'm happy :help:

Link to comment

That's great. Can it be included in G3DS? It's supposed to be a debugging tool after all, not just a reporting tool.

 

And incidentaly, I did eventually run G3DS on the NEJ2 spell (not by actually installing the latter, but by copying the spell temporarily to the override) and it bombed when it got to the spell with pretty much the same error in the original post, so it wasn't really that helpful. How'd you get it to work?

Link to comment

OK. It looks like the Tutu conversion (both v4 and easytutu left most .cres using eff v1. Running a tp2 created from Nythrun's code,

 

BACKUP ~nythrunfix/backup~ 
AUTHOR ~nythrun@gibberlings.net~

BEGIN ~Nythrun's Broken Cre/Itm/Spl Fix~

DEFINE_PATCH_MACRO ~enforce_cre_order~ BEGIN
 PATCH_IF ((SOURCE_SIZE > 0x02d3) AND !(~%SOURCE_RES%~ STRING_EQUAL_CASE ~charbase~)) THEN BEGIN
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" = 0x02d4
WRITE_LONG		0x02a0 "off"
PATCH_IF !(~%ks%~ STRING_EQUAL ~fail~) THEN BEGIN
  INSERT_BYTES	"off" (0x0c * "ksc")
  WRITE_ASCIIE	"off" ~%ks%~
END ELSE BEGIN
  SET			 "ksc" = 0x00
  WRITE_LONG	  0x02a4 "ksc"
END
SET			   "off" += (0x0c * "ksc")
WRITE_LONG		0x02a8 "off"
INSERT_BYTES	  "off" (0x10 * 0x11)
PATCH_IF ((~%sm%~ STR_CMP ~fail~) AND (smc = 0x11)) THEN BEGIN
  WRITE_ASCIIE	"off" ~%sm%~
END ELSE BEGIN
  SET			 "smc" = 0x11
  WRITE_LONG	  0x2ac "smc"
  FOR ("i1" = 0x00; "i1" < 0x07; "i1" += 0x01) BEGIN
	WRITE_SHORT   ("off" + (i1 * 0x10)) "i1"
  END
  FOR ("i1" = 0x00; "i1" < 0x09; "i1" += 0x01) BEGIN
	WRITE_SHORT   ("off" + ("i1" * 0x10) + 0x070) "i1"
	WRITE_SHORT   ("off" + ("i1" * 0x10) + 0x076) 0x01
  END
  WRITE_SHORT	 ("off" + 0x106) 0x02
END
SET			   "off" += (0x10 * "smc")
WRITE_LONG		0x02b0 "off"
PATCH_IF !(~%ms%~ STRING_EQUAL ~fail~) THEN BEGIN
  INSERT_BYTES	"off" (0x0c * "msc")
  WRITE_ASCIIE	"off" ~%ms%~
END ELSE BEGIN
  SET			 "msc" = 0x00
  WRITE_LONG	  0x02b4 "msc"
END
SET			   "off" += (0x0c * "msc")
WRITE_LONG		0x02c4 "off"
PATCH_IF !(~%el%~ STRING_EQUAL ~fail~) THEN BEGIN
  INSERT_BYTES	"off" ("elc" * (0x30 + ((("eff" & 0x01) = 0x01) ? 0xd8 : 0x00)))
  WRITE_ASCIIE	"off" ~%el%~
END ELSE BEGIN
  SET			 "elc" = 0x00
  WRITE_LONG	  0x02c8 "elc"
END
SET			   "off" += ("elc" * (0x30 + ((("eff" & 0x01) = 0x01) ? 0xd8 : 0x00)))
WRITE_LONG		0x02bc "off"
PATCH_IF !(~%il%~ STRING_EQUAL ~fail~) THEN BEGIN
  INSERT_BYTES	"off" (0x14 * "ilc")
  WRITE_ASCIIE	"off" ~%il%~
END ELSE BEGIN
   SET			"ilc" = 0x00
   WRITE_LONG	 0x02c0 "ilc"
END
SET			   "off" += (0x14 * "ilc")
WRITE_LONG		0x02b8 "off"
INSERT_BYTES	  "off" 0x50
PATCH_IF !(~%is%~ STRING_EQUAL ~fail~) THEN BEGIN
  WRITE_ASCIIE	"off" ~%is%~
END ELSE BEGIN
  FOR ("i1" = 0x00; "i1" < 0x4c; "i1" += 0x02) BEGIN
	WRITE_SHORT   ("off" + "i1") 0xffff
  END
END
SET SOURCE_SIZE = ("off" + 0x50)
 END
END
DEFINE_PATCH_MACRO ~use_v2_eff~ BEGIN
 PATCH_IF ((SOURCE_SIZE > 0x02d3) AND !(~%SOURCE_RES%~ STRING_EQUAL_CASE ~charbase~)) THEN BEGIN
READ_BYTE	0x0033 "eff_type"
WRITE_BYTE 0x0033 0x1
PATCH_IF (("eff_type" & 0x1) = 0x0) THEN BEGIN
  READ_LONG  0x02c8 "elc"
  PATCH_IF ("elc" > 0x0) THEN BEGIN
	READ_LONG  0x02c4 "elo"
	READ_ASCII   "elo" ~efx~ (0x30 * "elc")
	PATCH_FOR_EACH "off1" IN 0x02a0 0x02a8 0x02b0 0x02b8 0x02bc BEGIN
	  READ_LONG  "off1" "off2"
	  WRITE_LONG "off1" (("off2" > "elo") ? ("off2" + ("elc" * (0x108 - 0x30))) : ("off2" < 0x2d4 ? 0x2d4 : "off2"))
	END
	DELETE_BYTES "elo" (0x030 * "elc")
	INSERT_BYTES "elo" (0x108 * "elc")
	SPRINT ~rfx~ ~~
	INNER_PATCH ~%efx%~ BEGIN
	  FOR ("i1" = 0x0; "i1" < "elc"; "i1" += 0x1) BEGIN
		SET SOURCE_SIZE += 0xd8
		READ_SHORT   (("i1" * 0x30) + 0x00) "opcode"
		READ_BYTE	(("i1" * 0x30) + 0x02) "target"
		READ_BYTE	(("i1" * 0x30) + 0x03) "power"
		READ_LONG	(("i1" * 0x30) + 0x04) "parameter1"
		READ_LONG	(("i1" * 0x30) + 0x08) "parameter2"
		READ_BYTE	(("i1" * 0x30) + 0x0c) "timing_mode"
		READ_BYTE	(("i1" * 0x30) + 0x0d) "dispellability"
		READ_LONG	(("i1" * 0x30) + 0x0e) "duration"
		READ_BYTE	(("i1" * 0x30) + 0x12) "probability1"
		READ_BYTE	(("i1" * 0x30) + 0x13) "probability2"
		READ_ASCII   (("i1" * 0x30) + 0x14) ~resref~
		INNER_PATCH_SAVE ~rfx~ ~%rfx%~ BEGIN
		  INSERT_BYTES  (("i1" * 0x108) + 0x00) 0x110
		  WRITE_LONG	(("i1" * 0x108) + 0x10) "opcode"
		  WRITE_LONG	(("i1" * 0x108) + 0x14) "target"
		  WRITE_LONG	(("i1" * 0x108) + 0x18) "power"
		  WRITE_LONG	(("i1" * 0x108) + 0x1c) "parameter1"
		  WRITE_LONG	(("i1" * 0x108) + 0x20) "parameter2"
		  WRITE_BYTE	(("i1" * 0x108) + 0x24) "timing_mode"
		  WRITE_LONG	(("i1" * 0x108) + 0x28) "duration"
		  WRITE_SHORT   (("i1" * 0x108) + 0x2c) "probability1"
		  WRITE_SHORT   (("i1" * 0x108) + 0x2e) "probability2"
		  WRITE_ASCIIE  (("i1" * 0x108) + 0x30) ~%resref%~
		  WRITE_BYTE	(("i1" * 0x108) + 0x5c) "dispellability"
		  WRITE_LONG	(("i1" * 0x108) + 0x80) (` 0x0)
		  WRITE_LONG	(("i1" * 0x108) + 0x84) (` 0x0)
		  WRITE_LONG	(("i1" * 0x108) + 0x88) (` 0x0)
		  WRITE_LONG	(("i1" * 0x108) + 0x8c) (` 0x0)
		  WRITE_LONG	(("i1" * 0x108) + 0xa4) (` 0x0)
		  DELETE_BYTES  (("i1" * 0x108) + 0x08) 0x8
		END
	  END
	END
	WRITE_ASCIIE "elo" ~%rfx%~
  END
END
 END
END
DEFINE_PATCH_MACRO ~reindex_spell_or_item_extra_effects~ BEGIN
 PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN
PATCH_IF		  !(~%SOURCE_FILE%~ STRING_MATCHES_REGEXP ~^.+\.spl~) THEN BEGIN
  SET "hs" = 0x28
END ELSE PATCH_IF !(~%SOURCE_FILE%~ STRING_MATCHES_REGEXP ~^.+\.itm~) THEN BEGIN
  SET "hs" = 0x38
END
READ_LONG  0x64 "ho"
READ_SHORT 0x68 "hc"
READ_LONG  0x6a "eo"
READ_SHORT 0x70 "ei"
PATCH_IF (("ho" > "eo") AND ("hc" > 0x01)) THEN BEGIN
  READ_ASCII "ho" ~eh~ ELSE ~fail~ ("hs" * "hc")
  PATCH_IF (~%eh%~ STRING_EQUAL ~fail~) THEN BEGIN
	WHILE ((~%eh%~ STRING_EQUAL ~fail~) AND ("hc" > 0x00)) BEGIN
	  READ_ASCII "ho" ~eh~ ELSE ~fail~ ("hs" * "hc")
	  SET "hc" -= 0x01
	END
  END
  DELETE_BYTES "ho" ("hs" * "hc")
  SET "ho" = 0x72
  WRITE_LONG   0x64 "ho"
  WRITE_SHORT  0x68 "hc"
  PATCH_IF !(~%eh%~ STRING_EQUAL ~fail~) THEN BEGIN
	INSERT_BYTES "ho" ("hs" * "hc")
	WRITE_ASCIIE "ho" ~%eh%~
  END
END ELSE PATCH_IF (("ho" != 0x72) AND ("hc" = 0x00)) THEN BEGIN
  SET "ho" = 0x72
  WRITE_LONG   0x64 "ho"
END
FOR ("i1" = 0x00; "i1" < ("hs" * "hc"); "i1" += "hs") BEGIN
  WRITE_SHORT ("ho" + "i1" + 0x20) "ei"
  READ_SHORT  ("ho" + "i1" + 0x1e) "ec"
  SET "ei" += "ec"
END
PATCH_IF (SOURCE_SIZE > (0x72 + ("hs" * "hc") + (0x30 * "ei"))) THEN BEGIN
  DELETE_BYTES (0x72 + ("hs" * "hc") + (0x30 * "ei")) (SOURCE_SIZE - (0x72 + ("hs" * "hc") + (0x30 * "ei")))
END
 END
END

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
	LAUNCH_PATCH_MACRO ~enforce_cre_order~
	LAUNCH_PATCH_MACRO ~use_v2_eff~
  BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
	LAUNCH_PATCH_MACRO ~reindex_spell_or_item_extra_effects~
  BUT_ONLY_IF_IT_CHANGES

COPY_EXISTING_REGEXP GLOB ~^.+\.spl$~ ~override~
	LAUNCH_PATCH_MACRO ~reindex_spell_or_item_extra_effects~
  BUT_ONLY_IF_IT_CHANGES

 

I ran it on a clean EasyTutu_ToB with the latest BG1NPC Project. Then I diffed the pre-nythrunfix override I set aside with the new override, and came up with

 

This list: nythrunfix.html

 

As a good thing, the only X# stuff that gets picked up is the stuff we create from C_E patching of existing resources.

 

So, before I plop this puppy down as a universal fix at the start of the core of BG1 NPC, is there anything I can mess up for other mods by repairing Tutu this way? Are older things built for Tutu designed around eff v1?

 

I am going back, uninstalling, and doing these one macro at a time to generate specific lists for each patch.

 

Changes:

 

cre_orderfix.html

 

effversionfix.html

 

itemfix.html

 

spellfix.html

Link to comment

Running the same routine on vanilla BGT comes up with the following:

 

bgtCreOrderFix.html

 

bgtCreeffv2Fix.html

 

bgtItemFix.html

 

No spells show any errors.

 

I am holding off adding this as a fix until you folks let me know this will not mess with other folks code; I have repaired the very few .cres we have that are not created from C_E of existing resources that triggered under this check, and will wait for confirmation before incorporating the eff, spell, and .cre reorder.

 

 

EDIT:/ aww heck. I will just leave this to the big folks, and set up the macro to patch only the cre before we call it.

 

 COPY_EXISTING ~%tutu_var%BANDIT.cre~ ~override~
	LAUNCH_PATCH_MACRO ~enforce_cre_order~
	LAUNCH_PATCH_MACRO ~use_v2_eff~
  BUT_ONLY_IF_IT_CHANGES

 COPY_EXISTING  ~%tutu_var%BANDIT.cre~ ~override/X#BANDK1.cre~
			 ~%tutu_var%BANDIT.cre~ ~override/X#BANDK2.cre~
			 ~%tutu_var%BANDIT.cre~ ~override/X#BANDK3.cre~
SAY NAME1 @30
SAY NAME2 @30
SAY INITIAL_MEETING @31
SAY BATTLE_CRY1 @31
SAY BATTLE_CRY2 @31
SAY BATTLE_CRY3 @31
SAY BATTLE_CRY4 @31
SAY BATTLE_CRY5 @31
WRITE_LONG ATTACK1 (BNOT 0x0)
WRITE_LONG ATTACK2 (BNOT 0x0)
WRITE_LONG ATTACK3 (BNOT 0x0)
WRITE_LONG ATTACK4 (BNOT 0x0)
SAY DAMAGE @32
SAY DYING @33
SAY SELECT_COMMON1 @31
SAY SELECT_COMMON2 @31
SAY SELECT_COMMON3 @31
SAY SELECT_COMMON4 @31
SAY SELECT_COMMON5 @31
SAY SELECT_COMMON6 @31
WRITE_LONG DIALOGUE_HOSTILE (BNOT 0x0)
WRITE_LONG MORALE (BNOT 0x0)
WRITE_LONG HAPPY (BNOT 0x0)
WRITE_LONG UNHAPPY_ANNOYED (BNOT 0x0)
WRITE_LONG UNHAPPY_SERIOUS (BNOT 0x0)
WRITE_LONG UNHAPPY_BREAKING (BNOT 0x0)
WRITE_LONG LEADER (BNOT 0x0)
WRITE_LONG TIRED (BNOT 0x0)
WRITE_LONG BORED (BNOT 0x0)
WRITE_LONG SELECT_ACTION2 (BNOT 0x0)
WRITE_LONG SELECT_ACTION3 (BNOT 0x0)
WRITE_LONG SELECT_ACTION4 (BNOT 0x0)
WRITE_LONG SELECT_ACTION5 (BNOT 0x0)
WRITE_LONG SELECT_ACTION6 (BNOT 0x0)
WRITE_LONG SELECT_ACTION7 (BNOT 0x0)
WRITE_LONG SELECT_RARE1 (BNOT 0x0)
WRITE_LONG SELECT_RARE2 (BNOT 0x0)
WRITE_LONG CRITICAL_HIT (BNOT 0x0)
WRITE_LONG CRITICAL_MISS (BNOT 0x0)
WRITE_LONG TARGET_IMMUNE (BNOT 0x0)
WRITE_ASCII 0x2CC ~~ #8 // dialog
WRITE_ASCII 0x0258 ~NONE~ #8 // Creature script - Race
WRITE_ASCII 0x0260 ~NONE~ #8 // Creature script - General
WRITE_EVALUATED_ASCII 0x0268 ~%tutu_scriptw%TASIGHT~ #8 // Creature script - Default
WRITE_BYTE 0x270 ~128~ //Allegiance = Neutral
WRITE_EVALUATED_ASCII 0x280 ~%DEST_RES%~ #32 // death variable
Link to comment

I guess I don't get what you're trying to do. Isn't it necessary only to update CRE EFF versions for those CREs that actually have attached EFFs? And for BG1/Tutu, doesn't this apply only to joinable NPCs, and don't you already fix those?

Link to comment

Archived

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

×
×
  • Create New...