Conditional respawn
From NWNWiki
This conditional respawn script allows a module to temporarily disable respawning for particular player characters (PCs). This is accomplished by setting a local integer called RespawnDenied to a nonzero value on the PC in question. The local integer could be set, for example, in the OnEnter event for an area that is considered to be too distant from the respawn point, and cleared (set to 0) when exiting such an area. A PC that has this integer set will still be told that respawning is an option, but if that option is chosen, the PC will simply be left as a selectable, but not raisable, corpse.
This script is intended to be the OnPlayerRespawn event handler for a module.
[edit] Notes
- This script does not apply experience point and gold piece penalties. If these are desired, they should be copied from the default script (
nw_o0_respawn). - The respawn location is determined by the variable
sDestTag; the value of this variable is the tag of the object (probably a waypoint) that marks the respawn point. This likely should be changed depending on the module in which this script is used. - This was originally posted in the BioWare forums by Capn Gherkin.
[edit] The script
void main()
{
object oRespawner = GetLastRespawnButtonPresser();
// Check the respawn flag. Nonzero values deny respawning.
if ( GetLocalInt(oRespawner, "RespawnDenied") == FALSE )
{
string sDestTag = "NW_DEATH_TEMPLE"; // The tag of the respawn point.
// Raise and heal the PC.
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oRespawner);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(GetMaxHitPoints(oRespawner)), oRespawner);
// Move the PC to the respawn point.
AssignCommand(oRespawner, JumpToLocation(GetLocation(GetObjectByTag(sDestTag))));
}
else
{
// Respawning has been denied, so stop the respawn and leave a corpse.
AssignCommand(oRespawner, SetIsDestroyable(FALSE, FALSE, TRUE));
FloatingTextStringOnCreature("Respawning is no longer an option.", oRespawner, FALSE);
}
}
