//////////////////////////////////////////////////////
//	Author: Drammel									//
//	Date: 3/29/2009									//
//	Title: feat_strickster							//
//	Description: While in a Shadow Hand stance, gain//
//	+2 to the DC of illusion spells cast and +2 	//
//	damage to sneak attacks.						//
//////////////////////////////////////////////////////

#include "bot9s_include"

// The boost to illusion spell DC is covered in the override of nw_i0_spells.

void ShadowTrickster()
{
	object oPC = OBJECT_SELF;
	string sToB = GetFirstName(oPC) + "tob";
	object oToB = GetObjectByTag(sToB);
	int nStance = GetLocalInt(oToB, "Stance");
	int nStance2 = GetLocalInt(oToB, "Stance2");

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

	if (nStance == 116 || nStance2 == 116 || nStance == 117 || nStance2 == 117
	|| nStance == 119 || nStance2 == 119 || nStance == 122 || nStance2 == 122
	|| nStance == 129 || nStance2 == 129 || nStance == 139 || nStance2 == 139)
	{
		object oCreature = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, CREATURE_ALIVE_TRUE, oPC);

		if (IsTargetValidForSneakAttack(oCreature, oPC))
		{
			object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND);
			int nWeapon = GetWeaponDamageType(oWeapon);
			effect eTrickster = EffectDamageIncrease(DAMAGE_BONUS_2, nWeapon);
			eTrickster = ExtraordinaryEffect(eTrickster);
	
			ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eTrickster, oPC, 6.0f);
		}
	}
	DelayCommand(6.0f, ShadowTrickster());
}

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

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