Author Topic: Patching BCS files with D_B_T_B  (Read 1806 times)

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Patching BCS files with D_B_T_B
« on: July 21, 2006, 05:49:43 PM »
Having some trouble patching a .BCS:

In .tp2

COPY_EXISTING ~_KAGAIN.BCS~ ~override~
  DECOMPILE_BCS_TO_BAF
    REPLACE_TEXTUALLY ~GlobalTimerExpired("Kagain","GLOBAL")~ ~AreaCheck("FW2800")~
    REPLACE_TEXTUALLY ~Global("KagainCaravan","GLOBAL",0)~ ~Global("X#KagainCaravan","GLOBAL",0)~
    REPLACE_TEXTUALLY ~Global("KagainCaravan","GLOBAL",1)~ ~Global("X#KagainCaravan","GLOBAL",1)~
    REPLACE_TEXTUALLY ~Dialog([PC])~ ~SetGlobal("KagainCaravan","GLOBAL",10) StartDialogueNoSet(Player1)~
  COMPILE_BAF_TO_BCS
  BUT_ONLY_IF_IT_CHANGES

After install, the blocks look like this:

IF
  AreaCheck("FW2800")
  Global("X#KagainCaravan","GLOBAL",0)
THEN
  RESPONSE #100
    Dialog([PC])
END

IF
  AreaCheck("FW2800")
  Global("X#KagainCaravan","GLOBAL",1)
THEN
  RESPONSE #100
    Dialog([PC])
END

infinite loop time:
so my attempt to replace the responses fails. I am still looking for a good, solid way of adding actions to an existing script block the way you can with D files... can anyone help?

Thanks!

Offline Macready

  • Planewalker
  • *****
  • Posts: 1801
    • EasyTutu
Re: Patching BCS files with D_B_T_B
« Reply #1 on: July 21, 2006, 06:07:02 PM »
Hello -

REPLACE_TEXTUALLY can be a bit problematic.  At times I think that the code WeiDU is parsing internally after a TP2 DECOMPILE (either bcs or dlg) differs from what you see in a file you decompiled from the command line.  I fought this a number of times during my suboptimal R_T dialog patches.

Since you seem to be detecting the block triggers with no problem, you could always just patch in a False() to the trigger sections and then EXTEND in newly rewritten versions of the entire code blocks.
EasyTutu: Tutu installation made simple.

Offline Grim Squeaker

  • Fallen
  • Planewalker
  • *****
  • Posts: 1019
  • Gender: Male
Re: Patching BCS files with D_B_T_B
« Reply #2 on: July 21, 2006, 06:20:39 PM »
Quote
REPLACE_TEXTUALLY can be a bit problematic.

Actually the normal situation (and the one in this case) is that people don't realise or forget that the first argument of REPLACE_TEXTUALLY is a regular expression.  This means that anything including special characters isn't being interpreted how you expect. ~Dialog([PC])~ isn't working as you expect because square brackets are special characters.  What you want is: ~Dialog(\[PC\])~ (the backslashes mean 'treat the following character just as it is rather than as a special character')

Quote
I am still looking for a good, solid way of adding actions to an existing script block the way you can with D files... can anyone help?

The reason it's not as simple as dialogue files is of course script blocks don't have numbers, therefore we can't just say 'add a new action to this block'.  This means we have to do stuff like REPLACE_TEXTUALLY, which is fine if you know/remember that it's a regular expression.
« Last Edit: July 21, 2006, 06:26:07 PM by Grim Squeaker »
"You alone can make my song take flight..."

Offline cmorgan

  • Planewalker
  • *****
  • Posts: 1424
  • Gender: Male
  • Searcher of Bugs
Re: Patching BCS files with D_B_T_B
« Reply #3 on: July 21, 2006, 06:52:59 PM »
This is "regular expressions" is something that I have read over and over again... and had obviously not goetten through my thick skull!

Thank you both for the help.

Two answers:

1. patch the block to ~False()~, leave the rest of the block alone, and EXTEND the .BCS with the blocks you want, which means that you may do away with other people's patching of the script, but you are less likely to fail and mess your own up. Plus, it means you can do the whole thing in one swoop rather than line-by-line comparison swap-outs.

2. carefully read and understand the documentation and send Grim Squesaker a bottle of wine for helping without swearing and throwing things around, and follow the syntax for regular expressions:

Quote
The syntax for regular expressions is the same as in Gnu Emacs. The special characters are:
$^.*+?[]'"
The following constructs are recognized:
   .      matches any character except newline
   *      (postfix) matches the previous expression zero, one or several times
   +      (postfix) matches the previous expression one or several times
   ?      (postfix) matches the previous expression once or not at all
   [..]   character set; ranges are denoted with -, as in [a-z];
          an initial ^, as in [^0-9], complements the set
   ^      matches at beginning of line
   $      matches at end of line
   \|     (infix) alternative between two expressions
   \(..\) grouping and naming of the enclosed expression
   \1     the text matched by the first \(...\) expression
          (\2 for the second expression, etc)
   \b     matches word boundaries
   \      quotes special characters.
   '      interpret the characters inside '' literally
   "      interpret the characters inside "" literally

Understanding this for a non-programmer is definitely a trial-error-ask questions-repeat experience!

Offline Macready

  • Planewalker
  • *****
  • Posts: 1801
    • EasyTutu
