This script when placed in the onDeath event of any NPC will cause the NPC to respawn to where it died or the closest waypoint after so many seconds. This works by creating a copy of the killed NPC in an unaccessable NPC Limbo area and then assigning a DelayCommand to portal the NPC back after so many seconds. This gets rid of laggy heartbeat scripts and such. I've tested this alot on my own server and it seems to work very good. Note: There is a Local varible check in the code to make sure the code isn't executed more than once when an NPC dies. For some reason without this varible check, the code would fire seven or eight times after killing just one NPC. But with the check it works fine.
This is a compilation of the old system into a single score. There were 7 that made this score of 9.29 then rounded to 9.
Posted by Zanthoris ( ..xxx.xxx ) at 2003-12-04 16:49:00
I have used this script for awhile, and the only problems I have had were related to my factions and not the script itself. I did find one thing I changed that I thought I would share in case any of you want things set up the way I did. I wanted all my creatures to respawn at the same place I had originally placed them, so I decided to write a location variable to them in on spawn-in. But there was already one there! So I tried using it and viola, it worked wonderfully. Just do this:
Just a few minor changes and now your creatures will always spawn to the same spot, for those who want to do that. If you happen to use a custom on spawn file that doesnt have the default code you can just add this to yours:
Anyway great job on the script, and on the idea, very innovative!
Posted by Sycholic ( ..xxx.xxx ) at 2003-11-05 05:37:00
Wouldnt it be better to just define a variable inside the script at the beginning then just a for/while loop and at the end make the for/while statement false thus keeping multiple instances impossible? also you dont have to use a local variable (I dont think atleast) just a 'incode' variable.
Posted by Sommarnatt ( ..xxx.xxx ) at 2003-05-17 13:12:00
Would love to make it work, but somehow I can't get my mobs to spawn at the waypoint close to them. I've checked your code and everything seems to be in place. Built it and it compiled ok..
Any idea what I'm doing wrong? Using nwn 1.29
Posted by Scalz ( ..xxx.xxx ) at 2003-04-03 23:08:00
Great script, but I was also having a problem with the ActionRandomWalk() in the Heartbeat script. I tested this with a 20 second respawn. What I did was instead of just putting the ActionRandomWalk() in the Heartbeat by itself, I used DelayCommand(30.0, ActionRandomWalk()); I added a 10 second delay to my respawn time, and so far it works great. They don't start walking for a couple seconds longer then usual, but then it returns to normal it seems. Just thought i'd see what you guys think.
Posted by Nameles ( ..xxx.xxx ) at 2003-03-29 22:01:00
Ok... I think I need help about different factions When evil characters kill some NPC's (strong too), no one comes back.
Posted by Wolkenfels ( ..xxx.xxx ) at 2003-03-12 06:22:00
Great script - works well for me - added some simple things
in my version - maybe someone like the ideas:
1) if the tag of the creature has a String _SP and a number
in it e.g. MY_ZOMBIE_SP300 the delay is set to 300 instead
of the default delay.
2) instead of getting the nearest waypoint always check if
there is a Waypoint named WP_ e.g. WP_MY_ZOMBIE_SP300
and respawn there - or at death location like in the script.
3) if the Tag has a "_FRND_" in it the creature will spawn
in a non-Hostile Respawn-Area. So i dont need different
scripts for friendly and hostile creatures.
Posted by ItalianMage ( ..xxx.xxx ) at 2003-02-12 12:27:00
i need to get this to work in the official campaign. I need
the Intellect devourer to be respawned since it disappeared
escaping with one guard. Now that room is empty and that
beast will never come back, leaving me without an
ingredient. How can i put this into the official campaign?
Posted by Apparition ( ..xxx.xxx ) at 2003-02-11 08:08:00
The creatures will move randomly the first time if you put
a ActionRandomMove() in the heartbeat (is this hard on
CPU?). But when they are spawned back the hearbeat script
has stopped.
Posted by Derek ( ..xxx.xxx ) at 2003-02-11 04:09:00
I got this to work but, when i put waypoints down for the
creatures it doesent work. Is there a way to fix that or
better yet a way to get the creatures to walk randomly
Posted by Apparition ( ..xxx.xxx ) at 2003-02-10 13:45:00
I am using your script for my mod, but I've encountered a
problem (yes, I am changing the script).
In the hearbeat I've put a ActionRandomMove() and I've
changed the DelayCommand to a ActionWait() so the creature
will wait in limbo instead of walking around (which keeps
it from jumping back).
My problem is: The hearbeat script doesn't run aftert the
creature have jumped back the original spawnpoint. I am new
to scripting and can't figure this out.
Posted by tongmei ( ..xxx.xxx ) at 2003-02-10 02:12:00
Great idea Raz! Im new at nwscript and was wondering if
it is possible to assign a delayed command to any object?
If so then would it be possible to assign the delayed
command to an invisible object to spawn the creature
rather than having it sit in limbo?
Posted by Derek ( ..xxx.xxx ) at 2003-02-08 13:41:00
I cant get this to work
Posted by Razdyn ( ..xxx.xxx ) at 2003-02-04 08:22:00
A little update on how to use this code:
You must have 1.27 in order for the GetResRef function to
work.
Also, this script works by creating creatures in limbo via
the creature that died Blueprint ResRef. You must either
create custom creatures with custom blueprints with this
script in the onDeath event or change the default onDeath
script for all creatures to this one.
This is because say you paint a default skeleton in an
area and add the onDeath script to it. The default
skeleton will have a blueprint resref of "nw_skeleton".
When it dies, the onDeath script will fire and create a
new skeleton in limbo to jump back.. The problem is since
the resref is "nw_skeleton" it will create a new default
skeleton without the onDeath script anymore. This problem
is eliminated by choosing the NPC you want to respawn,
right click it, choose edit copy, and under the advanced
tab make sure it has a unique Blueprint ResRef. Put this
script in it's onDeath event and now you can paint as many
of this copy as you wish and the script will work just
fine.
Posted by Razdyn ( ..xxx.xxx ) at 2003-02-04 08:16:00
I disagree with the previous comment. Other ways involve
heartbeat scripts that would fire every 6 seconds. So, my
script calls 2 commands that create in limbo, then jump it
back after a delay. Where as every six seconds a
heartbeat script would process. I've tested my way and it
works much better. Besides, my script really doesn't add
much processing time, since every creature that dies
process through a script anyway.
The spawn is not CPU lagging because it's just one
command, and any other way you would choose to do the
spawn would be just as CPU intensive or more.
Posted by Aladrian ( ..xxx.xxx ) at 2003-01-31 19:03:00
Hmm ..
Wouldn't it still drain the cpu in the bursts?
I.E. creature spawns , killed , copied then sent back?
It seems to me though it is ingenius..this script in effect
does drain server cpu a bit more ((spawn copy and respawn
constants)) ..almost in effect causing the same amount of
client lag ((server latency)).
Posted by Santa's Helper ( ..xxx.xxx ) at 2003-01-30 20:37:00
Script is God-send... I love you even more than 30 seconds
ago. (made a typo in my email, lol)
Posted by Santa's Helper ( ..xxx.xxx ) at 2003-01-30 20:35:00
I love you.
Posted by John ( ..xxx.xxx ) at 2003-01-29 14:16:00
Stupendest! Good script for people looking to work on
persistent worlds.
You must be Logged In to post comments in this section.