Jump to content

Understanding Compiling Dialogues


Bill Bisco

Recommended Posts

The Branwen mod has the following lines of text in the TP2 file

COMPILE ~Branwen/Dialogue/O#BBran.d~ // All Branwen's banters with other party members will go here.
~Branwen/Dialogue/O#Bran.d~  // Branwen's greeting dialogue will go here. 
~Branwen/Dialogue/O#BranJ.d~ // The rest of Branwen's dialogue: her commentary, interjections, talks with the player, lovetalks and everything else.
~Branwen/Dialogue/O#BranP.d~ // Branwen's leaving party dialogue will go here.

Now, I know that somehow these all compile into O#Bran.DLG

 

None of the code in the above files explicity say they go with the CRE File O#Bran. See text below.

BEGIN O#BBRAN 


// This is Branwen's banter file. Remember how companions talk to each other? To do it, you need to write CHAINS like the ones below.
// Conditions: InParty(otherNPC) which means they're in party and not dead, See(other NPC), and CamDawg's !StateCheck("Name",CD_STATE_NOTVALID). NPCs can't talk if they're silenced or confused.
// Again, and I can't stress that enough, you have to set your variable to 1 in the banter, or it will trigger again.
CHAIN
IF ~InParty("Aerie")
See("Aerie")
!StateCheck("Aerie",CD_STATE_NOTVALID)
!StateCheck("O#Bran",CD_STATE_NOTVALID)
Global("O#BranAerie1","GLOBAL",0)~ THEN O#BBRAN O#BranAerie1
~Speak up, girl! Why are you always mumbling and stuttering?~
DO ~SetGlobal("O#BranAerie1","GLOBAL",1)~
== BAERIE ~I'm not!~
== O#BBRAN ~Are too!~
== BAERIE ~Not!~
== O#BBRAN ~Are!~
== BAERIE ~Not, not, not! And you're too big and too loud and your feet are smelly when you take your huge boots off! So there!~
== O#BBRAN ~Ha! When you want to, you're a regular little lioness, girl.~
EXIT
// Read this dialogue file FIRST.
// As for Branwen's scripts, I recommend to start with O#BranS.baf.


BEGIN O#BRAN 


CHAIN IF ~Global("O#BranMet","GLOBAL",0)~ THEN O#BRAN b1 
~<CHARNAME>! By Tempus, 'tis good to see you again! I feared you had perished!~ [o#bran01]
DO ~SetGlobal("O#BranMet","GLOBAL",1)~ 
== VICONIJ IF ~InParty("Viconia") InMyArea("Viconia") !StateCheck("Minsc",CD_STATE_NOTVALID)~ THEN ~I remember you, elg'caress. You were such an amusing statue with your mouth forever drooling. Pity someone had set you free.~
== MINSCJ IF ~InParty("Minsc") InMyArea("Minsc") !StateCheck("Minsc",CD_STATE_NOTVALID)~ THEN ~Little Branwen is back! Look, Boo, isn't it a proper reunion? Minsc and Boo and Branwen and friends!~
== EDWINJ IF ~InParty("Edwin") InMyArea("Edwin") !StateCheck("Edwin",CD_STATE_NOTVALID)~ THEN ~This one is useless, <CHARNAME>. Don't you remember how she got trapped in Nashkel? (Oh, fine, fine. But don't let her near my scrolls!)~
== JAHEIRAJ IF ~InParty("Jaheira") InMyArea("Jaheira") !StateCheck("Jaheira",CD_STATE_NOTVALID)~ THEN ~Well met, Branwen. It is good to see you once more.~
== O#BRAN ~I've learnt about mystery murders in this district and I've come to investigate. I am glad indeed that I've met you here! 'Twould be an honor to travel with you again.~
END 
++ ~It would be my pleasure, Branwen.~ EXTERN O#BRAN b1.1 
++ ~Not at this time.~  EXTERN O#BRAN b1.2
// Read this dialogue file second, after O#Bran.d.


BEGIN O#BranP


// This is the file we use when Branwen leaves the party. She can leave the party in two cases: first, she's VERY unhappy with the player's actions, and second, the player kicked her out.
// I use SAY here, since there is no one else but the player and Branwen.


// Just copy this and use your own filenames and variable names. Don't forget your very own modding prefix!


