//::///////////////////////////////////////////////
//:: Bolt: Poison
//:: NW_S1_BltPoison.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Must make a ranged touch attack. If successful
    the target is struck down with poison that
    scales with level.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: May 22, 2001
//:://////////////////////////////////////////////
#include "NW_I0_SPELLS"
#include "prc_inc_spells"
//#include "wm_include"

void main()
{
    //if (WildMagicOverride()) { return; }
	
//:: Declare major variables
	object oNPC		= OBJECT_SELF;
	object oTarget 	= PRCGetSpellTargetObject();
	
    int nHD 		= GetHitDice(oNPC);
	int nRacial 	= MyPRCGetRacialType(OBJECT_SELF);
	int nPoison;
	
    effect ePoison;

    //Fire cast spell at event for the specified target
    SignalEvent(oTarget, EventSpellCastAt(oNPC, SPELLABILITY_BOLT_POISON));

    //Determine the poison type based on the Racial Type and HD
    switch (nRacial)
    {
        case RACIAL_TYPE_OUTSIDER:
            if (nHD <= 9)
            {
                nPoison = POISON_QUASIT_VENOM;
            }
            else if (nHD > 9  && nHD < 13)
            {
                nPoison = POISON_BEBILITH_VENOM;
            }
            else if (nHD >= 13)
            {
                nPoison = POISON_PIT_FIEND_ICHOR;
            }
        break;
        case RACIAL_TYPE_VERMIN:
            if (nHD < 3)
            {
                nPoison = POISON_TINY_SPIDER_VENOM;
            }
            else if (nHD <= 3 && nHD < 6)
            {
                nPoison = POISON_SMALL_SPIDER_VENOM;
            }
            else if (nHD <= 6 && nHD < 9)
            {
                nPoison = POISON_MEDIUM_SPIDER_VENOM;
            }
            else if (nHD <= 9 && nHD < 12)
            {
                nPoison =  POISON_LARGE_SPIDER_VENOM;
            }
            else if (nHD <= 12 && nHD < 15)
            {
                nPoison = POISON_HUGE_SPIDER_VENOM;
            }
            else if (nHD <= 15 && nHD < 18)
            {
                nPoison = POISON_GARGANTUAN_SPIDER_VENOM;
            }
            else if (nHD >= 18)
            {
                nPoison = POISON_COLOSSAL_SPIDER_VENOM;
            }
        break;
        default:
            if (nHD < 3)
            {
                nPoison = POISON_NIGHTSHADE;
            }
            else if (nHD <= 3 && nHD < 6)
            {
                nPoison = POISON_BLADE_BANE;
            }
            else if (nHD <= 6 && nHD < 9)
            {
                nPoison = POISON_BLOODROOT;
            }
            else if (nHD <= 9 && nHD < 12)
            {
                nPoison =  POISON_LARGE_SPIDER_VENOM;
            }
            else if (nHD <= 12 && nHD < 15)
            {
                nPoison = POISON_LICH_DUST;
            }
            else if (nHD <= 15 && nHD < 18)
            {
                nPoison = POISON_DARK_REAVER_POWDER;
            }
            else if (nHD >= 18 )
            {
                nPoison = POISON_BLACK_LOTUS_EXTRACT;
            }

        break;
    }
    //Make a ranged touch attack
    if (TouchAttackRanged (oTarget))
    {
        ePoison = EffectPoison(nPoison);
        //Apply effects
        ApplyEffectToObject(DURATION_TYPE_PERMANENT, ePoison, oTarget);
    }
}

