Created by Palor Formerly known as the "UO Style Spawn System" See the NWN Spawn Script v.2.4.4c text file for more details on this versions changes and additions.
Introduction
PC tested, DM approved.
This is a single script that is placed as an OnHeartbeat on a single object in an area. Once placed you can setup individual Spawn Sites by placing WayPoints. Each Spawn Site can:
Spawn up to 99 creatures
Spawn a random amount of creatures between 1 and 99
Spawn a group of different creatures
Spawn random creatures from a group
Use a delay of up to 99 hours between each spawn
Use random delay of up to 99 hours between spawns
Spawn just at night or during the day
Spawn only at a specific hour or between certain hours
Spawn only on a specific day or between certain days
Spawn only if a PC is within up to 99 meters
Spawn creatures in random locations within a specified radius
Spawn creatures in random locations around the players
Optionaly not spawn if a player enters the radius and is already in combat
Spawn treasure chests or any other valid Placeable
Use Effects when it spawns or kills the creatures due to an invalid time
Setup radius based damage (traps) and have effects applied to simulate poisonous fogs or other effects
Have spawned creatures walk around randomly without editing their OnSpawn script
Make the creatures play animations while they are not walking without editing their default scripts
Generate treasure on a spawned creature without editing their OnSpawn script
Have the spawner wait until all creatures are killed before spawning again
Optionaly not spawn until all the creatures it spawns are killed
Other things you can do with the script if you like some added flavor:
Customize Groups or use existing ones
Customize the Traps by changing damage and visual effects
Easily create "magic" amulets that can protect players from the "traps"
Customize Spawn effects and effects used when the spawner destroys creatures
Setup camp items to be used as props for Monster Camp
.
Check for items and spawn based on whether the player has it or not
Create quest items on the creatures when they are spawned
Spawn at remote locations away from the spawn point
Create an invisible object and attach this script to it's Heartbeat. You only need the one object for all your spawn points in the area.
Decide what creature you want to spawn and make a note of it's Tag or create a custom creature.
Place a Waypoint and edit the properties to look like:
Name: SP_SX02
Tag: NW_DOG
Load your module and login and watch the 2 dogs standing there. :)
Place more Waypoints and populate your module!
For a complete list of valid switches that you can use on your Spawn Point to control the spawn, see the Switch Quick Reference and section Switches section sections of this document.
Switches tell the Spawn Point how to control the spawn. This ranges from telling it to spawn a random amount, to telling it to only spawn during the day or between 2:00pm and 3:00pm. For more information on using the switches, please read the section called Frequently Asked Questions, which can be found following below.
Spawn Switches
SP_
Tells the Spawn Control Object that this Waypoint is a Spawn Point.
IDnn
Sets the ID of the spawn point to nn. This is used for controlling the spawn point through outside triggers.
CHnn
Tells the spawner to spawn Champion nn at the spawn point. If R is specified and a valid roll is used, it will give the Champion a random chance of appearing.
Examples:
CH01 - Always spawn Champion 01 when all the creatures are dead.
CH01R1d4 - The Champion has a 1 in 4 chance of spawning when all the creatures are dead.
CH01R2d8 - The Champion has a 1 in 16 chance of spawning when all the creatures are dead.
Valid rolls are:
nd2
nd3
nd4
nd6
nd8
nd10
nd12
nd20
nd100
Champions are added by adding them to the list of Champions in the code. You can find the list around line 826 and it looks like:
Now you can make a Deer Champion appear by adding the switch CH02 to your spawn point. :) You can use any valid tag or you can create your own creature, but please follow the guide lines for creating custom creatures as mentioned throughout this thread.
CR
Used with CH and EX. If used it will only spawn the Champion at the remote location.
SS
Stops Spawn when all creatures are killed at spawn point.
NOTE: ALL creatures must be killed. The spawn point will continue to spawn until it finds no creatures at the spawn point.
RDnn
Only spawn creatures if a Player is within "nn" meters.
Examples:
RD10 - Only spawn if a player is within 10 meters. Kill the creatures when a player leaves the radius, unless the creatures are in combat.
RD10X - Only spawn if a player is within 10 meters. Kill the creatures when a player leaves the radius.
RD10N - Do NOT spawn if a player is within 10 meters.
RD101d4 - If a player is within 10 meters, roll and give the spawn point a 1 in 4 chance of spawning.
IC
Do not spawn when a player enters the radius and is already in combat. Used with RD.
SXnnRyy
Keep "nn" creatures spawned at this Spawn Point. If R is specified, it spawns a random number of creatures between nn and yy.
Examples:
SX02 - Keep 2 creatures spawned.
SX01R10 - Spawn a random amount between 1 and 10.
NOTE: nn is the MINIMUM you want. If you specify 01 as the minimum, it will not spawn anymore until they are ALL dead.
CPnn
Spawn a creature camp.
Example:
CP01 - Will place the objects listed in camp01 in random locations around the site.
Camp items can be added by including them in the Camp List. The list can be found around line 818 of the code and look like:
To add a second object to Group 01 you would first place the object in your area and get the Tag and Blueprint off the object, then delete it. Now create a new entry like:
CI01 - Creates Item 01 from the Item List and places it on all creatures
CI01R1d2 - Each creature has a 50/50 chance of receiving the item
The CI switch uses the same random call as the Champion Spawner. Please see list in the description of the Champion switch.
IG *
Informs the spawner to create an item out of a group. If used it will use the group number specified by CI. If an R is used, it will grab a random item from the group.
Examples:
IG - Give all items out of group 01.
IGR - Choose a random item from the group.
PI
Tells the spawner to spawn or not to spawn based on whether the player has an item. PI must be used with RD.
Examples:
PI01 - Player must have Item 01 in their inventory in order for this spawn site to spawn
PI01X - Player must NOT have Item 01 in their inventory in order for this spawn site to spawn
GTnn
Generate treasure. If specified it will generate treasure on the creatures that are spawned. If a roll is given using the same format as CI, there is only a chance of receiving loot. This uses the GenerateTreasure function found in the default NW_O2_CONINCLUDE file.
NTX
Only spawn during the night and kill any creatures left when it turns day, unless they are in combat. If an X is specified it will kill the creatures even if they are in combat.
DTX
Only spawn during the day and kill any creatures left when it turns night, unless they are in combat. If an X is specified it will kill the creatures even if they are in combat.
SHnnTyy
Spawn only at nn hour of the day. This is in 24 hour format. If T is specified it will spawn between the hours of nn and yy.
Examples:
SH23 - Spawn only while it is 11pm
SH00 - Spawn only while it is midnight
SH01 - Spawn only while it is 1am
SH01T03 - Spawn only between 1am and 3am
SDnnTyy
Spawn only on nn day of the month. If T is specified it will only spawn between the days of nn and yy.
Examples:
SD01 - Spawn only the first day of the month
SD01T03 - Spawn only between the first and third days of the month
TMxxRyy
Delay spawns by "xx" seconds. Specify Minutes by adding the M on the end or specify Hours by adding a H. Use R to generate a random number between xx and yy.
Examples:
TM02 - Delay spawn for 2 seconds
TM02M - Delay spawn for 2 minutes
TM02H - Delay spawn for 2 hours
TM10R30 - Random between 10 and 30 seconds
TM10R30M - Random between 10 and 30 minutes
TM10R30H - Random between 10 and 30 hours
NF
When used with the timers it tells the spawn system to NOT bypass the timers on the very first spawn.
DS
Wait until all creatures are killed before spawning any more.
RT
This switch is only used with PA and will reset the timer on the spawn point if a player is not in the area.
RHF
RH tells all creatures to return home (to the waypoint) if they are not in the middle of something. If an F is used, the creature will face the direction of the waypoint when it returns.
RWnn
If specified, the creature will walk randomly around after spawning.
Examples:
RW - Walk randomly around. Location does not matter
RW10 - Walk within a 10 meter radius of the spawn point
ANnnLyy
Used with RW, this switch gives the creature a 50% chance to play an animation when they are not walking. Using L will have it loop the animation for yy seconds.
Examples:
AN01 - The creature will play animation 01
AN15L10 - The creature will loop animation 15 for 10 seconds
A list of animations can be found around line 331 of the script.
RF
This switch gives the creature a 50% chance of facing a random direction every heartbeat.
FA - This switch will force all spawned creatures to attack the first Player that triggers the spawn through RD. This will bypass the initial wait for Perception.
AEnnRyy
This will produce the Area Effect nn throughout a 5 meter radius of the spawn point. If R is used it will make the effect throughout the radius yy. The location is random.
Examples:
AE01 - Will produce Area Effect 01 throughout a 5 meter radius of the spawn point
AE01R10 - Will produce Area Effect 01 throughout a 10 meter radius
Effects can be found around line 1215 of the script. This is work in progress and I have not had a chance to go through all of the effects in NWN. :)
VSnn
Tells the spawner to use effect nn on the location before spawning.
Valid effects are:
01 - VFX_FNF_SUMMON_MONSTER_1
02 - VFX_FNF_SUMMON_MONSTER_2
03 - VFX_FNF_SUMMON_MONSTER_3
04 - VFX_FNF_SUMMON_UNDEAD
05 - VFX_FNF_SUNBEAM
06 - VFX_FNF_WAIL_O_BANSHEES
07 - VFX_FNF_STORM
08 - VFX_FNF_STRIKE_HOLY
09 - VFX_FNF_IMPLOSION
VKnn
Same as above, except it happens when the spawner kills a creature due to it not being a valid spawn time. Example would be if it turned night and the creature is suppose to only spawn during the day. :)
Effects for spawning can be found around line 677 of the script, effects for killing can be found around line 565.
TPnnAyy
Use trap nn at the spawn point. This works with creature spawns. If A is specified and an amulet is listed in the amulet section, whoever is wearing it will not be affected.
Examples:
TP01 - Use trap 01
TP01A01 - Amulet 01 protects against the trap
TP01A02 - Amulet 02 protects against the trap
Traps are "Damage Effects" with a visual effect applied to the target
Traps can be found around line 1173 and Amulets around line 1193.
Note: If a tag of effect is used for the waypoint, it will only do the effect.
This section will be used to describe a few things that are possible to do using this script. It is by no means a complete description, as the minds of humans tend to come up with neat and brilliant ideas all their own :)
Wars
By strategically placing waypoints and setting them to spawn at different times and with different amounts of creatures, you can easily simulate a war between rival groups. A few people have mentioned to me that they have setup waypoints using timers of minutes and hours and each one being placed in different parts of the map. What this allows is a few creatures to spawn and start randomly walking. If they happen to see an enemy, they run after them. They may even call for help, which would draw more creatures into the battle. Since there are timers set, when the creatures die they wait a while before spawning and thus the battle is won or lost for a while.... until another spawns in another place and happens into a section of the map patrolled by their enemy :)
You can setup creatures to only spawn at certain times of the day, which allows for setting a quest that may have a person go to a particular place at a certain time. By setting a radius option and a hour option on the waypoint, the creature would only spawn if the player got within a certain radius at a certain time. The following example would only spawn between the hours of 1pm and 2pm and only if the player was within 20 meters. By adding a RS05 and a NP, you could have the creature spawn within 5 meters of the player :)
The SS switch is designed so that you can tell the spawn point not to spawn after all creatures are killed. By using this, no more creatures would spawn until the module is reset, or you set the local variable SpawnDestroyed on the waypoint through another script. One example would be having a group of players be able to destroy a group of monsters, but after talking with the Evil Mage they find out that the army is in fact still alive! Just have the Evil Mage set the LocalInt for the Waypoint back to 0 during the Conversation.
You can add any valid creatures tag into the Group section of the script and create your own groups. The group feature uses Tags just like the Waypoint does. If your spawning badgers that might be a good place to look :) Groups can be found around line 430 in the script and look like:
In order to add more creatures to a group or to create a new group, just add the appropriate Tag for the creature and give it a valid group. The groups or formatted like:
groupGroup Number_Creature Number
So to add a ghoul to the group above as the third creature:
Look for the line just after the comments (around line 779) that reads: #include "NW_O2_CONINCLUDE"
After that line, insert a line that reads: #include "YourScript"
Replacing "YourScript" with the name of your script you just created
Go to approximately line 879 in the NWN Spawner code and add the line of code as shown below
[nwscript]
void main()
{
// Setup Group, Champion, Item and Camp vars
//
if (!GetLocalInt(OBJECT_SELF, "ModInit")) {
sp_ModInit();
RegisterGroups(); // <--- Add this line *********************
}
[/nwscript]
Now you're done.. Save and compile the NWN Spawner Script.
To modify your groups, simply edit the section in the new script you created. When new versions of the script come out, simply re-add the 2 lines of code shows (The #INCLUDE line, and the RegisterGroups line).
This script comes predefined with a few different types of Traps. These are designed so that when a player enters the radius of the spawn point, it hits them for damage and adds a visual effect on them every heartbeat. You can design your own Amulets that they can put on to protect them... if they have it :) Adding a trap is as easy as finding the effect you want and changing the trap in the script to use that effect or just add multiple traps :) Amulets are made by creating a custom object and placing its tag in the trap section of the code. The Traps can be found around line 1279 of the script and look like:
Case 01:
eDamage = EffectDamage(d4(), DAMAGE_TYPE_MAGICAL, DAMAGE_POWER_PLUS_FIVE);
eEffect = EffectVisualEffect (VFX_FNF_GAS_EXPLOSION_NATURE);
sDamageCause = "You have stumbled into a poisonous fog.";
break;
eDamage is the type of damage and how hard it is going to hit. eEffect is the visual effect that will be applied to the target such as the above gas cloud. sDamageCause is what will be sent to the player to let them know why they are getting hurt :)
What monster camp would be good without a campfire or an impaled human corpse being around? By adding objects into the Camp section you can have as many different types of settings for your spawns as you like. Be careful though, some objects are flaky and might end up on top of each other. I have tested many of them, but some just won't work with others. The Camp section can be found around line 450 of the script and looks like:
Both of these lines belong to the same object. In order to add new objects you must first place the object in a test area, look at its properties and grab the Tag and ResRef from it. You cannot use the resref that is shown in the object list.
All of the rules for a spawn site can be modified through setting certain variables. In order to do this you must first give the spawn site a unique label. This label is called the ID and is specified by:
Spawn Point:
Name: SP_ID01
Tag:creatures tag/resref
In order to get the object and change any of the rules, all you need to do is use the following in a script.
When using the ID switch you must specify it in 2 digits, such as 01, 02, 09, 10. When getting the object, just use single digits, such as Spawner1, Spawner2.
Examples:
Kill off all the spawn and stop a spawn point by adding the following to the OnDeath of another creature, OnUse of an object or whatever.
This section will address common issues that you may have while trying to setup your area.
Question:
When I try to compile the script it gives me errors :(
Answer:
Before you paste the script into the OnHeartbeat of the invisible item you need to take out the existing lines shown below:
void main()
{
}
Remove those and then paste the script in.
Question:
When I create a custom creature and put it on a waypoint to spawn, it keeps spawning over and over and over and I get a TON of them!
Answer:
You need to make sure that the Tag of the creature you put on the waypoint does not have a typo in it and make sure it matches the creature you want to spawn. Having a mistyped tag will cause this every time.
They look the same, but it is case sensitive and so it will spawn since it is a valid resref, but the spawn point can never find the creature since the tag does not match. If it cannot find the creature it will think it is missing it and so spawn again.
When creating a custom creature give it a descriptive name inside the Creature Wizard and then go back in and edit it and change the name to what you want. The name given to it during the Wizard will be used by the toolset to assign a Tag and Blueprint.
Example:
Create a custom skeleton and give it the name weakskel001 during the Wizard. The finished info will look like:
You can use weakskel001 without having to worry :)
Question:
I setup a waypoint exactly like you said but all I get is badgers :(
Answer:
The single cause for badgers is an invalid blueprint. Use the above solution to check the blueprint and make sure it matches the tag of your waypoint. This only applies to custom created creatures.
Question:
I am experiencing huge lag in my module after setting up only a few waypoints!
Answer:
This would be caused by not having a valid blueprint in the tag of one of your waypoints you setup for a custom creature, or by having a typo :) If NWN cannot find the blueprint you specify it will create a badger. If you have a waypoint setup to spawn 4 creatures, within a minute you will have a ton of badgers :)
Question:
I setup a camp with a radius and when the player leaves the radius the creatures go away but the camp items stay (or never appear).
Answer:
You need to first place the object somewhere and grab the Tag and ResRef off that item, then delete it. If you use the information from the Placeables List it will not work.
Question:
How can I make my spawn point only spawn a couple of the same creatures and always have them there. If one of them dies I want it to come right back.
Answer:
If it is a Default NWN creature all you need to do is look in the creature list and look at the properties of the creature you want to spawn and grab the Tag. Create a Waypoint where you want the creatures to spawn. Let us pretend the creatures you want to spawn are the default dog. Setup a waypoint as follows:
Name: SP_SX02
Tag: NW_DOG
The SX02 tells it to keep two of the creatures there. NW_DOG is the tag of the default NWN dog.
Question:
What if I want the dogs to walk around randomly after they spawn?
Answer:
Change the name of the waypoint to:
Name: SP_SX02_RW
The RW switch tells it to make any creatures it controls walk around randomly when they are not talking or fighting.
Question:
How about having a couple of skeletons that only come out at night?
Answer:
Setup a waypoint with the following information:
Name: SP_SX02_NT
Tag: NW_SKELETON
The NT switch tells it to only spawn at night.
Question:
Could I add another spawn point there with a tougher creature and have it only spawn when it is midnight?
Answer:
Sure. Use the following:
Name: SP_SX01_SH00
The SH00 tells it to only spawn at 00:00 in 24 hour format, which is midnight.
Question:
What about a whole undead group?
Answer:
Yep! The script comes distributed with 2 predefined Groups. Group 01 is an undead group. Setup a waypoint with the following settings:
Name: SP_GP
Tag: Group01
The switch GP tells it to spawn all of the creatures listed in Group 01.
Question:
What if I only want 3 random creatures from that group?
Answer:
Change the waypoint to:
Name: SP_SX03_GP_GR
Tag: Group01
The GR switch tells it to choose random creatures from the group.
Question:
Can I check to see if the player has a certain item and spawn/not spawn based on that?
Answer:
Sure! You can use the PI switch to do just that. Use the following to check the item 01 in the Item List of the script and spawn if they have it:
Name: SP_PI01
Or the following to not spawn if they have it:
Name: SP_PI01X
Question::
My creatures look bored when they aren't walking around randomly. Can I do anything about that?
Answer::
You can use the switch AN to make them play an animation when they aren't busy.
SP_AN01
Or to loop animation 15 for 10 seconds:
SP_AN15L10
For more information about each switch, please read the section entitled Switches, or feel free to post your question to the Forum Discussion Topic.
Item Manager is a script that works alongside the NWN Style Spawn system to provide many of the rudimentary item management needs of any persistent or semi-persistent world module. It can also be used stand-alone without NWNSS if desired.
Uses a java page to setup all the tags for you. All you do is fill out what you want a certain spawn site to do and it generates the command line that needs to be used.
If you know of addition companion scripts please let us know.
I would say around 75-80% of this script is all community suggested features. This script is made for the community and your feedback helps to shape it and defines what features are added, removed or adjusted.
If you have an idea that you think would make a good feature, or even just be cool, please let me know. I am constantly working on the script and I am more than happy to add any feature that would make this script even better.
We currently have a thread setup strictly for feature requests. This enables me to be able to keep track of what people want and who requested it (so they get credit). If you have a suggestion, please feel free to visit this thread and let us know :)
If you have a problem with a feature that is not listed in the Troubleshooting section, please post about it. Bug tracking is the top priority and finding them naster critters and getting rid of them is very important :)
I hope you enjoy using this script and look forward to releasing even better features in upcoming versions!
The history of the script
The following are topics that were used for different versions.