ScriptName _amm_AlembicDistilleryScript Extends ObjectReference

Actor Property acPlayer Auto
Ingredient Property igMoonSugar Auto
Potion Property ptSkooma Auto
Potion Property ptDoubleDistilledSkooma Auto

Event OnActivate(ObjectReference akActionRef)

	If (akActionRef == acPlayer)
		Int iNum = acPlayer.GetNumItems()
		Int iCnt = 0
		Form fmItem
		
		While (iCnt < iNum)
			fmItem = acPlayer.GetNthForm(iCnt)
			If (fmItem == igMoonSugar As Form)
				acPlayer.RemoveItem(igMoonSugar As Form, 1, True)
				acPlayer.AddItem(ptSkooma As Form, 5, True)
			ElseIf (fmItem == ptSkooma As Form)
				acPlayer.RemoveItem(ptSkooma As Form, 1, True)
				acPlayer.AddItem(ptDoubleDistilledSkooma As Form, 1, True)
			EndIf
			iCnt += 1
		EndWhile
	EndIf

EndEvent
