137 lines
3.9 KiB
Plaintext
137 lines
3.9 KiB
Plaintext
//
|
|
#include "anph_inc"
|
|
#include "eye_dm_inc"
|
|
#include "faction_inc"
|
|
#include "sql_inc"
|
|
|
|
void DestroyDeathcorpse (object oPC)
|
|
{
|
|
string sCDK=GetPCPublicCDKey (oPC);
|
|
string sName=GetName(oPC);
|
|
string sID=sName+sCDK;
|
|
object oDeathCorpse;
|
|
object oDeadMan;
|
|
|
|
object oMod = GetModule();
|
|
oDeathCorpse = GetLocalObject (oMod,"DeathCorpse"+sID);
|
|
DestroyObject (oDeathCorpse);
|
|
oDeadMan = GetLocalObject (oMod,"PlayerCorpse"+sID);
|
|
DestroyObject (oDeadMan);
|
|
}
|
|
|
|
|
|
int CalculateXPLoss (object oPC, object oKiller, int PvPDeath = FALSE)
|
|
{
|
|
int level = util_GetLevel(oPC);
|
|
float f = SQLExecAndFetchFloat("SELECT PenaltyDeath FROM "+SQL_TABLE_XPDATA+" WHERE Level="+IntToString(level));
|
|
return FloatToInt(f * GetXP(oPC) * (PvPDeath ? 1.0 : 0.5));
|
|
}
|
|
|
|
void doXPLoss (object oPC, object oKiller, int nBurned=FALSE, object oBurner = OBJECT_INVALID, int nScalped = FALSE, int PvPDeath = FALSE)
|
|
{
|
|
int iLvlStart;
|
|
int iXPLoss;
|
|
int iCurrentXP;
|
|
int iNewXP;
|
|
int iLvl;
|
|
int iCurrentXPBurner;
|
|
int iNewXPBurner;
|
|
string sFactionPC;
|
|
string sFactionBurner;
|
|
|
|
// Addon to check if player has deathward item
|
|
object deathward;
|
|
if (GetIsObjectValid(deathward = GetItemPossessedBy(oPC, "deathward")))
|
|
{
|
|
DestroyObject(deathward);
|
|
return;
|
|
}
|
|
|
|
///////////////////////////////////////////////
|
|
|
|
iLvl = AnphGetPlayerLevel (oPC);
|
|
iCurrentXP = GetXP (oPC);
|
|
|
|
// make xp-loss dependant on burning
|
|
if (nBurned)
|
|
{
|
|
sFactionPC = AnphGetPlayerTeam(oPC);
|
|
sFactionBurner = AnphGetPlayerTeam(oBurner);
|
|
iCurrentXPBurner = GetXP(oBurner);
|
|
if (sFactionPC == sFactionBurner)
|
|
{
|
|
iXPLoss = iLvl * iLvl * 10 + 1000;
|
|
iNewXPBurner = iCurrentXPBurner - iXPLoss;
|
|
if (iNewXPBurner < 1)
|
|
{
|
|
iNewXPBurner = 1;
|
|
}
|
|
SendMessageToPC(oBurner, "*** You lost experience for burning a fellow " + sFactionPC + "***");
|
|
SetXP (oBurner, iNewXPBurner);
|
|
}
|
|
else
|
|
{
|
|
SendMessageToPC(oPC, "You were burned by the enemy.");
|
|
iXPLoss = iLvl * iLvl + 50;
|
|
}
|
|
}
|
|
else if (nScalped)
|
|
{
|
|
sFactionPC = AnphGetPlayerTeam(oPC);
|
|
sFactionBurner = AnphGetPlayerTeam(oBurner);
|
|
iCurrentXPBurner = GetXP(oBurner);
|
|
if (sFactionPC == sFactionBurner)
|
|
{
|
|
iXPLoss = iLvl * iLvl + 50;
|
|
iNewXPBurner = iCurrentXPBurner - iXPLoss;
|
|
if (iNewXPBurner < 1)
|
|
{
|
|
iNewXPBurner = 1;
|
|
}
|
|
SendMessageToPC(oBurner, "*** You lost experience for scalping a fellow " + sFactionPC + "***");
|
|
SetXP (oBurner, iNewXPBurner);
|
|
}
|
|
else
|
|
{
|
|
SendMessageToPC(oPC, "You were scalped by the enemy.");
|
|
iXPLoss = iLvl * iLvl + 50;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
iXPLoss = CalculateXPLoss (oPC, oKiller, PvPDeath);
|
|
}
|
|
|
|
iXPLoss = iXPLoss + Random (10 * iLvl);
|
|
|
|
iNewXP = iCurrentXP - iXPLoss;
|
|
|
|
if (iNewXP < 1)
|
|
iNewXP = 1;
|
|
|
|
string sMessage = "*** Player " + GetName(oPC) + " lost " + IntToString(iXPLoss) + " exp ***";
|
|
WriteTimestampedLogEntry(sMessage);
|
|
SendMessageToAllDMs(sMessage);
|
|
//SendMessageToSubscribers(SUBSCRIPTION_04, "*** Player " + GetName(oPC) + " lost " + IntToString(iXPLoss) + " exp ***");
|
|
|
|
SetXP (oPC, iNewXP);
|
|
}
|
|
|
|
|
|
void AnphRez (object oPC, int nBurned=FALSE, object oBurner = OBJECT_INVALID, int nScalped = FALSE)
|
|
{
|
|
ApplyEffectToObject (DURATION_TYPE_INSTANT, EffectHeal(
|
|
GetMaxHitPoints(oPC)), oPC);
|
|
|
|
doXPLoss (oPC, oBurner, nBurned, oBurner, nScalped);
|
|
|
|
DestroyDeathcorpse (oPC);
|
|
|
|
SetLocalInt (oPC, "LOGINDEATH", 0);
|
|
|
|
location lJump = fctn_GetFactionStartingLocation(fctn_GetFaction(oPC));
|
|
if (!GetIsObjectValid(GetAreaFromLocation(lJump)))
|
|
dbg_ReportBug("No starting location found for resurrection", oPC);
|
|
AssignCommand (oPC, JumpToLocation(lJump));
|
|
}
|