ScriptName aaaKimachuuGourmetScript Extends ActiveMagicEffect

FormList Property aaaKimachuuGourmetFoodBlackList Auto
GlobalVariable Property aaaKimachuuGourmetGetPerkNorma Auto
Keyword Property aaaKimachuuGourmetFilter Auto

Potion PotionRefLoad
Potion PotionRef
Potion PotionList

Event OnPlayerLoadGame()
	Int iIndex = aaaKimachuuGourmetFoodBlackList.GetSize()
	While iIndex > 0
		iIndex -= 1
		Utility.Wait(0.1)

		PotionRefLoad = aaaKimachuuGourmetFoodBlackList.GetAt(iIndex) as Potion
		if PotionRefLoad.GetWeight() != 0.0
			PotionRefLoad.SetWeight(0.0)
		Endif
	EndWhile
	Debug.Notification("Kimachuu Gourmet initialized")
endEvent

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
	If akBaseObject as Potion
		PotionRef = akBaseObject as Potion
		If PotionRef.IsFood() && !PotionRef.HasKeyword(aaaKimachuuGourmetFilter)
			Int iIndex = aaaKimachuuGourmetFoodBlackList.Find(PotionRef)
			If iIndex == -1
				Game.GetPlayer().SetActorValue("Health",( Game.GetPlayer().GetBaseActorValue("Health") + 5))
				Game.GetPlayer().SetActorValue("Stamina",( Game.GetPlayer().GetBaseActorValue("Stamina") + 5))
				Game.GetPlayer().SetActorValue("Magicka",( Game.GetPlayer().GetBaseActorValue("Magicka") + 5))

				aaaKimachuuGourmetGetPerkNorma.Mod(1)

				if aaaKimachuuGourmetGetPerkNorma.GetValue() >= 3
					Game.AddPerkPoints(1)
					Debug.Notification("Get Perk Point")
					aaaKimachuuGourmetGetPerkNorma.SetValue(0)
				endif

				aaaKimachuuGourmetFoodBlackList.AddForm(PotionRef)
				PotionRef.SetWeight(0.0)
			Endif
		EndIf
	EndIf
EndEvent