Conditional respawn

What it Does
This is a little script which I have found very useful in my mod. I wanted players to respawn in a freindly temple for most of the mod, but later on, I want to remove this ability (when tthe players are in an area outside the temple's influence).

The first thing to do is to use a script to set a variable, ("vRespawnok"in my particular script)to the value 1 (or any value other than 0), somewhwere in the are that you don't want players to be able to respawn You can use the SetLocalInt command,and place the script in the OnEnter section of the area properties, or attach it to a trigger, or even a useable object; a cursed altar perhaps?

The Script
Place the following script in the OnPlayerRespawn section of the module properties

void main {       object oRespawner = GetLastRespawnButtonPresser ; //check to make sure that respawn variable has been not been set to deny. int iResp=GetLocalInt(oRespawner, "vRespawnok"); if (iResp == 0) {       ApplyEffectToObject (DURATION_TYPE_INSTANT, EffectResurrection,oRespawner); ApplyEffectToObject (DURATION_TYPE_INSTANT,EffectHeal (GetMaxHitPoints (oRespawner)), oRespawner); string sDestTag = "NW_DEATH_TEMPLE"; object oSpawnPoint = GetObjectByTag(sDestTag); AssignCommand(oRespawner,JumpToLocation(GetLocation(oSpawnPoint))); }     else { // if respawn variable is set to 1 (or anything except 0), stop respawn & leave corpse. SetIsDestroyable (FALSE, FALSE, TRUE); } }

Foot Note
This checks for the value of the variable; if it is anything other than 0, then the player will not respawn; just their corpse will lie there dead, but not disappear. On respawn, it makes the player reappear in the temple (there are no XP penalties here, but you can copy and paste these lines from the default nwn script), at the waypoint named "NW_DEATH_TEMPLE".

This was a useful way for me to do things (and I'm not a scripting guru by any means!), because you can easily have another script attached to somethin, or in a conversation to reset the respawn variable back to 0 to allow respawning again. (such as talking to a priest to remove the effects of the cursed altar, for instance?) Also, it is not hard to modify this script to allow for different spawn points according to the value of the variable, by using further if/else statements, or switch/case statements, for instance.