Scriptname KNN_EatingDrinkingAnimationScript extends ReferenceAlias  

Quest Property FollowerAnimQS auto

aaaKNNUsePotionScript Property RegisterFood auto

GlobalVariable Property aaaSt_DrinkAnim auto
GlobalVariable Property aaaSt_EatAnim auto
GlobalVariable Property aaaSt_EatSoupAnim auto
GlobalVariable Property aaaSd_DrinkAnim auto
GlobalVariable Property aaaSd_EatAnim auto
GlobalVariable Property aaaSd_EatSoupAnim auto
GlobalVariable Property aaaGetAndFastEat auto
GlobalVariable Property aaaReadingBookAnim auto
GlobalVariable Property aaaKNNIsHarvestFood auto
GlobalVariable Property aaaKNNfeelThirsty auto
GlobalVariable Property aaaKNNHungry auto
GlobalVariable Property aaaKNNimDrunk auto
GlobalVariable Property aaaAllowPlayingAnim auto
GlobalVariable Property aaaIntensityBasicNeeds auto
GlobalVariable Property aaaIntensityBasicNeedsDrink auto
GlobalVariable Property aaaKNNFollowerNeedAnim auto
GlobalVariable Property aaaKNNEnablePotionHotKey auto

MiscObject Property DLC1WineBottle03Empty Auto
MiscObject Property DLC1WineBottle04Empty Auto
MiscObject Property WineBottle01AEmpty Auto
MiscObject Property WineBottle01BEmpty Auto
MiscObject Property WineBottle02AEmpty Auto
MiscObject Property WineBottle02BEmpty Auto
MiscObject Property WineSolitudeSpicedBottleEmpty Auto

Potion Property aaaBlackWaterBottleEmpty Auto
Potion Property aaaWaterBottleBEmpty Auto
Potion Property aaaWaterBottleSEmpty Auto
Potion Property aaaWaterMeshBottleBEmpty Auto
Potion Property aaaWaterMeshBottleSEmpty Auto
Potion Property aaaSolitudeSpicedWaterBottleEmpty Auto

FormList Property aaaKNNDrinkList auto
FormList Property aaaKNNAlcoholList auto
FormList Property aaaKNNFoodList auto
FormList Property aaaKNNPerishableFoodList auto
FormList Property aaaKNNSoupList auto
FormList Property aaaFoodCheeseWedgeList auto
FormList Property aaaFoodCheeseWheelList auto
FormList Property aaaFoodMeatList auto
FormList Property aaaMODAlcholList auto
FormList Property aaaMODDrinkList auto
FormList Property aaaMODFoodList auto
FormList Property aaaMODPerishableFoodList auto
FormList Property aaaMODSoupList auto
FormList Property aaaKNNNoFoodNoDrink auto

Message Property aaaKNNDrunkStage01 auto
Message Property aaaKNNDrunkStage02 auto
Message Property aaaKNNDrunkStage03 auto
Message Property aaaKNNDesireFilledMsg auto
Message Property aaaKNNMoreNeedMsg auto
Message Property aaaKNNAteFoodWithNameMsg auto
Message Property aaaKNNDrannkDrinkWithNameMsg auto
Message Property aaaKNNNewFoodAddListMsg auto
Message Property aaaKNNNewFoodAddListWithNameMsg auto

ReferenceAlias Property ItemToIdentify auto

Sound Property aaaKNNEatBreadSound auto
Sound Property aaaKNNDrinkSound auto
Sound Property aaaKNNSoupSound auto

Potion Property aaaKNNDummyPotion auto

bool animLocked = false
int kBook = 27
String eatText = "Ate a "
String drinkText = "Drunk a "
int AllowFollowerAnim
int CanUsePotionHotkey

Event OnInit()
	RegisterForModEvent("KNNPlayerStatus", "KNNsetPlayerStatus")
	RegisterForModEvent("KNNRegisterFoodHotkey", "KNNSetRegisterFoodHotkey")
	GetFollowerEatAnim()
