HoS_PRC8/_mod/_module/nss/temp_death.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

218 lines
9.6 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Death Script
//:: NW_O0_DEATH.NSS
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
This script handles the default behavior
that occurs when a player dies.
*/
//:://////////////////////////////////////////////
//:: Created By: Brent Knowles
//:: Created On: November 6, 2001
//:://////////////////////////////////////////////
// modified 06/16/2004 Jeremy Greene
// modified 08/20/2004 Deva Winblood
// modified 08/26/2004 Deva Winblood - Thanks to Timendainum and Wrabbit of The
// Known World (PW) for pinning down the
// cause of an obscure crash and the solution
// to fix it.
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);
//Search for negative effects
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)
{
//Remove effect if it is negative.
RemoveEffect(oPlayer, eBad);
}
eBad = GetNextEffect(oPlayer);
}
//Fire cast spell at event for the specified target
SignalEvent(oPlayer, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPlayer);
}
void fnForcedJump(location lLoc)
{ // PURPOSE: Jump to location
object oMe=OBJECT_SELF;
if (GetAreaFromLocation(lLoc)!=GetArea(oMe)||GetDistanceBetweenLocations(lLoc,GetLocation(oMe))>4.0)
{ // jump
AssignCommand(oMe,ClearAllActions(TRUE));
AssignCommand(oMe,JumpToLocation(lLoc));
DelayCommand(0.2,fnForcedJump(lLoc));
} // jump
else
{ // plot flag off
SetPlotFlag(oMe,FALSE);
} // plot flag off
} // fnForcedJump()
void main()
{
object oPlayer = GetLastPlayerDied();
object oArea=GetArea(oPlayer);
object oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPlayer);
string sTag;
string sOpposite;
object oOther;
effect eEffect;
int nC;
int nLevel=GetLevelByPosition(1,oPlayer)+GetLevelByPosition(2,oPlayer)+GetLevelByPosition(3,oPlayer);
if (!GetIsPC(oPlayer)) return; // protect game from invalid PC crash
if (!GetIsObjectValid(oArea)) // protect game from invalid PC crash
{
SendMessageToPC(oPlayer,"You do not appear to have the proper HAK or TLK setup!! If you do then something else is seriously wrong and you should report it.");
DelayCommand(2.5, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));
DelayCommand(30.0,BootPC(oPlayer));
return;
}
if (GetIsObjectValid(oItem)&&GetTag(oItem)=="rts_it_op20")
{ // has soul harvest
nC=GetLocalInt(oItem,"nStoredCR");
nLevel=nLevel*2;
if (nC>=nLevel)
{ // has enough
eEffect=EffectResurrection();
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer);
nC=nC-nLevel;
nLevel=GetMaxHitPoints(oPlayer)-GetCurrentHitPoints(oPlayer);
nLevel=nLevel/5;
if (nLevel>0)
{ // is damaged
if (nC>nLevel)
{ // have plenty of charges
nC=nC-nLevel;
eEffect=EffectHeal(GetMaxHitPoints(oPlayer));
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer);
} // have plenty of charges
else
{ // not enough charges
eEffect=EffectHeal(nC*5);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer);
nC=0;
} // not enough charges
} // is damaged
SetLocalInt(oItem,"nStoredCR",nC);
eEffect=EffectVisualEffect(VFX_IMP_RAISE_DEAD);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer);
return;
} // has enough
} // has soul harvest
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oPlayer);
nC=FALSE;
sTag=GetTag(oItem);
if (sTag=="rts_it_sra"||sTag=="rts_it_srb") nC=TRUE;
if (!nC)
{ // check left ring
oItem=GetItemInSlot(INVENTORY_SLOT_LEFTRING,oPlayer);
sTag=GetTag(oItem);
if (sTag=="rts_it_sra"||sTag=="rts_it_srb") nC=TRUE;
} // check left ring
if (nC)
{ // wearing a symbiotic ring
nC=GetCurrentHitPoints(oPlayer);
sOpposite="rts_it_srb";
if (sTag=="rts_it_srb") sOpposite="rts_it_sra";
nLevel=FALSE;
oOther=OBJECT_INVALID;
oItem=GetObjectByTag(sOpposite);
if (GetIsObjectValid(oItem))
{ // opposite ring exists
oOther=GetItemPossessor(oItem);
if (GetIsObjectValid(oOther))
{ // someone has the ring
if (GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oOther)==oItem||GetItemInSlot(INVENTORY_SLOT_LEFTRING,oOther)==oItem)
{ // other ring is being worn - symbiosis is in play
if (!GetIsDead(oOther))
{ // other is not dead
nLevel=GetCurrentHitPoints(oOther);
SendMessageToPC(oOther,"Dying HitPoints:"+IntToString(nC)+" Living HitPoints:"+IntToString(nLevel));
SendMessageToPC(oPlayer,"Dying HitPoints:"+IntToString(nC)+" Living HitPoints:"+IntToString(nLevel));
SendMessageToPC(oOther,"You feel a surge of sucking your life force into the symbiotic ring that you wear.");
if ((nLevel-abs(nC))>0)
{ // can cure
nLevel=1+abs(nC);
eEffect=EffectResurrection();
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer);
SendMessageToPC(oPlayer,"You feel a surge of energy from the symbiotic ring. It is forcing life back into you.");
eEffect=EffectDamage(nLevel);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oOther);
return;
} // can cure
else
{ // both die
eEffect=EffectDamage(nLevel);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oOther);
} // both die
} // other is not dead
} // other ring is being worn - symbiosis is in play
} // someone has the ring
} // opposite ring exists
} // wearing a symbiotic ring
oOther=GetLocalObject(oPlayer,"oClone");
if (GetIsObjectValid(oOther))
{ // has a clone
eEffect=EffectResurrection();
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer);
eEffect=EffectHeal(GetMaxHitPoints(oPlayer));
ApplyEffectToObject(DURATION_TYPE_INSTANT,eEffect,oPlayer);
SetPlotFlag(oPlayer,TRUE);
AssignCommand(oPlayer,fnForcedJump(GetLocation(oOther)));
DelayCommand(0.1,DestroyObject(oOther));
SendMessageToPC(oPlayer,"You jump back and inhabit the simulacrum body and do not die!");
return;
} // has a clone
DeleteLocalInt(oPlayer,"nFiendDeath");
ExecuteScript("rts_save_player",oPlayer);
if (GetLocalInt(oPlayer,"bWAZOOASTRAL")!=TRUE)
{ // not astral projecting
if (GetLocalInt(oPlayer,"nIsVampire")==TRUE) ExecuteScript("vamp_death",oPlayer);
else
{ // not vampire
ExecuteScript("rts_pc_death",oPlayer);
// * make friendly to Each of the 3 common factions
AssignCommand(oPlayer, ClearAllActions());
// * Note: waiting for Sophia to make SetStandardFactionReptuation to clear all personal reputation
if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer) <= 10)
{
SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer) <= 10)
{
SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
}
if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer) <= 10)
{
SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
}
} // not vampire
} // not astral projecting
else
{ // astral projecting
ExecuteScript("wazoo_s0_astret",oPlayer);
} // astral projecting
}