Scriptname _00E_MQ06_Functions extends Quest Conditional

Import Utility
Import Game
Import Actor
Import _00E_QuestFunctions

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

Function SetUp()

	UnsummonApparitionIfExists()
	_FS_TheriantrophistControlQuest.TransformBackIfTransformed()
	
	JorrekBartar.Disable()
	Game.ForceFirstPerson() ; Reset the camera if in 3p

	;The following check prevents the first possible grey screen bug https://sureai.net/tracker/view.php?id=32, not the prettiest solution
	
	if SuntempleKuratorium == None
		SuntempleKuratorium = Game.GetForm(0x000A19FF) as Cell
	endif
	
	If MQ06_SC1_PlayerBed.GetParentCell() == SuntempleKuratorium
		PlayerREF.MoveTo(MQ06_SC1_PlayerPortToMarker02)
		PlayerREF.MoveTo(MQ06_SC1_PlayerBed)
	Else
		PlayerREF.MoveTo(MQ06_SiriusREF)
	EndIf
	
	FadeToBlackHoldIMOD.Apply()
	FadeToWhiteHoldImod.Remove()
	PlayerREF.RemoveAllItems(akTransferTo = MQ05ContainerREF, abKeepOwnership = false, abRemoveQuestItems = true) ; Debug only! Obsolete when MQ05 has been played before.
	PlayerREF.AddItem(ClothesMinerClothes, 1, true)
	PlayerREF.EquipItem(ClothesMinerClothes, false, true)
	MQ06Linker.Enable()
	SkyrimOvercastRain.ForceActive(True)
	Levelsystem.SkipTimeToHour(22.5)
	_00E_SilenceAbruptHighPriority.Add()
	Levelsystem.SetAllowIdleChatter(False)
	
	SafeMoveTo_NoWait(_00E_MC_JesparREF, MQ06_SC1_JesparStartMarker)
	Dunwar.ForceRefIfEmpty(_00E_MQ05_DunwarREF)
	SafeMoveTo_NoWait(_00E_MQ05_DunwarREF, MQ06_SC2_DunwarPortMarker)
	_00E_MQ05_DunwarREF.BlockActivation(True)
	_00E_MQ05_DunwarREF.SetUnconscious(False)
	_00E_MQ05_DunwarREF.SetOutfit(_00E_MC_Calia_SimpleClothingBarefeet)
	_00E_MQ05_DunwarREF.MoveTo(MQ06_SC2_DunwarBedREF)
	_00E_MQ05_DunwarREF.EvaluatePackage()

	SafeMoveTo_NoWait(_00E_MC_NataraREF, MQ06_SC1_NataraAppearMarker)
	SafeMoveTo_NoWait(_00E_MC_CaliaREF, MQ06_SC1_CaliaStartMarker)
	SafeMoveTo_NoWait(_00E_MC_TealorREF, MQ06_SC1_TealorMarker)
	SafeMoveTo_NoWait(MQ06_KonstantinREF, MQ06_SC1_KonstantinWalkMarker)

	If MQ06_SiriusREF.IsDisabled()
		MQ06_SiriusREF.Enable()
	EndIf

	_00E_MC_NataraREF.GetActorBase().SetName("")
	_00E_MC_CaliaREF.GetActorBase().SetName("")
	_00E_MC_TealorREF.GetActorBase().SetName("")
	MQ06_SiriusREF.GetActorBase().SetName("")
	
	If MQ06_SC1_PlayerBed.GetParentCell() == SuntempleKuratorium 
		PlayerAIWalk(True)
	EndIf

	Wait(0.2)
	SetStage(5)

EndFunction

Function DisableCharacters()

	;Set everyone except Jespar to be disabled, and everyone (apart from Konstantin and Sirius, who are already flagged) to ghost

	_DisableCharacter(_00E_MC_NataraREF, MQ06_SC1_NataraAppearMarker)
	_DisableCharacter(_00E_MC_CaliaREF, MQ06_SC1_CaliaStartMarker)
	_DisableCharacter(MQ06_KonstantinREF, MQ06_SC1_KonstantinWalkMarker)
	_DisableCharacter(_00E_MC_TealorREF, MQ06_SC1_TealorMarker)
	_DisableCharacter(MQ06_SiriusREF, None)
	
