DMH-Online

Dungeon Masters Helper · Est. 2005

Npcs Scripts

NWN Script: monolouge.htm

Author Sticky: Post Working Scripts Here
DragonTayl Posted: Friday, 05 July 08:54PM
BIOWARE: a "preview" button for submitting to these message boards would help. I sure hope this posts nicely. I'd hate a typo to make my post look bad.

<b>1. NPC Monolog/Conversation</b>

<b>2. What it does: This script allows an NPC to run through several lines of his/her own "over the head" text.</b>

<b>3. Notes: </b>
I searched the boards and found this question came up a lot but there were no solutions that I could find. I finally figured this out and have tested it.

This script is set up for one NPC to talk as though giving a lecture. I haven't tested modifications on making two NPCs talk to each other, but that's coming shortly as I have another place where I want two NPCs to talk to each other.

First you must go into the NPC's OnSpawn event and simply uncomment the line:

SetSpawnInCondition (NW_FLAG_HEARTBEAT_EVENT);

found in the Custom User Defined Events section to activate the NPC's Heartbeat event. Don't forget to save the script under a different name so you don't over-write the default script (and don't forget to assign your new script to the NPC's OnSpawn event).


Next, you'll need to place the following script in the OnEnter event of a generic trigger defining the area in which you want the player to cause this conversation, or you might try placing it in the NPC's OnPerceive event (though I have not tested that). This script speaks the first line of the conversation and sets a local variable on the NPC that will control the flow of script.

NWScript:
void main()
{
  object oPriest=GetObjectByTag("fc_PlatformPriest");
  AssignCommand(oPriest, SpeakString("According to thy instructions, oh Great Mictlantecuhtli, we have weeded out the unworthy from our potential supplicants."));
  SetLocalInt(oPriest, "iShowLine", 1);
}



Then this is the template (complete with custom content from my module - sorry about the stereotypical cult-sacrificing-victims side-plot) for the custom conversation. Place this script in the NPC's OnUserDefined event. The example stops mid-conversation but by then you should have figured out the concept.

NWScript:
//::///////////////////////////////////////////////
//:: Default: On User Defined
//:: NW_C2_DEFAULTD
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Determines the course of action to be taken
    on a user defined event.
*/
//:://////////////////////////////////////////////
//:: Created By: Don Moar
//:: Created On: April 28, 2002
//:://////////////////////////////////////////////
void main()
{
    // enter desired behaviour here
    // 1001 = OnHeartbeat Event.
    int nEvent = GetUserDefinedEventNumber();
    if (nEvent == 1001)
      {
        object oPriest=GetObjectByTag("fc_PlatformPriest");
        // Check to see if the priest is conversing.
        // (Basically, is the last line still over his head?)
        // If so, wait for next heartbeat.
        if (IsInConversation(oPriest) == FALSE && GetIsInCombat(oPriest) == FALSE)
          {
            int iLine=GetLocalInt(oPriest, "iShowLine");
            object oVictim1=GetNearestObjectByTag("fc_PlatformVictim", OBJECT_SELF, 1);
            object oPC=GetFirstPC();
            switch(iLine)
              {
                case 1:
                  AssignCommand(oPriest, SpeakString("Now we are prepared to sacrifice them to thee, oh master!"));
                  SetLocalInt(oPriest, "iShowLine", 2);
                  break;
                case 2:
                  AssignCommand(oPriest, SpeakString("And through thy devine power, let fire fly from my fingertips --"));
                  SetLocalInt(oPriest, "iShowLine", 3);
                  break;
                case 3:
                  AssignCommand(oPriest, SpeakString("And through our gathered witnessing of this event, we shall all receive thy blessing!!"));
                  SetLocalInt(oPriest, "iShowLine", 4);
                  break;
                case 4:
                  AssignCommand(oPriest, SpeakString("Now DIE ye mortal scum! DIE for Mictlantecuhtli!!"));
                  SetLocalInt(oPriest, "iShowLine", 5);
                  break;
                case 5:
                  AssignCommand(oPriest, ActionCastSpellAtObject(SPELL_FLAME_ARROW, oVictim1, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
                  AdjustAlignment(oPC, ALIGNMENT_EVIL, 5);
                  SetLocalInt(oPriest, "iShowLine", 6);
                  break;
                case 6:
                  AssignCommand(oPriest, SpeakString("YES!! Feel the power! Feel the presence of Mictlantecuhtli seeping into your souls!"));
                  SetLocalInt(oPriest, "iShowLine", 7);
                  break;
                case 7:
                  AssignCommand(oPriest, SpeakString("And now for the second of three."));
                  SetLocalInt(oPriest, "iShowLine", 8) ;
                  break;
              }
          }
      };
    return;
}



Please note the last case should still set the NPC's local variable up, or the last line will continually repeat.

Members, please feel free to send me a message through the boards' "My Messages" system.

Hopefully, a multi-NPC conversation script is coming soon as I have a place for that too.


DragonTayl.

⌂ All Scripts ← PreviousNext → 👁 Category List

All Npcs Scripts

📄 ambient_animations 📄 barmaid 📄 barmaid002 📄 barmaid003 📄 barmaid003a 📄 barmaid004 📄 bitch_slap 📄 blacksmith 📄 blacksmith_001 📄 blacksmith_002 📄 blacksmith_003 📄 bounty_hunter 📄 check 📄 check_pc_item 📄 check_pc_item_002 📄 cheer_pcs 📄 cook 📄 daily_activity 📄 day_merchant 📄 determine_armed 📄 drunk 📄 equip_dequip 📄 equip_dequip_002 📄 escort 📄 flee 📄 flee_001 📄 force_pc_sit 📄 gate_guard 📄 get_nearest 📄 guard_dog_002 📄 guard_patrol 📄 healer 📄 impersonation 📄 item_guardian 📄 item_guardian_002 📄 jail_cell 📄 janitor 📄 janitor_002 📄 living_statues 📄 misc_activity 📄 monolouge 📄 multi_converse 📄 night_watch 📄 npc_brawls 📄 npc_pick_pocket 📄 npc_speak_onperception 📄 npc_start_conv 📄 npc_start_conv_002 📄 npc_start_conv_003 📄 npc_start_conv_004 📄 npc_start_conv_005 📄 open_door 📄 polymorph 📄 prostitute 📄 protect_items 📄 protect_items_002 📄 random_speak 📄 random_speak_002 📄 random_speak_003 📄 random_speak_004 📄 random_speak_005 📄 random_walk2 📄 reinforcements 📄 reinforcements_002 📄 remember_conv 📄 rowdy 📄 sheath_weapons 📄 sit_and_talk 📄 sit_and_talk_002 📄 sit_in_nearest_chair 📄 smart_npc 📄 smart_sitting 📄 streetfight 📄 tag 📄 tag_001a 📄 teleport_away 📄 teleport_away_002 📄 teleport_away_003 📄 town_crier 📄 trivia_bot 📄 walk_after 📄 woodcutter 📄 worker 📄 worker_002 📄 workstation 📄 wrestling_game