ScriptName aaaKimachuuBeheadingTake Extends ObjectReference

Armor Property aHead Auto
MiscObject Property mOldHead Auto
MiscObject Property mNewHead Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
	Actor actLoot = akNewContainer As Actor
	Actor actDead = akOldContainer As Actor
	actDead.EquipItem(aHead)
	If !actDead.IsDead()
		actDead.KillEssential(actLoot)
	EndIf
	akNewContainer.RemoveItem(mOldHead, 1, true)
	ObjectReference objHeadRef = actLoot.PlaceAtMe(mNewHead, 1, true, false)
	String sHeadName = actDead.GetDisplayName()
	objHeadRef.SetDisplayName(mNewHead.GetName() + " (" + sHeadName + ")")
	objHeadRef.SetActorOwner(actLoot.GetActorBase())
	objHeadRef.Activate(actLoot)
EndEvent