EndFunction

Function _DisableCharacter(Actor akChar, ObjectReference charMarkerRef)
	akChar.Disable()
	If charMarkerRef && akChar.GetParentCell() != SuntempleKuratorium
		akChar.MoveTo(charMarkerRef)
	EndIf
EndFunction

Function FadeBack()

	; Make sure Jespar is in the chair
	_00E_MC_JesparREF.MoveTo(MQ06_SC1_JesparJesparChair)
	MQ06_SC1_JesparJesparChair = None ; We don't need it anymore
	Wait(1.2)
	Game.ForceThirdPerson()
	Game.DisablePlayerControls(true, true, false, false, true, true, True, true)
	_00E_FadeBackLong.Apply()
	FadeToBlackHoldIMOD.Remove()
	Wait(5)
	MQ06_SC1_PlayerBed.Activate(PlayerREF)
	Game.EnablePlayerControls()
	Game.SetPlayerAIDriven(False)
	Game.RequestAutoSave()
	DeactivateBeds()
EndFunction

Function FadeInKonstantin()

	_00E_HighOnesMaterializeFXS.Stop(MQ06_SiriusREF)
	_00E_HighOnesMaterializeFXS.Play(MQ06_KonstantinREF)
	MAGConjurationCharge050M.Play(MQ06_KonstantinREF)
	Wait(0.5)
	MQ06_KonstantinREF.SetAlpha(1.0)
	
EndFunction

Function FadeInCalia()

	_00E_HighOnesMaterializeFXS.Stop(MQ06_KonstantinREF)
	_00E_HighOnesMaterializeFXS.Play(_00E_MC_CaliaREF)
	MAGConjurationCharge050M.Play(_00E_MC_CaliaREF)
	Wait(0.5)
	_00E_MC_CaliaREF.SetAlpha(1.0)

EndFunction

Function EnableAllCharacters()

	_EnableCharacter(MQ06_SiriusREF)
	_EnableCharacter(_00E_MC_NataraREF)
	_EnableCharacter(MQ06_KonstantinREF)
	_EnableCharacter(_00E_MC_CaliaREF)
	_EnableCharacter(_00E_MC_TealorREF)

EndFunction

Function _EnableCharacter(Actor akChar)
	akChar.EnableNoWait()
	akChar.SetAlpha(0.0)
EndFunction

Function StartCycleTheme()

	_00E_SilenceAbruptHighPriority.Remove()
	_00E_Music_Special_Zyklus_Loop.Add()

EndFunction

Function FadeInSirius()

	_00E_HighOnesMaterializeFXS.Play(MQ06_SiriusREF)
	MAGConjurationCharge050M.Play(MQ06_SiriusREF)
	Wait(0.25)
	MQ06_SiriusREF.SetAlpha(1.0)

EndFunction

Function FadeInNatara()

	_00E_HighOnesMaterializeFXS.Stop(_00E_MC_CaliaREF)
	_00E_HighOnesMaterializeFXS.Play(_00E_MC_NataraREF)
	MAGConjurationCharge050M.Play(_00E_MC_NataraREF)
	Wait(0.5)
	_00E_MC_NataraREF.SetAlpha(1.0)
	
EndFunction

Function FadeInTealor()

	If _00E_MC_TealorREF.IsDisabled()
		_00E_MC_TealorREF.Enable()
	EndIf
	
	If _00E_MC_TealorREF.GetParentCell() != SuntempleKuratorium
		_00E_MC_TealorREF.MoveTo(MQ06_SC1_TealorMarker)
		Wait(0.5)
		_00E_HighOnesMaterializeFXS.Play(_00E_MC_TealorREF)
	EndIf
	
	_00E_HighOnesMaterializeFXS.Stop(_00E_MC_NataraREF)
	_00E_HighOnesMaterializeFXS.Play(_00E_MC_TealorREF)
	MAGConjurationCharge050M.Play(_00E_MC_TealorREF)
	Wait(0.5)
	_00E_MC_TealorREF.SetAlpha(1.0)
	Wait(1)
	_00E_HighOnesMaterializeFXS.Stop(_00E_MC_TealorREF)
	
