Jump to content

[Tutorial] How to interject into mod added dialogue lines using STATE_WHICH_SAYS


Recommended Posts

This is a quick tutorial how to insert additional dialogue lines into mod added lines. This can be used to make parts of your own mod optional (as in the example below). It is also the choice for crossmod into other mods where e.g. your mod NPC should interject into lines of a quest mod.


Note: STATE_WHICH_SAYS only works if that line does not exist more than once in the specified dlg, i.e. only one dialogue state with this text line should be existent in the dlg or the patching will fail.

Also: The mod /contents you want to interject into has to be installed already (obviously). Checks for installation are not included in the example below as it is not necessary in this case (because the main component has to be installed in this case).

The example is taken from Endless BG1: The main component inserts dialogue for Duke Belt where the PC is called "Hero of Baldur's Gate". If only the main component of Endless BG1 is installed, the dialogue lines go the following:

Spoiler

~<CHARNAME>, you were successful! You defeated Sarevok who conspired against the city, the Sword Coast, even Amn - for his own dark goals and purpose.~
= ~You opened our eyes to the deceit and saved us from a great peril while we remained blind to the threat. By the power bestowed upon me as Duke of the Council of Four of this city I herewith name you "Hero of Baldur's Gate"! On behalf of the city let me express our deepest gratitude!~
= ~<CHARNAME>, Hero of Baldur's Gate. Are you ready to combine forces with the Flaming Fist and go against the last followers of Sarevok?~

 

The second component of Endless BG1 inserts another line from Duke Belt giving the room on the 3rd floor of the Palace to the PC as their quarters.

For this, the component should insert the new line

Quote

~With the title come official quarters for you on the third level of the Ducal Palace! The servants will help you settle in as soon as you are ready. Everyone, praise our Hero of Baldur's Gate!~

after the 2nd line:

Quote

~You opened our eyes to the deceit and saved us from a great peril while we remained blind to the threat. By the power bestowed upon me as Duke of the Council of Four of this city I herewith name you "Hero of Baldur's Gate"! In the name of the city let me express our deepest gratitude!~

 

To do this, we first need to read in the state number of the line we want to interject into so we can use INTERJECT_COPY_TRANS (I_C_T). The main component is installed so inside the player's game this line is now a normal state in BELT.dlg. Since the line was added by Endless BG1's first component itself, we do not have a fixed number but need to evaluate the state number using STATE_WHICH_SAYS.

STATE_WHICH_SAYS needs the following specifications:
- the dlg the line is in. Here it is "BELT".
- a name for the variable for the state number which we will use internally in our mod. You can name this anything you want and it should be something unique in your mod. In this example it will be "belt_victory_01".
- we also need to know the tra line we want to search for. In this case, it is @1 in ~c#endlessbg1/translations/%s/dialogues.tra~.
Note: if you interject into another mod, this will work even if the other mod is installed in another language than yours!

Inside the tp2 we now have:

// Get state for BELT %belt_victory_01%
/* ~You opened our eyes to the deceit and saved us from a great peril while we remained blind to the threat. By the power bestowed upon me as Duke of the Council of Four of this city I herewith name you "Hero of Baldur's Gate"! In the name of the city let me express our deepest gratitude!~
*/
OUTER_SET belt_victory_01 = STATE_WHICH_SAYS 1 IN ~c#endlessbg1/translations/%s/dialogues.tra~ FROM ~BELT~

After this, the state number will be stored in %belt_victory_01% and can be used inside the mod.

In our example, it is used inside the d-file "add_ee.d", which containes the following. This is a normal I_C_T where the state number is our variable:
 

I_C_T BELT %belt_victory_01% c#st_belt_victory_01
== BELT @42 /* ~With the title come official quarters for you on the third level of the Ducal Palace! The servants will help you settle in as soon as you are ready. Everyone, praise our Hero of Baldur's Gate!~ */
END

And in the tp2, we add the compilation of this d-file with EVALUATE_BUFFER so the variable will evaluated (note: I put all tra lines fom Endless BG1 into one file "dialogues.tra" that is why it is specified here):
 

 COMPILE EVALUATE_BUFFER ~c#endlessbg1/pc_palaceresidence/add_ee.d~ USING ~c#endlessbg1/translations/%s/dialogues.tra~

And that's it! The dialogue from Duke Belt ingame now reads:

Spoiler

~<CHARNAME>, you were successful! You defeated Sarevok who conspired against the city, the Sword Coast, even Amn - for his own dark goals and purpose.~
= ~You opened our eyes to the deceit and saved us from a great peril while we remained blind to the threat. By the power bestowed upon me as Duke of the Council of Four of this city I herewith name you "Hero of Baldur's Gate"! On behalf of the city let me express our deepest gratitude!~
= ~With the title come official quarters for you on the third level of the Ducal Palace! The servants will help you settle in as soon as you are ready. Everyone, praise our Hero of Baldur's Gate!~
= ~<CHARNAME>, Hero of Baldur's Gate. Are you ready to combine forces with the Flaming Fist and go against the last followers of Sarevok?~

 

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...