Code: Select all
// Local area transition script.
// Created by Somnium in 2015 for the Alangara server.
// This area-transition script teleports both the entering PC and any
// followers he might have, to a destination waypoint.
// Usage:
// 1) Put this script on an area transition trigger (onEnter event).
// 2) Place a local string named TELEPORT_TARGET on the trigger, with
// a value corresponding to the tag of the target waypoint.
//// - Repeatedly attempts to jump to lTarget until successful
void FailsafeJump(object oJumper, location lTarget);
void main()
{
object oPC = GetEnteringObject();
if (GetIsObjectValid(oPC) && GetIsPC(oPC))
{
string targetName = GetLocalString(OBJECT_SELF, "TELEPORT_TARGET");
if (targetName != "")
{
object target = GetWaypointByTag(targetName);
location targetLocation = GetLocation(target);
if (GetIsObjectValid(target))
{
FailsafeJump(oPC, targetLocation);
object factionMember = GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(factionMember))
{
if (!GetIsPC(factionMember) && GetMaster(factionMember) == oPC)
{
FailsafeJump(factionMember, targetLocation);
}
factionMember = GetNextFactionMember(oPC, FALSE);
}
}
}
}
}
//// - Repeatedly attempts to jump to lTarget until successful
void FailsafeJump(object oJumper, location lTarget)
{
float fDist = GetDistanceBetweenLocations(GetLocation(oJumper), lTarget);
if (fDist > 1.5 || fDist < 0.0)
{
AssignCommand(oJumper, ClearAllActions());
DelayCommand(0.05, AssignCommand(oJumper, ActionJumpToLocation(lTarget)));
DelayCommand(0.1, FailsafeJump(oJumper, lTarget));
}
}