73 lines
1.8 KiB
Plaintext
73 lines
1.8 KiB
Plaintext
//::
|
|
//:: lvl_drain_onhit.nss
|
|
//::
|
|
//:: Modified by: Jaysyn 20221215
|
|
//::
|
|
|
|
#include "NW_I0_GENERIC"
|
|
#include "nw_i0_spells"
|
|
#include "nw_i0_plot"
|
|
#include "prc_inc_spells"
|
|
|
|
|
|
void DoLevelDrain(object oTarget, object oCaster)
|
|
{
|
|
// Setup oCaster's healing
|
|
effect eDrain = EffectTemporaryHitpoints(5);
|
|
eDrain = ExtraordinaryEffect(eDrain);
|
|
effect eVis1 = EffectVisualEffect(VFX_IMP_HEALING_L);
|
|
|
|
// Setup Level Drain
|
|
effect eVis2 = EffectVisualEffect(VFX_IMP_NEGATIVE_ENERGY);
|
|
effect eNeg;
|
|
|
|
if (GetResRef(oCaster) == "RA_SPECTRE001")
|
|
{
|
|
eNeg = EffectNegativeLevel(2);
|
|
}
|
|
else
|
|
{
|
|
eNeg = EffectNegativeLevel(1);
|
|
}
|
|
|
|
eNeg = SupernaturalEffect(eNeg);
|
|
|
|
// Drain levels from oTarget
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eNeg, oTarget, HoursToSeconds(24));
|
|
// Apply Temp HP to oCaster
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis1, oCaster);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDrain, oCaster, HoursToSeconds(1));
|
|
|
|
}
|
|
|
|
|
|
void main()
|
|
{
|
|
//:: Declare major variables
|
|
object oCaster = OBJECT_SELF ; //:: Where the spell came from
|
|
object oTarget = PRCGetSpellTargetObject(); //:: What the spell is aimed at
|
|
|
|
int nRaceType = MyPRCGetRacialType(oTarget);
|
|
int nChaMod = GetAbilityModifier(5, oCaster);
|
|
int nMobHD = GetHitDice(oCaster);
|
|
int nDC = 10 + (nMobHD / 2) + nChaMod;
|
|
int nSave = FortitudeSave( oTarget, nDC );
|
|
|
|
//:: Check for Negative Level Immunity
|
|
if ( GetIsImmune(oTarget, IMMUNITY_TYPE_NEGATIVE_LEVEL) )
|
|
{
|
|
SendMessageToPC(oTarget, "Immune to level drain.");
|
|
return;
|
|
}
|
|
|
|
//:: Saving throw
|
|
if ( nSave )
|
|
return;
|
|
|
|
//:: if you got this far, you're taking negative levels.
|
|
|
|
DelayCommand(0.1, DoLevelDrain(oTarget,oCaster));
|
|
|
|
}
|
|
|