BioWare Atari
BioWare Info BioWare Games Support Forums Visit the BioWare Store
Neverwinter Nights Home
Neverwinter Nights Home

How Do I Make My NPC's Initiate Dialogue On Their Own?

Intended Audience: For Builders
By David Gaider

[Printer Friendly / Syntax Highlight]

OK, first off: until you know EXACTLY what you are doing, do NOT alter the script that is normally in the OnPerception event ("nw_c2_default2"). Leave it alone. If anyone tells you to alter anything but the OnSpawn and OnUserDefined scripts for you NPCs and you aren't confident of doing so, tell them they're full of monkeypoo.

As mentioned earlier, here, regarding UserDefined events, the generic AI is set up to allow you to use these events without altering the default scripting.

Using the OnPerceive method of starting conversation

1) Go into your OnSpawn script. Save it under a new name. Then go down to the line where it says 'SetSpawnInCondition (NW_FLAG_PERCIEVE_EVENT);' and uncomment it (remove the '//' double slashes at the beginning of the line). Compile the new script.

2) In your NPC's dialogue file, go to the very first line where he starts his dialogue with the PC. If you only want him to start this with any given PC once, add the following script into 'Actions Taken':

NWScript:

This sets the variable that is used in the script you were using, so the dialogue isn't done more than once.

3) Now create a new script in the OnUserDefined event for your NPC. You can put that second script in here, as follows:

NWScript:

POSSIBLE DRAWBACK: Now... one reason why this may not work? If your PC starts the game visible to this NPC, there is no OnPerceive event. The event only fires if the PC was previously non-perceived and then became perceived.

Using the Trigger Method for starting a Conversation

This is the one we use in the official campaign. It allows you to control at which point the NPC will run up to the PC, and also determine how far the NPC will run after the PC before giving up.

To set this up, you need to do the following:

1) Like as in #2 above, in your NPC's dialogue file, go to the very first line where he starts his dialogue with the PC. If you only want him to start this with any given PC once, add the script from #2 above into 'Actions Taken':

NWScript:

2) Go into your toolset. Put down a waypoint at the spot where your NPC will return to. Label it "WP_RETURN_" + the tag of the NPC. (so if the tag is 'Fred', label it "WP_RETURN_Fred". Remember that all tags are case-sensitive!

3) While in the toolset, create a new generic trigger and draw a polygon around your NPC. When the PC crosses into this area, the NPC will start running toward the PC to talk. If the NPC leaves this area, he will stop chasing the PC and return to the waypoint.

4) Go to the trigger's 'Scripts' tab and include the following script under 'OnEnter':

NWScript:

5) Now you want to prevent the NPC from chasing after the PC. Enter the following under the trigger's OnExit event:

NWScript:

This method doesn't care if the PC is visible or not... crossing into the trigger will cause the NPC to initiate. If you want to make sure that the NPC sees the PC, add the following line immediately under 'if(GetIsPC(oPC) &&' in the OnEnter script:

GetObjectSeen(oPC, oNPC) &&

As well, in a multiplayer game, the NPC will attempt to talk to each and every player at least one with this method. If you only want him to run up to one PC EVER, then do the following:

1) In the dialogue script, replace 'GetPCSpeaker()' with 'OBJECT_SELF'.
2) In the OnUserDefined script (in the first method) or the OnEnter script (in the second method), replace the 'oPC' in the GetLocalInt command to 'oNPC'.

 

 

Dragon Age: Origins Video E3 2008
Neverwinter Nights 2 Forums
Hide/Show

English
Deutsch
Français
Español
Italiano

Hide/Show

View Latest Screenshots 

View Latest Screenshots
Hide/Show

Multiplayer Games at Neverwinter Connections

Today
Schedule a Game...



Current time is: (set time)
Fri, 25 July 2008 08:53AM

Hide/Show

Buy Premium Modules

Top NWN: HotU Modules:
1. The Aielund Saga Act IV The Fall of...
2. More...

Top NWN: SoU Modules:
1. The Aielund Saga Act IV The Fall of...
2. More...

Top CEP Modules:
1. The Lord of Terror The Diablo Campa...
2. More...

Top Modules - NWVault:
1. Hall of Fame
2. More...

Total Modules: 4423

Hide/Show

4,060,570 BioWare Users:
  47 Logged In
  4 Hidden
  263 Guests

860 Playing Online
  100% NWN
  97% NWN: SoU
  97% NWN: HotU

542 Registered Guilds

7,723,085 posts in forums

Newest Forum Topics:
1. Looking for a Melee PvP Build (NWN2: Persistent Worlds & Multiplayer)

2. Config tool (Jade Empire Technical Support (Self-Help))

3. NVN 1 installation problem (NWN 1: Macintosh Version - General Discussion)

4. Mini/Area Map Can Now Be Disable... (NWN2: Builders - NWN2 Toolset)

5. Bugs report (Mass Effect PC Version General Discussion (Spoilers will be moved))