DMH-Online

Dungeon Masters Helper · Est. 2005

Placeables Scripts

NWN Script: smart_doors.htm

Author Sticky: Post Working Scripts Here
zandramus Posted: Tuesday, 23 July 12:30AM
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:
//::///////////////////////////////////////////////
//:: Name Smart Door System
//:: FileName smartdoor.nss
//:://////////////////////////////////////////////
/*
    Place this script in the door in your area
    leading to a shared room.
    name this door the same name as the target
    room you are going to
    place a waypoint inside the room you are going
    to with a tag of DST_areaname
    Ie.
    if your are going to an area named Appartment
    you need to do the following
    1. create an area Named Appartment with a tag
       of Appartment.
    2. create a waypoint inside that area with
       a tag of DST_Appartment facing the way you
       want the character to enter.
    3. create a door with the Tag of Appartment
       in your area, you can have as many of these
       as you want each one will lead to the area
       Appartment. Click the door's area transition
       tab and select waypoint but leave the destination
       field blank. In the doors OnAreaTransitionClicked
       script Place this script.
    4. create an exit door in the appartment area
       it doesnt matter what the tag or name of this door
       is, but click the doors area transition tag and
       select waypoint and leave the destination field
       blank. In the doors OnAreaTransitionClicked
       script Place the return script.
    5. In the Area Appartment Place in the OnExit event
       the script oexit_smartdoor
     you should now have an area with a tag of Appartment
     a main area you are going from
     a door in the main area with a tag of Appartment
     a door in the Appartment area
     a waypoint in the Appartment area named DST_Appartment.
     both doors area transitions set to waypoint with the
     destination blank.
     all the scripts in their proper locations.
*/
//:://////////////////////////////////////////////
//:: Created By: Zandramus
//:: Created On: 07.23.2002
//:://////////////////////////////////////////////
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);
// we need to find out if area is locked
if (GetLocalInt(GetModule(),sDest) == 0) // Room is Unused
    {
     SetLocalLocation(GetModule(),sTag,dLocation);
     SetLocalInt(GetModule(),sDest, 1);
     AssignCommand(oidUser,JumpToObject(oidDest,FALSE));
    }
    else
    {
    if (GetLocalLocation(GetModule(),sTag)== dLocation) // Room is Being Used By this Door
       {
       AssignCommand(oidUser,JumpToObject(oidDest,FALSE));
       }
       else
          {
          SendMessageToPC(oidUser,"An Unknown Force Prevents you from entering");// Room is Being Used By another door
          }
    }
}




NWScript:
//::///////////////////////////////////////////////
//:: Name   Smart Door Return
//:: FileName  return.nss
//:://////////////////////////////////////////////
/*
    Place this script in your interior exit door's
    ontransitionclicked event. This will check the
    last location of the pc and return him there.
*/
//:://////////////////////////////////////////////
//:: Created By: Zandramus
//:: Created On: 07.23.2002
//:://////////////////////////////////////////////
void main()
{
object oidUser;
object oidDest;
string sDest;
oidUser = GetLastUsedBy();
AssignCommand(oidUser,JumpToLocation(GetLocalLocation(oidUser,"IWASHERE")));
}



NWScript:
//::///////////////////////////////////////////////
//:: Name  On Exit Smartdoor
//:: FileName oexit_smartdoor.nss
//:://////////////////////////////////////////////
/*
    Place this in the on exit event of your fluff area's
    it will pull the global variable name from the tag
    of that area so your area tag must match your door name
    this should be obvious by now.
*/
//:://////////////////////////////////////////////
//:: Created By: Zandramus
//:: Created On: 07.23.2002
//:://////////////////////////////////////////////
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);   // area is empty unlock it
  }
}



you can download the erf of the 3 scripts here

http://mynwnserver.kicks-ass.net

enjoy

Zandramus

⌂ All Scripts ← PreviousNext → 👁 Category List

All Placeables Scripts

📄 cast_haste 📄 check_fire 📄 chest_puzzle 📄 close_door 📄 close_door_002 📄 close_door_003 📄 close_door_004 📄 create_item_with_delay 📄 darklamp 📄 darklamp_002 📄 day_night_lights 📄 day_night_lights_002 📄 destroy_spawned_items 📄 destroy_spawned_items_002 📄 door_guard 📄 door_lock_item 📄 dragging_placeables 📄 encounter_on_open 📄 encounter_on_open_002 📄 fair_loot 📄 fire_burns 📄 guarded_chest 📄 kill_attacker 📄 kill_nearby 📄 lights_on_off 📄 linked_doors 📄 moveable_placeables 📄 multi_door 📄 open_doors 📄 poly_attacker 📄 polymorph_pc 📄 polymorph_pc_002 📄 random_teleport 📄 refil_chest 📄 refil_chest_002 📄 refil_chest_003 📄 refil_chest_004 📄 refil_chest_005 📄 refil_chest_006 📄 refil_chest_007 📄 remove_with_item 📄 respawner 📄 smart_doors 📄 spit_treasure 📄 talkable_placeables 📄 talking_door 📄 talking_sign 📄 talking_sign_002 📄 talking_sign_003 📄 talking_sign_004 📄 teleporting_chairs 📄 useable_bedroll 📄 useable_birdcage 📄 useable_cannon 📄 useable_catapult 📄 useable_chair 📄 useable_chair_002 📄 useable_chair_003 📄 useable_chair_004 📄 useable_couch 📄 useable_divining_pool 📄 useable_gong 📄 useable_kegs 📄 useable_kegs_002 📄 useable_placeables_002 📄 useable_sign 📄 useable_sign_002 📄 useable_sundial 📄 useable_sundial_002 📄 useable_sundial_003 📄 useable_sundial_004 📄 useable_sundial_005 📄 useable_sundial_006 📄 useable_training_dummy 📄 useable_training_dummy_002 📄 useable_training_dummy_003 📄 useable_training_dummy_004 📄 useable_trapdoor 📄 useable_trapdoor_002 📄 useable_trapdoor_003 📄 useable_trapdoor_004 📄 weapon_spawn_per_class 📄 worth