IF ~Global("O#BranKickedOut","GLOBAL",0) HappinessLT(Myself,-299)~ b1
SAY ~By Auril's frozen breath, I am leaving! May Tempus someday show you the error of your ways.~
IF ~~ DO ~EscapeArea()~ EXIT
END

Awhile ago, Jastey said:

 

jastey, on 16 Jun 2015 - 11:17 PM, said:snapback.png

 

Bill Bisco, on 16 Jun 2015 - 8:31 PM, said:snapback.png

I assume because I want to affect the DEREVAIN.DLG file, I by default the .D file must be named DEREVAIN.D correct?

no. The name of your .d file is unimportant. The result of a .d file is only dependent of what is inside. You specified inside that the derevain.dlg should be affected, the .d file can have whatever name you want.

 

In Essence because The file for Branwen named O#BRAN, starts with

BEGIN O#BRAN

That tells that the rest of the file will be compiled into O#BRAN.DLG ?

Link to comment

Well most of the interactions between those files is fixed into being by this at the end of the .tp2 file:

// These files add Branwen's scripts and dialogue files to the game(except for the banter file, that's below). The first block is for SoA-only installs, the second one is for ToB.
// Here's the order: death variable, leaving party file, main dialogue file(J for joined), dream script for SoA.
// Or death variable, leaving party file, main dialogue file(J for joined), dream script for SoA, leaving party file for ToB, main dialogue(J) file for ToB, ToB dream script, ToB main script.

APPEND ~pdialog.2da~
~O#Bran        O#BranP             O#BranJ            O#BranD~
UNLESS ~O#Bran~
UNLESS ~25POST~

APPEND ~pdialog.2da~
~O#Bran        O#BranP             O#BranJ            O#BranD             O#Bra25P             O#Bra25J             O#Bra25D       O#Bra25S~
UNLESS ~O#Bran~
IF ~25POST~

// These files add Branwen's banter files to the game. The first block is for SoA-only installs, the second one is for ToB.
// Here's the order: death variable, SoA banter file for SoA. Or death variable, SoA banter file, ToB banter file for ToB.
APPEND ~interdia.2da~
~O#Bran       O#BBran~
UNLESS ~O#Bran~
UNLESS ~25FILE~

APPEND ~interdia.2da~
~O#Bran       O#BBran       O#BBra25~
UNLESS ~O#Bran~
IF ~25FILE~
Link to comment

In Essence because The file for Branwen named O#BRAN, starts with

BEGIN O#BRAN
That tells that the rest of the file will be compiled into O#BRAN.DLG ?

 

That's correct. While the most common form of .d is often BEGIN-some states-END, d code is really a set of instructions. Don't let the fact that you have to 'compile' it fool you--functionally it's closer to tp2 code than a baf file. The file name is not relevant, only the contents.

 

When you start using things like CHAINs and INTERJECTs, you're changing all of the files involved. A CHAIN, for example, will add new states to all of the dialogue files referenced in the CHAIN. In the code you use as an example:

CHAIN IF ~Global("O#BranMet","GLOBAL",0)~ THEN O#BRAN b1 
~<CHARNAME>! By Tempus, 'tis good to see you again! I feared you had perished!~ [o#bran01]
DO ~SetGlobal("O#BranMet","GLOBAL",1)~ 
== VICONIJ IF ~InParty("Viconia") InMyArea("Viconia") !StateCheck("Minsc",CD_STATE_NOTVALID)~ THEN ~I remember you, elg'caress. You were such an amusing statue with your mouth forever drooling. Pity someone had set you free.~
== MINSCJ IF ~InParty("Minsc") InMyArea("Minsc") !StateCheck("Minsc",CD_STATE_NOTVALID)~ THEN ~Little Branwen is back! Look, Boo, isn't it a proper reunion? Minsc and Boo and Branwen and friends!~
== EDWINJ IF ~InParty("Edwin") InMyArea("Edwin") !StateCheck("Edwin",CD_STATE_NOTVALID)~ THEN ~This one is useless, <CHARNAME>. Don't you remember how she got trapped in Nashkel? (Oh, fine, fine. But don't let her near my scrolls!)~
== JAHEIRAJ IF ~InParty("Jaheira") InMyArea("Jaheira") !StateCheck("Jaheira",CD_STATE_NOTVALID)~ THEN ~Well met, Branwen. It is good to see you once more.~
== O#BRAN ~I've learnt about mystery murders in this district and I've come to investigate. I am glad indeed that I've met you here! 'Twould be an honor to travel with you again.~
END 
++ ~It would be my pleasure, Branwen.~ EXTERN O#BRAN b1.1 
++ ~Not at this time.~  EXTERN O#BRAN b1.2
WeiDU will add the necessary states and transitions to o#bran, viconij, minscj, edwinj, and jaheiraj to make this banter happen. If you try to do this without CHAIN, you would have to use APPEND and manually hit all of these files.
Link to comment