EndFunction

Function SetLookAtPlayer()

	_00E_MC_JesparREF.SetLookAt(PlayerREF)
	MQ06_KonstantinREF.SetLookAt(PlayerREF)
	_00E_MC_CaliaREF.SetLookAt(PlayerREF)
	_00E_MC_NataraREF.SetLookAt(PlayerREF)
	_00E_MC_TealorREF.SetLookAt(PlayerREF)
	MQ06_SiriusREF.SetLookAt(PlayerREF)

EndFunction

Function TurnActorsTranslucent()

	;Game.DisablePlayerControls()
	_00E_MQ06_HighOneVisionIntro.Apply()
	MakeActorTranslucent(_00E_MC_JesparREF)
	MakeActorTranslucent(MQ06_KonstantinREF)
	MakeActorTranslucent(_00E_MC_CaliaREF)
	MakeActorTranslucent(_00E_MC_NataraREF)
	MakeActorTranslucent(_00E_MC_TealorREF)
	MakeActorTranslucent(MQ06_SiriusREF)
	_00E_Horror_Ghosts_01M.Play(HighOnesSculpture.GetReference())
	Wait(2)
	_00E_MQ06_HighOneVisionIntro.PopTo(_00E_MQ06_HighOneVisionLoop)

EndFunction


Function EndVision()

	; Wait(2)
	Wait(0.1)
	_00E_MagicProtectionSpellM.Play(PlayerREF)
	Wait(2)
	Game.DisablePlayerControls()
	_00E_MC_TealoRREF.BlockActivation(True)
	_00E_MC_NataraREF.BlockActivation(True)
	_00E_MC_CaliaREF.BlockActivation(True)
	MQ06_SiriusREF.BlockActivation(True)
	MQ06_KonstantinREF.BlockActivation(True)
	_00E_MQ06_VisionFadeOut.Play(_00E_MC_JesparREF)
	_00E_MQ06_VisionFadeOut.Play(MQ06_KonstantinREF)
	_00E_MQ06_VisionFadeOut.Play(_00E_MC_CaliaREF)
	_00E_MQ06_VisionFadeOut.Play(_00E_MC_TealorREF)
	_00E_MQ06_VisionFadeOut.Play(MQ06_SiriusREF)
	_00E_MQ06_VisionFadeOut.Play(_00E_MC_NataraREF)
	Wait(2)
	FXExplosionCatapultNearM.Play(playerREF)
	_00E_MQ06_HighOneVisionLoop.PopTo(FadeToBlackHoldIMOD)
	FadeToBlackHoldIMOD.Apply()
	; Reset the camera if in 3p, so Dunwar would have time to finish the lie down animation out of sight
	Game.ForceFirstPerson()
	MakeActorInTranslucent(_00E_MC_TealorREF) ; Do this BEFORE disabling Tealor
	_00E_MC_TealoRREF.Disable()
	Wait(2)
	SetStage(20)

EndFunction

Function MakeActorTranslucent(Actor TargetActor)

	MS04MemoryFXBody01VFX.Play(TargetActor)
	TargetActor.SetAlpha(0.1, True)

EndFunction

Function MakeActorInTranslucent(Actor TargetActor)

	MS04MemoryFXBody01VFX.Stop(TargetActor)
	TargetActor.SetAlpha(1, True)

EndFunction

