Files
HeroesStone_PRC8/_module/nss/js_util_onrespwn.nss
Jaysyn904 1eefc84201 Initial Commit
Initial Commit.
2025-09-14 15:40:46 -04:00

40 lines
998 B
Plaintext

#include "NW_i0_plot"
int XPForLevel(int level)
{
if (level > 0)
return ((level * (level - 1)) / 2) * 1000;
else
return 0;
}
void main()
{
object oPlayer = GetLastRespawnButtonPresser();
if (!GetIsObjectValid(oPlayer))
return;
effect eRes = EffectResurrection();
ApplyEffectToObject(DURATION_TYPE_INSTANT, eRes, oPlayer);
effect eHeal = EffectHeal(GetMaxHitPoints(oPlayer));
ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oPlayer);
RemoveEffects(oPlayer);
SetLocalInt(oPlayer, "BLEED_STATUS", 0);
// Penalty: lose 1 level (but don't fall below 1st level/0 xp)
int iCurrentXP = GetXP(oPlayer);
int iExtraXP = iCurrentXP - XPForLevel(GetHitDice(oPlayer));
int iNewXP = XPForLevel(GetHitDice(oPlayer) - 1) + iExtraXP;
if (iNewXP < 0)
iNewXP = 0;
SetXP(oPlayer, iNewXP);
AssignCommand(oPlayer, ClearAllActions());
AssignCommand(oPlayer, ActionJumpToLocation(GetStartingLocation()));
}