////////////////////////////////////////////////////////////
//	Author: Drammel										  //
//	Date: 5/8/2009										  //
//	Name: gui_wbl_recovery								  //
//	Description: Allows the Warblade to recover all of his//
//	expended maneuvers.									  //
////////////////////////////////////////////////////////////

#include "bot9s_inc_maneuvers"
#include "bot9s_inc_misc"

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

	RunSwiftAction(222, "");
	SetGUIObjectDisabled(oPC, "SCREEN_MARTIAL_MENU_WB", "RECOVERY_IMAGE", TRUE);
	DelayCommand(6.0f, SetGUIObjectDisabled(oPC, "SCREEN_MARTIAL_MENU_WB", "RECOVERY_IMAGE", FALSE));

	string sScreen = "SCREEN_QUICK_STRIKE_WB";

	RecoverAllManeuvers(sScreen);

	if ((GetHasFeat(FEAT_VITAL_RECOVERY, oPC)) && (GetLocalInt(oToB, "VitalRecovery") == 0))
	{
		int nMax = GetMaxHitPoints(oPC);
		int nHP = GetCurrentHitPoints(oPC);
	
		if (nHP < nMax) // Won't heal when we're at full HP.
		{
			int nHitDice = GetHitDice(oPC);
			effect eHeal = ManeuverHealing(oPC, 3 + nHitDice);

			ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oPC);
			SetLocalInt(oToB, "VitalRecovery", 1);
		}
	}
}

void main()
{
	object oOrigin = OBJECT_SELF;
	object oPC = GetControlledCharacter(oOrigin);
	object oWeapon = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);

	if ((GetIsInCombat(oPC)) && (GetCurrentAction(oPC) == ACTION_ATTACKOBJECT) && (!GetWeaponRanged(oWeapon)))
	{
		string sToB = GetFirstName(oPC) + "tob";
		object oToB = GetObjectByTag(sToB);

		if ((GetLocalInt(oToB, "Swift") == 0) && (GetLocalInt(oToB, "Quicksilver") == 0))
		{
			SetLocalInt(oToB, "WarbladeRecovery", 1);
			DelayCommand(6.0f, SetLocalInt(oToB, "WarbladeRecovery", 0));
			WarbladeRecovery(oPC);
		}
	}
}