FANDOM


Random Dialogue ScriptEdit

/*
  cn_rnd14
  Starting conditional for conversations, the line has a 25% chance of being spoken.
  Make sure to place the condition in order on dialogue nodes from least chance to greatest chance.
  Created by Ghostdreamer for NWN1, modified by Paul V for the Witcher.
*/
int StartingConditional()
{
    int iResult;
    iResult = d100() < 26;
    return iResult;
}

The above script is an example of a randomized dialogue script. In this example it would be assigned as a conditional script to the first of four dialogue nodes. The second dialogue node would be given a similar conditional script, but instead of the

iResult = d100() <26; it would be:

iResult = d100() <51;

This tells D'Jinni to roll a 100 sided die when initiating the dialogue. If the result is <26, play that dialogue node. If the die result is >25, it moves on to the next dialogue, and rolls there.


It's important to note that the scripts must be placed from least likely chance to most likely chance,
top to bottom respectively, on the dialogue nodes in the .dlg. This is because D'Jinni reads from top
to bottom, and if the top node is iResult = d100() < 100; then it will be the dialogue selected
100 percent of the time, defeating the purpose of the script.


Likewise, each dialogue node in the .dlg file should have separate conditional scripts, each with an equal chance of being rolled, according to the total number of possible dialogue nodes. Whats this mean? Well, if you have 10 dialogue nodes that you want to be randomly chosen each time Geralt speaks to this person, then the conditional script will read as above, but with the following variables:

  • iResult = d100() < 11;
  • iResult = d100() < 21;
  • iResult = d100() < 31;
  • iResult = d100() < 41;
  • iResult = d100() < 51;
  • iResult = d100() < 61;
  • iResult = d100() < 71;
  • iResult = d100() < 81;
  • iResult = d100() < 91;
  • iResult = d100() < 100;

Script Naming ConventionEdit


Eventually you will have so many of these scripts saved to your hard drive that keeping track of them might become difficult. To simplify this, I've posted the following naming convention for easy memory and convenience.

cn_rnd14 (This represents condition-random-1 of 4. an iResult= <26)
cn_rnd24 (This represents condition-random-2 of 4. an iResult= <51)
cn_rnd15 (This represents condition-random-1 of 5. an iResult= <21)
etc.

Hope this helps, will update regularly with more scripts and answer questions on the D'Jinni forums!

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.