This ERF provides a basic blank starting point for customising your ondeath and onplayerrespawn events. Currently the onrespawn event does not fire which may confuse some people. I decided to create a basic blank starting point for people to use.
The ERF contains three files.
mod_onplayerdeath - Module level event that fires on death.
mod_onplayerrespawn - Module level event that does not fire by default on respawn. I still put mine in the module level events though just in case.
gui_death_respawn_self - Only slightly modified from the default one. Of course you will not over write the one that came with NWN2, it creates a copy in your module level scripts. This is the script that gets called when the player selects Respawn from the death menu.
**UPDATE 8/28/2009**
It was brought to my attention that in version 3, at line 35 I have it as int nHPHealed = GetHPHealed(oRespawner, FALSE); This will have the player respawn with hit points equal to their hit die, to have them respawn at full hit points change that to TRUE. I am sorry for any confusion.
Version 3.
The update in this version is a function to set the hit points restored to the player. This call takes two parameters, the respawning object and a boolean (true or false). If set to true then it will restore the maximum hit points to the player. If set to false it will restore a number of hit points equal to the player's hit dice. Feel free to alter that function if you like.
I have also included a simple test module. It consists of three traps, two are lethal the other is just a gas trap. I wouldn't test it with a high level character.
One correction. The name of the variable my scripts look for on the module and or the areas is sRespawnTag. Obviously a string type variable that contains the tag of the way point where you want the player to spawn.
Here is a second version. I modified the mod_onplayerrespawn file. Basically it breaks down getting key variables by using function calls. I belive this will make it easier for builders and scripters to modify.
You can modify the functions, or just not use them and manually set the values where needed. I just think it adds a level of flexibility.
Also by default it will look for an area level variable named sRespawnTag to get the tag of the respawn waypoint. If that is blank it will look for the sRespawnTag on the module, again the tag of the respawn waypoint. This will allow you to easily set a different respawn point for each area and still keep a default fall back plan just in case you forget to put one on an area.
Posted by erikbreau at 2009-09-21 05:59:29 Voted 10.00 on 09/21/09
I implemented this (with a little help form Zheldon) into my future PW: Europa. My test players are raving about it and I am very impressed with it's manageability. Easy to use, easy to modify, and effective. Deserve the 10!
**UPDATE 8/28/2009**
It was brought to my attention that in version 3, at line 35 I have it as int nHPHealed = GetHPHealed(oRespawner, FALSE); This will have the player respawn with hit points equal to their hit die, to have them respawn at full hit points change that to TRUE. I am sorry for any confusion.
It looks like you are trying to manually set the tag of the respawn waypoint. To do it that way you will want to comment out the function calls that try to obtain the waypoint string from module or area level variables.
string sTag = "LIMB";
object oArea = GetArea(oDead);
//Get tag based on area level variable
//sTag = GetLocalString(oArea,"sRespawnTag");
//Check for tag and default to a module level variable
if(sTag == "LIMB")
{
//sTag = GetLocalString(GetModule(),"sRespawnTag");
If you were using the second version of the script I made it easier in the mod_onplayerrespawn file to do the manual setting, here is part of that file.
void main()
{
//Create initial variables
object oRespawner = GetRespawningPlayer();
object oArea = GetArea(oRespawner);
string sDestTag = GetDestinationTag(oRespawner);
object oRespawnPoint = GetRespawnPoint(sDestTag, oRespawner);
location lDeathSpot = GetLocation GetLastRespawnButtonPresser());
location lRespawnPoint;
What you would want to do is modify the sDestTag from this
string sDestTag = GetDestinationTag(oRespawner);
to this
string sDestTag = "LIMB";
Of course all this is assuming you are trying to manually set a respawn point where players will always respawn. If this is not the case let me know and I will help you further.
Posted by fanidhol at 2008-09-20 00:32:57 Voted 10.00 on 09/21/08
this does not work, the pj stays or he died, I put TAG here:
string sTag = "LIMB";
object oArea = GetArea(oDead);
//Get tag based on area level variable
sTag = GetLocalString(oArea,"sRespawnTag");
//Check for tag and default to a module level variable
if(sTag == "LIMB")
{
sTag = GetLocalString(GetModule(),"sRespawnTag");
Thank�s
(I am French, be able to speak simply)
Posted by Timidon at 2008-08-27 12:51:38 Voted 9.00 on 08/27/08
Worked right off the bat. Thanks, I was having problem with the death scripts. Fixed it up real nice. A must have for the new to NWN2 modding.
Yes, that would be great. I figured it would have to be an "on enter", but since I have very little scripting knowledge, I wasn't going to make any suggestions.
Thanks for your quick response, by the way. I'm not used to that, so I didn't check back right away.
But anyway, that sounds perfect, and I look forward to seeing the results.
It seems it would be possible until you think about how NWN2 looks at the waypoints. The system does not have a way of rating distance to a waypoint outside of your current area.
With that said it could be done but not perfectly. What I am getting at is basing the respawn points on the area of death. You can use an on enter event for the area to set the variable, or ideally set the variable on an area object.
Since you offered, I would like to see a system that has multiple respawn points and respawns a player to the closest one upon death. Can you help with that, Zheldon? Thanks, in advance, for any help.
Posted by Evliss at 2008-04-03 07:31:53 Voted 9.50 on 04/01/08
Ah... there we go. Thanks!
Yeah, I've seen mods where you go to different places based on your alignment, but I'm not doing that. This works good for me.
Yes, instead of using the one for getnearestobjectbytag use the getwaypointbytag. One is commented out and the other uncommented out. I left those in as examples.
Of course you would need to setup something a little more elaborate for multiple respawn points. I can probably help you out with that as well if you need it.
Posted by Evliss at 2008-04-02 19:30:32 Voted 9.50 on 04/01/08
Hmmm... it seems to me that player teleport works only if the waypoint is in the same area. Any ideas on how to correct this?
Zhjaeve � Know that I must begin every sentence with the word �Know�. Know that everything I say must be known. Know that it is important that you know this.
Posted by Evliss at 2008-04-01 20:32:22 Voted 9.50 on 04/01/08
Just what I was looking for. Thanks!
You must be Logged In to post comments in this section.
10 - A Masterpiece, Genuinely Groundbreaking 9 - Outstanding, a Must Have 8 - Excellent, Recommended to Anyone 7 - Very Good, Deserves a Look 6 - Good, Qualified Recommendation 5 - Fair, Solid yet Unremarkable 4 - Some Merit, Requires Improvements 3 - Poor Execution, Potential Unrealized 2 - Very Little Appeal 1 - Not Recommended to Anyone