Function SetUpReal()

	ActivateBeds()
	SkyrimOvercastRain.ForceActive(True)
	Levelsystem.SkipTimeToHour(22.5)

	SafeMoveTo_NoWait(_00E_MQ05_DunwarREF, MQ06_SC2_DunwarBedREF)
	SafeMoveTo_NoWait(_00E_MC_CaliaREF, MQ06_SC2_CaliaLean)
	_00E_MC_CaliaREF.SetOutfit(_00E_MC_Calia_SimpleClothingBarefeet)
	_00E_MC_CaliaREF.UnEquipItem(_00E_MC_CaliaREF.GetEquippedWeapon())

	MQ12c_SC01_FailsaveREF.Enable()
	PlayerREF.MoveTo(MQ06_SC02_PlayerBed)
	PlayerAIWalk(True)
	Game.ForceThirdPerson()

	MQ06_SC2_PlayerWakesUp.ForceStart()

	_00E_MQ06_VisionFadeOut.Stop(_00E_MC_CaliaREF)
	_00E_Music_Special_Zyklus_Loop.Remove()
	Levelsystem.RemoveSilence()
	String facegen = "bUseFaceGenPreprocessedHeads:General"
	SetINIBool(facegen, False)
	Game.GetPlayer().QueueNiNodeUpdate()
	SetINIBool(facegen, True)

	MakeActorInTranslucent(_00E_MC_JesparREF)
	MakeActorInTranslucent(MQ06_KonstantinREF)
	MakeActorInTranslucent(_00E_MC_CaliaREF)
	MakeActorInTranslucent(_00E_MC_NataraREF)
	MakeActorInTranslucent(MQ06_SiriusREF)

EndFunction

Function RefreshPlayerEyes()

	String facegen = "bUseFaceGenPreprocessedHeads:General"
	SetINIBool(facegen, False)
	Game.GetPlayer().QueueNiNodeUpdate()
	SetINIBool(facegen, True)

EndFunction

Function DisableDoorBlocker()

	MQ12c_SC01_FailsaveREF.Disable()
	_00E_TeleportGlobal.SetValue(0)

EndFunction

Function StartCQC01()

	CQC01.SetStage(5)
	CQC01.SetObjectiveDisplayed(5)

EndFunction

Function FadeBackReal()

	MQ12c_SC1_ExecutionDoor001.SetOpen(False)
	_00E_MC_TealoRREF.BlockActivation(False)
	_00E_MC_NataraREF.BlockActivation(False)
	_00E_MC_CaliaREF.BlockActivation(False)
	MQ06_SiriusREF.BlockActivation(False)
	MQ06_KonstantinREF.BlockActivation(False)
	_00E_MC_NataraREF.GetActorBase().SetName("Natara Dal'Veram")
	_00E_MC_CaliaREF.GetActorBase().SetName("Calia Sakaresh")
	_00E_MC_TealorREF.GetActorBase().SetName("Tealor Arantheal")
	MQ06_SiriusREF.GetActorBase().SetName("Sirius")

	String facegen = "bUseFaceGenPreprocessedHeads:General"
	SetINIBool(facegen, False)
	Game.GetPlayer().QueueNiNodeUpdate()
	SetINIBool(facegen, True)
	Game.DisablePlayerControls(true, true, false, false, true, true, True, true)
	Game.RequestAutoSave()
	_00E_FadeBackLong.Apply()
	FadeToBlackHoldIMOD.Remove()
	Wait(2)
	MQ06_SC02_PlayerBed.Activate(PlayerREF, True)
	Wait(3)
	PlayerAIWalkStop()
	_00E_Music_Special_Zyklus_Loop.Remove()
	Levelsystem.RemoveSilence()
	DeactivateBeds()
	Levelsystem.SetAllowIdleChatter(True)
	
EndFunction

Function CaliaPutOnShoes()

	Levelsystem.RemoveSilence()
	_00E_MC_CaliaREF.SetOutfit(_00E_MC_Calia_SimpleClothing)
	MQ06_SC3_CaliaShowsPlayerAround.ForceStart()
	If _00E_MC_CaliaREF.GetEquippedWeapon() != None
		_00E_MC_CaliaREF.RemoveItem(_00E_MC_CaliaREF.GetEquippedWeapon())
	EndIf
	SkyrimOvercastRain.SetActive()

EndFunction

