View Single Post
Old 12-01-2002, 03:22 PM   #4
Darkman
Avatar
 

Join Date: July 11, 2001
Location: Austin, Texas
Age: 44
Posts: 525
In response to #2...

It depends on how you want the NPC to initiate the conversation. You can have the NPC start the conversation on sight, after a different conversation has ended, after a certain event has occurred, when the PC steps on a trigger, etc. Here I'll show you how to use the on sight method. Put the following code at the top of the NPC's OnPercieved script (directly after the void main(){ and before anything else). This will have the NPC initiate conversation with the PC when the NPC first sees the PC.

object oPC = GetLastPerceived();
if (GetIsPC(oPC) && GetLocalInt(oPC,"nNameofLocalVariable") != 1)
{
ActionStartConversation(oPC,"NameOfConversationFile",FALSE);
}

At the start of the conversation have a script that checks to make sure the above local variable is not 1. Put this script in the Text Appears When slot. The advantage of using variables is to allow for mistakes to occur and not hamper the module. If the script misfires for some reason and the NPC doesn't have the conversation with the PC, or if the PC quits the conversation before it has ended, then the PC can still manually start the conversation with the NPC to get the necessary information or whatever. Then the NPC will make an exit, but a nosey PC won't be able to talk to him again.

int StartingConditional()
{
if(!(GetLocalInt(GetPCSpeaker(), "nNameOfLocalVariable") != 1))
{
return FALSE;
}
return TRUE;
}

Then, at the end of the conversation (where it says END DIALOGUE), place a script that will change the above local variable to 1 and then move the NPC to a location and "destroy" him. Put this script in the Actions Taken slot. For this example, I have my NPC move to a certain door, then disappear. You could instead move your NPC to a certain Way Point at the edge of the map or whatever.

void main()
{
SetLocalInt(GetPCSpeaker(),"nNameOfLocalVariable",1);
object oDoor = GetObjectByTag("BluePrintNameOfDoor");
object oCreature = GetNearestObjectByTag("Yastyrr");
if (GetIsObjectValid(oDoor) == TRUE)
{
// Yastyrr should walk back to the door and leave
// Change the FALSE to TRUE if you want the NPC to run
// The number is the distance in meters to stand from the end location
AssignCommand(oCreature, ActionMoveToObject(oDoor, FALSE, 1.0));
// It takes Yastyrr about 27 seconds to walk to the door
// So use the DelayCommand to postpone her destruction until she reaches the door
DelayCommand(27.0,DestroyObject(oCreature));
}
}

There are more ways of doing this type of thing, like using flashy visual effects to have the NPC portal out of the room instead of walk away. If you want an example of starting the conversation on a trigger or within a certain range, then load up the Official Campaign's Prelude and look at the scripts they have for Bim at the very beginning of the game.
__________________
There more of it there is,<br />The less you see.
Darkman is offline   Reply With Quote