Re: Patching BCS files with D_B_T_B
« Reply #4 on: July 21, 2006, 07:41:54 PM »
Hello -

Quote
REPLACE_TEXTUALLY can be a bit problematic.

Actually the normal situation (and the one in this case) is that people don't realise or forget that the first argument of REPLACE_TEXTUALLY is a regular expression.

Good catch.  Yet, R_T can definitely be problematic.  Try a R_T on a decompiled DLG string which includes a GOTO state#.  If you have a quick answer to that one, I'll  buy you a drink if we ever meet. :)
EasyTutu: Tutu installation made simple.

Offline Grim Squeaker

  • Fallen
  • Planewalker
  • *****
  • Posts: 1019
  • Gender: Male
Re: Patching BCS files with D_B_T_B
« Reply #5 on: July 22, 2006, 05:58:11 AM »
Hello -

Quote
REPLACE_TEXTUALLY can be a bit problematic.

Actually the normal situation (and the one in this case) is that people don't realise or forget that the first argument of REPLACE_TEXTUALLY is a regular expression.

Good catch.  Yet, R_T can definitely be problematic.  Try a R_T on a decompiled DLG string which includes a GOTO state#.  If you have a quick answer to that one, I'll  buy you a drink if we ever meet. :)

Gotta admit I've never tried that one before, as for dialogues I tend to use the already existing dialogue functions.  My only advice on that is manually decompiling the file, copying the text from there and see if it works.  I mean there's a chance it's actually an EXTERN for some reason.  Also, R_Ting that actually contains a decompiled string is gonna be hell, due to language stuff (WeiDU decompiles with a comment just after the stringref saying what the native text for that string is).

Quote
Understanding this for a non-programmer is definitely a trial-error-ask questions-repeat experience!

Basically, unless you're trying to do weird matching stuff, the only thing you need to remember is to stick a backslash before any of those special characters to make sure they are interpreted just as text.  This often comes up with square brackets or if you're doing IDS patching, watching out for asterisks.

Quote
...send Grim Squeaker a bottle of wine...

That's a good Q&A policy.
« Last Edit: July 22, 2006, 06:00:43 AM by Grim Squeaker »
"You alone can make my song take flight..."

Offline Macready

  • Planewalker
  • *****
  • Posts: 1801
    • EasyTutu
Re: Patching BCS files with D_B_T_B
« Reply #6 on: July 22, 2006, 07:32:18 AM »
Hello -

Gotta admit I've never tried that one before, as for dialogues I tend to use the already existing dialogue functions.  My only advice on that is manually decompiling the file, copying the text from there and see if it works.  I mean there's a chance it's actually an EXTERN for some reason.  Also, R_Ting that actually contains a decompiled string is gonna be hell, due to language stuff (WeiDU decompiles with a comment just after the stringref saying what the native text for that string is).

I was hoping to entice you into a heroic feat of problem solving. :)  I've attempted this with numerous GOTO clauses before finally figuring out the GOTO clause was the culprit, so I don't think it's an EXTERN situation.  Also, WeiDU has a command line switch to decompile sans comments.
EasyTutu: Tutu installation made simple.

Offline Grim Squeaker

  • Fallen
  • Planewalker
  • *****
  • Posts: 1019
  • Gender: Male
Re: Patching BCS files with D_B_T_B
« Reply #7 on: July 22, 2006, 08:01:03 AM »
Hello -

Gotta admit I've never tried that one before, as for dialogues I tend to use the already existing dialogue functions.  My only advice on that is manually decompiling the file, copying the text from there and see if it works.  I mean there's a chance it's actually an EXTERN for some reason.  Also, R_Ting that actually contains a decompiled string is gonna be hell, due to language stuff (WeiDU decompiles with a comment just after the stringref saying what the native text for that string is).

I was hoping to entice you into a heroic feat of problem solving. :)  I've attempted this with numerous GOTO clauses before finally figuring out the GOTO clause was the culprit, so I don't think it's an EXTERN situation.  Also, WeiDU has a command line switch to decompile sans comments.

Hmmm... wel, I suppose I could have a crack at solving the problem.  I'll see what I can do, though no promises.  And as for the command line switch, we can't use that with the DECOMPILE_DLG_TO_D command, which is the matter at hand.  The point of manually decompiling and copying is that we get to see exactly what WeiDU is dealing with when it tries to REPLACE_TEXTUALLY.
"You alone can make my song take flight..."

Offline Macready

  • Planewalker
  • *****
  • Posts: 1801
    • EasyTutu
Re: Patching BCS files with D_B_T_B
« Reply #8 on: July 22, 2006, 08:41:06 AM »
Hello -

Hmmm... wel, I suppose I could have a crack at solving the problem.  I'll see what I can do, though no promises.  And as for the command line switch, we can't use that with the DECOMPILE_DLG_TO_D command, which is the matter at hand.  The point of manually decompiling and copying is that we get to see exactly what WeiDU is dealing with when it tries to REPLACE_TEXTUALLY.

Well, you don't really have to.  I was just hoping the facility with which you answered cmorgan's question might mean you had a similar quick answer for me.  As far as comments go, in my experience the internal DECOMPILEs are comment-free.  I've done copious amounts of successful multi-line replaces, including SAY lines, acting as if no comments were present.
EasyTutu: Tutu installation made simple.

 

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)?: