Scriptname zbfEffectBondage extends activemagiceffect  

zbfBondageShell Property zbf Auto

Actor kTarget
;Int iEffectId

keyword Property zbfEffectOpenMouth Auto
keyword Property zbfEffectWrist Auto
keyword Property zbfEffectSetExpression Auto

Bool bApplyWrist
Bool bApplyMouth
Bool bApplyMovement
Bool bApplySilence
Bool bApplyPlayerControls

Function RegisterForAnotherUpdate()
	Float fRegisterFrequency = zbf.GetNextUpdate(kTarget)
	If fRegisterFrequency >= 0.1
		RegisterForSingleUpdate(fRegisterFrequency)
	EndIf
EndFunction

Auto State Default
	Event OnUpdate()
		zbf.ApplyAllModifiers(kTarget, bApplyWrist, bApplyMouth, bApplyMovement, bApplySilence, bApplyPlayerControls)

		RegisterForAnotherUpdate()
	EndEvent

	Event OnEffectStart(Actor akTarget, Actor akCaster)
		;iEffectId = Utility.RandomInt(0, 1000)
		;Debug.Trace("zbf Effect start: " + iEffectId)
		kTarget = akTarget
		bApplyWrist = zbf.HasWristModifier(akTarget)
		bApplyMouth = zbf.HasExpressionModifier(akTarget)
		bApplyMovement = zbf.HasMovementModifier(akTarget)
		bApplySilence = zbf.HasSilenceEffect(akTarget)
		bApplyPlayerControls = zbf.HasPlayerControls(akTarget)
		
		zbf.ApplyAllModifiers(kTarget, bApplyWrist, bApplyMouth, bApplyMovement, bApplySilence, bApplyPlayerControls)

		RegisterForAnotherUpdate()
	EndEvent

	Event OnEffectFinish(Actor akTarget, Actor akCaster)
		;Debug.Trace("zbf Effect finish: " + iEffectId)
		zbf.ApplyAllModifiers(kTarget, bApplyWrist, bApplyMouth, bApplyMovement, bApplySilence, bApplyPlayerControls)

		; UpdateEvent is unregistered automatically when script terminates.
	EndEvent
EndState