EndEvent

Event OnPlayerLoadGame()
	RegisterForModEvent("KNNPlayerStatus", "KNNsetPlayerStatus")
	RegisterForModEvent("KNNRegisterFoodHotkey", "KNNSetRegisterFoodHotkey")
	GetFollowerEatAnim()
	;Debug.Notification("OnPlayerLoadGame")
EndEvent

Function GetFollowerEatAnim()											;MCMから飛んでくる
	AllowFollowerAnim = aaaKNNFollowerNeedAnim.GetValueInt()
	CanUsePotionHotkey = aaaKNNEnablePotionHotKey.GetValueInt()
EndFunction

bool Function isKNNFood(Form akBaseObject)
	if (akBaseObject.getWeight() > 0 )
		if (akBaseObject.getType() == 46 )
			if ((akBaseObject as Potion).isFood())
				return true
			endIf
		endIf
	endIf
	return false
endFunction

int typeDrink = 0
int typeFood = 1
int typePerishableFood = 2
int typeSoup = 3
int typeNoDrinkNoFood = 4
int TypeAlchol = 5
form potionObj

Event KNNsetPlayerStatus(string eventName, string strArg, float numArg, form sender)
	float IntensityBN = aaaIntensityBasicNeeds.GetValue()
	float IntensityBND = aaaIntensityBasicNeedsDrink.GetValue()
	float totalThirsty
	float totalHungry
	float totalDrunk
	;Debug.Notification("MODSendEvent")
	if numArg == typeDrink as float
		totalThirsty = aaaKNNfeelThirsty.mod( potionObj.getWeight() * 1000 * IntensityBND )
		ateDrankShowMsg(numArg as int)
		if ( totalThirsty >= 1440 )			
			aaaKNNDesireFilledMsg.show()
		Else
			aaaKNNMoreNeedMsg.show()
		endIf
	elseIf numArg == TypeAlchol as float
		totalThirsty = aaaKNNfeelThirsty.mod( potionObj.getWeight() * 1000 * IntensityBND )
		ateDrankShowMsg(numArg as int)
		if ( totalThirsty >= 1440 )
			aaaKNNDesireFilledMsg.show()
		Else
			aaaKNNMoreNeedMsg.show()
		endIf
		totalDrunk = aaaKNNimDrunk.mod( potionObj.getWeight() * 1000 * IntensityBND )
		if ( totalDrunk >= 2000 )
			aaaKNNDrunkStage01.show()
		elseif ( totalDrunk >= 4000 )
			aaaKNNDrunkStage02.show()
		elseif ( totalDrunk >= 8000 )
			aaaKNNDrunkStage03.show()
		endIf
	elseIf numArg == typeFood as float
		ateDrankShowMsg(numArg as int)
		float fFoodWeight = potionObj.getWeight()
		if ( fFoodWeight < 1.0 )
			totalHungry = aaaKNNHungry.mod( fFoodWeight * 1000 * IntensityBN )
		else
			totalHungry = aaaKNNHungry.mod( fFoodWeight * 750 * IntensityBN )
		endIf
		if ( totalHungry >= 1440 )
			aaaKNNDesireFilledMsg.show()
		Else
			aaaKNNMoreNeedMsg.show()
		endIf
	elseIf numArg == typePerishableFood as float
		totalHungry = aaaKNNHungry.mod( 0 - (potionObj.getWeight() * 1000 * IntensityBN) )
		ateDrankShowMsg(numArg as int)
		if ( totalHungry >= 1440 )
			aaaKNNDesireFilledMsg.show()
		Else
			aaaKNNMoreNeedMsg.show()
		endIf
	elseIf numArg == typeSoup as float
		totalHungry = aaaKNNHungry.mod( potionObj.getWeight() * 1000 * IntensityBN )
		ateDrankShowMsg(numArg as int)
		if ( totalHungry >= 1440 )
			aaaKNNDesireFilledMsg.show()
		Else
			aaaKNNMoreNeedMsg.show()
		endIf
		totalThirsty = aaaKNNfeelThirsty.mod( potionObj.getWeight() * 250 * IntensityBND )
		if ( totalThirsty >= 1440 )
			aaaKNNDesireFilledMsg.show()
		Else
			aaaKNNMoreNeedMsg.show()
		endIf
	endIf
EndEvent

form DrinkTypeObj
form AlcholTypeObj
form FoodTypeObj
form SoupTypeObj

Event KNNSetRegisterFoodHotkey(string eventName, string strArg, float numArg, form sender)
	if numArg == typeDrink as float
		RegisterFood.RegisterModFoodToList(DrinkTypeObj, typeDrink)
		DrinkTypeObj = none
	elseIf numArg == typeFood as float
		RegisterFood.RegisterModFoodToList(FoodTypeObj, typeFood)
		FoodTypeObj = none
	elseIf numArg == TypeAlchol as float
		RegisterFood.RegisterModFoodToList(AlcholTypeObj, TypeAlchol)
		AlcholTypeObj = none
	elseIf numArg == typeSoup as float
		RegisterFood.RegisterModFoodToList(SoupTypeObj, typeSoup)
		SoupTypeObj = none	
	endIf
EndEvent

Function ateDrankShowMsg(int fdType)
	if ( fdType == typeDrink || fdType == TypeAlchol )
		if (ItemToIdentify)
			ObjectReference dummyDrink = getRef().placeAtMe(potionObj, 1, false, true)
			ItemToIdentify.forceRefTo(dummyDrink)
			aaaKNNDrannkDrinkWithNameMsg.show()
			dummyDrink.delete()
		else
			String itemName = potionObj.GetName()
			Debug.Notification(drinkText + itemName)
		endIf
	else
		if (ItemToIdentify)
			ObjectReference dummyFood = getRef().placeAtMe(potionObj, 1, false, true)
			ItemToIdentify.forceRefTo(dummyFood)
			aaaKNNAteFoodWithNameMsg.show()
			dummyFood.delete()
		else
			String itemName = potionObj.GetName()
			Debug.Notification(eatText + itemName)
		endIf
	endIf
EndFunction

;===== addNewFood : iButton =======
; 0 : drink
; 1 : alcohol
; 2 : food
; 3 : soup
; 4 : raw food
; 5 : no food no drink
; 6 : cancel
;==================================

int Function addNewFood(Form akBaseObject)
	int iButton 
	if (ItemToIdentify)
		ObjectReference dummy = getRef().placeAtMe(akBaseObject, 1, false, true)
		ItemToIdentify.forceRefTo(dummy)
		iButton = aaaKNNNewFoodAddListWithNameMsg.show()
		dummy.delete()
	else
		iButton = aaaKNNNewFoodAddListMsg.show()
	endIf
	if iButton == 0
		aaaMODDrinkList.AddForm(akBaseObject)
		if CanUsePotionHotkey == 1
			DrinkTypeObj = akBaseObject
			SendModEvent("KNNRegisterFoodHotkey", "", typeDrink as float)
		endIf
		return typeDrink
	elseIf iButton == 1
		aaaMODAlcholList.AddForm(akBaseObject)
		if CanUsePotionHotkey == 1
			AlcholTypeObj = akBaseObject
			SendModEvent("KNNRegisterFoodHotkey", "", TypeAlchol as float)
		endIf
		return TypeAlchol
	elseIf iButton == 2
		aaaMODFoodList.AddForm(akBaseObject)
		if CanUsePotionHotkey == 1
			FoodTypeObj = akBaseObject
			SendModEvent("KNNRegisterFoodHotkey", "", typeFood as float)
		endIf
		return typeFood
	elseIf iButton == 3
		aaaMODSoupList.AddForm(akBaseObject)
		if CanUsePotionHotkey == 1
			SoupTypeObj = akBaseObject
			SendModEvent("KNNRegisterFoodHotkey", "", typeSoup as float)
		endIf
		return typeSoup
	elseIf iButton == 4
		aaaMODPerishableFoodList.AddForm(akBaseObject)
		return typePerishableFood
	elseIf iButton == 5
		aaaKNNNoFoodNoDrink.AddForm(akBaseObject)
		return typeNoDrinkNoFood
	endIf
EndFunction

int Function KNNfoodType(Form akBaseObject)	
	if (isKNNFood(akBaseObject))
		if ( aaaKNNDrinkList.hasForm(akBaseObject) || aaaMODDrinkList.hasForm(akBaseObject) )
			return typeDrink
		elseif (aaaKNNAlcoholList.hasForm(akBaseObject) || aaaMODAlcholList.hasForm(akBaseObject) )
			return TypeAlchol
		elseIf (aaaKNNFoodList.hasForm(akBaseObject) || aaaMODFoodList.hasForm(akBaseObject) )
			return typeFood
		elseIf (aaaKNNPerishableFoodList.hasForm(akBaseObject) || aaaMODPerishableFoodList.hasForm(akBaseObject) )
			return typePerishableFood
		elseIf (aaaKNNSoupList.hasForm(akBaseObject) || aaaMODSoupList.hasForm(akBaseObject) )
			return typeSoup
		elseIf aaaKNNNoFoodNoDrink.hasForm(akBaseObject)
			return typeNoDrinkNoFood
		else
			int ModFoodType = addNewFood(akBaseObject)
			if ModFoodType == typeDrink
				return typeDrink
			elseIf ModFoodType == TypeAlchol
				return TypeAlchol
			elseIf ModFoodType == typeFood
				return typeFood
			elseIf ModFoodType == typeSoup
				return typeSoup
			elseIf ModFoodType == typePerishableFood
				return typePerishableFood
			elseIf ModFoodType == typeNoDrinkNoFood
				return typeNoDrinkNoFood
			endIf
		endIf
	endIf
	return typeNoDrinkNoFood
endFunction

Function ateFoodDrankDrink(Form akBaseObject, int ftype)
	potionObj = akBaseObject
	if ( ftype == typeDrink )
		SendModEvent("KNNPlayerStatus","",typeDrink as float)
	elseIf ( ftype == TypeAlchol )
		SendModEvent("KNNPlayerStatus","",TypeAlchol as float)
	elseIf ( ftype == typeFood )
		SendModEvent("KNNPlayerStatus","",typeFood as float)
	elseIf ( ftype == typeSoup )
		SendModEvent("KNNPlayerStatus","",typeSoup as float)
	elseIf ( ftype == typePerishableFood )
		SendModEvent("KNNPlayerStatus","",typePerishableFood as float)
	endIf
EndFunction

bool Function PlayFoodAnimation(actor player)
	if !animLocked
		if ( aaaAllowPlayingAnim.GetValueInt() == 1 )
			if (!player.IsSwimming())
				if (!player.isInCombat())
					if (!player.IsSneaking())
						if (!player.IsOnMount())
							if !player.IsSprinting()
								if !player.IsRunning()
									if !player.IsWeaponDrawn()
										if !player.GetAnimationVariableBool("bInJumpState")
											Return true
										endIf
									endIf
								endIf
							endIf
						endIf
					endIf
				endIf
			endIf	
		endIf
	endIf
	return false
EndFunction

Function animForceThirdCam()
	Game.ForceThirdPerson()
EndFunction

int Function GetRandomInt(int min, int max)
	int ReRandom = Utility.RandomInt(min, max)
	return ReRandom
EndFunction

bool CanFollowerPlayAnim = true

Event OnUpdate()
	if FollowerAnimQS.IsRunning()
		FollowerAnimQS.Stop()
		CanFollowerPlayAnim = true
		;Debug.Notification("FollowerAnimQS stop")
	endIf
