Sd dynamic rooms and sd dynamic exit

sd_dynamic_rooms and sd_dynamic_exit

What it does
Ok, it's pretty powerful, but basically it allows a builder to create one Area as a template, and then just by naming the door and attaching the first script it will load predefined Objects into the room, and delete them when the player exits. It basically allows an infinite amount of Areas to be created in the one Area. The idea was to make the multiple houses in a town easier to use, but still able to have different characters and objects in the house without creating 10 or 20 areas.

Ok, the script is pretty basic, but has a number of things that need to be done.

Area and Area Requirements

 * An area must be created. Since the door's tag has to have the Area's name in it, I suggest very simple, short names... "House" or "Cave" or "Blagh", etc.


 * The Door must have the "Area Transition" option under the "Area Transition" tab set to "Door". Leave the "Destination Tag" box empty, however.


 * The Area must have 5 waypoints called "general_spawn1" to "general_spawn5".


 * The Door must have the "sd_dynamic_exit" script attached to the "OnAreaTransitionClick" on the Script tab.

Entrance to the Area Door and Door Naming

 * The Door must have the "Area Transition" option under the "Area Transition" tab set to "Door". Leave the "Destination Tag" box empty, however.


 * The Door's name must be as follows.

ex. If your area was called "House", the Door's Tag must start with "House_"

Now you need to put the ResRef of each Object or NPC that you want to be created when the player enters the room. If I had an elven fighter named "Sylvia Cross" who's ResRef was "sylvia", I would now name the door: "House_sylvia" and when the player entered "Sylvia Cross" would be in the room. **Note that you MUST have the Tag name the same as the ResRef!!!!**


 * Now set the Door's "OnAreaTransitionClick" to the "sd_dynamic_rooms" script.

Extra Options!

 * If you want an NPC or object to spawn in a specific spot, create a waypoint named "_spawn", ex. "sylvia_spawn" and "Sylvia Cross" will be at that waypoint when she is created.

FINAL NOTES
IF the script is NOT working, check these things:


 * Make sure the NPC or Object being added has the EXACT same ResRef and Tag! They must also be the same (including case-sensitivity) as the reference in the doors name!
 * House_sylvia_ted_bob_Zilla* will load the Area named "House" and load the Object with a ResRef of "sylvia", "ted", "bob" and "Zilla" to random (or specified) locations! It will also LOAD objects with ResRef's of "Sylvia", "Ted", "Bob", "ZiLLA", etc. BUT! It will NOT Remove "Sylvia" or "Ted" or "Bob" or "ZiLLA" as their Tag's, only the Objects with Tags "sylvia" "ted" "bob" "zilla".

sd_dynamic rooms
/* .-. '-' void main {   /* Get the door and it's Tag. */   string sFullString = GetTag(OBJECT_SELF); object oPC = GetClickingObject; /* Set the counter for parsing the string, and the  */ /* Length of the string to be parsed. */   SetLocalInt(OBJECT_SELF, "counter", 0); SetLocalInt(OBJECT_SELF, "length", GetStringLength(sFullString)); /* Get the first character into the subString vari- */ /* able and declare the roomTemplate variable. */   string subString = GetSubString(sFullString,(GetLocalInt(OBJECT_SELF,"counter")),1); string sRoomTemplate; /* Now read in the second part, which is the room's */ /* templates name. */   while(subString != "_" && GetLocalInt(OBJECT_SELF,"counter") < GetStringLength(sFullString)) {       sRoomTemplate = sRoomTemplate + subString; SetLocalInt(OBJECT_SELF, "counter", (GetLocalInt(OBJECT_SELF,"counter")+1)); subString = GetSubString(sFullString,(GetLocalInt(OBJECT_SELF,"counter")),1); }   /* Now grab the remainer, which is the identifier    */ /* for the objects to be spawned in this new room. */   //int lengthIn = GetLocalInt(OBJECT_SELF,"counter"); //string sCustomTag = GetSubString(sFullString, (lengthIn + 1), (GetLocalInt(OBJECT_SELF,"length")-lengthIn)); /* Load all of the possible Objects to add to the   */ /* room template. */   string sHabitant; int i;   for(i = 1; subString == "_"; i++) {       SetLocalInt(OBJECT_SELF, "counter", (GetLocalInt(OBJECT_SELF,"counter")+1)); subString = GetSubString(sFullString,(GetLocalInt(OBJECT_SELF,"counter")),1); while(subString != "_" && GetLocalInt(OBJECT_SELF,"counter") < GetStringLength(sFullString)) {           sHabitant = sHabitant + subString; SetLocalInt(OBJECT_SELF, "counter", (GetLocalInt(OBJECT_SELF,"counter")+1)); subString = GetSubString(sFullString,(GetLocalInt(OBJECT_SELF,"counter")),1); }       SetLocalString(oPC,("npc" + IntToString(i)), sHabitant); sHabitant = ""; }   /* Get your current location so you can get back! */   SetLocalLocation(oPC, "entrance", GetLocation(OBJECT_SELF)); /* Get the next location necessary to load at. */   object oTarget = GetObjectByTag((sRoomTemplate + "_entrance")); location lTarget = GetLocation(oTarget); /* Force a move to that location. */   AssignCommand(oPC,ActionJumpToLocation(lTarget)); /* Now create each object loaded onto the player at */ /* either the created location, or at a random one. */   for(i = 1; GetLocalString(oPC,("npc" + IntToString(i))) != ""; i++) {       location lSpawn; object oSpawnPoint = GetWaypointByTag(GetLocalString(oPC,("npc" + IntToString(i))) + "_spawn"); if(oSpawnPoint != OBJECT_INVALID) {           lSpawn = GetLocation(GetWaypointByTag(GetLocalString(oPC,("npc" + IntToString(i))) + "_spawn")); }       else {           lSpawn = GetLocation(GetWaypointByTag("general_spawn" + IntToString(Random(4)+1))); }       object oTemp = CreateObject(OBJECT_TYPE_CREATURE, GetLocalString(oPC,("npc" + IntToString(i))), lSpawn); } }
 * Neverwinter Nights Room Generator           |
 * Author: Skye Darkangel                                 |
 * Date: 8/14/2002                                        |
 * Purpose: Easy to create and reuse a single room temp-  |
 * late to spawn a cities worth of inside houses. |
 * late to spawn a cities worth of inside houses. |

sd_dynamic_exit
Save this one as "sd_dynamic_exit" and attach it to the Door in the Area that's being used as a Template!

/* .-. '-' void main {   /* Get the door and it's Tag. */   /* Get the player, and then where he entered from. */   object oClicker = GetClickingObject; location lEntrance = GetLocalLocation(oClicker,"entrance"); /* Now remove all the objects we added upon entering */ /* the room! */   int i;    object oToDelete; for(i = 1; GetLocalString(oClicker,("npc" + IntToString(i))) != ""; i++) {       oToDelete = GetNearestObjectByTag(GetLocalString(oClicker,("npc" + IntToString(i)))); DestroyObject(oToDelete); }   /* Send the player back to where he entered from     */ AssignCommand(oClicker,ActionJumpToLocation(lEntrance)); }
 * Neverwinter Nights Room Generator Exit Script      |
 * Author: Skye Darkangel                                 |
 * Date: 8/14/2002                                        |
 * Purpose: Easy to create and reuse a single room temp-  |
 * late to spawn a cities worth of inside houses. |
 * late to spawn a cities worth of inside houses. |

Save this as "sd_dynamic_rooms" and attach it to the door that ENTERS INTO the room.