generated from Jaysyn/ModuleTemplate
133 lines
4.8 KiB
Plaintext
133 lines
4.8 KiB
Plaintext
// Travel Builder
|
|
|
|
// Example of a user-defined script for the OnTransitionRequest pseudo-event
|
|
|
|
// This event occurs in either of the following situations :
|
|
// (1) A creature clicks on a door or area transition trigger.
|
|
// (2) A creature is about to take a Travel Builder shortcut.
|
|
|
|
// Case 1 is only supported if you are using the custom version of
|
|
// nw_g0_transition supplied with Travel Builder.
|
|
|
|
// The caller is the creature that triggered the event.
|
|
|
|
// Local variables on the caller on entry are
|
|
//
|
|
// bhTargetObject object The door or waypoint the creature wishes to jump to.
|
|
// bhShortcutRequest int TRUE if event is a Travel Builder shortcut request.
|
|
// bhPC object The PC requesting the Travel Builder shortcut.
|
|
|
|
// Local variables you can set on the caller in this script are
|
|
//
|
|
// bhTargetObject object Set to OBJECT_INVALID to stop the transition.
|
|
// For doors and triggers only, you can also
|
|
// change so that the transition is to a different
|
|
// location (see comment below on shortcuts).
|
|
// bhJumpAssociates int TRUE if associates should jump to the PC.
|
|
|
|
// Resetting bhTargetObject will not work for a Travel Builder shortcut.
|
|
// The procedure here is to stop the current transition, and request
|
|
// a new one using bhtJumpToTravelNode. Be careful - that will trigger this
|
|
// exit again, by definition, so you may need to take steps to prevent a loop.
|
|
|
|
// Author : Proleric
|
|
|
|
// Modified : 31-Mar-2007
|
|
|
|
void main()
|
|
{
|
|
object oCreature = OBJECT_SELF;
|
|
object oPC = OBJECT_INVALID;
|
|
object oTarget = GetLocalObject(oCreature, "bhTargetObject");
|
|
int bStopTransition = FALSE;
|
|
|
|
// Uncomment these lines if you need this information :
|
|
string sTarget = GetTag(oTarget);
|
|
string sCurrentArea = GetTag(GetArea(oCreature));
|
|
string sTargetArea = GetTag(GetArea(oTarget));
|
|
|
|
if (GetLocalInt(oCreature, "bhShortcutRequest"))
|
|
oPC = GetLocalObject(oCreature, "bhPC"); // Note oPC is undefined for a normal transition
|
|
|
|
// #### Insert module-specific code here
|
|
|
|
// In this example, we manage access to and from the ship's cabin.
|
|
|
|
// On attempted entry to the Cabin,
|
|
// - If the Captain is here, remember where we were, then allow transition to
|
|
// continue.
|
|
// - Otherwise, this is a "different" ship, so stop entry to the cabin.
|
|
|
|
if (GetTag(GetArea(oTarget)) == "Cabin")
|
|
if (GetArea(oCreature) == GetArea(GetObjectByTag("CaptainKirk")))
|
|
SetLocalLocation(oCreature, "CabinExit", GetLocation(oCreature));
|
|
else
|
|
{
|
|
FloatingTextStringOnCreature("Wait - this isn't my ship!", oCreature);
|
|
bStopTransition = TRUE;
|
|
}
|
|
|
|
// On exit from the cabin, jump to correct area and stop the original
|
|
// transition (unless this is a shortcut, in which case Travel Builder
|
|
// already knows where the PC can go).
|
|
|
|
if (GetTag(GetArea(oCreature)) == "Cabin")
|
|
if (!GetLocalInt(oCreature, "bhShortcutRequest"))
|
|
{
|
|
AssignCommand(oCreature, ActionJumpToLocation(GetLocalLocation(oCreature, "CabinExit")));
|
|
bStopTransition = TRUE;
|
|
}
|
|
|
|
// We could achieve the same thing by resetting the transition location. This
|
|
// is potentially safer, because the transition is then subject to the
|
|
// standard Bioware code. The example above works for a cabin, because
|
|
// we know horses aren't allowed there, but that won't always be true.
|
|
// The example below would work for doors (but not triggers) :
|
|
/*
|
|
if (GetTag(GetArea(oTarget)) == "Cabin")
|
|
if (GetArea(oCreature) == GetArea(GetObjectByTag("CaptainKirk")))
|
|
SetLocalObject(oCreature, "CabinExit", GetNearestObject(OBJECT_TYPE_DOOR, oCreature)); // Store door not location
|
|
else
|
|
{
|
|
FloatingTextStringOnCreature("Wait - this isn't my ship!", oCreature);
|
|
bStopTransition = TRUE;
|
|
}
|
|
|
|
if (GetTag(GetArea(oCreature)) == "Cabin")
|
|
if (!GetLocalInt(oCreature, "bhShortcutRequest"))
|
|
{
|
|
SetLocalObject(oCreature, "bhTargetObject", GetLocalObject(oCreature, "CabinExit")); // Reset target object and continue
|
|
}
|
|
*/
|
|
|
|
// #### bhtGetTravelRoute example
|
|
/*
|
|
int nArea = 1;
|
|
object oArea;
|
|
|
|
if (GetLocalInt(oCreature, "bhShortcutRequest"))
|
|
{
|
|
oArea = bhtGetTravelRoute(oCreature, nArea);
|
|
|
|
while (GetIsObjectValid(oArea))
|
|
{
|
|
SendMessageToPC(oCreature, GetName(oArea));
|
|
oArea = bhtGetTravelRoute(oCreature, ++nArea);
|
|
}
|
|
}
|
|
// #### End module-specific code
|
|
*/
|
|
if (bStopTransition)
|
|
{
|
|
SetLocalObject(oCreature, "bhTargetObject", OBJECT_INVALID);
|
|
return;
|
|
}
|
|
|
|
// Request that associates jump to creature's new location if it's in the same area.
|
|
// I'm not sure why nw_g0_transition doesn't do this by default.
|
|
|
|
SetLocalInt(oCreature, "bhJumpAssociates", TRUE);
|
|
|
|
}
|
|
|