Script Names: dl_on_death & dl_respawn &
teleport_respawn
What they do: Track PC Death Location and respawn in different location with
ability to be sent back to spot of death
I have stolen from other scripts here, including some from the basic module.
The dl_respawn script was written by a community member here with some minor
mods from me.
OnDeath script, place in module OnDeath event:
NWScript:
void Raise(object oPlayer)
{
effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);
effect eBad = GetFirstEffect(oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPlayer)), oPlayer);
while(GetIsEffectValid(eBad))
{
if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)
{
RemoveEffect(oPlayer, eBad);
}
eBad = GetNextEffect(oPlayer);
}
SignalEvent(oPlayer, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPlayer);
}
void main()
{
object oPlayer = GetLastPlayerDied();
location lLoc = GetLocation(oPlayer);
SetLocalLocation(oPlayer, "DL_L_DEATHLOC", lLoc);
AssignCommand(oPlayer, ClearAllActions());
if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10);
SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10);
SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer) <= 10)
{ SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10);
SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
}
DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));
}
OnRespawn script added to module OnRespawn event:
Added code to respawn somewhere other than where PC died
Original code taken from database on
nwn.lyoness.com
NWScript: #include "nw_i0_plot"
void main()
{
object oDead = GetLastRespawnButtonPresser();
location lLoc = GetLocation(GetObjectByTag("IOTLH_RESPAWN"));
int nXP = GetXP(oDead);
int nPenalty = 50 * GetHitDice(oDead);
int nHD = GetHitDice(oDead);
int nMin = ((nHD * (nHD - 1)) / 2) * 1000;
int nNewXP = nXP - nPenalty;
if (nNewXP < nMin)
nNewXP = nMin;
SetXP(oDead, nNewXP);
int nGoldToTake = FloatToInt(0.10 * GetGold(oDead));
if (nGoldToTake > 10000)
{
nGoldToTake = 10000;
}
AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE));
DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE));
DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oDead);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oDead))
, oDead);
AssignCommand(oDead,ActionJumpToLocation(lLoc));
}
SendtoDeathLocation script placed in conversation file with NPC:
NWScript: #include "nw_i0_generic"
#include "nw_o2_coninclude"
void main()
{
object oPC = GetPCSpeaker();
location lLoc = GetLocalLocation(oPC, "DL_L_DEATHLOC");
AssignCommand(oPC, ActionJumpToLocation(lLoc));
}
I hope that this helps someone. I've tested it and it works like a charm.
Some modifications, you could put a series of if-then-else statements in to
change the respawn point depending on the area that you died in if you
wanted to have different respawn points for different areas.
[ Edited By Ranthalas: Sunday, 30 June 05:58AM (GMT) ]
|