Had a report of Tweaks' Reveal City Area Maps
butchering some area scripts (WeiDU v242), and found what I think is a bug with DECOMPILE_AND_PATCH.
Here's the relevant bit of code from tweaks:
ACTION_IF GAME_IS ~iwdee iwd_in_bg2 iwd how totlm~ THEN BEGIN
ACTION_FOR_EACH file IN
~AR1000~ // EASTHAVEN (PROLOGUE)
// ~AR1100~ // EASTHAVEN (FINALE)
~AR2100~ // KULDAHAR
~AR9100~ // LONELYWOOD
BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%file%.bcs~ BEGIN
COPY_EXISTING ~%file%.bcs~ ~override~
DECOMPILE_BCS_TO_BAF
APPEND_FILE ~cdtweaks/baf/reveal.baf~
REPLACE_TEXTUALLY ~CD_MYAREA_VAR_SCOPE~ ~%SOURCE_RES%~ // bg1 doesn't like MYAREA
COMPILE_BAF_TO_BCS
BUT_ONLY_IF_IT_CHANGES
END
END
END
When this is run, it strips out the variable scopes of all of the existing variables. I thought it might be the old, deprecated DECOMPILE_BCS_TO_BAF but using DECOMPILE_AND_PATCH yields the same bug. Removing the APPEND and REPLACE don't affect it either (though the block was added and compiled correctly with the correct scope).
As a test, you can run
COPY_EXISTING ~ar1101.bcs~ ~override/ar1101.baf~
DECOMPILE_BCS_TO_BAF
and it will turn this (NI)
IF
!Global("RETURN_TO_LONELYWOOD","GLOBAL",0)
THEN
RESPONSE #100
StartCutSceneMode()
StartCutScene("keRtrnLW")
SetGlobal("RETURN_TO_LONELYWOOD","GLOBAL",0)
END
Into this (baf):
IF
!Global("GLOBALRETURN_TO_LONELYWOOD","",0)
THEN
RESPONSE #100
StartCutSceneMode()
StartCutScene("keRtrnLW")
SetGlobal("GLOBALRETURN_TO_LONELYWOOD","",0)
END
edit: The player having the problem also posted before-and-after files from the three patched scripts, so you have some additional examples if you want to follow the link.