PoA_PRC8/_module/nss/pcdeath.nss
Jaysyn904 8d97886c3f Changed folder name.
Changed folder name.
2022-10-07 21:08:37 -04:00

318 lines
9.9 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//This script is part of Multple Scripters Scripts
//Merged, Compiled, and Modified by Guile 1/11/08
#include "nw_i0_plot"
#include "x2_inc_compon"
//#include "ld_inc_gwshp"
effect eEffect;
object oTarget;
void AdjustPlayerStats()
{
// Get the last player that died
object oDied = GetLastPlayerDied();
// Increment or set the death variable
int iDied = GetLocalInt (oDied, "iDied");
++iDied;
SetLocalInt(oDied, "iDied", iDied);
object oKiller = GetLastHostileActor(oDied);
// Is this object a PC?
if (GetIsPC(oKiller) == TRUE)
{
// Increment or set the killer var
int iKilled = GetLocalInt (oKiller,"iKilled");
++iKilled;
SetLocalInt(oKiller, "iKilled", iKilled);
}
}
// Raise OnDeath function
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);
}
// Respawn/Teleporter OnDeath function
// Optionally you can create the waypoints described to send the dead player
// to their respective locations.
void Respawn(object oPlayer)
{
string waiting = "<c <20> >The gods show you favor, your life is restored.";
if (GetIsDead(oPlayer))
{
location lTarget;
object oPC = GetLastPlayerDied();
if (!GetIsPC(oPC)) return;
if (GetItemPossessedBy(oPC, "arenatoken")!= OBJECT_INVALID)
{
object oTarget = GetWaypointByTag("arenaspawnpt");
effect eTeleport = EffectVisualEffect(VFX_FNF_HOWL_WAR_CRY);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eTeleport, oPlayer);
Raise(oPlayer);
AssignCommand(oPlayer, ActionSpeakString(waiting, TALKVOLUME_TALK));
DelayCommand(0.5, AssignCommand(oPlayer, JumpToObject(oTarget)));
return;
}
else
{
object oTarget;
oTarget = oPC;
CreateItemOnObject("death", oPC,1);
}
}
}
void main()
{
//Count up the kills and deaths
AdjustPlayerStats();
//Standard Ondeath stuff
object oPlayer = GetLastPlayerDied();
// * make friendly to Each of the 3 common factions
AssignCommand(oPlayer, ClearAllActions());
//Shifter stored info cleared
// ClearShifterStored(oPlayer);
// * 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);
}
//Begin kill/death messages
object oVictor = GetLastHostileActor(oPlayer);
object oPC = GetFirstPC();
int count = 0;
int nVictims = GetLocalInt(oVictor, "iKilled");
string sKilled = GetName(oPlayer);
//Send Message to all PC's
sKilled += "<c<> > was slain by ";
sKilled += GetName(oVictor);
sKilled += "<c<> >\n";
sKilled += GetName(oVictor);
sKilled += "<c<> > has ";
sKilled += IntToString(nVictims);
sKilled += "<c<> > kills.";
while (GetIsPC(oPC) == TRUE)
{
SendMessageToPC(oPC, sKilled);
oPC = GetNextPC();
}
oPC = GetLastPlayerDied();
location lSelf = GetLocation(oPC);
effect eVis = EffectVisualEffect(234);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, lSelf);
//This death token prevents logging to cheat death :)
//Other scripts check to see if they have the token.
CreateItemOnObject("death", oPlayer, 1);
if (GetItemPossessedBy(oPC, "immotoken")!= OBJECT_INVALID)
{
object oTarget;
oTarget = oPC;
int nInt;
nInt = GetObjectType(oTarget);
if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_PARALYZED), oTarget);
else ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_PARALYZED), GetLocation(oTarget));
effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);
effect eBad = GetFirstEffect(oTarget);
DelayCommand(120.0,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oTarget));
DelayCommand(120.5,ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oTarget)), oTarget));
object oItem;
oItem = GetFirstItemInInventory(oPC);
while (GetIsObjectValid(oItem))
{
if (GetTag(oItem)=="death") DestroyObject(oItem);
oItem = GetNextItemInInventory(oPC);
}
return;
}
//Since they are not immo, give them the chance to respawn.
DelayCommand(4.0, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));
//After PC Dies, start PK script, though the PC will rez fast if effy killed
{
object oDead = GetLastPlayerDied();
object oKiller = GetLastHostileActor(oDead);
if(GetIsPC(GetMaster(oKiller)))
{
oKiller = GetMaster(oKiller);
}
if(!GetIsPC(oKiller))return;
//define variables
int kLvl = GetHitDice(oKiller);
int pLvl = GetHitDice(oDead);
int dLvl = kLvl - pLvl;
int aLvl = pLvl - kLvl;
effect eKill = EffectDeath(TRUE);
effect eRaise = EffectResurrection();
effect eVis = EffectVisualEffect(VFX_FNF_MYSTICAL_EXPLOSION);
effect eEffect;
eEffect = EffectHeal(GetMaxHitPoints(oPC));
if(dLvl >= 7)
{
object oItem;
oItem = GetFirstItemInInventory(oDead);
while (GetIsObjectValid(oItem))
{
if (GetTag(oItem)=="death") DestroyObject(oItem);
oItem = GetNextItemInInventory(oDead);
}
//Raise the victim of the high level killer
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oDead);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eRaise,oDead);
//Kill the offender & take xp/gold (uncomment line below to use)
//ApplyEffectToObject(DURATION_TYPE_INSTANT,eKill,oKiller);
SetXP(oKiller,GetXP(oKiller)-200);
AssignCommand(oKiller,TakeGoldFromCreature(2000,oKiller,TRUE));
AssignCommand(oKiller, ClearAllActions());
AssignCommand(oKiller, ActionSpeakString("<c<>> I am a newbie killer!!!", TALKVOLUME_SHOUT));
Raise(oPlayer);
}
else if(aLvl >= 1)
{
if (aLvl >=6)
{
int nXP = 400;
int nGold = 8000;
GiveXPToCreature(oKiller,nXP);
GiveGoldToCreature(oKiller,nGold);
}
//award xp/gold by level difference, if it's 1 or greater
else if (aLvl <=5)
{
int nXP = aLvl * 80;
int nGold = aLvl * 800;
GiveXPToCreature(oKiller,nXP);
GiveGoldToCreature(oKiller,nGold);
AssignCommand(oDead, ActionSpeakString("I got pwned!!", TALKVOLUME_SHOUT));
}
}
//Otherwise just give a base xp/gold reward.
else
{
//award xp/gold by level difference + standard PK Award 150xp/2000gp
int nXP = 200;
int nGold = 4000;
GiveXPToCreature(oKiller,nXP);
GiveGoldToCreature(oKiller,nGold);
AssignCommand(oDead, ActionSpeakString("I got pwned!!", TALKVOLUME_SHOUT));
}
}
//Rez & Teleport Player to the Guild if they have a guild stone.
//Optional (You don't have to hand these stones out.)
if (GetItemPossessedBy(oPC, "guildstone")== OBJECT_INVALID)
return;
{
object oTarget;
location lTarget;
effect eBad = GetFirstEffect(oPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPC)), oPC);
oTarget = GetWaypointByTag("guildway");
lTarget = GetLocation(oTarget);
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
//This option allows you to create something that can send players back
//to the place where they last died, open up the "pcdeathport" script
SetLocalLocation(oPC, "dth_stored_loc", GetLocation(oPC));
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, ActionJumpToLocation(lTarget));
}
}