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

133 lines
4.7 KiB
Plaintext
Raw Blame History

#include"aps_include"
//////////////////////////////////////
///// Created by: bushido/////////////
//////////////////////////////////////
//////////////////////////////////////
// AdjustPlayerStats()////////////////
// Developed by: Wouter Dhondt////////
// Slightly modified by: bushido//////
//////////////////////////////////////
// Adjust Player Stats function///////
// Edited For Database By Knowj///////
//////////////////////////////////////
void AdjustPlayerStats()
{
object oDied = GetLastPlayerDied();
object oKiller = GetLastHostileActor(oDied);
if (!GetIsDM(oKiller) || !GetIsDM(oDied) )
{
// Increment or set the death variable
int iDied = GetPersistentInt(oDied, "iDied", "score");
++iDied;
SetPersistentInt(oDied, "iDied", iDied, 0, "score");
// Is this object a PC?
if (GetIsPC(oKiller) == TRUE)
{
// Increment or set the killer var
int iKilled = GetPersistentInt(oKiller, "iKilled", "score");
++iKilled;
SetPersistentInt(oKiller, "iKilled", iKilled, 0, "score");
}
}
}
// Raise OnDeath function
void Raise(object oPlayer)
{
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));
}
// 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))
{
Raise(oPlayer);
AssignCommand(oPlayer, ClearAllActions());
AssignCommand(oPlayer, ActionSpeakString(waiting, TALKVOLUME_TALK));
DelayCommand(0.5, AssignCommand(oPlayer, JumpToObject(GetWaypointByTag("w_main"))));
}
}
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());
/*
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 = GetPersistentInt(oVictor, "iKilled", "score");
string sKilled = GetName(oPlayer);
//Send Message to all PC's
sKilled += "<c <20> > was slain by ";
sKilled += GetName(oVictor);
sKilled += "<c <20> >\n";
sKilled += GetName(oVictor);
sKilled += "<c <20> > has ";
sKilled += IntToString(nVictims);
sKilled += "<c <20> > kills.";
while (GetIsPC(oPC) == TRUE)
{
SendMessageToPC(oPC, sKilled);
oPC = GetNextPC();
}
//Respawn if noone rez'd The Player
DelayCommand(8.0, Respawn(oPlayer));
}