//////////////////////////////////////////////////////
//	Author: Drammel									//
//	Date: 3/29/2009									//
//	Title: feat_shadow_bld							//
//	Description: While in a Shadow Hand stance, 	//
//	apply Dex mod to weapon damage.					//
//////////////////////////////////////////////////////

#include "bot9s_inc_variables"

void ShadowBlade()
{
	object oPC = OBJECT_SELF;
	string sToB = GetFirstName(oPC) + "tob";
	object oToB = GetObjectByTag(sToB);
	object oLeftHand = GetItemInSlot(INVENTORY_SLOT_LEFTHAND);
	object oRightHand = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND);

	DelayCommand(6.0f, ShadowBlade());
	SetLocalInt(oToB, "SBladeActive", 1); //Loop status check.

	if (GetIsShadowBladeValid(oRightHand) == TRUE)
	{
		int nDexMod = GetAbilityModifier(ABILITY_DEXTERITY, oPC);
		int nBonus, nDamage;

		if (!GetIsObjectValid(oLeftHand))
		{
			//Two-Handed
			nBonus = ((nDexMod * 3)/2);
		}
		else
		{
			//One-Handed
			nBonus = nDexMod;
		}

		nDamage = GetConstDamageBonusFromNumber(nBonus);

		int nWeapon = GetWeaponType(oRightHand);
				
		if (nWeapon == WEAPON_TYPE_PIERCING_AND_SLASHING || WEAPON_TYPE_PIERCING)
		{
			effect eDamage = EffectDamageIncrease(nDamage, DAMAGE_TYPE_PIERCING);
			eDamage = SupernaturalEffect(eDamage);
			ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDamage, oPC, 6.0f);
		}
		else if (nWeapon == WEAPON_TYPE_SLASHING)
		{
			effect eDamage = EffectDamageIncrease(nDamage, DAMAGE_TYPE_SLASHING);
			eDamage = SupernaturalEffect(eDamage);
			ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDamage, oPC, 6.0f);
		}
		else
		{
			effect eDamage = EffectDamageIncrease(nDamage, DAMAGE_TYPE_BLUDGEONING);
			eDamage = SupernaturalEffect(eDamage);
			ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDamage, oPC, 6.0f);
		}
	}
}


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

	if (GetLocalInt(oToB, "SBladeActive") == 1)
	{
		return; // Prevents duplicate checks.
	}
	else
	{
		ShadowBlade();
	}
}