MODS: This is an update to the post on page 28
for the same scripts, that post can be deleted, as all the information is
contained here.
Script Name: randominterior and exitrandomtp
What it does: This pair of scripts takes players to randomly selected
interiors when using doors and returns them back to their original location
when they leave the interior space.
Description
UPDATED TO VERSION 1.5
Here is a little script I put together to use for big cities where every
building has some random filler content that isn't plot or important, but is
filled in with possible encounters.
Here is what you need to do:
1) Make 1-20 interior areas generically, and fill with items, encounters,
etc.
2) Place a waypoint in each one with the TAG WP_RandomX where X = 1 to 20
(actually the tag is not name specific, but you'll need to specify the right
tag in the script.)
3) On the door out, attach the exitrandomtp script to the
OnAreaTransitionClick or OnOpen event.
4) Now for each door in the outer area you create, attach the randominterior
script to the OnAreaTransitionClick or OnOpen event.
This should take the party to a randomly selected interior let them fight,
loot, etc, then take them back to the starting point when they use the door
to get out. Once they leave the treasure will delay then respawn, encounters
in the interiors will respawn at intervals set on the encounter.
Notes:
New in 1.5:
Now henchmen, familiars, summoned, etc will come with you into the rooms.
Treasure respawning code added to repopulate placeables that can contain
loot.
Future Improvements Pending:
Set random chance to lock chest on treasure respawn.
Use random doors unless character has a city map, then all doors stay static
once visited.
Currently not tested or written for multiparty modules or persistent worlds.
The variables used will have to be adjusted or this could result in parties
teleporting to each others locations.
I suggest setting the encounter respawns to a minimum of 5 minutes and
maximum of 7 minutes, depending on how close together the doors are. This is
subject to your own testing based on the size of the areas you build for the
interiors.
The treasure respawn is set to 45 seconds after exiting, but this is
adjustable to your needs.
Some side effects of this are present, not sure I know how to avoid them at
this point. First, the same door may take you to different interiors when
revisting the door. Also if the party splits up and clicks multiple doors,
they will end up in the same place. Not good for Hard Core RP Rules or
"reality" in the game.
Module Level variables used:
iPartyCount - Used to track how many go in so you can get them all
back out and reset at teh end.
iRandomTPActive - Flag for determining if a current random Teleport
is going on so all party members can be sent to same location.
User Level Variables:
lRandomTPLoc - THe loc a user teleported from so they can be returned
to that location later.
The Scripts:
NWScript:
string sWaypoint1 = "WP_Random1";
string sWaypoint2 = "WP_Random2";
string sWaypoint3 = "WP_Random3";
string sWaypoint4 = "WP_Random4";
string sWaypoint5 = "WP_Random5";
string sWaypoint6 = "WP_Random6";
object oUser = GetClickingObject();
object oTarget;
int iRolledNum;
int iTempCount;
void main()
{
if (GetLocalInt(GetModule(), "iRandomTPActive") == 0)
{
iRolledNum = d6(1);
}
else
{
iRolledNum = GetLocalInt(GetModule(), "iRandomTPActive");
}
if(iRolledNum != 0)
{
switch(iRolledNum)
{
case 1:
oTarget = GetWaypointByTag(sWaypoint1);
break;
case 2:
oTarget = GetWaypointByTag(sWaypoint2);
break;
case 3:
oTarget = GetWaypointByTag(sWaypoint3);
break;
case 4:
oTarget = GetWaypointByTag(sWaypoint4);
break;
case 5:
oTarget = GetWaypointByTag(sWaypoint5);
break;
case 6:
oTarget = GetWaypointByTag(sWaypoint6);
break;
}
}
else
{
iRolledNum = 1;
oTarget = GetWaypointByTag(sWaypoint1);
}
if (GetLocalInt(GetModule(), "iRandomTPActive") == 0)
{
SetLocalInt(GetModule(), "iRandomTPActive", iRolledNum);
}
iTempCount = GetLocalInt(GetModule(), "iPartyCount");
iTempCount++;
SetLocalInt(GetModule(), "iPartyCount", iTempCount);
SetLocalLocation(oUser, "lRandomTPLoc", GetLocation(oUser));
AssignCommand(oUser, JumpToObject(oTarget));
AssignCommand(GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION,oUser),JumpToObject(oTarget));
AssignCommand(GetAssociate(ASSOCIATE_TYPE_DOMINATED,oUser),JumpToObject(oTarget));
AssignCommand(GetAssociate(ASSOCIATE_TYPE_FAMILIAR,oUser),JumpToObject(oTarget));
AssignCommand(GetAssociate(ASSOCIATE_TYPE_HENCHMAN,oUser),JumpToObject(oTarget));
AssignCommand(GetAssociate(ASSOCIATE_TYPE_SUMMONED,oUser),JumpToObject(oTarget));
}
NWScript:
#include "NW_O2_CONINCLUDE"
int iRandomFlag;
int iTempCount;
int iRandNum;
location lTargetLoc;
object oUser;
object oContainer;
object oArea;
float fDelay;
void main()
{
oUser = GetClickingObject();
oArea = GetArea(OBJECT_SELF);
iRandomFlag = GetLocalInt(GetModule(), "iRandomTPActive");
iTempCount = GetLocalInt(GetModule(), "iPartyCount");
lTargetLoc = GetLocalLocation(oUser, "lRandomTPLoc");
if(iTempCount >= 1)
{
iTempCount--;
}
else
{
iTempCount = 0;
}
if(iTempCount == 0)
{
SetLocalInt(GetModule(), "iRandomTPActive", 0);
oContainer = GetFirstObjectInArea(oArea);
while (oContainer != OBJECT_INVALID)
{
if (GetObjectType(oContainer) == OBJECT_TYPE_PLACEABLE)
{
fDelay = 45.0;
iRandNum = d6(1);
switch(iRandNum)
{
case 1:
case 2:
case 3:
DelayCommand(fDelay, GenerateLowTreasure(oUser, oContainer));
break;
case 4:
case 5:
DelayCommand(fDelay, GenerateMediumTreasure(oUser, oContainer));
break;
case 6:
DelayCommand(fDelay, GenerateHighTreasure(oUser, oContainer));
break;
}
}
oContainer = GetNextObjectInArea(oArea);
}
}
SetLocalInt(GetModule(), "iPartyCount", iTempCount);
AssignCommand(oUser, JumpToLocation(lTargetLoc));
AssignCommand(GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION, oUser), JumpToLocation(lTargetLoc));
AssignCommand(GetAssociate(ASSOCIATE_TYPE_DOMINATED, oUser), JumpToLocation(lTargetLoc));
AssignCommand(GetAssociate(ASSOCIATE_TYPE_FAMILIAR, oUser), JumpToLocation(lTargetLoc));
AssignCommand(GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oUser), JumpToLocation(lTargetLoc));
AssignCommand(GetAssociate(ASSOCIATE_TYPE_SUMMONED, oUser), JumpToLocation(lTargetLoc));
}
[ Edited By jordinn: Monday, 22 July 09:21AM (GMT) ]
|