Function DespawnDunwar()

	If _00E_MQ05_DunwarREF.IsEnabled()
		_00E_MQ05_DunwarREF.Disable()
	EndIf

EndFunction

Function StartTealorScene()

	ActivateBeds()
	_00E_MC_TealorREF.Enable()
	Levelsystem.RemoveSilence()
	MQ06Linker.Disable()
	_00E_MC_TealorREF.MoveToMyEditorLocation()
	_00E_MC_TealorREF.MoveTo(MQ16_SC04_TealorStartMarker)
	KonstantinBasic.MoveTo(MQ06KonstTelRef)
	MQ06_SC4_TealorScene.ForceStart()
	
EndFunction

Function StartJesparQuest()

	If CQJ01.IsCompleted()
		CQJ02.SetStage(5)
	Elseif !(CQJ01.IsCompleted())
		CQJ01.FailAllObjectives()
		CQJ01.SetStage(20)
	EndIf
	
	If CQJ01_SC01_DancingNomadScene.IsPlaying()
		CQJ01_SC01_DancingNomadScene.Stop()
	EndIf

EndFunction


Function SetCereTimer()

	StartJesparQuest()
    _00E_TeleportGlobal.SetValue(0) ; Failsave, in case
                                    ; DisableDoorBlocker() fails to
                                    ; get called for some reason.
	RegisterForUpdateGameTime(24)
	GameDay = GameDaysPassed.GetValue() as Int
	
EndFunction


Function StartCer()

	CompanionIsTalking.SetValueInt(0)
	PlaceCeremonyKeeper()
	_00E_EnderalOvercast.SetActive(True)
	FillSpectators()
	JorrekBartar.Enable()
	Magier.Enable()
	_00E_MC_TealorREF.MoveTo(TealorRitualIdle)
	
	If _00E_MC_CaliaREF.IsDisabled()
		_00E_MC_CaliaREF.Enable()
	EndIf

	MQ06_SC05_JorekBench.SetFactionOwner(MQ06_SC05_JorekBenchFaction)

	Form[] idleMarkers = MQ06_SC05_IdleMarkerList.ToArray()
	Int iIndex = 0
	While iIndex < idleMarkers.Length
		(idleMarkers[iIndex] as ObjectReference).Disable()
		iIndex += 1
	EndWhile
	
	_00E_MC_CaliaREF.MoveTo(CaliaRitualMarker)
	_00E_MC_CaliaREF.SetOutfit(_00E_MC_Calia_Outfit)
	MQ06_SC5_RitualScene.ForceStart()
	JorrekBartar.Enable()
	JorrekBartar.MoveTo(MQ06_SC05_JorekBench)
	_00E_MC_NataraREF.MoveTo(MQ06_SC05_NataraMarker)
	_00E_MQ06_SunTempleArmoryGlobal.SetValueInt(0) ;This allows the player to buy all kinds of keeper / order stuff from the suntemple armory
	
EndFunction

Function ConsecreationFailsave()
	
	if _00E_MC_TealorREF.GetParentCell() != SuntempleSanctum
		_00E_MC_TealorREF.MoveTo(MQ06_Tealor_FailsaveREF)
	EndIf
	
	If _00E_MC_CaliaREF.GetParentCell() != SuntempleSanctum
		_00E_MC_CaliaREF.MoveTo(CaliaRitualMarker)
	EndIf
	
	If !MQ06_SC5_RitualScene.IsPlaying()
		MQ06_SC5_RitualScene.ForceStart()
	EndIf

EndFunction

Function OnConsecrationKicksIn()
	Levelsystem.StopRandomHeadTracking()

	Int iIndex = 0
	While iIndex < SC05_SpectatorArray.Length
		Actor akSpectator = SC05_SpectatorArray[iIndex].GetActorReference()
		If akSpectator
			akSpectator.SetLookAt(_00E_MC_TealorREF)
		EndIf
		iIndex += 1
	EndWhile

	Alias_Magier01.GetActorReference().SetLookAt(_00E_MC_TealorREF)
	JorrekBartar.SetLookAt(_00E_MC_TealorREF)
	_00E_MC_NataraREF.SetLookAt(_00E_MC_TealorREF)
