Author Sticky: Post Working Scripts Here
DragonTayl Posted: Saturday, 06 July 01:36PM
1) Name: Multi NPC conversation (no PC)

2) What it does: This is set of two scripts, one to trigger a conversation between two NPCs, the other to control and run through the conversation.

3) Notes: Adding more NPCs is simply a matter of increasing the NPC objects (don't forget to give them unique tags or all the script will come out of one NPC).

Here's my method:

Create a trigger area the PC enters to "cause" the conversation (basically, what's the eavesdropping distance?) This script goes in that trigger's OnEnter event.:

///////////////////////////////////////////////
// Multi-NPC Conversation Trigger
// coded by DragonTayl
///////////////////////////////////////////////
void main()
{
object oChick1=GetObjectByTag("fc_CultChick1");
object oPC=GetEnteringObject();
/* Check to see if it's a PC entering, this if
can be removed if you wish to have it triggered any
time even an NPC goes through the listening area,
but be aware that the conversation starts over any
time a valid object enters the trigger area. */
if (GetIsPC(oPC))
{
/* Note that this is the first line of the
conversation. This is done so that there isn't
a long pause between the PC entering the area
and the first line of the conversation (while
the engine waits for the NPC's Heartbeat event).
If you want a pause, simply comment out the next
line. */
AssignCommand(oChick1, SpeakString("He's such a lug."));
SetLocalInt(oChick1, "iShowLine", 1);
}
}
 



Then in the NPC you wish to "start" the conversation (this NPC will also basically control the conversation) make a copy of the default OnSpawn script, un-comment the following line:

SetSpawnInCondition (NW_FLAG_HEARTBEAT_EVENT);

Save the OnSpawn script you just created and assign it to the "start" NPC's OnSpawn event.

Finally, add the following script (changing the text to suit your needs, this is again part of my cliche cult) to the NPC's OnUserDefined event.

NWScript:
//::///////////////////////////////////////////////
//:: Default: On User Defined
//:: NW_C2_DEFAULTD
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
    This specific OnUserEvent script plays out a
    Multi-NPC Conversation.
    Coded by DragonTayl
*/
//:://////////////////////////////////////////////
//:: Created By: Don Moar
//:: Created On: April 28, 2002
//:://////////////////////////////////////////////
void main()
{
    // enter desired behaviour here
    // 1001 = OnHeartbeat Event.
    int nEvent = GetUserDefinedEventNumber();
    if (nEvent == 1001)
      {
        /* Add more objects here if you wish the
           conversation to have more participants */
        object oChick1=GetObjectByTag("fc_CultChick1");
        object oChick2=GetObjectByTag("fc_CultChick2");
        int iLine=GetLocalInt(oChick1, "iShowLine");
        // Check to see if the trigger started the conversation
        if (iLine > 0
            && IsInConversation(oChick1) == FALSE
            && IsInConversation(oChick2) == FALSE)
          {
            /* This is the meat of the conversation.
               Change the text in the SpeakString(s) to
               the lines of your conversation. Simply
               remove cases if your conversation isn't
               this long, add them if your conversation
               is longer. Please note that the last case
               needs to increase the iShowLine variable or
               the last line of the conversation will loop.*/
            switch(iLine)
              {
                case 1:
                  AssignCommand(oChick2, SpeakString("Tell me about it. Always running into things."));
                  SetLocalInt(oChick1, "iShowLine", 2);
                  break;
                case 2:
                  AssignCommand(oChick1, SpeakString("And his appetite is impossible"));
                  SetLocalInt(oChick1, "iShowLine", 3);
                  break;
                case 3:
                  AssignCommand(oChick2, SpeakString("I don't know what to do with mine, either."));
                  SetLocalInt(oChick1, "iShowLine", 4);
                  break;
                case 4:
                  AssignCommand(oChick1, SpeakString("I have thought about sacrificing him. There's always fresh meat around to replace him."));
                  SetLocalInt(oChick1, "iShowLine", 5);
                  break;
                case 5:
                  AssignCommand(oChick2, SpeakString("Really? How would you get that done?"));
                  SetLocalInt(oChick1, "iShowLine", 6);
                  break;
                case 6:
                  AssignCommand(oChick1, SpeakString("Easy. Most of the Superiors are all too eager to make an example of someone."));
                  SetLocalInt(oChick1, "iShowLine", 7);
                  break;
                case 7:
                  AssignCommand(oChick2, SpeakString("But they don't always listen and might sacrifice YOU!"));
                  SetLocalInt(oChick1, "iShowLine", 8) ;
                  break;
                case 8:
                  AssignCommand(oChick1, SpeakString("They do what you want if you get intimate with them."));
                  SetLocalInt(oChick1, "iShowLine", 9);
                  break;
                case 9:
                  AssignCommand(oChick2, SpeakString("Not a bad idea. I know just who I'd use..."));
                  SetLocalInt(oChick1, "iShowLine", 10);
                  AssignCommand(oChick1, ActionPlayAnimation(ANIMATION_LOOPING_TALK_LAUGHING, 1.0, 5.0));
                  AssignCommand(oChick2, ActionPlayAnimation(ANIMATION_LOOPING_TALK_LAUGHING, 1.0, 5.0));
                  break;
              }
          }
      };
    return;
}



Members, feel free to message me in the My Messages feature of the website.

DragonTayl.