NWNWiki
Advertisement
NWNWiki
3,718
pages

This ring of travel set of scripts creates a "stone of recall"-type item that allows the user to use that item to teleport to a specific location in the module. After teleporting, the user can be given the choice to teleport to the party's leader, or to return to where the item had been used. Although the nomenclature suggests a ring, these scripts can be used with any item that has the "cast spell: unique power self only" item property.

Note: This script differs from some others in that the return portal is intended to be a placeable, whereas other scripts use the exit of an area.

How to[]

To begin, make sure tag-based scripting is enabled in the module. This can be accomplished by using x2_mod_def_load in the module's OnModuleLoad event and x2_mod_def_act in the OnActivateItem event. In addition, place a waypoint where characters should appear after using the item. The below scripts assume the tag of the waypoint is ringspawnpoint; adjust this as needed.

The tag of the "ring of travel" item is the name of the following script. It does not need to be specified as an event handler.


// Tag-based script for "ring of travel".

#include "x2_inc_switches"

const string LV_RECALL     = "RING_OF_TRAVEL_LOCATION";
const string TAG_RECALL_WP = "ringspawnpoint";  // Tag of the waypoint where PCs go upon using the ring.

void main()
{
    // We care about only activation.
    if ( GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE )
        return;

    object oPC = GetItemActivator();

    // Record the user's location so we can return there later.
    SetLocalLocation(oPC, LV_RECALL, GetLocation(oPC));
    // Send the PC to the designated waypoint.
    AssignCommand (oPC, JumpToObject(GetWaypointByTag(TAG_RECALL_WP)));
    ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HOLY_AID), oPC);
}


Accessible from the destination waypoint should be a "recall portal", a placeable (or creature) with a conversation that will present three choices: go to the party leader, go to where the "ring of travel" was last used, or end the conversation without teleporting. For the party leader option, the "actions taken" script can be set to nw_all_feedbackg. For the return-to-where-the-item-was-used option, the following script may be used.


// Sends the PC speaker to where the "ring of travel" was last used.

const string LV_RECALL     = "RING_OF_TRAVEL_LOCATION";

void main()
{
    object oPC = GetPCSpeaker();
    location lTarget = GetLocalLocation(oPC, LV_RECALL);

    // Send the PC to the last place the ring was used.
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_UNSUMMON),
                          GetLocation(oPC));
    DelayCommand(0.5, AssignCommand(oPC, JumpToLocation(lTarget)));
}
Advertisement