EndFunction

Function StartSilence()

	if _00E_MC_TealorREF.GetParentCell() != SuntempleSanctum
		
		_00E_MC_TealorREF.MoveTo(TealorRitualIdle)
		
	EndIf

	bRitualPlaying = True
	Levelsystem.RemoveSilence()
	CompanionIsTalking.SetValueInt(0)
	_00E_Music_Special_MQ06_Consecration.Add()
	_00E_SilenceTransitionLowPriority02.Add()
	PlayerREF.EquipItem(_00E_InvisibleHelmet_Armor, false, true)	
	Wait(0.1)
	PlayerREF.RemoveItem(_00E_InvisibleHelmet_Armor, 1, true)

EndFunction

Function CrowdSayLine()

	_00E_Crowd_MQ06MayYourLightGuideMeM.Play(PlayerREF)

EndFunction

Function FillSpectators()

	Form[] spectators = MQ06_SC05_RitualList.ToArray()
	Int iIndex = 0
	While iIndex < spectators.Length
		Actor akSpectator = (spectators[iIndex] as Actor)
		If akSpectator.IsDead() == False
			akSpectator.MoveTo(CaliaRitualMarker)
			SC05_SpectatorArray[iIndex].ForceRefTo(akSpectator)
		EndIf
		iIndex += 1
	EndWhile

EndFunction

Function UnfillSpectators()

	Int iIndex

	Levelsystem.ResumeRandomHeadTracking()

	JorrekBartar.ClearLookAt()
	_00E_MC_NataraREF.ClearLookAt()
	Alias_Magier01.GetActorReference().ClearLookAt()

	iIndex = 0
	While iIndex < SC05_SpectatorArray.Length
		Actor akSpectator = SC05_SpectatorArray[iIndex].GetActorReference()
		If akSpectator
			akSpectator.ClearLookAt()
		EndIf
		iIndex += 1
	EndWhile

	MQ06_SC05_JorekBench.SetFactionOwner(None)

	Form[] idleMarkers = MQ06_SC05_IdleMarkerList.ToArray()
	iIndex = 0
	While iIndex < idleMarkers.Length
		(idleMarkers[iIndex] as ObjectReference).Enable()
		iIndex += 1
	EndWhile

	Levelsystem.RemoveSilence()
	_00E_Music_Special_MQ06_Consecration.Remove()
	RegisterForSingleUpdateGameTime(1.0)

	iIndex = 0
	While iIndex < SC05_SpectatorArray.Length
		SC05_SpectatorArray[iIndex].Clear()
		iIndex += 1
	EndWhile
	
	CompanionIsTalking.SetValueInt(0)
	Levelsystem.SetAllowIdleChatter(True)

EndFunction

Function StopWeatherFX()

	bRitualPlaying = False
	Weather.ReleaseOverride()
	_00E_SilenceLongTransitionHighPriority.Remove()
	
EndFunction

Function GivePlayerArmor(int iSetIndex)

	SetObjectiveCompleted(35)
	bPlayerGotArmor = True

	if iSetIndex == 1
		PlayerREF.AddItem(_00E_Order_Warden_Boots, 1)
		PlayerREF.AddItem(_00E_Order_Warden_Helmet, 1)
		PlayerREF.AddItem(_00E_Order_Warden_Cuirass, 1)
		PlayerREF.AddItem(_00E_Order_Warden_Gauntlets, 1)
		PlayerREF.AddItem(_00E_Order_Warden_Cape, 1)
	ElseIf iSetIndex == 2
		PlayerREF.AddItem(_15E_LightCityGuardBoots, 1)
		PlayerREF.AddItem(_15E_LightCityGuardCuirass, 1)
		PlayerREF.AddItem(_15E_LightCityGuardHelmet, 1)
	Else
		PlayerREF.AddItem(_00E_Order_ArcanistRobe, 1)
		PlayerREF.AddItem(_00E_Order_ArcanistHood, 1)
	EndIf
		
