//On Use Function for item foodForRest
//For use in the Food System
//Created by: Cody Houston 12/20/2007 with the use of the ItemActivate Template
// Modified by Shazbotian for magic meal summoned by "Create Food and Water"
//===================================================================================

//Main Function DO NOT TOUCH!!!!!!!!!
void main()
{
    object oActivator	= GetItemActivator();
    object oItem    	= GetItemActivated();
    object oTarget 		= GetItemActivatedTarget();
    location lTarget	= GetItemActivatedTargetLocation();
	effect eEffect;
	

	if (GetIsInCombat(oActivator)) {

		SendMessageToPC(GetItemActivator(), "You can't eat food while fighting!");
		return;
	}
	
	effect eHeal = EffectHeal(2);
	ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oActivator);

	if(GetLocalInt(oActivator, "ISHungry") > 0) {
		//SetLocalInt(oActivator, "ISHungry", 0);
		eEffect = GetFirstEffect(oTarget);
		while (GetIsEffectValid(eEffect))
		{
			if (GetEffectType(eEffect)==EFFECT_TYPE_ABILITY_DECREASE) RemoveEffect(oTarget, eEffect);
			eEffect = GetNextEffect(oTarget);
		}
	}
	
	//================================================================================================================
	// Below Allows for multiple types of food with different timers.
	// To create: change the DelayCommand float to the value you wish (Default = 5.0)
	// then just save this script as i_<Tag of new food item here>_ac. 	
//	SetLocalInt(oPC, "ISHungry", 1);
//	DelayCommand(5.0,ExecuteScript("func_hungry", oPC));
}