//////////////////////////////////////////////
//	Author: Drammel							//
//	Date: 2/8/2009							//
//	Title: sa_stncoclr						//
//	Description: Stance; +2 to AC vs one foe//
//	and -2 AC vs all others.				//
//////////////////////////////////////////////

#include "x0_i0_enemy"
#include "bot9s_inc_maneuvers"

void StanceOfClarity()
{
	object oPC = OBJECT_SELF;
	string sToB = GetFirstName(oPC) + "tob";
	object oToB = GetObjectByTag(sToB);
	
	object oTarget = IntToObject(GetLocalInt(oToB, "StanceOfClarity"));
	float fDuration = 1.0f;
	
	effect eACPlus = ExtraordinaryEffect(EffectACIncrease(2, AC_DODGE_BONUS, AC_VS_DAMAGE_TYPE_ALL, FALSE));
	effect eACMinus = ExtraordinaryEffect(EffectACDecrease(2, AC_DODGE_BONUS, AC_VS_DAMAGE_TYPE_ALL));
	
	if (ValidateStance(74) == TRUE)
	{
		DelayCommand(1.0f, StanceOfClarity());
		
		ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eACMinus, oPC, fDuration);
		
		if (GetNearestEnemy(oPC, 1) == oTarget)
		{
			RemoveEffect(oPC, eACMinus);
			ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eACPlus, oPC, fDuration);
		}
	}
}

void main()
{
	object oPC = OBJECT_SELF;
	string sToB = GetFirstName(oPC) + "tob";
	object oToB = GetObjectByTag(sToB);
	
	if (NotMyFoe("Target") == TRUE)
	{
		return;
	}
	
	int nTarget = GetLocalInt(oToB, "Target");

	SetLocalInt(oToB, "StanceOfClarity", nTarget);		
	StanceOfClarity();
}