EndFunction

Function DeactivateBeds()

	int iIndex = MQ06_BedsFormlist.GetSize()
	
	while iIndex > 0
		iIndex -= 1
		ObjectReference objBedRef = MQ06_BedsFormlist.GetAt(iIndex) as ObjectReference
		objBedRef.BlockActivation(True)
	endwhile

EndFunction

Function ActivateBeds()

	int iIndex = MQ06_BedsFormlist.GetSize()
	
	while iIndex > 0
		iIndex -= 1
		ObjectReference objBedRef = MQ06_BedsFormlist.GetAt(iIndex) as ObjectReference
		objBedRef.BlockActivation(False)
	endwhile

EndFunction

Function PlaceCeremonyKeeper()

	MQ06_SC06_CeremonyKeeperSC.ForceStart()

	MQ06_SC06_CeremonyKeeperREF.Enable()

EndFunction

Function DisableCeremonyKeeper()

	MQ06_SC06_CeremonyKeeperREF.Disable()

EndFunction

Function AddSilence()

	_00E_SilenceLongTransitionHighPriority.Add()

EndFunction

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


Event OnUpdate()

if MQ06_SC1_PlayerEncountersHighOne.IsPlaying()
	SetLookAtPlayer()
	RegisterForSingleUpdate(7)
Else
	Return
EndIf

EndEvent

Event OnUpdateGameTime() ; because of how we registered, this event occurs every 30 minutes of game time	

	if (GameDaysPassed.GetValue() + 1 >= GameDay) && GetStage() == 35
		SetStage(40)
		UnregisterForUpdateGameTime()
	ElseIf GetStage() == 55
		StopWeatherFX()
	EndIf
	
endEvent


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

bool Property bPlayerGotArmor Auto Conditional Hidden
bool Property bRitualPlaying Auto Conditional Hidden

int Property __Config_RewardEXP Auto
{How much EXP is granted upon completion}

int Property iKeeperMiniStage Auto Conditional Hidden

_00E_QuestFunctions Property Levelsystem Auto

Int GameDay

GlobalVariable Property GameDaysPassed Auto
GlobalVariable Property _00E_MQ06_SunTempleArmoryGlobal Auto
GlobalVariable Property CompanionIsTalking Auto
GlobalVariable Property _00E_TeleportGlobal Auto

Quest Property CQC01 Auto
Quest Property CQJ01 Auto
Quest Property CQJ02 Auto

Actor Property PlayerREF Auto
Actor Property _00E_MC_JesparREF Auto
Actor Property MQ06_KonstantinREF Auto
Actor Property _00E_MC_CaliaREF Auto
Actor Property _00E_MC_NataraREF Auto
Actor Property _00E_MC_TealorREF Auto
Actor Property MQ06_SiriusREF Auto
Actor Property _00E_MQ05_DunwarREF Auto
Actor Property KonstantinBasic Auto
Actor Property JorrekBartar Auto
Actor Property Magier Auto
Actor Property MQ06_SC06_CeremonyKeeperREF Auto

EffectShader Property _00E_MQ06_VisionFadeOut Auto
EffectShader Property _00E_HighOnesMaterializeFXS Auto

Outfit Property _00E_MC_Calia_SimpleClothingBarefeet Auto
Outfit Property _00E_MC_Calia_SimpleClothing Auto
Outfit Property _00E_MC_Calia_Outfit Auto

ReferenceAlias Property HighOnesSculpture Auto
ReferenceAlias Property Alias_Magier01 Auto
ReferenceAlias Property Dunwar Auto

ReferenceAlias[] Property SC05_SpectatorArray Auto

Sound Property _00E_MagicProtectionSpellM Auto
Sound Property _00E_Horror_Ghosts_01M Auto
Sound Property FXExplosionCatapultNearM Auto
Sound Property _00E_Crowd_MQ06MayYourLightGuideMeM Auto
Sound Property MAGConjurationCharge050M Auto

