Author Topic: IWD (orig) DECOMPILE bug?  (Read 1336 times)

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 859
  • Dreaming of a red Xmas
    • The Gibberlings Three
IWD (orig) DECOMPILE bug?
« on: December 26, 2017, 03:52:25 PM »
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:

Code: [Select]
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

Code: [Select]
COPY_EXISTING ~ar1101.bcs~ ~override/ar1101.baf~
  DECOMPILE_BCS_TO_BAF

and it will turn this (NI)

Code: [Select]
IF
  !Global("RETURN_TO_LONELYWOOD","GLOBAL",0)
THEN
  RESPONSE #100
    StartCutSceneMode()
    StartCutScene("keRtrnLW")
    SetGlobal("RETURN_TO_LONELYWOOD","GLOBAL",0)
END

Into this (baf):

Code: [Select]
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.
« Last Edit: December 26, 2017, 03:57:15 PM by CamDawg »
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 859
  • Dreaming of a red Xmas
    • The Gibberlings Three
Re: IWD (orig) DECOMPILE bug?
« Reply #1 on: December 26, 2017, 03:58:47 PM »
And I can confirm the same result at the command line. 'weidu ar1101.bcs' results in the same baf chunk as above, with or without --script-style iwd.
« Last Edit: December 26, 2017, 04:00:13 PM by CamDawg »
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

Offline The Imp

  • Planewalker
  • *****
  • Posts: 288
  • Gender: Male
Re: IWD (orig) DECOMPILE bug?
« Reply #2 on: December 26, 2017, 04:08:16 PM »
You might just... replace the previous with, starting and ending with included first and last lines of your code:
Code: [Select]
      COPY_EXISTING ~%file%.bcs~ ~override~
        DECOMPILE_AND_PATCH BEGIN EXTEND_TOP
~cdtweaks/baf/reveal.baf~
        END
        BUT_ONLY_IF_IT_CHANGES
Or:
Code: [Select]
      EXTEND_TOP ~%file%.bcs~
        DECOMPILE_AND_PATCH BEGIN
~cdtweaks/baf/reveal.baf~
        END
        BUT_ONLY_IF_IT_CHANGES

or ... however one goes with that... and remember the BEGIN .. and END with DECOMPILE_AND_PATCH.

And you might want to use a LOCALS instead of GLOBAL in the .baf script, as that's for sure meant for the area and local creature scripts, aka this:
IF
   Global("CDRevealArea","CD_MYAREA_VAR_SCOPE",0)
THEN
   RESPONSE #100
      SetGlobal("CDRevealArea","CD_MYAREA_VAR_SCOPE",1)
      Explore()
      Continue()
END

Becomes:
IF
   Global("CDRevealArea","LOCALS",0)
THEN
   RESPONSE #100
      SetGlobal("CDRevealArea","LOCALS",1)
      Explore()
      Continue()
END

This will work on BG2... and IWD, but I can't say for non-EE BG1, or non-EE PST, yet.
« Last Edit: December 26, 2017, 05:58:06 PM by The Imp »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: IWD (orig) DECOMPILE bug?
« Reply #3 on: December 27, 2017, 06:32:48 AM »
You know, I was pretty certain I had released version 243 already. But evidently I have not, so I'll get to work right away. Sorry about that.

Scratch that. There have been too many changes. I'll put out a new beta and v243 will follow a couple of weeks after that.
« Last Edit: December 27, 2017, 07:13:46 AM by Wisp »

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: