Jump to content

Home

Script Question: Multiple Dialogs


goldberry

Recommended Posts

How can I make it so that the first time the PC holds a conversation with an NPC, it does one dialog file, and then from then on it does another depending on the answers given in the first conversation?

 

Thanks alot for any help.

 

Set a local boolean on the NPC in the first dialog when you want to switch over to the second. Then, in the OnDialogue event script of the NPC add a check for that local boolean, and if it's set you run BeginConversation() with the name of the second DLG file as parameter instead. Something like this might work:

 

// This is run from a node in the first dialog file...
void main() {
   SetLocalBoolean(OBJECT_SELF, [color=SkyBlue]118[/color], TRUE);
}

 

// This is the OnDialogue event script of the NPC...
void main() {
   if (!GetLocalBoolean(OBJECT_SELF, 97) 
       && !GetLocalBoolean(OBJECT_SELF, 87)
       && GetCommandable()
       && (GetListenPatternNumber() == -1))
   {                 
       object oShouter = GetLastSpeaker();
       object oAttacker = GetLastHostileActor(oShouter);

       if (!GetIsObjectValid(oAttacker) 
           || GetIsDead(oAttacker) 
           || !GetObjectSeen(oAttacker, oShouter)
           || !GetIsEnemy(oAttacker, oShouter))      
       {
           ClearAllActions();
           if (GetLocalBoolean(OBJECT_SELF, [color=SkyBlue]118[/color]))
               BeginConversation("[color=Yellow]MyOtherDialog[/color]");
           else
               BeginConversation();
       }

       if (GetLocalBoolean(OBJECT_SELF, 26))
           SignalEvent(OBJECT_SELF, EventUserDefined(1004));   
   }
   else {
       ExecuteScript("k_ai_master", OBJECT_SELF, 1004);
   }
}

 

I've colored the parts that may need to be modified. The part in yellow is the ResRef of the secondary DLG file. The part in blue is the Local Boolean index used to keep track of the switch.

 

That said, in most cases you don't really need multiple dialog files, it's much easier to just add all conversation possibilities to the same DLG file and put conditional scripts on them to control when they become available.

Link to comment
Share on other sites

As mentioned by DarthInsidious, depending on what you want to do, you may only need one .dlg file to do all this.

 

You can specify conditions that will determine which dialogue node will be fired next. See stoffe's post here: http://www.lucasforums.com/showpost.php?p=2120440&postcount=5 and this thread: http://www.lucasforums.com/showthread.php?t=154242

 

You can have all kind of conditions: items possessed, plot advancement, level, sex, location, etc, etc.

You can see some examples here: http://www.lucasforums.com/showthread.php?p=1906451#post1906451

 

Check the .nss files to see if there's an existing generic script that already does what you want (very likely in KotOR 2). If so, all you have to do is to type the name of the script in the conditional field (and specify the parameters in K2)

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...