VisualEffect Property MS04MemoryFXBody01VFX Auto

Weather Property _00E_EnderalOvercast Auto
Weather Property SkyrimOvercastRain Auto

ImageSpaceModifier Property FadeToBlackHoldIMOD Auto
ImageSpaceModifier Property _00E_FadeBackLong Auto
ImageSpaceModifier Property _00E_MQ06_HighOneVisionIntro Auto
ImageSpaceModifier Property _00E_MQ06_HighOneVisionLoop Auto
ImageSpaceModifier Property FadeToWhiteHoldImod Auto

MusicType Property _00E_SilenceLongTransitionHighPriority Auto
MusicType Property _00E_Music_Special_MQ06_Consecration Auto
MusicType Property _00E_SilenceAbruptHighPriority Auto
MusicType Property _00E_Music_Special_Zyklus_Loop Auto
MusicType Property _00E_SilenceTransitionLowPriority02 Auto

ObjectReference Property MQ06_SC1_JesparStartMarker Auto
ObjectReference Property MQ06_SC1_JesparJesparChair Auto
ObjectReference Property MQ06_SC1_PlayerPortToMarker02 Auto
ObjectReference Property MQ06_SC1_PlayerBed Auto
ObjectReference Property MQ06_SC1_CaliaStartMarker Auto
ObjectReference Property MQ06_SC1_NataraAppearMarker Auto
ObjectReference Property MQ06_SC1_KonstantinWalkMarker Auto
ObjectReference Property MQ06_SC1_TealorMarker Auto
ObjectReference Property MQ06_SC2_DunwarPortMarker Auto
ObjectReference Property MQ05ContainerREF Auto
ObjectReference Property MQ06_SC2_CaliaLean Auto
ObjectReference Property MQ06_SC05_JorekBench Auto
ObjectReference Property MQ16_SC04_TealorStartMarker Auto
ObjectReference Property MQ12c_SC01_FailsaveREF Auto
ObjectReference Property MQ06_SC2_DunwarBedREF Auto
ObjectReference Property MQ12c_SC1_ExecutionDoor001 Auto
ObjectReference Property MQ06_Tealor_FailsaveREF Auto
ObjectReference Property MQ06KonstTelRef Auto
ObjectReference Property TealorRitualIdle Auto
ObjectReference Property CaliaRitualMarker Auto
ObjectReference Property MQ06_SC05_NataraMarker Auto
ObjectReference Property MQ06Linker Auto
ObjectReference Property MQ06_SC02_PlayerBed Auto

Cell Property SuntempleSanctum Auto
Cell Property SuntempleKuratorium Auto

Formlist Property MQ06_BedsFormlist Auto
Formlist Property MQ06_SC05_IdleMarkerList Auto
Formlist Property MQ06_SC05_RitualList Auto

Armor Property ClothesMinerClothes Auto
Armor Property _00E_InvisibleHelmet_Armor Auto
Armor Property _00E_Order_Warden_Boots Auto
Armor Property _00E_Order_Warden_Cuirass Auto
Armor Property _00E_Order_Warden_Helmet Auto
Armor Property _00E_Order_Warden_Gauntlets Auto
Armor Property _00E_Order_Warden_Cape Auto
Armor Property _15E_LightCityGuardBoots Auto
Armor Property _15E_LightCityGuardCuirass Auto
Armor Property _15E_LightCityGuardHelmet Auto
Armor Property _00E_Order_ArcanistRobe Auto
Armor Property _00E_Order_ArcanistHood Auto
Scene Property MQ06_SC1_PlayerEncountersHighOne Auto
Scene Property MQ06_SC2_PlayerWakesUp Auto
Scene Property MQ06_SC3_CaliaShowsPlayerAround Auto
Scene Property MQ06_SC4_TealorScene Auto
Scene Property MQ06_SC5_RitualScene Auto
Scene Property MQ06_SC06_CeremonyKeeperSC Auto
Scene Property CQJ01_SC01_DancingNomadScene Auto

Faction Property MQ06_SC05_JorekBenchFaction Auto