//////////////////////////This is the trigger's OnEnter Event\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#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));
DestroyObject(OBJECT_SELF,0.1);
}
}
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);
DestroyObject(OBJECT_SELF,0.1);
}
}
else
{
}
}
//////////////////////////This is the script that sends the NPC to the next waypoint\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#include "al_inc_rep"
void main()
{
int iTrig = GetLocalInt(OBJECT_SELF,"WP_"+GetTag(OBJECT_SELF));
if(iTrig < 1)
{
object oWP = GetNearestObjectByTag("WP1_"+GetTag(OBJECT_SELF));
AssignCommand(OBJECT_SELF,ActionMoveToObject(oWP,TRUE));
IncreaseLocalInt(OBJECT_SELF,"WP_"+GetTag(OBJECT_SELF));
}
else if(iTrig == 1)
{
object oWP = GetNearestObjectByTag("WP2_"+GetTag(OBJECT_SELF));
AssignCommand(OBJECT_SELF,ActionMoveToObject(oWP,TRUE));
IncreaseLocalInt(OBJECT_SELF,"WP_"+GetTag(OBJECT_SELF));
}
else if(iTrig == 2)
{
object oWP = GetNearestObjectByTag("WP3_"+GetTag(OBJECT_SELF));
AssignCommand(OBJECT_SELF,ActionMoveToObject(oWP,TRUE));
IncreaseLocalInt(OBJECT_SELF,"WP_"+GetTag(OBJECT_SELF));
}
else if(iTrig == 3)
{
object oWP = GetNearestObjectByTag("WP4_"+GetTag(OBJECT_SELF));
AssignCommand(OBJECT_SELF,ActionMoveToObject(oWP,TRUE));
IncreaseLocalInt(OBJECT_SELF,"WP_"+GetTag(OBJECT_SELF));
}
else
{
}
}