/*
Generic OnEnter event script for a trigger intended to cause an NPC to speak to the PC.
To use this place the this script in the desired trigger.
Make the trigger tag tr_[NPC_tag] replacing [NPC_tag] with the desired NPC's tag.
The NPC's tag should be no longer than 15 characters.
Example
Trigger: tr_hen_shae001
NPC: hen_shae001
*/
#include "al_inc_rep"
void main()
{
//Lets define variables.
//The Player's Character.
object oPC = GetPC();
//Get the trigger's tag
string sTag = GetTag(OBJECT_SELF);
//Get the length of the trigger's tag, then subtract three
int iLength = GetStringLength(sTag)-3;
//all but the first three characters of the tag
string sNPC = GetStringRight(sTag,iLength);
//The npc is the tag of the trigger, minus the first three characters
object oNPC = GetObjectByTag(sNPC);
//The variable is "Spoke_" plus all but the first three characters of the trigger's tag
int iTrig = GetLocalInt(oPC,"Spoke_"+sNPC);
if(iTrig < 1)
{
if(!GetIsPC(oPC)) return;
{
//Speak your first dialog node, that node must use the sc_spoke_snpc file
AssignCommand(oNPC,SpeakOneLinerConversation("con_"+sNPC,oPC));
//Ensure it isn't spoken again
IncreaseLocalInt(oPC,"Spoke_"+sNPC);
AssignCommand(oPC,ClearAllActions());
AssignCommand(oNPC,ClearAllActions());
//Walk to the PC
AssignCommand(oNPC,ActionMoveToObject(oPC));
//Talk
AssignCommand(oNPC,ActionStartConversation(oPC));
}
}
else if(iTrig >= 1)
{
if(!GetIsPC(oPC)) return;
{
AssignCommand(oPC,ClearAllActions());
AssignCommand(oNPC,ClearAllActions());
//Walk to the PC
AssignCommand(oNPC,ActionMoveToObject(oPC));
//Talk
AssignCommand(oNPC,ActionStartConversation(oPC));
//Add one to the variable
IncreaseLocalInt(oPC,"Spoke_"+sNPC);
}
}
else
{
}
}