;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 9
Scriptname SF_MQ11b_SC03_Interrupt_00145912 Extends Scene Hidden

;BEGIN FRAGMENT Fragment_8
Function Fragment_8()
;BEGIN CODE
StopTryingEnableBarrier()
(Game.GetPlayer() as _00E_PlayerFunctions).ResumeRandomHeadTracking()
;END CODE
EndFunction
;END FRAGMENT

;BEGIN FRAGMENT Fragment_3
Function Fragment_3()
;BEGIN CODE
_00E_MQ11b_Questfunctions MQ11bquest = GetOwningQuest() as _00E_MQ11b_Questfunctions
MQ11bquest.SetCurrentStageID(190)
MQ11bquest.StartCombatAdila()
;END CODE
EndFunction
;END FRAGMENT

;BEGIN FRAGMENT Fragment_7
Function Fragment_7()
;BEGIN CODE
RegisterForSingleUpdate(0.25)
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

Function TryEnableBarrier()
	If bBarrierEnablePeriod == False
		Return
	EndIf
	
	; Wait for Jespar and Adila to travel inside the (future) barrier. Screw Gefangener.
	ObjectReference markerRef = Alias_SC02_CaptiveMarker.GetRef()
	If Alias_Jespar.GetRef().GetDistance(markerRef) <= 250.0 && Alias_Adila.GetRef().GetDistance(markerRef) <= 250.0
		If bBarrierEnablePeriod
			bBarrierEnablePeriod = False
			MQ11b.KnockPlayer()
		EndIf
	Else
		RegisterForSingleUpdate(0.25)
	EndIf
EndFunction

Event OnUpdate()
	TryEnableBarrier()
EndEvent

Function StopTryingEnableBarrier()
	If bBarrierEnablePeriod
		bBarrierEnablePeriod = False
		UnregisterForUpdate()
	EndIf
EndFunction

_00E_MQ11b_Questfunctions Property MQ11b Auto
ReferenceAlias Property Alias_Jespar Auto
ReferenceAlias Property Alias_Adila Auto
ReferenceAlias Property Alias_SC02_CaptiveMarker Auto
Bool bBarrierEnablePeriod = True