To install simply import the .erf. From there all you have to do is to place the Waypoint titled Portal Drop - Starkhaven in the location of your choice (Make certain it's a valid location first and as to where you can find the WP it's in under Items: Custum: Special - Custom 5). Once this is done all you have to do is to edit the modules events; OnActivate, OnAcquire and OnUnAcquire, I have included these for your use under the titles of ns_on(etc.). After you have done this you can then add the two example items into the module as drops, special acquires or sell them in shops. (You can find the two items under the tabs; Item: Custom: Special - Custom 5 (The names start with Scroll: [Party or Player] Town Portal)).
Modification of this script is fairly simple, to make more locations and scrolls all you have to do is make copies of the items and scripts (Make certain the item and script names are both unique and that they match) as well as make a copy of the waypoint with it's own unique tag and resref, open the scripts and add your new location tag to the target location for the teleportation script and viola you have your own location based teleportation scrolls.
It is a rather well made point, however like I've said before I'm not a scripter I just like sharing some of the things I've made and found useful in my own modules. If it helps someone else in the process then I'm more than happy to have helped them. _________________________ "Eloquence dear freind, Eloquence in simplicity."
-Arken Deadroth
Correction to my earlier comments. Do not replace *all* underscores with spaces. Instead, replace all groups of four (or eight) underscores with spaces. (The underscores in the symbolic constants are supposed to be there. It's the underscores at the beginning of each line that need to be converted to spaces.)
Come to think of it, you could make this more generic so that a new script does not need to be made for each "town" you can portal to. Tags are 32 characters long, while script names are only 16. You could set it up so that both the script and the destination are encoded in the scroll item's tag. (You could also use a local variable for the destination, but that would be lost if the item was in infinite supply in a store.) Add in support for standard tag-based scripting, and you would only need one script. Give that script a 16-character name (not shorter), and give the destination waypoint a tag of 16 or fewer characters. Then create the portal scroll with the ability to cast "unique power self-only" and with a tag consisting of the script name followed by the destination waypoint's tag. For example, if the script is called "ns_portalscroll_" and the destination waypoint's tag is "stp_link_strk", then the item's tag would be "ns_portalscroll_stp_link_strk".
The script needed would be a bit beyond what the script generator can produce (otherwise I would give you a chance to work on it before posting the script in the comments). It would look something like the following. (Replace all underscores with spaces. I'm using them so that the Vault does not clobber the indents.)
____// Spells might continue to their spell scripts. All other events are
____// completely handled by this script.
____if ( nEvent != X2_ITEM_EVENT_SPELLCAST_AT )
________SetExecutedScriptReturnValue();
____// We are only interested in activation.
____if ( nEvent != X2_ITEM_EVENT_ACTIVATE )
________return;
____// Get information about this activation.
____object oActivator = GetItemActivator();
____object oItem = GetItemActivated();
____// Have the PC "read" the scroll.
____AssignCommand(oActivator, ClearAllActions());
____AssignCommand(oActivator, ActionPlayAnimation(ANIMATION_FIREFORGET_READ));
____// Determine where to jump to.
____string sTargetTag = GetSubString(GetTag(oItem), 16, 16);
____object oTarget = GetWaypointByTag(sTargetTag);
____AssignCommand(oActivator, ActionWait(0.5)); // Adjust this wait if the timing of the jump seems off.
____AssignCommand(oActivator, ActionJumpToObject(oTarget));
}
With this script, each new destination would still need a new item and a new waypoint, but not a new script.
Lilac Soul's NWN Script Generator is effective, but it produces rather ugly and inefficient scripts. Here is scrl_twnp_strk cleaned up with the standard tag-based check added to it: (Replace all underscores with spaces. I'm using them so that the Vault does not clobber the indents.)
#include "x2_inc_switches"
void main()
{
____// We are only interested in activation.
____if ( GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE )
________return;
Slight Typo, the WP is actually located in the Waypoints tab and not the item tab... Heh whoops. _________________________ "Eloquence dear freind, Eloquence in simplicity."
-Arken Deadroth
You must be Logged In to post comments in this section.