ScriptName _amm_FoodTriggerScript Extends ObjectReference

Actor Property acPlayer Auto
GlobalVariable Property gvSaxhleelQst Auto
GlobalVariable Property gvLastVisit Auto
GlobalVariable Property gvDaysPassed Auto
ObjectReference[] Property orFoodBarrel Auto

Event OnTriggerEnter(ObjectReference akActionRef)

	Float fltLastVisit
	Float fltCurrVisit
	Int iNdx = 0
	
	If (akActionRef == acPlayer && gvSaxhleelQst.GetValue() As Int == 1)
		fltLastVisit = gvLastVisit.GetValue()
		fltCurrVisit = gvDaysPassed.GetValue()
		; If at least half a game day has passed, reset the food barrels and cookie jar
		If (fltCurrVisit - fltLastVisit > 0.5)
			While (iNdx < 9)
				orFoodBarrel[iNdx].Reset()
			EndWhile
			gvLastVisit.SetValue(fltCurrVisit)
		EndIf
	EndIf

EndEvent
