Scriptname _00E_CQC06_GetCaliaSC extends ObjectReference  

;=====================================================================================
;                                        EVENTS                                      
;=====================================================================================

Event OnTriggerEnter(ObjectReference akActionRef)

	If akActionRef == PlayerREF
		CheckForCalia()
	EndIf

EndEvent

Event OnTriggerLeave(ObjectReference akActionRef)

	If bDone && !CQC06.IsCompleted() && akActionRef == PlayerREF
		bDone = False
	EndIf

EndEvent

;=====================================================================================
;                                        FUNCTIONS                                      
;=====================================================================================

Function CheckForCalia()

; Enabling Calia and set stage.

	If !bDone && CQC06.GetCurrentStageID() == 5
		If (GameHour.GetValue() < 18) && (GameHour.GetValue() > 4)
			_00E_CQC06_sComeBackLater.Show()
		Else
			CQC06.SetCurrentStageID(10)
			bDone = True
		EndIf
	EndIf

	; Making sure that the scene is actually running.
	If (CQC06.GetCurrentStageID() >= 10 || bDone) && CQC06.GetCurrentStageID() < 25
		If !CQC06.IsCompleted() && !CQC06_SC01_CaliaGoToTavern.IsPlaying()
			CQC06_SC01_CaliaGoToTavern.ForceStart()
		EndIf
	EndIf

EndFunction

;=====================================================================================
;                                        PROPERTIES                                      
;=====================================================================================

bool bDone
_00E_CQC06_Functions Property CQC06 Auto
Actor Property PlayerREF Auto
GlobalVariable Property GameHour Auto
Message Property _00E_CQC06_sComeBackLater Auto
Scene Property CQC06_SC01_CaliaGoToTavern Auto