1. immigration_main
2. This is a very usefull script for semi-persistant worlds. When
implimented, it keeps track of the areas the player has last been in. If
the player logs off the server and back on, or if the player goes to
another erver running the same module with this script implimented, the
player character will jump to the last area he/she was at. Actually, it
does not have to go to the last area...the Builder reduce scripting work
by selecting only certain areas to impliment. The best way to describe
the usage is to compare it to Diablo 2; when a player logs on, they will
appear at the last town of the Act that they last played.
This script allows that functionality accross different servers and can
be used cooperatively between Builders.
Note...its my first time scripting and programming. I'm sure people out
there can make this better. This is already updated from an earlier post
making the script a little more efficient.
3. Basically this script checks a token passport item in the characters
inventory and jumps the player to a corresponding waypoint. If there was
no passport item, the script creates one.
In order to impliment, you need several components. First, for every
area that can be a "save area", you need to create a "passport" item. In
this script, the passports are "oOutTown", "oStagingArea", "oWestDock",
etc. If the player discards this passport, they are SOL.
I created these three areas. StagingArea is a 1X1 room. This script "immigration_main"
is attached to the "OnEnter" of Staging Area.
The other areas need to have waypoints. In this script, the waypoints
are "MULTI_OutTown", "MULTI_WestDock". Those areas run corresponding "imm_"
scripts on enter.
ONE VERY IMPORTANT ITEM is the TOTALAREAS constant. I don't know how to
automate the counting of the number of save areas. Each time a save area
is added to the module, you need to add to the TOTALAREAS constant in
this script and in each of the imm_scripts.
fendis_khan and others helped me make this. Thanks to all the friendly
NWN community people who helped me learn how to script.
There are a bunch of testing messages in here that you will need to
delete later.
NWScript:
void main()
{
int TOTALAREAS=4;
string lastarea;
object oPC= GetEnteringObject();
SendMessageToPC (oPC, "Immigration script is running!");
int haspass=0;
int nSteps;
for (nSteps=0; nSteps <= TOTALAREAS; nSteps++)
{
if (haspass==1 ) break;
switch (nSteps)
{
case 0:
lastarea= "oStagingArea";
if ( GetItemPossessedBy ( oPC,lastarea)!= OBJECT_INVALID)
{
SendMessageToPC ( oPC,"You seem to have received the Staging Area Passport");
AssignCommand ( oPC, ActionJumpToObject (
GetWaypointByTag ( "MULTI_OutTown" ),0 ));
haspass=1;
SetLocalString ( oPC,"MULTI_Area", "StagingArea" );
}
break;
case 1:
lastarea= "oOutTown";
if (GetItemPossessedBy ( oPC,lastarea )!= OBJECT_INVALID)
{
SendMessageToPC ( oPC,"You seem to have received the Out Town Passport");
AssignCommand ( oPC, ActionJumpToObject (
GetWaypointByTag ( "MULTI_OutTown" ),0 ));
haspass=1;
SetLocalString ( oPC,"MULTI_Area", "OutTown");
}
break;
case 2:
lastarea= "oWestDock";
if (GetItemPossessedBy (oPC,lastarea)!= OBJECT_INVALID)
{
SendMessageToPC(oPC,"You seem to have received the West Dock Passport");
AssignCommand ( oPC, ActionJumpToObject(
GetWaypointByTag ( "MULTI_WestDock" ),0 ));
haspass=1;
SetLocalString ( oPC, "MULTI_Area", "WestDock");
}
break;
case 3:
lastarea= "oFloatingDistrict";
if (GetItemPossessedBy (oPC,lastarea)!= OBJECT_INVALID)
{
SendMessageToPC (oPC, "You seem to have received the Floating District Passport");
AssignCommand ( oPC, ActionJumpToObject (
GetWaypointByTag ( "MULTI_FloatingDistrict" ),0 ));
haspass=1;
SetLocalString (oPC, "MULTI_Area", "FloatingDistrict" );
}
break;
case 4:
lastarea = "oUnderTheCity1";
if (GetItemPossessedBy (oPC,lastarea)!= OBJECT_INVALID)
{
SendMessageToPC (oPC, "You seem to have received the Sewers Passport");
AssignCommand ( oPC, ActionJumpToObject(
GetWaypointByTag ( "MULTI_UnderTheCity1" ) ,0 ));
haspass=1;
SetLocalString ( oPC, "MULTI_Area", "UnderTheCity1");
}
break;
}
}
if (haspass==0)
{
CreateItemOnObject ( "passport001", oPC,1 );
SendMessageToPC (oPC, "You should have received the Staging Area Passport" );
SetLocalString ( oPC, "MULTI_Area", "StagingArea");
AssignCommand( oPC, ActionJumpToObject(
GetWaypointByTag ( "MULTI_OutTown" ),0 ));
}
}
Also, each save area should have "immigration_area" on their OnEnter
script. This destroys the last passport and sets a new passport object.
This script needs to be updated as new save-areas are added
NWScript:
void main()
{
int TOTALAREAS= 4;
string lastarea;
object oPC= GetEnteringObject ();
SendMessageToPC (oPC, "West Dock script is running!" );
int nSteps;
object currentpassport;
if (GetLocalString ( oPC, "MULTI_Area" ) != GetTag(OBJECT_SELF))
{
for (nSteps=0; nSteps <= TOTALAREAS; nSteps++)
{
switch (nSteps)
{
case 0:
lastarea= "oStagingArea";
if (GetItemPossessedBy ( oPC,lastarea) != OBJECT_INVALID)
{
currentpassport = GetItemPossessedBy (oPC,lastarea);
DestroyObject ( currentpassport,0.0) ;
}
break;
case 1:
lastarea= "oOutTown";
if (GetItemPossessedBy (oPC,lastarea)!= OBJECT_INVALID)
{
currentpassport = GetItemPossessedBy ( oPC,lastarea);
DestroyObject (currentpassport,0.0);
}
break;
case 2:
lastarea= "oWestDocks";
if (GetItemPossessedBy (oPC,lastarea ) != OBJECT_INVALID)
{
currentpassport = GetItemPossessedBy (oPC,lastarea);
DestroyObject ( currentpassport,0.0 );
}
break;
case 3:
lastarea= "oFloatingDistrict";
if (GetItemPossessedBy (oPC,lastarea)!= OBJECT_INVALID)
{
currentpassport= GetItemPossessedBy (oPC,lastarea);
DestroyObject (currentpassport,0.0);
}
break;
case 4:
lastarea= "UnderTheCity1";
if (GetItemPossessedBy (oPC,lastarea)!= OBJECT_INVALID)
{
currentpassport = GetItemPossessedBy (oPC,lastarea);
DestroyObject (currentpassport,0.0);
}
break;
}
}
if (GetTag (OBJECT_SELF) == "OutTown") CreateItemOnObject ("passport002", oPC,1);
if (GetTag (OBJECT_SELF) == "UnderTheCity1") CreateItemOnObject ("passport004" ,oPC,1);
if (GetTag (OBJECT_SELF) == "WestDocks") CreateItemOnObject ("passport003", oPC,1);
if (GetTag (OBJECT_SELF) == "FloatingDistrict") CreateItemOnObject ( "passport005", oPC,1);
SetLocalString (oPC, "MULTI_Area", GetTag(OBJECT_SELF));
}
}
|