196 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			196 lines
		
	
	
		
			6.9 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
//::///////////////////////////////////////////////
 | 
						|
//:: Melf's Acid Arrow
 | 
						|
//:: MelfsAcidArrow.nss
 | 
						|
//:: Copyright (c) 2000 Bioware Corp.
 | 
						|
//:://////////////////////////////////////////////
 | 
						|
/*
 | 
						|
    An acidic arrow springs from the caster's hands
 | 
						|
    and does 3d6 acid damage to the target.  For
 | 
						|
    every 3 levels the caster has the target takes an
 | 
						|
    additional 1d6 per round.
 | 
						|
*/
 | 
						|
/////////////////////////////////////////////////////////
 | 
						|
//:://////////////////////////////////////////////
 | 
						|
//:: Created By: Aidan Scanlan
 | 
						|
//:: Created On: 01/09/01
 | 
						|
//:://////////////////////////////////////////////
 | 
						|
//:: Rewritten: Georg Zoeller, Oct 29, 2003
 | 
						|
//:: Now uses VFX to track its own duration, cutting
 | 
						|
//:: down the impact on the CPU to 1/6th
 | 
						|
//:://////////////////////////////////////////////
 | 
						|
 | 
						|
#include "ke_spell_factor"
 | 
						|
 | 
						|
#include "X0_I0_SPELLS"
 | 
						|
#include "x2_inc_spellhook"
 | 
						|
#include "x2_i0_spells"
 | 
						|
 | 
						|
void RunImpact(object oTarget, object oCaster, int nMetamagic);
 | 
						|
 | 
						|
