SmartDoor
smart door.nss
return.nss
oexit_smart door.nss
By Zandramus
SmartDoor system is complete , this works for multiple doors leading to one
room. it will lock the entry of a different door from a pc trying to enter
from somewhere else. Ie two pc's cannot enter the same room from 2 different
doors. However everyone can enter the area from the same door.
Basically it allows you to have generic area's that many doors link to
instead of having to have 1 area for each door. simply name the area's and
doors correctly and it works like a charm
if the area is empty it can again be entered from any door assigned to it.
if it is occupied the pc attempting to enter from a different door gets the
message an unknown force keeps you from entering.
it is simple and works very well.
it consists of 3 scripts
smartdoor.nss the main script
return.nss the script that returns the pc to where they left from
oexit_smartdoor.nss the script that checks if the area is now empty and
disassociates the last door from it.
NWScript:
void main()
{
object oidUser;
object oidDest;
string sTag = GetTag(OBJECT_SELF);
string sDest;
location dLocation;
SetLocalString(OBJECT_SELF, "Destination" , "DST_"+sTag );
sDest = GetLocalString( OBJECT_SELF, "Destination" );
oidUser = GetLastUsedBy();
SetLocalLocation(oidUser,"IWASHERE",GetLocation(oidUser));
oidDest = GetWaypointByTag(sDest);
dLocation = GetLocation(OBJECT_SELF);
if (GetLocalInt(GetModule(),sDest) == 0)
{
SetLocalLocation(GetModule(),sTag,dLocation);
SetLocalInt(GetModule(),sDest, 1);
AssignCommand(oidUser,JumpToObject(oidDest,FALSE));
}
else
{
if (GetLocalLocation(GetModule(),sTag)== dLocation)
{
AssignCommand(oidUser,JumpToObject(oidDest,FALSE));
}
else
{
SendMessageToPC(oidUser,"An Unknown Force Prevents you from entering");
}
}
}
NWScript:
void main()
{
object oidUser;
object oidDest;
string sDest;
oidUser = GetLastUsedBy();
AssignCommand(oidUser,JumpToLocation(GetLocalLocation(oidUser,"IWASHERE")));
}
NWScript:
void main()
{
string sTag = GetTag(OBJECT_SELF);
string sDest;
SetLocalString(OBJECT_SELF, "Destination" , "DST_"+sTag );
sDest = GetLocalString( OBJECT_SELF, "Destination" );
if(GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC,OBJECT_SELF,1) == OBJECT_INVALID)
{
SetLocalInt(GetModule(),sDest, 0);
}
}
you can download the erf of the 3 scripts here
http://mynwnserver.kicks-ass.net
enjoy
Zandramus
|