Simple respawn system
From NWNWiki
[edit] Simple Respawn System
[edit] What It Does
Simple Respawn System 01
------------------------
by T. Buckermann (TaBu-NiW at the bioware NWN forums)
Included Scripts:
tb_os_res_1 - OnSpawn script for respawnable creatures.
tb_ude_respawn - UserDefined script for respawnable creature.
tb_i0_respawn - Include file with the SetRespawnPoint() Function. Used in tb_os_res_1.
tb_hb_spawnpoint.nss - OnHearbeat script of the tb_spawn_point placeable.
Included Objects:
Goblin (tb_goblina)- Demonstration of the Simple Respawn System.
tb_spawn_point - Spawn Point object.
Notes:
If you want to see the "Simple Respawn System 01" in action, just import tb-sires_01.erf
place the included goblin somewhere, kill him and watch how he respawns a hour later.
If you want other creatures to respawn, create a copy of it (IMPORTANT: the tag and the
template (or ResRef) must be exactly the same) and change the scripts to the following:
OnSpawn = tb_os_res_1
(Or if you are using your own OnSpawn scripts, remove the "//" in
front of "SetSpawnInCondition(NW_FLAG_DEATH_EVENT);" and add the following
function at the end of the script: "SetRespawnPoint(X);" where X are the hours
when the you want the creature to respawn after its death. If X = 0 the creature
SHOULD (not tested fully) respawn immediatly after its death.
Example: if you want the creature respawn in 1 year, 2 months, 8 days and 6 hours
then X = 9606 (8064+1344+192+6) = SetRespawnPoint(9606) .
But nobody wants to wait so long, better use some random element. If you want
your creature to respawn 3-10 hours after its death use SetRespawnPoint(Random(8)+3).
Random(X) creates a random number between zero and X-1, so Random(8) creates a
number between zero and seven.)
OnUserDefined = tb_ude_respawn
(only the on death event is used to activate the respawn point)
The spawn point object:
You can ignore it. It will created automatically with the OnSpawn script of the creature.
But if you want to create your own spawn point object, you have to change the line
"string SPAWN_POINT_TAG = "tb_spawn_point";" in the tb_i0_respawn include scripts to
match the tag of your new object (again, the tag and ResRef of your object should be
exactly the same). Maybe you want to use a destroyable placeable, so if the players
destroy the spawn point object no more monster will respawn.
Final notes:
In the scripts are still many debug messages which are logged to the nwclientlog. I didn't
removed them because i'm not 100% sure that my Simple Respawn System 01 is without flaws.
For example i did not test what happens if the respawn time is longer than one month. I
put all functions in for REALLY long respawn times, and they should work. But as i said
no 100% working guarantee.
If you have questions, problems or ideas for improvment email me or send me a
Private Mail at the bioware forums.
T. Buckermann (TaBu-NiW at the bioware NWN forums)
Email: tabu_niw@freenet.de
