I was asked to post this script that is
somewhat of a compliation of several other scripts that are posted and then
tweaked a little bit by me:
1. Script Name: Player Intro to Mod
2. What it does: Designates an NPC to initiate dialog with a PC upon
perception explaining whatever rules or information you feel is important to
relay to the player before they start your mod. I use this NPC to tell
players of the respawn penalty and to encourage them to use team tactics to
defeat some of the spawns...
3. Notes: Create an NPC of course.. Also create whatever dialog you are
wanting to share with each client that comes to your mod. These scripts will
be placed in the onPerceived script holder of the NPC and in the "Actions
Taken" tab of the dialog.
4. The Script itself:
This to be placed in the onPerceived portion of you NPC's script holders:
NWScript: void main()
{
string sTag = "Lorio";
object oNPC = GetObjectByTag("Lorio");
object oPC = GetLastPerceived();
if(GetIsPC(oPC) &&
GetLocalInt( oPC,"SR_Init" + GetTag(oNPC)) == FALSE &&
IsInConversation(oNPC) == FALSE)
{
AssignCommand(oPC, ClearAllActions());
AssignCommand(oNPC, ClearAllActions());
AssignCommand(oNPC, ActionStartConversation(oPC));
}
}
Remember to replace the name Lorio with the tag of whatever your NPC is.
The next script makes sure that your NPC doesn't tell you the same
information twice.. (you can get the information twice by having the PC
initiate the conversation but this script makes it so the NPC only initiates
the conversation once). This script is vital if you don't want to have your
NPC following you around the mod initiating the same dialog with you over
and over.
on the FIRST node of your NPC's dialog (the very first thing he says to you)
place in the actions taken tab a script that says:
NWScript: void main()
{
SetLocalInt( GetPCSpeaker(), "SR_InitLorio", TRUE);
}
What the scripts do: On perceiving a player, the NPC does a couple checks
with this line of code:
if(GetIsPC(oPC) &&
GetLocalInt( oPC,"SR_Init" + GetTag(oNPC)) == FALSE &&
IsInConversation(oNPC) == FALSE)
{
This says, if what the NPC is a player and the tag that is created "SR_InitLorio"
equals false and is that NPC is not already involved in a conversation then
go spill your guts to him.
The other script in the "Actions Taken" portion of the dialog sets "SR_InitLorio"
to true so that the next time the NPC perceives the PC he doesn't go up to
him and say what he already told him because the second condition of the if
statment is not met. (That being that SR_InitLorio is not equal to false
anymore)
Tips to improve: It was proposed to me by David Gaider who helped me out
with this, that you make a trigger area around this NPC that will clear his
actions and return him to his post so that he can never get too far from his
post. I have yet to implement this but I think it is a good idea. Feel free
to send me personal messages about getting this script to work or what
certain element of the script mean.
|