I noticed a couple other oddities though. The ~~~~~string ~blah~ here~~~~~ thing doesn't seem to parse for me. I got around it by using "string ~blah~ here" instead, since I didn't need any other special characters.
What was the parse error you got?
Here is the working code:
BACKUP ~1itemchk/backup~
AUTHOR ~null~
BEGIN ~Item Type Check~
INSTALL_BY_DEFAULT
NO_LOG_RECORD
<<<<<<<< .../1itemchk-inlined/t-item_list.txt
Item name Item file BAM Attack type
===================================================
>>>>>>>>
<<<<<<<< .../1itemchk-inlined/t-item_desc.txt
>>>>>>>>
COPY + ~.../1itemchk-inlined/t-item_list.txt~ ~1itemchk~
~.../1itemchk-inlined/t-item_desc.txt~ ~1itemchk~
OUTER_SET hn = 0
OUTER_SET hd = 0
COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
PATCH_IF SOURCE_SIZE > 0x71 BEGIN
READ_STRREF 0xc n1 //Name
READ_SHORT 0x1c tp //Item type
READ_ASCII 0x3a bm //BAM
READ_STRREF 0x54 d1 //Description
READ_LONG 0x64 hf //Extended header offset
READ_SHORT 0x68 hc //Extended header count
FOR (i = 0; i < hc; i += 1) BEGIN //Cycle through headers
READ_BYTE (0x38 * i + hf) pt //Attack type
PATCH_IF tp = 0x15 BEGIN //Hammer
hn = hd + 1
hd = hn + 1
INNER_ACTION BEGIN
APPEND_OUTER ~1itemchk/t-item_list.txt~ ~%n1% %SOURCE_FILE% %bm% %pt%~
APPEND_OUTER ~1itemchk/t-item_desc.txt~ "@%hn% = ~%n1%~
@%hd% = ~%d1%~"
END
END
END
END
BUT_ONLY_IF_IT_CHANGES
Change the "s to ~~~~~s instead, and you get:
[SETUP-1ITEMCHK.TP2] LEXER ERROR at line 39 column 1-18
Near Text: ~
invalid character [~]
HINT: Don't use MS Word to edit your .tp2 files - use ConTEXT (http://www.context.cx instead).
[SETUP-1ITEMCHK.TP2] ERROR at line 39 column 1-18
Near Text: ~
Parsing.Parse_error
ERROR: parsing [SETUP-1ITEMCHK.TP2]: Parsing.Parse_error
ERROR: problem parsing TP file [SETUP-1ITEMCHK.TP2]: Parsing.Parse_error
FATAL ERROR: Parsing.Parse_error
(That HINT is obnoxious btw. As if I use Word, or even ConText to edit tp2s
.)
Also, can someone tell me the difference between these expressions:
PATCH_IF (~%SOURCE_RES%~ STRING_COMPARE_CASE ~charbase~ = 1) BEGIN
PATCH_IF NOT(~%SOURCE_RES%~ STRING_COMPARE_CASE ~charbase~ = 0) BEGIN
PATCH_IF NOT(~%SOURCE_RES%~ STRING_EQUAL_CASE ~charbase~ = 1) BEGIN
PATCH_IF (~%SOURCE_RES%~ STRING_EQUAL_CASE ~charbase~ = 0) BEGIN
No difference at all. Behave the same for me.
Run this (code
stolen from Nythrun and the bigg):
BACKUP ~1script/backup~
AUTHOR ~null~
BEGIN ~Script Patching Test~
INSTALL_BY_DEFAULT
OUTER_SPRINT sn ~ ghoulsu.cre gibbersu.cre gnollsu.cre hobgobsu.cre koboldsu.cre nymphsu.cre ogregrsu.cre tasloisu.cre xvartsu.cre~ //Non-animal summonees
<<<<<<<< .../1script-inlined/t-testsc.baf
IF
Die()
Global("T-Drop","LOCALS",0)
OR(2)
StateCheck(Myself,STATE_FROZEN_DEATH)
HitBy([ANYONE],2)
THEN
RESPONSE #100
SetGlobal("T-Drop","LOCALS",1)
DropInventory()
END
>>>>>>>>
COMPILE ~.../1script-inlined/t-testsc.baf~
COPY_EXISTING_REGEXP GLOB ~^.*\.cre$~ ~override~
PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN
READ_BYTE 0x271 g2 //General
READ_BYTE 0x275 r2 //Gender
PATCH_IF (g2 != 0) AND (g2 != 2) AND (r2 != 6) AND (r2 != 7) AND (r2 != 9) AND (r2 != 0xc) BEGIN
PATCH_IF (~%sn%~ STRING_CONTAINS_REGEXP ~ %SOURCE_FILE%~ = 1) BEGIN
PATCH_IF NOT(~%SOURCE_RES%~ STRING_COMPARE_CASE ~charbase~ = 0) BEGIN
READ_ASCII 0x248 ~vs~ //Override script
PATCH_IF FILE_EXISTS_IN_GAME ~%vs%.bcs~ BEGIN
PATCH_IF NOT VARIABLE_IS_SET $df(EVALUATE_BUFFER ~%vs%~) BEGIN
READ_STRREF 0x8 n1 //Name
PATCH_PRINT ~Marking script %vs% of %SOURCE_FILE% (%n1%) for extension.~
SPRINT $df(EVALUATE_BUFFER ~%vs%~) ~%vs%~
END
END ELSE BEGIN
READ_STRREF 0x8 n1 //Name
PATCH_PRINT ~Assigning new override script to %SOURCE_FILE% (%n1%).~
WRITE_EVALUATED_ASCII 0x248 ~t-testsc~ #8
END
END
END
END
END
BUT_ONLY_IF_IT_CHANGES
ACTION_PHP_EACH df AS i => xs BEGIN
EXTEND_TOP ~%xs%.bcs~ ~override/t-testsc.bcs~
END
And it doesn't start patching until chore.cre:
[C:\Archive\BG2\/DATA/SCRIPTS.BIF] 6510702 bytes, 2826 files, 0 tilesets
Marking script SHOUT of CHORE.CRE (Chore) for extension.
Marking script SPSEQ16A of CHSAM01.CRE (Semaj) for extension.
Marking script GRPSHT01 of CHTAZ01.CRE (Tazok) for extension.
Assigning new override script to CHTAZ02.CRE (Tamoko).
Copied [CHTAZ02.CRE] to [override/CHTAZ02.CRE]
...
Change the PATCH_IF NOT(~%SOURCE_RES%~ STRING_COMPARE_CASE ~charbase~ = 0) to any of the 3 other equivalents above, and it works correctly:
[C:\Archive\BG2\/DATA/SCRIPTS.BIF] 6510702 bytes, 2826 files, 0 tilesets
Marking script SHOUTDL2 of AATAQAH.CRE (Aataqah) for extension.
Assigning new override script to ABAZIGAL.CRE (Abazigal).
Copied [ABAZIGAL.CRE] to [override/ABAZIGAL.CRE]
Assigning new override script to ABISRED1.CRE (Abishai).
Copied [ABISRED1.CRE] to [override/ABISRED1.CRE]
Marking script shoutdlg of ABYDEM01.CRE (Tanar'ri) for extension.
...