//////////////////////////////////////////////////////
//	Author: Drammel									//
//	Date: 3/2/2009									//
//	Title: feat_dwd									//
//	Description: If you move at least 10 feet from	//
//	your original position, you gain a +1 dodge 	//
//	bonus to AC and deal an extra 1 point of fire 	//
//	damage with any attack you make with a Desert	//
//	Wind weapon.									//
//////////////////////////////////////////////////////

#include "bot9s_inc_variables"

void RunDWD()
{
	object oPC = OBJECT_SELF;
	string sToB = GetFirstName(oPC) + "tob";
	object oToB = GetObjectByTag(sToB);
	object oMyWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
	location lPC = GetLocation(oPC);
	location lLast = GetLastLocationOfCreature(oPC);

	SetLocalInt(oToB, "DWDActive", 1); // Loop status check.

	if (GetDistanceBetweenLocations(lPC, lLast) >= FeetToMeters(10.0f))
	{
		effect eAC = EffectACIncrease(1, AC_DODGE_BONUS);
		eAC = SupernaturalEffect(eAC);
		ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAC, oPC, 6.0f);

		if (GetIsDesertWindWeapon(oMyWeapon) == TRUE)
		{
			effect eFire = EffectDamageIncrease(DAMAGE_BONUS_1, DAMAGE_TYPE_FIRE);
			ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFire, oPC, 6.0f);
		}
	}
	DelayCommand(6.0f, RunDWD());
}

void main()
{
	object oPC = OBJECT_SELF;
	string sToB = GetFirstName(oPC) + "tob";
	object oToB = GetObjectByTag(sToB);

	if (GetLocalInt(oToB, "DWDActive") == 1)
	{
		return; // Prevents duplicate checks.
	}
	else if (GetLocalInt(oToB, "DWDActive") == 0)
	{
		RunDWD();
	}
}