Author Sticky: Post Working Scripts Here
Viikto Posted: Friday, 21 June 07:04PM
Script: Trigger alternative node of conversation with NPC with generic triggers/events

Use with: NPCs . Trigger basics


I figured a neat trick out. Say you want your NPC to have two different possible conversations with the PCs: 1) a general, unrevealing conversation prior to the PCs discovering something vital to the plot;
2) a revealing and helpful conversation AFTER the PCs have discovered something vital to the plot.

EXAMPLE

Lets say that seeing the King's fresh corpse will trigger a new conversation with the gaurds in your module.

1) Using the trigger paint tool, lay down a "generic" trigger at a location where the PC will cross it in order to see the King's dead corpse.

2) Edit the script for trigger via OnEnter script editor;

3) CODE THE FOLLOWING

NWScript:
void main()

{

    object oPC= GetEnteringObject( );

    if (GetIsPC(oPC))

    SetLocalInt(GetEnteringObject(), "Isawdeadking", 1);

}



4) Now go to the conversation editor of your NPC gaurds and on the alternative node from the conversation dialogue tree, edit the following in the TextAppearsWhen.... script (you can manually script or use the wizard)

NWScript:
int StartingConditional()

{

if(!(GetLocalInt(GetPCSpeaker(), "Isawdeadking") == 1))

		return FALSE;

	return TRUE;

}



VOILA! Your new secretly triggered alternative conversational node will work as intended. After not having touched C for over 8 years, I'm pretty proud of my little discovery.