//::///////////////////////////////////////////////
//:: Caltrops
//:: x0_s3_caltrop
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*

    Creates a permanent field of caltrops that will disappear
    after 25 points of damage have been dished out.
    (1 point per creature per round)

*/
//:://////////////////////////////////////////////
//:: Created By: Brent
//:: Created On: September 10, 2002
//:://////////////////////////////////////////////

#include "X0_I0_SPELLS"
#include "jx_inc_magic"
#include "x2_inc_spellhook"


void SetObject(location lTarget, object oVisual)
{
    object oArea = GetNearestObjectToLocation(OBJECT_TYPE_AREA_OF_EFFECT, lTarget);
    if (GetIsObjectValid(oArea) == TRUE)
    {
        SetLocalObject(oArea, "X0_L_IMPACT", oVisual);
    }
}


void mainSpell();
void main()
{
	AssignCommand(JXGetCaster(), mainSpell());
}

void mainSpell()
{
	if (!X2PreSpellCastCode()) { JXPostSpellCastCode(); return; }


    //Declare major variables including Area of Effect Object
    // * passing dirge script for exit because it is an empty script (i.e., there is no special exit effects)
    location lTarget = JXGetSpellTargetLocation();

    //effect eImpact = EffectVisualEffect(257);

    //JXApplyEffectAtLocation(DURATION_TYPE_INSTANT, eImpact, lTarget);
    //Create an instance of the AOE Object using the Apply Effect function
    JXApplyAreaEffectAtLocation(37, lTarget, 0.0f, "x0_s3_calEN", "x0_s3_calHB");
    object oVisual = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_invisobj", lTarget);
    SetObject(lTarget, oVisual);

    effect eFieldOfSharp = EffectVisualEffect(VFX_DUR_CALTROPS);
    JXApplyEffectToObject(DURATION_TYPE_PERMANENT, eFieldOfSharp, oVisual);


	JXPostSpellCastCode();
}

