All right, I haven't tried this yet, but this is what I came up with:
Code:
void main()
{
//Roll the encounter die.
int nEncounter = d3();
object oPC = GetEnteringObject();
//Set the random encounter area.
object oEncounter = GetWaypointByTag("WP_EncounterFromWesternRegion");
//Set the target destination.
object oTarget = GetWaypointByTag("WP_CrossroadsFromWesternRegion");
//Encounter state variables are assigned to the party leader.
object oLeader = GetFirstPC();
//If an encounter is already active, the exit will automatically transport players to the encounter area until it is resolved.
if (GetLocalInt( oLeader, "nEncounterActive") == 1)
{
AssignCommand( oPC, JumpToObject( oEncounter));
}
//If a negative encounter check was already made today, the script will not make another check until tomorrow.
else if (GetLocalInt( oLeader, "nEncounterInactive") == GetCalendarDay())
{
AssignCommand( oPC, JumpToObject( oTarget));
}
//If neither encounter state variable checks out, the script makes a new encounter check.
else if (nEncounter < 3)
{
AssignCommand( oPC, JumpToObject( oTarget));
SetLocalInt( oLeader, "nEncounterInactive", GetCalendarDay());
}
else
{
AssignCommand( oPC, JumpToObject( oEncounter));
SetLocalInt( oLeader, "nEncounterActive", 1);
}
}