72 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
//::///////////////////////////////////////////////
 | 
						|
//:: [Harm]
 | 
						|
//:: [NW_S0_Harm.nss]
 | 
						|
//:: Copyright (c) 2000 Bioware Corp.
 | 
						|
//:://////////////////////////////////////////////
 | 
						|
//:: Reduces target to 1d4 HP on successful touch
 | 
						|
//:: attack.  If the target is undead it is healed.
 | 
						|
//:://////////////////////////////////////////////
 | 
						|
//:: Created By: Keith Soleski
 | 
						|
//:: Created On: Jan 18, 2001
 | 
						|
//:://////////////////////////////////////////////
 | 
						|
//:: VFX Pass By: Preston W, On: June 20, 2001
 | 
						|
//:: Update Pass By: Preston W, On: Aug 1, 2001
 | 
						|
 | 
						|
#include "NW_I0_SPELLS"
 | 
						|
void main()
 | 
						|
{
 | 
						|
    //Declare major variables
 | 
						|
    object oTarget = GetSpellTargetObject();
 | 
						|
    int nDamage, nHeal;
 | 
						|
    int nCasterHD = GetHitDice(OBJECT_SELF);
 | 
						|
    int nHarmDC = ((nCasterHD - 9) + GetSpellSaveDC());
 | 
						|
    int nMetaMagic = GetMetaMagicFeat();
 | 
						|
    int nHalfHp = GetMaxHitPoints(oTarget)/2;
 | 
						|
    int nTouch = TouchAttackMelee(oTarget);
 | 
						|
    effect eVis = EffectVisualEffect(246);
 | 
						|
    effect eVis2 = EffectVisualEffect(VFX_IMP_HEALING_G);
 | 
						|
    effect eHeal, eDam;
 | 
						|
    //Check that the target is undead
 | 
						|
    if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD)
 | 
						|
    {
 | 
						|
        //Figure out the amount of damage to heal
 | 
						|
        nHeal = GetMaxHitPoints(oTarget) - GetCurrentHitPoints(oTarget);
 | 
						|
        //Set the heal effect
 | 
						|
        eHeal = EffectHeal(nHeal);
 | 
						|
        //Apply heal effect and VFX impact
 | 
						|
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
 | 
						|
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);
 | 
						|
        //Fire cast spell at event for the specified target
 | 
						|
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HARM, FALSE));
 | 
						|
    }
 | 
						|
    else if (nTouch) //== TRUE) 1 or 2 are valid return numbers from TouchAttackMelee
 | 
						|
    {
 | 
						|
        if(!GetIsReactionTypeFriendly(oTarget))
 | 
						|
        {
 | 
						|
            //Fire cast spell at event for the specified target
 | 
						|
            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HARM));
 | 
						|
            if (!MyResistSpell(OBJECT_SELF, oTarget)&& !/*Fort Save*/ MySavingThrow(SAVING_THROW_FORT, oTarget, nHarmDC, SAVING_THROW_TYPE_NEGATIVE))
 | 
						|
            {
 | 
						|
                if ((GetCurrentHitPoints(oTarget)) > nHalfHp)
 | 
						|
                {
 | 
						|
                nDamage = GetCurrentHitPoints(oTarget)- nHalfHp;
 | 
						|
                }
 | 
						|
                else {nDamage = d6(8);}
 | 
						|
                //Check for metamagic
 | 
						|
                if (nMetaMagic == METAMAGIC_MAXIMIZE)
 | 
						|
                {
 | 
						|
                if ((GetCurrentHitPoints(oTarget)) > nHalfHp)
 | 
						|
                {
 | 
						|
                nDamage = GetCurrentHitPoints(oTarget)- nHalfHp;
 | 
						|
                }
 | 
						|
                else {nDamage = d6(nCasterHD/2);}
 | 
						|
                }
 | 
						|
                eDam = EffectDamage(nDamage,DAMAGE_TYPE_NEGATIVE);
 | 
						|
                //Apply the VFX impact and effects
 | 
						|
                DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
 | 
						|
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
 | 
						|
            }
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |