Scriptname SuH_contS_sacchest extends ObjectReference 

SuH_Fun property _f auto
int itempoints

Event OnInit()
	_f = Game.GetFormFromFile(0x814, "Succubus Heart.esp") as SuH_Fun
endEvent

Event OnOpen(ObjectReference akActionRef)
   Debug.MessageBox("'Feed me, for I lust for substance...'")
   itempoints = 0
endEvent

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	;calc item points to add
	itempoints += Math.Floor((((akBaseItem.GetWeight() * aiItemCount) * 100 ) + (akBaseItem.GetGoldValue())))
endEvent

Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
	itempoints -= Math.Floor((((akBaseItem.GetWeight() * aiItemCount) * 100 ) + (akBaseItem.GetGoldValue())))
endEvent

Event OnClose(ObjectReference akActionRef)
	if itempoints > 0
		int xpconvert = Math.Floor(itempoints * 0.1)
		debug.MessageBox("'Forever hunger for mass...' ("+xpconvert+" HeartXP gifted)")
		_f.XPcalc(XPearn=xpconvert)
	endIf
	self.RemoveAllItems()
	itempoints = 0
endEvent