Scriptname aaaBundoriOnhit extends ActiveMagicEffect  

Event OnHit(ObjectReference akAggressor,Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
	if akAggressor != Game.Getplayer()
		return
	elseif akSource as Spell
		return
	elseif akProjectile != none
		return
	endif

	Actor targetRef = GetTargetActor()
	int index = targetRef.GetNumItems()
	form akForm
	
	if index > 1
		int random = Utility.RandomInt(1, index)
		akForm = targetRef.GetNthForm(random)
	elseif index == 1
		akForm = targetRef.GetNthForm(index)
	endif

	if akForm != none
		targetRef.RemoveItem(akForm,1,false,Game.GetPlayer())
	endif
EndEvent