Thank you for the replies. One thing I don't understand is the below:

COMPILE ~Branwen/Dialogue/O#BBra25.d~  // All Branwen's ToB banters with other party members will go here. Again, we use 25, because it's a tradution for ToB.
    ~Branwen/Dialogue/O#Bran25.d~  // Branwen's ToB greeting dialogue will go here.
    ~Branwen/Dialogue/O#Bra25J.d~  // The rest of Branwen's ToB dialogue: her commentary, interjections, talks with the player, lovetalks and everything else.
    ~Branwen/Dialogue/O#Bra25P.d~  // Branwen's ToB leaving party dialogue will go here.

    ~Branwen/Scripts/O#Bra25S.baf~ // Branwen's script for ToB.
    ~Branwen/Scripts/O#Bra25D.baf~ // Branwen's dream script for ToB.

// Baldur's Gate 2: Enhanced Edition adds four new NPCs for your party. Naturally, Branwen banters with these NPCs, too. Let's compile a separate banter file here in ToB section(because it involves Branwen's ToB banter file):
ACTION_IF GAME_IS ~BG2EE~ BEGIN
COMPILE    ~Branwen/Dialogue/BranEE.d~
END

BranEE.d is not referenced again. The BranEE.d file itself only contains code like this:

// Crossmod for BG2EE

// Dorn

CHAIN
IF ~InParty("O#Bran")
See("O#Bran")
!StateCheck("Dorn",CD_STATE_NOTVALID)
!StateCheck("O#Bran",CD_STATE_NOTVALID)
Global("O#BranDorn1","GLOBAL",0)~ THEN BDORN O#BranDorn1
~We travel side by side again, I see. My master grows very interested in you.~
DO ~SetGlobal("O#BranDorn1","GLOBAL",1)~
== O#BBRAN ~Don't tell me. Same old "Join the dark side, Branwen, we have cookies?"~
== BDORN ~Ha! Do you expect me to bake you cookies, woman?~
== O#BBRAN ~Well, you'd look good in an apron.~
== BDORN ~Not in this lifetime.~
== O#BBRAN ~Thought you'd chicken out.~
EXIT

There's no BEGIN. There's no APPEND, yet somehow I assume these make it into the Banter file, O#BBran.d?

 

BranEE.d is not mentioned in the section Jarno copied earlier:

 

// These files add Branwen's banter files to the game. The first block is for SoA-only installs, the second one is for ToB.
// Here's the order: death variable, SoA banter file for SoA. Or death variable, SoA banter file, ToB banter file for ToB.
APPEND ~interdia.2da~
~O#Bran O#BBran~
UNLESS ~O#Bran~
UNLESS ~25FILE~

APPEND ~interdia.2da~
~O#Bran O#BBran O#BBra25~
UNLESS ~O#Bran~
IF ~25FILE~

Link to comment

Thank you for the replies. One thing I don't understand is the below:

COMPILE ~Branwen/Dialogue/O#BBra25.d~  // All Branwen's ToB banters with other party members will go here. Again, we use 25, because it's a tradution for ToB.
    ~Branwen/Dialogue/O#Bran25.d~  // Branwen's ToB greeting dialogue will go here.
    ~Branwen/Dialogue/O#Bra25J.d~  // The rest of Branwen's ToB dialogue: her commentary, interjections, talks with the player, lovetalks and everything else.
    ~Branwen/Dialogue/O#Bra25P.d~  // Branwen's ToB leaving party dialogue will go here.

    ~Branwen/Scripts/O#Bra25S.baf~ // Branwen's script for ToB.
    ~Branwen/Scripts/O#Bra25D.baf~ // Branwen's dream script for ToB.

