I'd like to expand or re-do some parts of Cipher's specifications, as follows:
Functional Requirements
The spawn system will handle the spawning and de-spawning of objects in areas.
For the player
Ideally, the player would never know the spawn system existed, not having the opportunity to see any evidence of its existance.
For the builder
The building will place spawn points by placing a waypoint with a specific tag in an area. He will then let local variables on this waypoint to determine its behavior. These variables will have descriptive, intuitive names so that there is as little confusion as possible with builders, and they will come listed on the waypoint blueprint included in the spawn system. The options these variables represent could include the following:
- Spawn ResRef (for use with single-type spawns)
- Spawn group name (for use with the population system)
- Spawn group strength
- Spawn name
- Spawn name prefix
- Spawn name suffix
- Spawn faction (lets hope Obsidian gives us this ability)
- Spawn-in script(s) (possible array of local strings)
- Respawn count (maximum number of times the spawn will activate if its children have been removed from the area)
- Respawn delay (in game-time)
- Spawn-in radius (float distance value)
- Spawn persistance flag (whether or not the child object will be spawned normally, or loaded from the database and saved upon despawn).
- Spawn hour
- Despawn hour
- Spawn chance (0% to 100%)
- Spawn day (1 to 10)
- Despawn day (1o to 10)
- Spawn month
- Despawn month
- Spawns in rain
- Spawns in snow
- Spawns in * weather (ie, other types of weather we haven't defined yet, relates to the weather system)
- Spawns in sight of PCs (whether or not the spawn point will activate if a PC is watching)
- Respawns with PC in area (whether or not the spawn will respawn if PCs have not left the area).
- Spawns when PC nears (distance float value)
- Spawn in VFX
- Spawn in SFX
- Uses spawn-in animation
- Whether or not the spawn is active or disabled
Functions should be present to allow external systems to add, modify and delete spawn points. Functions to modify existing spawn points should include, at the least:
- Enable/disable
- Respawn count
- Group strength
- Respawn delay
NWN Object Dependencies
Waypoints.
Logging and Debugging (global LOG & DEBUG (on/off) constants)
All resrefs spawned will produce debug output on the informational channel. Resrefs not found will produce warnings.
Persistence Requirements
None in itself, the encounter system handles persistance.
If the child persistance option is implemented, a seperate subsystem could be used to store and track saved creatures, since this functionality would undoubtably be used for other purposes.
Event Dependencies
OnAreaEnter, OnAreaExit, possibly others.
Custom events could be added to each spawned child to track whether or not the spawn has been depleted. But I'm not sure if DestroyObject() would bypass this.
Dependancies on other (sub)systems
Population system, encounter system, deubugging system, time system, possibly custom events system, possibly persistant object storage system.
Design Comments
Behind the vault, NESS is the largest source of burst-lag I have seen. Spawn-lag on area ATs has killed many PCs, and this is totally unacceptable to me. Though I have no proof, I suspect the cause of this lag is two-fold: looping through every object in an area and parsing waypoint tags, and so many CreateObject() calls at once. Some strageties I can think of for aiding this are:
- Loop through all spawn points in the module OnLoad, and cache them to local variables on areas. Combine boolean flags into single bitwise integers, and destroy the waypoints as you progress.
- At the very least, begin spawning creatures when a PC exits an area (by retrieving his destination OnExit).
- Possibly "cache" areas by slowly spawning in areas the PC is near, spreading CreateObject() calls over a longer period of time.
