JediMindTrix

Dialog Node Conditionals

Recommended Posts

The following script (and ones similar to it) seems to be used for most of the conditionals that determine whether a node is shown to the player in a dialog tree.

// Globals
    int intGLOB_1 = 0;
    int intGLOB_2 = 1;
    int intGLOB_3 = 2;
    int intGLOB_4 = 3;
    int intGLOB_5 = 4;
    int intGLOB_6 = 5;
    int intGLOB_7 = 6;
    int intGLOB_8 = 7;
    int intGLOB_9 = 8;
    int intGLOB_10 = 9;
    int intGLOB_11 = 10;
    int intGLOB_12 = 11;
    int intGLOB_13 = 12;
    int intGLOB_14 = 13;
    int intGLOB_15 = 14;
    int intGLOB_16 = 15;
    int intGLOB_17 = 16;
    int intGLOB_18 = 17;
    int intGLOB_19 = 18;
    int intGLOB_20 = 19;
    int intGLOB_21 = 1100;
    int intGLOB_22 = (-6);
    int intGLOB_23 = (-5);
    int intGLOB_24 = (-4);
    int intGLOB_25 = (-2);
    int intGLOB_26 = (-1);
    int intGLOB_27 = 0;

void main() {
    int nParam1 = GetScriptParameter(1);
    string sParam = GetScriptStringParameter();
    object object1;
    if ((sParam == "")) {
        object1 = OBJECT_SELF;
    }
    else {
        object1 = GetObjectByTag(sParam, 0);
    }
    SetLocalBoolean(object1, nParam1, 1);
}

Another example:

int StartingConditional() {
    string sParam = GetScriptStringParameter();
    int nParam1 = GetScriptParameter(1);
    if ((GetGlobalNumber(sParam) > nParam1)) {
        return 1;
    }
    return 0;
}

What I am not understanding is where these scripts are obtaining the values for GetScriptStringParameter(); and GetScriptParameter(1);. Can anyone explain to me, or point me towards a tutorial or example, how this functions?

Share this post


Link to post
Share on other sites

First a breakdown on conditional scripts even if you already know them:

 

A conditional script's goal is to eventually tell you 0 or 1, or FALSE or TRUE. Whatever determines the value returned are the conditions.

 

As to your question about GetScriptStringParameter and GetScriptParameter(1), those functions are TSL-specific and get there values from the DLG file. They're also only supported by K-GFF and DLG Editor (KT's Conversation Editor is a NO).

 

Capture.PNG

Here's a picture of an entry in a TSL dialog, and I've drawn a red line around the pieces. P1 is GetScriptParameter(1), and the rest follow suit. The one on the end is the big box for GetScriptStringParameter();.

Share this post


Link to post
Share on other sites

Thank you! That was very informative, and explains why I was completely missing where the script was getting these values from (I was using Kotor Tool to view the .dlg).

Share this post


Link to post
Share on other sites

To chime in and add to what Fair Strides said, you may notice how the first of your example is not a conditional script. 

 

Conditional scripts start with  

 

int StartingConditional()

 

and must return a value of 0 or 1 (like the second example instead does).

Share this post


Link to post
Share on other sites

To chime in and add to what Fair Strides said, you may notice how the first of your example is not a conditional script. 

 

Conditional scripts start with  

 

int StartingConditional()

 

and must return a value of 0 or 1 (like the second example instead does).

Right, that was an 'action taken' script - but it was setting variables used by conditional scripts and thusly I gave it the wrong name.

Share this post


Link to post
Share on other sites

but it was setting variables used by conditional scripts and thusly I gave it the wrong name.

If you look at the picture again, you'll see that the P1-P5 and the String boxes are also available for the Script #1 and Script #2 fields. Those Script fields are for Action Scripts and they can use the parameters as well.

Share this post


Link to post
Share on other sites

Correct. That picture wasn't lying.

 

Each dialog node, whether it's an Entry (NPC line) or a Reply (PC line) can have two Conditional Scripts that determine whether the line is shown and can then fire two Action Scripts.

 

Each of the four scripts can use up to 5 Script Parameters and 1 String Parameter for extra versatility.

 

This all was a handy upgrade from KotOR 1, where each line only had one Conditional and one Action script, and no parameters of any kind. This upgrade easily reduced the number of scripts by hundreds, if not thousands.

Share this post


Link to post
Share on other sites

Do new dialog lines inside of a .dlg need to reference a string in the dialog.tlk or can they be defined solely inside of a .dlg?

Share this post


Link to post
Share on other sites

Just to clarify, dialog can be in the TLK and/or in the DLG itself, and you can mix the two.

 

New dialog can be in either the TLK (in which case you reference the entry number in the dlg file's entries) or in the dlg itself (in which case the String Ref is -1 and you can just enter your text).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.