// Baldur's Gate 2: Enhanced Edition adds four new NPCs for your party. Naturally, Branwen banters with these NPCs, too. Let's compile a separate banter file here in ToB section(because it involves Branwen's ToB banter file):
ACTION_IF GAME_IS ~BG2EE~ BEGIN
COMPILE    ~Branwen/Dialogue/BranEE.d~
END

BranEE.d is not referenced again. The BranEE.d file itself only contains code like this:

// Crossmod for BG2EE

// Dorn

CHAIN
IF ~InParty("O#Bran")
See("O#Bran")
!StateCheck("Dorn",CD_STATE_NOTVALID)
!StateCheck("O#Bran",CD_STATE_NOTVALID)
Global("O#BranDorn1","GLOBAL",0)~ THEN BDORN O#BranDorn1
~We travel side by side again, I see. My master grows very interested in you.~
DO ~SetGlobal("O#BranDorn1","GLOBAL",1)~
== O#BBRAN ~Don't tell me. Same old "Join the dark side, Branwen, we have cookies?"~
== BDORN ~Ha! Do you expect me to bake you cookies, woman?~
== O#BBRAN ~Well, you'd look good in an apron.~
== BDORN ~Not in this lifetime.~
== O#BBRAN ~Thought you'd chicken out.~
EXIT

There's no BEGIN. There's no APPEND, yet somehow I assume these make it into the Banter file, O#BBran.d?

 

BranEE.d is not mentioned in the section Jarno copied earlier:

 

// These files add Branwen's banter files to the game. The first block is for SoA-only installs, the second one is for ToB.

// Here's the order: death variable, SoA banter file for SoA. Or death variable, SoA banter file, ToB banter file for ToB.

APPEND ~interdia.2da~

~O#Bran O#BBran~

UNLESS ~O#Bran~

UNLESS ~25FILE~

 

APPEND ~interdia.2da~

~O#Bran O#BBran O#BBra25~

UNLESS ~O#Bran~

IF ~25FILE~

BranEE does not create an extra DLG but actually is just the name of a file that adds to existing dlg files (the ones referenced inside the chain. i.e BDorn and O#BBRAN. The chain format is just a handy form of appending to existing dialogue without the need to cross referencing between multiple files (providing all of them already exist).

 

This Is equivalent to

 

APPEND BDorn

IF ~InParty("O#Bran")

See("O#Bran")

!StateCheck("Dorn",CD_STATE_NOTVALID)

!StateCheck("O#Bran",CD_STATE_NOTVALID)

Global("O#BranDorn1","GLOBAL",0)~ THEN BEGIN O#BranDorn1

SAY~We travel side by side again, I see. My master grows very interested in you.~

IF~~THEN DO ~SetGlobal("O#BranDorn1","GLOBAL",1)~ EXTERN O#BBRAN O#BranDorn2

END

END

 

APPEND O#BBRAN

IF~~THEN BEGIN O#BranDorn2

SAY ~Don't tell me. Same old "Join the dark side, Branwen, we have cookies?"~

IF~~THEN EXTERN BDORN O#BranDorn3

END

END

 

....and so on...

 

And you can also involve other NPCs easily

 

CHAIN

IF ~InParty("O#Bran")

See("O#Bran")

!StateCheck("Dorn",CD_STATE_NOTVALID)

!StateCheck("O#Bran",CD_STATE_NOTVALID)

Global("O#BranDorn1","GLOBAL",0)~ THEN BDORN O#BranDorn1

~We travel side by side again, I see. My master grows very interested in you.~

DO ~SetGlobal("O#BranDorn1","GLOBAL",1)~

== O#BBRAN ~Don't tell me. Same old "Join the dark side, Branwen, we have cookies?"~

== BDORN ~Ha! Do you expect me to bake you cookies, woman?~

== O#BBRAN ~Well, you'd look good in an apron.~

==BImoen2 IF~InParty("Imoen2")~THEN~Who's got the cookies, I'm starving already?~

== O#BBRAN IF~InParty("Imoen2")~THEN~Child, go to sleep, we're not talking about that kind of cookies here.~

==IF_FILE_EXISTS BSUFINCH IF~ InParty("Sufinch") ~ THEN ~No, I say no, stop it!~ //and this will only compile if the FinchNPC mod is in the game

== BDORN ~Not in this lifetime.~

== O#BBRAN ~Thought you'd chicken out.~

EXIT

Link to comment

Archived

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

×
×
  • Create New...