EndEvent

Event onObjectEquipped(Form akBaseObject, ObjectReference akReference)
	if ( akBaseObject == aaaKNNDummyPotion )
		;Debug.Notification("This is dummy potion. retrun")
		return
	endIf
	Actor player = Game.GetPlayer()
	int type = KNNfoodType(akBaseObject)	
	if (type != typeNoDrinkNoFood )
		ateFoodDrankDrink(akBaseObject, type)
		if AllowFollowerAnim == 1
			if CanFollowerPlayAnim
				CanFollowerPlayAnim = false
				FollowerAnimQS.Start()
				RegisterForSingleUpdate(25.0)
				;Debug.Notification("FollowerAnimQS Start")
			endIf
		endIf
		if ( !PlayFoodAnimation(player) )
			return
		endIf
		animLocked = true
		aaaAllowPlayingAnim.SetValueInt(0)
		if (player.getSitState() >= 3)				
			if (type == typeDrink || type == TypeAlchol )
				if ( aaaSd_DrinkAnim.GetValueInt() == 1 )						
					Debug.sendAnimationEvent(player, "idleStop")
					Utility.wait(0.5)
					animForceThirdCam()					
					Debug.sendAnimationEvent(player, "ChairDrinkingStart")
					Utility.wait(20)
					Debug.sendAnimationEvent(player, "idleStop")
					;Utility.wait(0.1)
				endIf
			elseIf (type == typeFood || type == typePerishableFood)
				if ( aaaSd_EatAnim.GetValueInt() == 1 )
					Debug.sendAnimationEvent(player, "idleStop")
					Utility.wait(0.5)
					animForceThirdCam()
					Debug.sendAnimationEvent(player, "ChairEatingStart")
					Utility.wait(20)
					Debug.sendAnimationEvent(player, "idleStop")
					;Utility.wait(0.1)
				endIf
			elseIf (type == typeSoup)
				if ( aaaSd_EatSoupAnim.GetValueInt() == 1 )	
					Debug.sendAnimationEvent(player, "idleStop")
					Utility.wait(0.5)
					animForceThirdCam()
					Debug.sendAnimationEvent(player, "ChairEatingStart")
					Utility.wait(20)
					Debug.sendAnimationEvent(player, "idleStop")
					;Utility.wait(0.1)
				endIf
			endIf				
		else
			if (type == typeDrink || type == TypeAlchol )
				if ( aaaSt_DrinkAnim.GetValueInt() == 1 )
					;Game.DisablePlayerControls()
					Debug.sendAnimationEvent(player, "idleStop")
					Utility.wait(0.5)
					animForceThirdCam()
					int random = GetRandomInt(1, 3)
					if ( random == 1 )
						Debug.sendAnimationEvent(player, "idleDrinkingStandingStart")
						Utility.wait(7)
					elseIf ( random == 2 )
						Debug.sendAnimationEvent(player, "KNNAnimObjectDrinkStart")
						Utility.wait(10.1)
						aaaKNNDrinkSound.play(Game.GetPlayer())
						Utility.wait(7.1)
					else
						Debug.sendAnimationEvent(player, "KNNAnimObjectDrinkMeadStart")
						Utility.wait(5.0)
						aaaKNNSoupSound.play(Game.GetPlayer())
						Utility.wait(2.96)
					endIf
					Debug.sendAnimationEvent(player, "idleStop")
					;Utility.wait(0.1)
				endIf
			elseIf (type == typeFood || type == typePerishableFood)
				if ( aaaSt_EatAnim.GetValueInt() == 1 )
					;Game.DisablePlayerControls()
					Debug.sendAnimationEvent(player, "idleStop")
					Utility.wait(0.5)
					animForceThirdCam()
					if ( aaaFoodCheeseWedgeList.hasForm(akBaseObject) )
						Debug.sendAnimationEvent(player, "KNNAnimObjectEatCheeseWedge")
						Utility.wait(5.93)
						aaaKNNEatBreadSound.play(Game.GetPlayer())
						Utility.wait(5.54)
					elseif ( aaaFoodCheeseWheelList.hasForm(akBaseObject) )
						Debug.sendAnimationEvent(player, "KNNAnimObjectEatCheeseWheelStart")
						Utility.wait(5.93)
						aaaKNNEatBreadSound.play(Game.GetPlayer())
						Utility.wait(5.54)
					elseif ( aaaFoodMeatList.hasForm(akBaseObject) )
						Debug.sendAnimationEvent(player, "KNNAnimObjectEatBeef")
						Utility.wait(5.93)
						aaaKNNEatBreadSound.play(Game.GetPlayer())
						Utility.wait(5.54)
					else
						int random = GetRandomInt(1, 2)
						if ( random == 1 )
							Debug.sendAnimationEvent(player, "idleEatingStandingStart")
							Utility.wait(7)
						else
							Debug.sendAnimationEvent(player, "KNNAnimObjectEatStart")
							Utility.wait(5.93)
							aaaKNNEatBreadSound.play(Game.GetPlayer())
							Utility.wait(5.54)
						endIf
					endIf					
					Debug.sendAnimationEvent(player, "idleStop")
				endIf
			elseIf (type == typeSoup)
				if ( aaaSt_EatSoupAnim.GetValueInt() == 1 )
					;Game.DisablePlayerControls()
					Debug.sendAnimationEvent(player, "idleStop")
					Utility.wait(0.5)
					animForceThirdCam()
					Debug.sendAnimationEvent(player, "KNNAnimObjectEatSoupStart")
					Utility.wait(5.93)
					aaaKNNDrinkSound.play(Game.GetPlayer())	
					Utility.wait(5.54)
					Debug.sendAnimationEvent(player, "idleStop")
				endIf
			endIf
		endIf
		animLocked = false
		aaaAllowPlayingAnim.SetValueInt(1)
	else
		if ( akBaseObject.getType() == kBook )
			if ( akBaseObject.getWeight() == 1.0 || akBaseObject.getWeight() == 0.0 )
				if ( !PlayFoodAnimation(player) || aaaReadingBookAnim.GetValueInt() == 0 )
					return
				endIf
				animLocked = true
				aaaAllowPlayingAnim.SetValueInt(0)
				if (player.getSitState() >= 3)
					if ( akBaseObject.getWeight() == 1.0 )			
						Debug.sendAnimationEvent(player, "idleStop")
						Utility.wait(0.5)
						animForceThirdCam()
						Debug.sendAnimationEvent(player, "ChairReadingStart")
						Utility.wait(30.0)
						Debug.sendAnimationEvent(player, "idleStop")
					endIf
				else
					if ( akBaseObject.getWeight() == 1.0 )			
						Debug.sendAnimationEvent(player, "idleStop")
						Utility.wait(0.5)
						animForceThirdCam()
						Debug.sendAnimationEvent(player, "IdleBook_Read")
						Utility.wait(7.0)
						Debug.sendAnimationEvent(player, "idleStop")
					elseIf ( akBaseObject.getWeight() == 0.0 )
						Debug.sendAnimationEvent(player, "idleStop")
						Utility.wait(0.5)
						animForceThirdCam()
						Debug.sendAnimationEvent(player, "IdleNoteRead")
						Utility.wait(7.0)
						Debug.sendAnimationEvent(player, "idleStop")
					endIf
				endIf
				animLocked = false
				aaaAllowPlayingAnim.SetValueInt(1)				
			endIf
		endIf		
	endIf
EndEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	;Debug.Notification("Add Item Food")
	if ( akBaseItem == aaaKNNDummyPotion )
		;Debug.Notification("This is dummy potion. retrun")
		return
;	elseIf( akBaseItem.GetFormID() == DLC1WineBottle03Empty.GetFormID() )
;		GetActorReference().RemoveItem( akBaseItem, aiItemCount, true )
;		GetActorReference().AddItem( aaaBlackWaterBottleEmpty , aiItemCount, true )
;	elseIf( akBaseItem.GetFormID() == DLC1WineBottle04Empty.GetFormID() )
;		GetActorReference().RemoveItem( akBaseItem, aiItemCount, true )
;		GetActorReference().AddItem( aaaBlackWaterBottleEmpty , aiItemCount, true )
;	elseIf( akBaseItem.GetFormID() == WineBottle01AEmpty.GetFormID() )
;		GetActorReference().RemoveItem( akBaseItem, aiItemCount, true )
;		GetActorReference().AddItem( aaaWaterBottleBEmpty , aiItemCount, true )
;	elseIf( akBaseItem.GetFormID() == WineBottle01BEmpty.GetFormID() )
;		GetActorReference().RemoveItem( akBaseItem, aiItemCount, true )
;		GetActorReference().AddItem( aaaWaterMeshBottleBEmpty, aiItemCount, true )
;	elseIf( akBaseItem.GetFormID() == WineBottle02AEmpty.GetFormID() )
;		GetActorReference().RemoveItem( akBaseItem, aiItemCount, true )
;		GetActorReference().AddItem( aaaWaterBottleSEmpty, aiItemCount, true )
;	elseIf( akBaseItem.GetFormID() == WineBottle02BEmpty.GetFormID() )
;		GetActorReference().RemoveItem( akBaseItem, aiItemCount, true )
;		GetActorReference().AddItem( aaaWaterMeshBottleSEmpty , aiItemCount, true )
;	elseIf( akBaseItem.GetFormID() == WineSolitudeSpicedBottleEmpty.GetFormID() )
;		GetActorReference().RemoveItem( akBaseItem, aiItemCount, true )
;		GetActorReference().AddItem( aaaSolitudeSpicedWaterBottleEmpty, aiItemCount, true )
	elseIf ( KNNfoodType(akBaseItem) ==  typeFood || KNNfoodType(akBaseItem) == typeSoup || KNNfoodType(akBaseItem) == TypeAlchol )
		If ( aaaGetAndFastEat.GetValueInt() == 1  )
			if ( aaaKNNIsHarvestFood.GetValueInt() == 1 )
				;Debug.Notification( "Keep " + akBaseItem.GetName() + " without eating" )						;収穫(アニメーション再生)時は食べない
				aaaKNNIsHarvestFood.SetValueInt(0)
			else
				;Debug.Notification("food")
				if ( !isPlayerMenuOpen() )
					Game.GetPlayer().EquipItem(akBaseItem, false, true)
					;String itemName = akBaseItem.GetName()
					;Debug.Notification(eatText + itemName)
				endIf
				;Debug.Notification( "GlobalValue is " + aaaKNNIsHarvestFood.GetValueInt() )
			endIf
		endIf
	endIf
EndEvent

bool Function isPlayerMenuOpen()
	if ( UI.IsMenuOpen("Crafting Menu") )							;クラフト中(料理含む)
		;Debug.Notification( "Player is crafting menu opened" )
		return true
	elseIf ( UI.IsMenuOpen("BarterMenu") )							;買い物中
		;Debug.Notification( "Player is BarterMenu opened" )
		return true
	elseIf ( UI.IsMenuOpen("ContainerMenu") )						;コンテナー（宝箱/樽/死体等）物色中
		;Debug.Notification( "Player is ContainerMenu opened" )
		return true
	elseIf ( UI.IsMenuOpen("Dialogue") )							;話し中
		;Debug.Notification( "Player is Dialogue opened" )
		return true
	elseIf ( UI.IsMenuOpen("Console") ) 							;コンソール入力中
		return true
	else
		return false
	endIf
EndFunction