void main()
 | 
						|
{
 | 
						|
 | 
						|
    int nDamage;
 | 
						|
    object oTarget = GetSpellTargetObject();
 | 
						|
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    // Spellcast Hook Code
 | 
						|
    // Added 2003-06-20 by Georg
 | 
						|
    // If you want to make changes to all spells, check x2_inc_spellhook.nss to
 | 
						|
    // find out more
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    if (!X2PreSpellCastCode())
 | 
						|
    {
 | 
						|
        return;
 | 
						|
    }
 | 
						|
    // End of Spell Cast Hook
 | 
						|
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    // This spell no longer stacks. If there is one of that type, thats ok
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    if (GetHasSpellEffect(GetSpellId(),oTarget))
 | 
						|
    {
 | 
						|
        FloatingTextStrRefOnCreature(100775,OBJECT_SELF,FALSE);
 | 
						|
        return;
 | 
						|
    }
 | 
						|
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    // Calculate the duration
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    int nMetaMagic = GetMetaMagicFeat();
 | 
						|
    int nDuration = (GetCasterLevel(OBJECT_SELF)/3);
 | 
						|
    int nCasterLevel = GetCasterLevel(OBJECT_SELF);
 | 
						|
 | 
						|
    if (nMetaMagic == METAMAGIC_EXTEND)
 | 
						|
    {
 | 
						|
       nDuration = nDuration * 2;
 | 
						|
    }
 | 
						|
 | 
						|
    if (nDuration < 1)
 | 
						|
    {
 | 
						|
        nDuration = 1;
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    // Setup VFX
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    effect eVis      = EffectVisualEffect(VFX_IMP_ACID_L);
 | 
						|
    effect eDur      = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);
 | 
						|
    effect eArrow = EffectVisualEffect(245);
 | 
						|
 | 
						|
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    // Set the VFX to be non dispelable, because the acid is not magic
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    eDur = ExtraordinaryEffect(eDur);
 | 
						|
     // * Dec 2003- added the reaction check back i
 | 
						|
    if (GetIsReactionTypeFriendly(oTarget) == FALSE)
 | 
						|
    {
 | 
						|
 | 
						|
 | 
						|
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, GetSpellId()));
 | 
						|
 | 
						|
        float fDist = GetDistanceToObject(oTarget);
 | 
						|
        float fDelay = (fDist/25.0);//(3.0 * log(fDist) + 2.0);
 | 
						|
 | 
						|
 | 
						|
        if(MyResistSpell(OBJECT_SELF, oTarget) == FALSE)
 | 
						|
        {
 | 
						|
            //----------------------------------------------------------------------
 | 
						|
            // Do the initial 3d6 points of damage
 | 
						|
            //----------------------------------------------------------------------
 | 
						|
 | 
						|
 | 
						|
            nDamage = d4(nCasterLevel)+20;
 | 
						|
 | 
						|
            //starting the grand circus of importing and converting back and forth //
 | 
						|
 | 
						|
                float fDamage = IntToFloat(nDamage);
 | 
						|
 | 
						|
                // multiplaying damage with fFactor //
 | 
						|
 | 
						|
                float fFactor = CalculateFactor();
 | 
						|
 | 
						|
                fDamage = fDamage * fFactor;
 | 
						|
 | 
						|
                // converting the float damage back to INT damage so we can use it again //
 | 
						|
 | 
						|
                int nDamage2 = FloatToInt(fDamage);
 | 
						|
 | 
						|
               // Done and remember to change nDamage with nDamage2 below :) //
 | 
						|
 | 
						|
 | 
						|
 | 
						|
            // int nDamage = MaximizeOrEmpower(6,5,nMetaMagic);
 | 
						|
            effect eDam = EffectDamage(nDamage2, DAMAGE_TYPE_ACID);
 | 
						|
 | 
						|
            DelayCommand(fDelay,ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
 | 
						|
            DelayCommand(fDelay,ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
 | 
						|
 | 
						|
            //----------------------------------------------------------------------
 | 
						|
            // Apply the VFX that is used to track the spells duration
 | 
						|
            //----------------------------------------------------------------------
 | 
						|
            DelayCommand(fDelay,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eDur,oTarget,RoundsToSeconds(nDuration)));
 | 
						|
            object oSelf = OBJECT_SELF; // because OBJECT_SELF is a function
 | 
						|
            DelayCommand(6.0f,RunImpact(oTarget, oSelf,nMetaMagic));
 | 
						|
        }
 | 
						|
        else
 | 
						|
        {
 | 
						|
            //----------------------------------------------------------------------
 | 
						|
            // Indicate Failure
 | 
						|
            //----------------------------------------------------------------------
 | 
						|
            effect eSmoke = EffectVisualEffect(VFX_IMP_REFLEX_SAVE_THROW_USE);
 | 
						|
            DelayCommand(fDelay+0.1f,ApplyEffectToObject(DURATION_TYPE_INSTANT,eSmoke,oTarget));
 | 
						|
        }
 | 
						|
    }
 | 
						|
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eArrow, oTarget);
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void RunImpact(object oTarget, object oCaster, int nMetaMagic)
 | 
						|
{
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    // Check if the spell has expired (check also removes effects)
 | 
						|
    //--------------------------------------------------------------------------
 | 
						|
    if (GZGetDelayedSpellEffectsExpired(SPELL_MELFS_ACID_ARROW,oTarget,oCaster))
 | 
						|
    {
 | 
						|
        return;
 | 
						|
    }
 | 
						|
 | 
						|
    if (GetIsDead(oTarget) == FALSE)
 | 
						|
    {
 | 
						|
        //----------------------------------------------------------------------
 | 
						|
        // Calculate Damage
 | 
						|
        //----------------------------------------------------------------------
 | 
						|
        int nCasterLevel = GetCasterLevel(OBJECT_SELF);
 | 
						|
        int nDamage = d4(nCasterLevel);
 | 
						|
 | 
						|
        //starting the grand circus of importing and converting back and forth //
 | 
						|
 | 
						|
                float fDamage = IntToFloat(nDamage);
 | 
						|
 | 
						|
                // multiplaying damage with fFactor //
 | 
						|
 | 
						|
                float fFactor = CalculateFactor();
 | 
						|
 | 
						|
                fDamage = fDamage * fFactor;
 | 
						|
 | 
						|
                // converting the float damage back to INT damage so we can use it again //
 | 
						|
 | 
						|
                int nDamage2 = FloatToInt(fDamage);
 | 
						|
 | 
						|
               // Done and remember to change nDamage with nDamage2 below :) //
 | 
						|
 | 
						|
 | 
						|
        // int nDamage = MaximizeOrEmpower(6,1,nMetaMagic);
 | 
						|
        effect eDam = EffectDamage(nDamage2, DAMAGE_TYPE_ACID);
 | 
						|
        effect eVis = EffectVisualEffect(VFX_IMP_ACID_S);
 | 
						|
        eDam = EffectLinkEffects(eVis,eDam); // flare up
 | 
						|
        ApplyEffectToObject (DURATION_TYPE_INSTANT,eDam,oTarget);
 | 
						|
        DelayCommand(6.0f,RunImpact(oTarget,oCaster,nMetaMagic));
 | 
						|
    }
 | 
						|
}
 | 
						|
 |