Scriptname _00E_FS_NQR05_Functions extends Quest Conditional

Import Utility

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

int iTimer
bool bSlowMoActive

Event OnSleepStop(bool abInterrupted)
	;If !(MQ09.GetStage() >= 5) && !(MQ09.GetStage() < 80) ; awakening in train in MQ09, awakening after 2nd Dream on the boat in MQ10a/b?, 3rd Dream in MQ12c Dream after siege, awakening in FS_MQ18c, in MQ06 in the curarium
		SetStage(10)
	;EndIf
endEvent

Event OnUpdate()

	If GetStage() == 215
	
		ShootArrow()
	
	ElseIf GetStage() == 320

		If iTimer < 0 && !bSlowMoActive
			iTimer += 1
		ElseIf iTimer == 0 && !bSlowMoActive
			bSlowMoActive = true
			EnterSlowMotion()
		EndIf
		
		If bAnimationFired == false 
			Debug.SendAnimationEvent(FS_NQR05_TharaelREF, "attackPowerStartForward")
			bAnimationFired = true
		EndIf
		
		If !bSlowMoActive || !bAnimationFired
			RegisterForSingleUpdate(0.1)
		EndIf
		
	EndIf
		
EndEvent

Event OnAnimationEvent(ObjectReference akSource, string asEventName)

	If (akSource == FS_NQR05_TharaelREF) && (asEventName == "PowerAttack_Start_End")
		UnregisterForAnimationEvent(FS_NQR05_TharaelREF, "PowerAttack_Start_End")
	EndIf
		
EndEvent

Event OnUpdateGameTime()
	If PlayerREF.GetParentCell() != FS_NQR05_Temple_03
		Player.Clear()
		If FS_NQR05_SC21_LethoStitched.IsEnabled()
			FS_NQR05_SC21_LethoStitched.Disable()
		EndIf
	Else
		RegisterForSingleUpdateGameTime(0.5)
	EndIf
EndEvent

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

Function SetUp()
	
	;gets called at the end of FS_NQR04, registers for sleep
	RegisterForSleep()
	SetObjectiveDisplayed(5)

EndFunction

Function StartSC01()
	
	; called on stage 10 when the player sleeps, 
	; sets up the dream sequence and starts it, prevents the player from teleporting out of it
	_00E_TeleportGlobal.SetValueInt(1)
	
	If FS_NQR03_LethoREF.IsDisabled()
		FS_NQR03_LethoREF.Enable()
	EndIf
	
	FS_NQR03_LethoREF.MoveTo(FS_NQR03_BrotherGriefMarkerREF)

	UnregisterForSleep()
	FS_NQR05_SC01_Dream.ForceStart()
	FadeToBlackHoldIMOD.Apply()
	
	returnFurniture = PlayerREF.GetFurnitureReference()
	
	If returnFurniture == None
		returnFurniture = PlayerREF.PlaceAtMe(XMarkerHeading)
	EndIf
	
	PlayerREF.MoveTo(FS_NQR05_DreamStartMarkerREF)
	FS_NQR05_SC01_FakeFatherREF.MoveTo(FS_NQR05_SC01_FatherMarkerREF)
	Wait(1)
	FadeToBlackHoldIMOD.Remove()
	FadeToBlackBackIMOD.ApplyCrossFade(afFadeDuration = 0.5)
	Game.DisablePlayerControls(false, false, false, false, false, false, true, false)
	SetObjectiveDisplayed(10)
	
EndFunction


Function FinishDream()
	
	; dream sequence is finished, player gets moved back to their inital place
	_00E_MQ09KnockOutLong.Apply()
	Wait(7)
	FadeToBlackHoldIMOD.ApplyCrossFade()
	SetObjectiveCompleted(5)
	SetObjectiveCompleted(10)
	PlayerREF.MoveTo(returnFurniture)
	Game.EnablePlayerControls()
	SetObjectiveDisplayed(15)
	SetObjectiveDisplayed(20)
	FS_NQR05_TharaelREF.Enable()
	FS_NQR05_TharaelREF.SetOutfit(_00E_FS_TharaelOutfit)
	FadeToBlackBackIMOD.ApplyCrossFade()
	FS_NQR03_SC03_SecretDoorREF.BlockActivation(False)
	FS_NQR03_SC03_SecretDoorREF.Lock(False)
	_00E_TeleportGlobal.SetValueInt(0)
	
EndFunction

Function StartSC02()
	
	; sets up the scene where the player encounters the father for the first time
	FS_NQR05_FatherREF.Enable()
	FS_NQR05_FatherREF.MoveTo(FS_NQR05_FatherStartMarker)
	SetObjectiveCompleted(15)
	SetObjectiveDisplayed(25)
	FS_NQR05_SC02_Father.ForceStart()

EndFunction

Function DissolveWall()
	
	; removes obstacle that blocked the way to the room of the father
	OBJEyeofMagnusVanishM.Play(FS_NQR05_SC02_DissolveWallREF)
	_00E_MQ07b_DissolvePlatformFXS.Play(FS_NQR05_SC02_DissolveWallREF)
	Wait(3)
	FS_NQR05_SC02_DissolveWallREF.Disable()
	MAGIllusionReleaseAimedSDM.Play(PlayerREF)

EndFunction

Function AddFatherMusic()

	_00E_FS_Music_Explore_RhalataTempleSingle.Add()
	
EndFunction

Function UpdateObjectives01()

	SetObjectiveCompleted(26)
	SetObjectiveDisplayed(30)

EndFunction

Function UpdateObjectives02()

	Game.DisablePlayerControls()
	SetObjectiveCompleted(30)

EndFunction

Function GiveFirstRate()

	PlayerREF.AddItem(Gold001, 250)

EndFunction

Function UpdateObjectives03()
	
	; Called in stage 60
	GiveFirstRate()
	SetObjectiveDisplayed(35)
	FS_NQR05_TharaelREF.Disable()
	FS_NQR05_SC03_TriggerREF.Enable()

EndFunction

Function StartSC03()

	; Called in stage 65, sets up the preparation
	FadeToBlackIMOD.Apply()
	Wait(3.0)
	FadeToBlackBackIMOD.ApplyCrossFade()
	FS_NQR05_TharaelREF.MoveTo(FS_NQR05_TharaelMarkerREF)
	FS_NQR05_TharaelREF.Enable(True)
	FS_NQR05_SC03_TharaelPreparation.ForceStart()
	
EndFunction

Function FadeToBlackAndBack()

	FadeToBlackIMOD.Apply()
	Wait(3.0)
	FadeToBlackBackIMOD.ApplyCrossFade()

EndFunction

Function UpdateObjectives04()

	; Called in stage 75
	SetObjectiveCompleted(35)
	SetObjectiveDisplayed(40)
	FS_NQR05_SC03_TriggerREF.Disable()
	FS_NQR05_SC05_GateREF.BlockActivation(true)
	EnableAllRhalataSiteNPC()
	FS_NQR05_SC04_BrotherSorrowREF.Enable()
	FS_NQR05_SC04_BrotherSorrowREF.MoveTo(FS_NQR05_SC04_BrotherSorrowMarker)

EndFunction

Function EnableAllRhalataSiteNPC()
	
	; making sure that all necessary NPCs are enabled for the scenes in the frostcliff mountains
	int iIndex = FS_NQR05_RhalataSiteNPCs.GetSize()
	
	While iIndex > 0
		iIndex -= 1
		ObjectReference objToDisable = FS_NQR05_RhalataSiteNPCs.GetAt(iIndex) as ObjectReference
		objToDisable.Enable()
	EndWhile
	
EndFunction

Function OpenGate()

	; Called in stage 80
	FS_NQR05_SC05_GateREF.BlockActivation(False)
	FS_NQR05_SC05_GateREF.SetOpen(True)

EndFunction

Function UpdateObjectives05()

	; Called in stage 85
	SetObjectiveCompleted(40)
	SetObjectiveDisplayed(45)

EndFunction

Function UpdateObjectives06()

	; Called in stage 90
	SetObjectiveCompleted(45)
	SetObjectiveDisplayed(50)
	FS_NQR05_SC05_Zaraah.ForceStart()

EndFunction

Function UpdateObjectives07()

	; Called in stage 100
	SetObjectiveCompleted(50)
	SetObjectiveDisplayed(55)

EndFunction

Function UpdateObjectives08()

	; Called in stage 110
	SetObjectiveCompleted(55)
	SetObjectiveDisplayed(60)
	FS_NQR05_SC05_GateREF.SetOpen(False)
	FS_NQR05_SC06_ActivationTriggerREF.Enable()

EndFunction

Function StartSC06()

	; Called in stage 115
	FS_NQR05_SC06_ActivationTriggerREF.Disable()
	; transform the player back if currently a werewolf, due to being used as actor in scenes in SC06
	_FS_TheriantrophistControlQuest.TransformBackIfTransformed()
	FS_NQR05_SC06_FatherArrival.ForceStart()
	FadeToBlackIMOD.Apply()
	Wait(2.5)
	FadeToBlackHoldIMOD.ApplyCrossFade()
	Timescale.SetValue(0.01) ; preventing the time from advancing during this lengthy scene
	Levelsystem.SkipTimeToHour(18.75)
	_00E_FS_NQR05_SiteWeatherSnow.ForceActive(True)
	Levelsystem.SetAllowIdleChatter(false)
	FS_NQR05_SC05_GateREF.SetOpen(False)
	FS_NQR05_SC05_GateREF.BlockActivation(True)
	_00E_TeleportGlobal.SetValueInt(1)
	PlayerREF.MoveTo(FS_NQR05_SC06_WallMarkerREF)
	Game.DisablePlayerControls()

EndFunction

Function FadeBack()

	; Called in Phase 2, FS_NQR05_SC06_FatherArrival
	; FadeToBlackHoldIMOD.Remove()
	; FS_NQR05_ZaraahREF.Enable()
	FadeToBlackBackIMOD.ApplyCrossFade()
	FS_NQR05_SiteWorkingAmbREF.Disable()
	Wait(2)
	MAGShockExpImod.Apply()
	AMBRumbleShake.Play(PlayerREF)
	FS_NQR05_ZaraahREF.MoveTo(FS_NQR05_SC08_SisterAddiction_GroupMarker003)
	FS_NQR05_Dust_TriggerREF.Activate(FS_NQR05_Dust_TriggerREF)
	Game.ShakeCamera(afStrength = 0.2)
	; starts moving all necessary NPCs towards their idle markers just before the arrival
	int iIndex = FS_NQR05_RhalataSiteNPCs.GetSize()
	
	While iIndex > 0
		iIndex -= 1
		Actor akActor = FS_NQR05_RhalataSiteNPCs.GetAt(iIndex) as Actor
		akActor.EvaluatePackage()
	EndWhile

EndFunction

Function OpenPortal()
	
	FS_NQR05_FatherPortal_Outside_REF.Enable()
	_00E_FS_NQR05_FatherArrival.Add()
	iPortalSound = QSTDA02ShrineActivateLPMM.Play(PlayerREF)
	FS_NQR05_FatherPortal_Outside_REF.Enable()
	MAGConjurePortalOpenM.Play(FS_NQR05_FatherPortal_Outside_REF)
	; FS_NQR05_ZaraahREF.MoveTo(FS_NQR05_SC08_SisterAddiction_GroupMarker003)
	FS_NQR05_FatherPortal_Outside_REF.PlayGamebryoAnimation("animTrans01")
	Wait(2.90)
	FS_NQR05_FatherPortal_Outside_REF.PlayGamebryoAnimation("AnimIdle02")
	; initiating player AI walk without locking vision controls
	_00E_QuestFunctions.PlayerAIWalk(false)
	SetStage(125)
	
EndFunction

Function SpawnBrotherGreed()

	SpawnSingleNPC(FS_NQR03_BrotherGreedREF)

EndFunction

Function SpawnTharael()

	FS_NQR05_TharaelREF.Enable()

	SpawnSingleNPC(FS_NQR05_TharaelREF)

EndFunction

Function SpawnFather()

	SpawnSingleNPC(FS_NQR05_FatherREF)

EndFunction


Function SpawnSingleNPC(Actor akNPCToSpawn)
	
	; this function is used for materializing the NPCs that arrive via portal
	If akNPCToSpawn.IsDisabled()
		akNPCToSpawn.Enable()
	EndIf
	
	
	akNPCToSpawn.SetAlpha(0.0)
	akNPCToSpawn.MoveTo(FS_NQR05_NPCSpawnmarkerREF)
	_00E_A2_Ghostwalk_TeleportDoneSound.Play(FS_NQR05_NPCSpawnmarkerREF)
	Wait(0.4)
	_00E_FS_NQR05_Father_Materializer.Play(akNPCToSpawn)
	Wait(0.4)
	akNPCToSpawn.SetAlpha(1.0)
	_00E_FS_NQR05_Father_Materializer.Stop(akNPCToSpawn)
	Wait(0.4)
	akNPCToSpawn.EvaluatePackage()

EndFunction

Function LookAtFather()

	int iIndex = FS_NQR05_RhalataSiteNPCs.GetSize()
	
	While iIndex > 0
		iIndex -= 1
		Actor akActor = FS_NQR05_RhalataSiteNPCs.GetAt(iIndex) as Actor
		akActor.SetLookAt(FS_NQR05_FatherREF)
	EndWhile

EndFunction

Function ClosePortal()

	Sound.StopInstance(iPortalSound)
	FS_NQR05_FatherPortal_Outside_REF.PlayGamebryoAnimation("AnimTrans02")
	Wait(1)
	FS_NQR05_FatherPortal_Outside_REF.Disable()
	
EndFunction

Function StartSC07()

	; Called in Phase 10, SC06
	; creates the copy of the father, needs to enabled before being moved to the marker
	SetStage(130)
	FS_NQR05_SC07_FatherREF.Enable()
	FS_NQR05_SC07_FatherREF.SetAlpha(0.0)
	FS_NQR05_SC07_FatherREF.MoveTo(FS_NQR05_SC08_FatherArrivalMarker)
	FS_NQR05_SC07_FatherREF.Enable()
	FS_NQR05_SC07_FatherREF.SetAlpha(1.0)
	MAGIllusionCharm.Play(FS_NQR05_SC08_FatherArrivalMarker)
	FS_NQR05_SC07_FatherREF.PlaceAtMe(FXDragonPriestSmallExplosion)
	
	If FS_NQR05_SC07_FatherREF.IsEnabled()
		FS_NQR05_SC07_FatherPlanning.ForceStart()
	Else
		FS_NQR05_SC07_FatherREF.Enable()
		FS_NQR05_SC07_FatherPlanning.ForceStart()
	EndIf
	
EndFunction

Function StartSC08()

	; Called in stage 135
	; give controls back to the player, remove father copy
	_00E_QuestFunctions.PlayerAIWalkStop()
	_00E_FS_NQR05_FatherArrival.Remove()
	_00E_SilenceTransitionLowPriority.Add()
	SetObjectiveCompleted(60)
	SetObjectiveDisplayed(65)
	FS_NQR05_SC07_FatherPlanning.Stop()
	FS_NQR05_SC06_FatherArrival.Stop()
	FS_NQR05_SC08_Preparation.ForceStart()
	FS_NQR05_SC07_FatherREF.PlaceAtMe(FXDragonPriestSmallExplosion)
	MAGIllusionCharm.Play(FS_NQR05_SC07_FatherREF)
	
	int iIndex02 = FS_NQR05_RhalataSiteNPCs.GetSize()
	
	While iIndex02 > 0
		iIndex02 -= 1
		Actor akActor = FS_NQR05_RhalataSiteNPCs.GetAt(iIndex02) as Actor
		akActor.EvaluatePackage()
	EndWhile
	
	FS_NQR05_SC07_FatherREF.Disable()
		

EndFunction

Function EnableWaitMarker()

	;Called in stage 140
	; sending down the first two groups of the expedition, starting the prepartion scene
	FS_NQR05_SC09_EnterScene.ForceStart()
	Game.DisablePlayerControls()
	FS_NQR05_SC05_GateREF.SetOpen(False)
	FS_NQR05_SC05_GateREF.BlockActivation(True)
	FS_NQR05_SC09_CollisionParentREF.Enable()
	FadeToBlackIMOD.Apply()
	Wait(2.5)
	FadeToBlackImod.PopTo(FadeToBlackHoldImod)
	FS_NQR05_ZaraahREF.MoveTo(FS_NQR05_SC08_BoxingMarker)
	FS_NQR05_TharaelREF.MoveTo(FS_NQR05_SC09_TharaelMarker)
	DisableAllInGroup(FS_NQR05_Group_BrotherHatred)
	DisableAllInGroup(FS_NQR05_Group_SisterAddiction)
	FS_NQR05_SC04_BrotherSorrowREF.MoveTo(FS_NQR05_SC06_SpectatorMarker_001)
	Wait(5)
	FadeToBlackHoldImod.PopTo(FadeToBlackBackImod)
	Wait(2)
	Game.EnablePlayerControls()
	FS_NQR05_SC11_PlayerDoorREF.BlockActivation(True)
	FS_NQR05_SC10_SisterLustGroup.ForceStart()
	SetStage(145)
	
EndFunction

Function DisableAllInGroup(Formlist actorsToDisable)
	
	; disables all NPCs on the formlist
	int iIndex = actorsToDisable.GetSize()
	
	While iIndex > 0
		iIndex -= 1
		ObjectReference akActors = actorsToDisable.GetAt(iIndex) as ObjectReference
		akActors.Disable()
	EndWhile

EndFunction

Function ZaraahMoveToTharaelFailsave()

	FS_NQR05_ZaraahREF.MoveTo(FS_NQR05_SC08_BrotherWrath_Group_Zaraah)

EndFunction

Function UpdateObjectives09()

	; Called in stage 150
	FS_NQR05_TempleDoorREF.Lock(False)
	SetObjectiveCompleted(65)
	SetObjectiveDisplayed(70)
	Debug.SendAnimationEvent(FS_NQR05_ZaraahREF, "IdleForceDefaultState")
	
EndFunction

Function StartSC11()

	FS_NQR05_SC11_EntranceScene.ForceStart()

EndFunction

Function MoveMercenariesFailsave()

	FS_NQR05_SisterLust.MoveTo(FS_NQR05_SC10_SisterLustWaitMarker)
	FS_NQR05_SC08_Mercenary_Ewah.MoveTo(FS_NQR05_SC10_SisterLustWaitMarker)
	FS_NQR05_SC08_Mercenary_Kaylan.MoveTo(FS_NQR05_SC10_SisterLustWaitMarker)

EndFunction

Function UpdateObjectives10()

	; Called in stage 160
	SetObjectiveCompleted(70)
	SetObjectiveDisplayed(75)
	FS_NQR05_SC09_CollisionParentREF.Disable()
	FS_NQR05_SC05_GateREF.SetOpen(True)
	FS_NQR05_SC05_GateREF.BlockActivation(False)
	FS_NQR05_SC11_PlayerDoorREF.BlockActivation(False)

EndFunction

Function StartSC12()

	; Called in stage 165
	; setting Tharael and Zar'Ah as allies, enabling companion health bars removing ghost flag, but setting essential
	_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_ZaraahREF, True, 400, 600, 100)
	_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_TharaelREF, True, 550, 500, 100)
	;FS_NQR05_ExitDoor.BlockActivation()
	
	; checking which main quest companion should appear as illusion, depends on the romance decision or sympathy global
	If CaliaRomance.GetValueInt() == 1
		bJespar = False
	ElseIf JesparRomance.GetValueInt() == 1
		bJespar = True
	Else
		
		If SympathyCalia.GetValueInt() > SympathyJespar.GetValueInt() && MQ05.IsCompleted()
			bJespar = False
		Else
			bJespar = True
		EndIf
		
	EndIf
	
	If bJespar == False
		FS_NQR05_SC12_Calia_REF.Enable()
		FS_NQR05_SC12_Calia_REF.SetOutfit(_00E_MC_Calia_Outfit)
		SC12_Enemy.ForceRefTo(FS_NQR05_SC12_Calia_REF)
	ElseIf bJespar == True
		FS_NQR05_SC12_Jespar_REF.Enable()
		SC12_Enemy.ForceRefTo(FS_NQR05_SC12_Jespar_REF)
	EndIf
		
	akFakeCompanion = SC12_Enemy.GetActorReference()
	FS_NQR05_SC12_Temple_01.ForceStart()
	
EndFunction

Function StartCombatWithCompanion()

	FS_NQR05_SC12_DevourSoundREF.Disable()
	akFakeCompanion.SetGhost(False)
	akFakeCompanion.SetActorValue("Health", 850)
	akFakeCompanion.SetActorValue("Magicka", 500)
	akFakeCompanion.SetActorValue("Aggression", 3)
	SetObjectiveDisplayed(80)

EndFunction

Function UpdateObjectives11()

	akFakeCompanion.BlockActivation(True)
	SetObjectiveCompleted(80)

EndFunction

Function StartSC13()

	; Called in stage 180
	FS_NQR05_SC13_Temple_02.ForceStart()
	SetObjectiveDisplayed(75, True)

EndFunction

Function ActivateDoor()

	FS_NQR05_SC13_DoorREF.Activate(PlayerREF)
	FS_NQR05_GlyphLightREF.Enable()
	FS_NQR05_SC13_DoorREF.KnockAreaEffect(1, 1024)

EndFunction

Function DisableDoor()

	FS_NQR05_Barrier02REF.Disable()
	
EndFunction

Function StartSC14()

	; Called in stage 185
	FS_NQR05_SC14_Temple_03.ForceStart()
	SetObjectiveDisplayed(85, True)

EndFunction

Function UpdateObjectives12()

	; Called in stage 190	
	SetObjectiveDisplayed(85, True)

EndFunction

Function StartSC15()

	; Called in stage 210
	; setting up final dialogue between Zar'Ah and player as well as Tharael killing her
	SetObjectiveDisplayed(90, True)
	_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_ZaraahREF, False)
	_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_TharaelREF, False)
	FS_NQR05_ZaraahREF.BlockActivation(true)
	FS_NQR05_ZaraahREF.UnequipItemEx(_00E_FS_NQR05_ZarAhSabre, 0)
	FS_NQR05_ZaraahREF.UnequipItemEx(_00E_FS_NQR05_ZarAhSabre, 1)
	FS_NQR05_ZaraahREF.UnequipItemEx(_00E_FS_NQR05_ZarAhSabre, 2)
	FS_NQR05_TharaelREF.unequipitemex(_00E_FS_NQR05_Tharael_Dagger, 1, True)
	FS_NQR05_TharaelREF.unequipitemex(_00E_FS_NQR05_Tharael_Dagger, 2, True)
	FS_NQR05_SC15_Temple_04.ForceStart()

EndFunction

Function RegisterForShot()
	
	; player needs to be set to ghost because sometimes even though the arrow did not hit the player visually it got stuck on some armor meshes
	; resulting in Zar'Ah not being killed by any visual effect. The arrow is so fast, the player doesn't even notice IF it passes through them
	PlayerREF.SetGhost(True)
	FS_NQR05_ZaraahREF.SetGhost(False)
	FS_NQR05_ZaraahREF.GetActorBase().SetEssential(False)
	FS_NQR05_TharaelREF.MoveTo(FS_NQR05_SC15_TharaelShootMarker)
	RegisterForSingleUpdate(1.0)

EndFunction

Function ShootArrow()

	_00E_FakeArrowSP.Cast(FS_NQR05_TharaelREF, FS_NQR05_ZaraahREF)
	Wait(0.25)
	FS_NQR05_TharaelREF.AddItem(_00E_FS_NQR_TharaelsBow, 1, true)
	FS_NQR05_TharaelREF.EquipItem(_00E_FS_NQR_TharaelsBow, true)
	KillZarah()
	
EndFunction

Function KillZarah()

	FS_NQR05_ZaraahREF.GetActorBase().SetEssential(True)
	FS_NQR05_ZaraahREF.Kill(FS_NQR05_TharaelREF)
	_00E_BloodyFXShader.Play(FS_NQR05_ZaraahREF)
	FS_NQR05_ZaraahREF.DamageAV("Health", 10000)
	SetStage(220)

EndFunction

Function HeartAbsorbZaraah()
	
	; Applies all the visual effects between the heart and Zar'Ah
	PlayerREF.SetGhost(False)
	FS_NQR05_ZaraahREF.GetActorBase().SetEssential(False)
	_00E_FS_NQR05_Temple_AbsorbRoarMarker.Play(PlayerREF)
	FS_NQR05_ZaraahREF.Kill(FS_NQR05_TharaelREF)
	FS_NQR05_ZaraahREF.DamageAV("Health", 10000)
	Wait(3)
	FS_NQR05_SC12_DustDropREF.Activate(FS_NQR05_SC12_DustDropREF)
	Game.ShakeCamera(None, 0.75, 13.5)
	FS_NQR05_HeartSwirlREF.Enable()
	_00E_FS_NQR05_Absorb_StartM.Play(PlayerREF)
	FS_NQR05_BeamZarah.MoveTo(FS_NQR05_ZaraahREF)
	FS_NQR05_BeamZarah.Enable()
	FS_NQR05_BeamHeart.Enable()
	IllusionDarkMassiveImod.Apply()
	Wait(10)
	WerewolfExtractVFX.Play(FS_NQR05_ZaraahREF, 3)
	_00E_HighOnesDisintegrate.Play(FS_NQR05_ZaraahREF)
	Wait(3.5)
	WerewolfExtractVFX.Stop(FS_NQR05_ZaraahREF)
	IllusionDarkMassiveImod.Apply()
	Game.ShakeCamera()
	FS_NQR05_BeamHeart.PlayGamebryoAnimation("AnimPlay")
	FS_NQR05_BeamZarah.PlayGamebryoAnimation("AnimPlay")
	FS_NQR05_ZaraahREF.PlaceAtMe(_00E_FS_PsionicExplosionSmallNoEffects)
	FS_NQR05_ZaraahREF.PlaceAtMe(_00E_FS_NQR05_BloodGeysir)
	FS_NQR05_ZaraahREF.PlaceAtMe(_00E_FS_NQR05_PerversionExp)
	FS_NQR05_ZaraahREF.SetAlpha(0.0)
	FS_NQR05_ZaraahREF.Disable()
	FS_NQR05_SC12_DevourSoundREF.Disable()
	Wait(3)
	FS_NQR05_BeamHeart.Disable()
	FS_NQR05_BeamZarah.Disable()
	SetObjectiveCompleted(90)
	FS_NQR05_ZaraahSoulREF.Enable()
	; enables Zar'Ahs soul for the Phasmalist
	(FS_NQR05_ZaraahSoulREF as _00E_Phasmalist_Soul).updateCanSee(true)
	FS_NQR05_ElkREF.Disable()
	SetStage(225)

EndFunction

Function StartSC16()

	; Called in stage 230

	FS_NQR05_BarrierREF.Disable()
	FS_NQR05_GateGuardianREF.Enable()
	SetObjectiveCompleted(85)
	SetObjectiveCompleted(90)
	SetObjectiveDisplayed(95)
	FS_NQR05_SC16_Temple_05.ForceStart()
	_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_TharaelREF, True, 550, 500, 100)
	FS_NQR05_SC16_BrotherHatredREF.Enable()
	FS_NQR05_SC16_BrotherHatredREF.BlockActivation()
	TharaelEquipDaggers()

EndFunction

Function TharaelBackstab()

	; Called in stage 235
	; Tharael kills Brother Hatred with a backstab animation
	FS_NQR05_SC16_BrotherHatredREF.GetActorBase().SetEssential(False)
	FS_NQR05_SC16_BrotherHatredREF.SetGhost(False)
	_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_TharaelREF, False)
	wait(0.5)
	FS_NQR05_TharaelREF.PlayIdleWithTarget(pa_1HMSneakKillBackA, FS_NQR05_SC16_BrotherHatredREF)
	wait(2)
	FS_NQR05_SC16_BrotherHatredREF.Kill(FS_NQR05_TharaelREF)
	FS_NQR05_SC16_BloodDecalREF.MoveTo(FS_NQR05_SC16_BrotherHatredREF)
	FS_NQR05_SC16_BloodDecalREF.Enable()
	wait(1)
	; fixing AI bug, sometimes got stuck in the backstab pose
	FS_NQR05_TharaelREF.resurrect()
	_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_TharaelREF, True, 550, 500, 100)

EndFunction

Function TharaelEquipBow()

	; FS_NQR05_TharaelREF.equipitem(_00E_FS_NQR_TharaelsBow, true, true)

EndFunction

Function SpawnAbnormality()
	
	; sets up bossfight against the abnormality
	Game.DisablePlayerControls()

	If SC_Abnormality.GetReference() == None
		SC_Abnormality.ForceRefTo(Game.GetForm(0x0102A094) as Actor)
	EndIf

	If FS_NQR05_Abnormality_CollisionParentREF == None
		FS_NQR05_Abnormality_CollisionParentREF = Game.GetForm(0x02010340) as ObjectReference
	EndIf
	
	FS_NQR05_Abnormality_CollisionParentREF.Disable()
	FS_NQR05_Abnormality.Enable()
	FS_NQR05_Abnormality.SetAlpha(0.0)
	FS_NQR05_Abnormality.MoveTo(FS_NQR05_AbnormalityStartingPOS)
	Wait(2)
	FS_NQR05_Abnormality.SetAlpha(1.0)
	
EndFunction

Function AwakenAbnormality()
	
	; using explosions to cover up some of inaccurate / clunky animations
	FS_NQR05_Abnormality_HeartbeatREF.Disable()
	FS_NQR05_Abnormality_CollisionParentREF.Disable()
	FS_NQR05_Abnormality.SetMotionType(4)
	_00E_FS_Music_Special_BlackWaltz.Add()
	Game.ShakeCamera(afStrength = 0.1)
	FS_NQR05_Abnormality_Explosion_01.PlaceAtMe(_00E_FS_NQR05_Abnormality_EXP_02)
	FS_NQR05_Abnormality_Explosion_01.PlaceAtMe(_00E_FS_NQR05_BloodGeysir)
	FS_NQR05_Abnormality_Egg_Parent_03.DisableNoWait()
	Wait(1)
	Game.ShakeCamera(afStrength = 0.1)
	FS_NQR05_Abnormality_Explosion_02.PlaceAtMe(_00E_FS_NQR05_Abnormality_EXP_02)
	FS_NQR05_Abnormality_Explosion_02.PlaceAtMe(_00E_FS_NQR05_BloodGeysir)
	FS_NQR05_Abnormality_Egg_Parent_01.DisableNoWait()
	Wait(1)
	Game.ShakeCamera(afStrength = 0.1)
	FS_NQR05_Abnormality_Explosion_03.PlaceAtMe(_00E_FS_NQR05_Abnormality_EXP_02)
	FS_NQR05_Abnormality_Explosion_03.PlaceAtMe(_00E_FS_NQR05_BloodGeysir)
	FS_NQR05_Abnormality_Egg_Parent_02.DisableNoWait()
	Wait(1)
	FS_NQR05_Abnormality_Explosion_04.PlaceAtMe(_00E_FS_NQR05_Abnormality_EXP_02)
	FS_NQR05_Abnormality_Explosion_03.PlaceAtMe(_00E_FS_NQR05_Abnormality_EXP_02)
	FS_NQR05_Abnormality_Explosion_02.PlaceAtMe(_00E_FS_NQR05_Abnormality_EXP_02)
	FS_NQR05_Abnormality_Explosion_01.PlaceAtMe(_00E_FS_NQR05_Abnormality_EXP_02)
	FS_NQR05_Abnormality_Explosion_04.PlaceAtMe(_00E_FS_NQR05_BloodGeysir)
	; FS_NQR05_Abnormality.AddItem(_00E_FS_NQR05_GrotesqueHammer, 1)
	; FS_NQR05_Abnormality.EquipItem(_00E_FS_NQR05_GrotesqueHammer)
	FS_NQR05_Abnormality_Egg_Parent_04.Disable()
	FS_NQR05_Abnormality.PlaceAtMe(_00E_FS_NQR05_FireStormAbnormality)
	Game.ShakeCamera()
	FS_NQR05_Abnormality.PlaceAtMe(_00E_FS_NQR05_BloodGeysir_Big)
	_00E_FS_NQR05_RoarM.Play(PlayerRef)
	FS_NQR05_Abnormality.PlaceAtMe(_00E_FS_NQR05_Abnormality_EXP_02)
	MAGFireStormImod.Apply()
	FS_NQR05_Abnormality_Egg_Marker.Disable()
	Wait(2)
	TharaelSwitchToWeaponSet("Bow")
	FS_NQR05_Abnormality.SetMotionType(7)
	FS_NQR05_Abnormality.SetPosition(FS_NQR05_Abnormality.GetPositionX(), FS_NQR05_Abnormality.GetPositionY(), -4265.2437)
	If FS_NQR05_Abnormality.PlayIdle(giantGetUp)

	EndIf
	
EndFunction

Function TharaelSwitchToWeaponSet(String sWeaponType = "Daggers")
	
	; making sure Tharael has the correct weapons equipped at certain points during the quest
	; gets also called from other script fragments
	If sWeaponType == "Bow"
	
		FS_NQR05_TharaelREF.unequipitemex(_00E_FS_NQR05_Tharael_Dagger, 0, True)
		FS_NQR05_TharaelREF.unequipitemex(_00E_FS_NQR05_Tharael_Dagger, 1, True)
		FS_NQR05_TharaelREF.unequipitemex(_00E_FS_NQR05_Tharael_Dagger, 2, True)
		FS_NQR05_TharaelREF.equipitem(_00E_FS_NQR_TharaelsBow, true, true)
		FS_NQR05_TharaelREF.AddItem(_00E_FS_NQR_TharaelsArrows, 55, true)
		
	ElseIf sWeaponType == "Daggers"
	
		FS_NQR05_TharaelREF.unequipitem(_00E_FS_NQR_TharaelsBow, true, true)
		FS_NQR05_TharaelREF.RemoveItem(_00E_FS_NQR_TharaelsArrows, 55, true)
		FS_NQR05_TharaelREF.equipitemex(_00E_FS_NQR05_Tharael_Dagger, 0, True)
		FS_NQR05_TharaelREF.equipitemex(_00E_FS_NQR05_Tharael_Dagger, 1, True)
		FS_NQR05_TharaelREF.equipitemex(_00E_FS_NQR05_Tharael_Dagger, 2, True)
		
	Else
	
		If FS_NQR05_TharaelREF.GetEquippedWeapon() == !_00E_FS_NQR_TharaelsBow
	
			FS_NQR05_TharaelREF.unequipitem(_00E_FS_NQR_TharaelsBow, true, true)
			FS_NQR05_TharaelREF.unequipitem(FS_NQR05_TharaelREF, true, true)
			FS_NQR05_TharaelREF.RemoveItem(_00E_FS_NQR_TharaelsArrows, 55, true)
			
		Else
		
			FS_NQR05_TharaelREF.unequipitemex(_00E_FS_NQR05_Tharael_Dagger, 1, True)
			FS_NQR05_TharaelREF.unequipitemex(_00E_FS_NQR05_Tharael_Dagger, 2, True)
			
		EndIf
	
	EndIf

EndFunction

Function AbnormalityDrawWeapon()

	; FS_NQR05_Abnormality.DrawWeapon()

EndFunction

Function StartBossfight()

	; most of the bossfight is handled within FS_NQR05_BossfightAbnormalitySC attached to the abnormality actor
	AwakenAbnormality()
	FS_NQR05_SC_Bossfight.ForceStart()
	
EndFunction

Function StartFightReal()

	Game.EnablePlayerControls()
	; the Reset() functions needs to be checked, it seems to cause actors easily getting stuck in a T-Pose
	; a better otion would probably be SendAnimationEvent(FS_NQR05_Abnormality, "IdleForceDefaultState")
	; more cases of Reset() can be found in the script
	; this will be looked at post 1.5.6.0
	FS_NQR05_Abnormality.Reset()
	FS_NQR05_Abnormality.SetActorValue("Aggression", 3)
	FS_NQR05_Abnormality.SetGhost(False)
	SetUpBossfight()
	_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_TharaelREF, True, 550, 500, 100)
	FS_NQR05_Abnormality.StartCombat(PlayerREF)
	FS_NQR05_TharaelREF.equipitem(_00E_FS_NQR_TharaelsBow, true, true)
	FS_NQR05_Abnormality.SetActorValue("speedMult", 100.0)
	SetObjectiveCompleted(95)
	SetObjectiveDisplayed(100)
	Game.ShakeCamera(FS_NQR05_Abnormality, 1, 1)
	FireFXShader.Play(FS_NQR05_Abnormality)
	FS_NQR05_TharaelREF.StartCombat(FS_NQR05_Abnormality)
	FXExplosionCatapultNearM.Play(PlayerREF)
	FS_NQR05_BattleLinkerREF.Enable()
	FS_NQR05_BossfightFireParent.Enable()
	SetStage(251)
	FS_NQR05_Abnormality.RegisterCombatStart()

EndFunction

Function AbnormalityDeath()

	; remove visiauls of the abnormality
	FS_NQR05_Abnormality.SetCriticalStage(FS_NQR05_Abnormality.CritStage_DisintegrateStart)
	
	If	_00E_DissolveInFlames != none
		_00E_DissolveInFlames.play(FS_NQR05_Abnormality, 2)
	EndIf
	
	Wait(2)
	FS_NQR05_Abnormality.GetActorBase().SetEssential(False)
	FS_NQR05_Abnormality.Kill(PlayerREF)
	FS_NQR05_Abnormality.PlaceAtMe(_00E_FS_NQR05_FireStormAbnormalityDeath)
	FS_NQR05_Abnormality.PlaceAtMe(_00E_FS_NQR05_Abnormality_EXP_02)
	FS_NQR05_Abnormality.PlaceAtMe(_00E_FS_NQR05_BloodGeysir)
	FS_NQR05_Abnormality.AttachAshPile(DefaultAshPileGhostBlack)
	
	If	_00E_DissolveInFlames != none
		_00E_DissolveInFlames.stop(FS_NQR05_Abnormality)
	EndIf
		
	FS_NQR05_Abnormality.SetAlpha (0.0,True)
	
	FS_NQR05_Abnormality.SetCriticalStage(FS_NQR05_Abnormality.CritStage_DisintegrateEnd)

EndFunction

Function StartSC17()

	; Called in stage 255
	; setting up dialogue after the fight against the abnormality
	FireFXShader.Stop(FS_NQR05_Abnormality)
	FS_NQR05_FatherVoiceREF.MoveTo(FS_NQR05_FatherPortal)
	
	FS_NQR05_TharaelREF.Enable()
	FS_NQR05_BossfightFireParent.Enable()
	FS_NQR05_TharaelREF.MoveTo(_00E_FS_NQR05_SC17_TharaelMarker)
	
	SetObjectiveCompleted(100)
	SetObjectiveDisplayed(105)
	_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_TharaelREF, False)
	_00E_FS_Music_Special_BlackWaltz.Remove()
	FS_NQR05_SC17_AfterBossfight.ForceStart()
	
EndFunction

Function PlaceRune()
	
	; might need to change ApplyCrossFade() to PopTo(), requires further testing
	FadeToBlackIMOD.Apply()
	Wait(1)
	FadeToBlackHoldIMOD.ApplyCrossFade()
	Wait(2)
	FS_NQR05_Portal_Rune_008.Enable()
	TharaelSwitchToWeaponSet("Nothing")
	FS_NQR05_TharaelREF.AddSpell(_00E_FS_NQR05_TharaelSummon, false)
	Wait(1)
	FadeToBlackBackIMOD.ApplyCrossFade()
	Wait(2)
	ActivateRune()
	SetStage(261)
	
Endfunction

Function ActivateRune()

	FS_NQR05_TharaelREF.EquipSpell(_00E_FS_NQR05_TharaelSummon, 0)
	MAGEnchantedUnsheatheOtherM.Play(FS_NQR05_Portal_Rune_002)
	FS_NQR05_Portal_Rune_002.PlayAnimation("Unlock")
	FS_NQR05_Portal_Rune_003.PlayAnimation("Unlock")
	Wait(1)
	MAGEnchantedUnsheatheOtherM.Play(FS_NQR05_Portal_Rune_004)
	FS_NQR05_Portal_Rune_004.PlayAnimation("Unlock")
	FS_NQR05_Portal_Rune_005.PlayAnimation("Unlock")
	Wait(1)
	FS_NQR05_Portal_Rune_011.PlayAnimation("Unlock")
	FS_NQR05_Portal_Rune_012.PlayAnimation("Unlock")
	FS_NQR05_Portal_Rune_013.PlayAnimation("Unlock")
	FS_NQR05_Portal_Rune_014.PlayAnimation("Unlock")
	Wait(1)
	MAGIllusionFireLP.Play(FS_NQR05_Portal_Rune_006)
	FS_NQR05_PortalLightNew002.Enable()
	FS_NQR05_Portal_Rune_006.PlayAnimation("Unlock")
	FS_NQR05_Portal_Rune_007.PlayAnimation("Unlock")
	FS_NQR05_Portal_Rune_008.PlayAnimation("Unlock")
	FS_NQR05_Portal_Rune_009.PlayAnimation("Unlock")
	FS_NQR05_Portal_Rune_010.PlayAnimation("Unlock")


EndFunction

Function OpenFatherPortal()
	
	; elegant
	FS_NQR05_Portal_Rune_002.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_003.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_004.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_005.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_011.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_012.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_013.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_014.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_006.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_007.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_008.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_009.PlayAnimation("UnlockedFadeOut")
	FS_NQR05_Portal_Rune_010.PlayAnimation("UnlockedFadeOut")

	FS_NQR05_Portal_Rune_008.DisableNoWait(true)

	MAGShockExpImod.Apply()
	FS_NQR05_Portal_ExplosionREF.PlaceAtMe(ExplosionRuneShockSmallNoEffects)
	FS_NQR05_FatherPortal.PlayGamebryoAnimation("animTrans01")
	MAGConjurePortalOpenM.Play(FS_NQR05_FatherPortal)
	Wait(2.90)
	FS_NQR05_FatherPortal.PlayGamebryoAnimation("AnimIdle02")
	FS_NQR03_LethoREF.Disable()
	FS_NQR05_FatherREF.Disable()
	;FS_NQR03_LethoREF.SetAlpha(0.0)
	;FS_NQR05_FatherREF.SetAlpha(0.0)
	SetObjectiveCompleted(105)
	
Endfunction

Function TharaelDisableHeadtracking()

	FS_NQR05_TharaelREF.SetHeadTracking(False)
	
EndFunction

Function TharaelEnableHeadtracking()

	FS_NQR05_TharaelREF.SetHeadTracking(True)
	
EndFunction

Function TharaelRemoveSpell()

	FS_NQR05_TharaelREF.RemoveItem(_00E_FS_NQR_TharaelsArrows, 55, true)
	FS_NQR05_TharaelREF.UnequipSpell(_00E_FS_NQR05_TharaelSummon, 0)
	FS_NQR05_TharaelREF.UnequipSpell(_00E_FS_NQR05_TharaelSummon, 1)
	FS_NQR05_TharaelREF.UnequipSpell(_00E_FS_NQR05_TharaelSummon, 2)
	; need wait, animations otherwise seem to get "stuck" / were cut more likely
	Wait(1)
	TharaelSwitchToWeaponSet("Daggers")

EndFunction

Function MaterializeFatherBrotherSorrow()
	
	FS_NQR03_LethoREF.moveto(FS_NQR05_SC17_LethoMarker)
	FS_NQR03_LethoREF.Enable()
	Wait(0.6)
	_00E_FS_NQR05_Father_Materializer.Play(FS_NQR03_LethoREF)
	_00E_A2_Ghostwalk_TeleportDoneSound.Play(FS_NQR03_LethoREF)
	FS_NQR05_FatherREF.moveto(FS_NQR05_SC17_FatherMarker)
	FS_NQR05_FatherREF.Enable()
	Wait(0.4)
	_00E_FS_NQR05_Father_Materializer.Play(FS_NQR05_FatherREF)	
	_00E_A2_Ghostwalk_TeleportDoneSound.Play(FS_NQR05_FatherREF)
	FS_NQR03_LethoREF.SetAlpha(1.0)
	FS_NQR05_FatherREF.SetAlpha(1.0)
	_00E_FS_NQR05_Father_Materializer.Stop(FS_NQR05_FatherREF)
	_00E_FS_NQR05_Father_Materializer.Stop(FS_NQR03_LethoREF)
	
Endfunction

Function MoveFatherVoiceToSource()
	; FS_NQR05_FatherVoiceREF needs to be moved back to its prior location otherwise subtitles of talking activators being stuck when near the player
	FS_NQR05_FatherVoiceREF.MoveTo(FS_NQR05_FatherVoiceSourceREF)
EndFunction

Function DisablePortal()
	
	; Tharael amushes the father after they materialized
	FS_NQR05_TharaelREF.PlayIdle(_00E_IdleStomp)
	Wait(0.2)
	_00E_FS_NQR05_BanishTharaelIMOD.Apply()
	FS_NQR05_PortalLightNew002.disable()
	FS_NQR05_DustParent.Activate(FS_NQR05_TharaelREF)
	FS_NQR05_TharaelREF.PlaceAtMe(TG08BShockwaveExplosion)
	Game.ShakeCamera()
	QSTMS06PotemaBanishExplosion.Play(FS_NQR05_FatherPortal)
	FS_NQR05_FatherPortal.KnockAreaEffect(512, 1.0)
	FS_NQR05_FatherPortal.PlaceAtMe(ExplosionShockMassNoEffectsSmall)
	FS_NQR05_FatherPortal.disable()

EndFunction

Function AddMusic()

	_00E_FS_Music_Special_Character_Tharael.Add()

EndFunction

Function TharaelReequipDaggers()

	;To avoid "weapons stuck"
	FS_NQR05_TharaelREF.unequipitemex(_00E_FS_NQR05_Tharael_Dagger, 1, True)
	FS_NQR05_TharaelREF.unequipitemex(_00E_FS_NQR05_Tharael_Dagger, 2, True)
	FS_NQR05_TharaelREF.equipitemex(_00E_FS_NQR05_Tharael_Dagger, 1, True)
	FS_NQR05_TharaelREF.equipitemex(_00E_FS_NQR05_Tharael_Dagger, 2, True)

EndFunction

Function TharaelEquipDaggers()

	If FS_NQR05_TharaelREF.GetItemCount(_00E_FS_NQR05_Tharael_Dagger) < 2
		FS_NQR05_TharaelREF.additem(_00E_FS_NQR05_Tharael_Dagger, 2)
	EndIf
	
	FS_NQR05_TharaelREF.equipitemex(_00E_FS_NQR05_Tharael_Dagger, 1, True)
	FS_NQR05_TharaelREF.equipitemex(_00E_FS_NQR05_Tharael_Dagger, 2, True)

EndFunction

Function StartSC18()

	wait(0.5)
	; decision if the father mistrusts the player based on all other previous decisions
	; starting the respective scenes accordingly
	If _00E_FS_NQR_RhalataMistrust.getValue() > 20
		FS_NQR05_SC18a_FatherRhalataMistrustTooHigh.forceStart()
		_00E_FS_NQR05_RhalataMistrustTooHight.setValue(1)
	Else
		FS_NQR05_SC18b_FatherRhalataMistrustSmallEnough.forceStart()
		_00E_FS_NQR05_RhalataMistrustTooHight.setValue(0)
	EndIf
	wait(0.25)
	PlayerREF.drawWeapon()

Endfunction

Function StartSC19()
	FS_NQR05_SC19_FatherStory.forceStart()
Endfunction

Function takeOfMask()
	
	;Letho's reveal
	FS_NQR03_LethoREF.SetGhost(false)
	_00E_FS_Music_Special_Character_Tharael.Remove()
	wait(1)
	FS_NQR03_LethoREF.playIdle(takeOfMask)
	wait(0.5)
	ITMGenericClothingDown.Play(FS_NQR03_LethoREF)
	FS_NQR03_LethoREF.unequipitem(_00E_FS_Rhalata_Voice_Hood, true, true)
	
Endfunction

Function DebugKillLetho()

	FS_NQR05_BossfightFireParent.Enable()
	FS_NQR05_TharaelREF.Enable()
	FS_NQR05_TharaelREF.MoveTo(FS_NQR05_SC16_TharaelKillLethoREF)
	FS_NQR03_LethoREF.Enable()
	FS_NQR03_LethoREF.MoveTo(FS_NQR05_SC16_LethoDeathMarker)
	FS_NQR05_TharaelREF.additem(_00E_FS_NQR05_Tharael_Dagger, 2)
	TharaelEquipDaggers()
	Wait(4)
	killLetho()
	
EndFunction

Function killLetho()

	FS_NQR03_LethoREF.SetGhost(false)
	wait(0.1)
	FS_NQR05_TharaelREF.Say(FS_NQR05_D99_TharaelKillLethoTopic)
	
	FS_NQR05_TharaelREF.PlayIdleWithTarget(pa_2HMKillMoveDualWieldDecap, FS_NQR03_LethoREF)
	
	Wait(2.75)
	_00E_FS_NQR05_BrotherSorrowDeathM.Play(FS_NQR03_LethoREF)
	Wait(1.0)
	FS_NQR05_SC19_LethoKilled.SetValueInt(1)
	; FS_NQR03_LethoREF.SetMotionType(4) not needed anymore
	
EndFunction

Function StartSC19_02()

	; Tharael starts attacking the father
	; start of the cinematic slow mo scene
	FS_NQR05_TharaelREF.Enable()
	FS_NQR05_TharaelREF.MoveTo(FS_NQR05_SC19_02_TharaelStabMarker)
	TharaelEquipDaggers()
	FS_NQR05_FatherREF.Enable()
	FS_NQR05_FatherREF.MoveTo(FS_NQR05_SC19_02_FatherPrepareMarker)
	FS_NQR05_BossfightFireParent.Enable()
	Utility.Wait(10.0)
	
	FS_NQR05_TharaelREF.TranslateToRef(FS_NQR05_SC19_02_TharaelStabMarker, 600, 600)
	FS_NQR05_SC19_02_Cinematic.ForceStart()
	
EndFunction

;==================================CINEMATIC===================================================

Function TharaelScream()

	FS_NQR03_LethoREF.SetMotionType(4, false)
	FS_NQR05_TharaelREF.Say(FS_NQR05_D99_TharaelScreamTopic)

EndFunction

Function EnterSlowMotion()
	
	; this function solely handles the slow motion effect on the player, tharael and the father
	; and updates the objectives according to the fact if the father tricked tharael into thinking that the player worked against him
	; if so, it forces the player to side with the father in the final fight
	; both potential final fights are handeld in either _00E_FS_NQR05_Bossfight_FatherSC or _00E_FS_NQR05_Bossfight_TharaelSC attached to the aliases
	If PlayerREF == None
		PlayerREF = Game.GetPlayer()
	EndIf
	
	FS_NQR03_LethoREF.EnableAI(0)
	; FS_NQR03_LethoREF.SetMotionType(4, false)
	FS_NQR05_FatherREF.PlaceAtMe(FXDragonPriestSmallExplosion)
	PlayerREF.AddSpell(_00E_FS_NQR05_SlowMotionSP, False)
	_00E_FS_NQR05_SlowMotion_IntroM.Play(PlayerREF)
	Wait(1)
	; AudioCategorySFX.Mute()
	_00E_FS_Music_Special_BattleOfTheFleshless.Add()
	
	If _00E_FS_NQR05_TharaelTrickedByFather.GetValueInt() == 1
		SetObjectiveDisplayed(117)
	Else
		SetObjectiveDisplayed(110)
		SetObjectiveDisplayed(115)
	EndIf
	
	Wait(8.5)
	; AudioCategorySFX.UnMute()
	_00E_FS_NQR05_SlowMotion_OutroM.Play(PlayerREF)
	PlayerREF.RemoveSpell(_00E_FS_NQR05_SlowMotionSP)
	FS_NQR05_FatherREF.MoveTo(FS_NQR05_Cinematic_TeleportMarkerREF003)
	FS_NQR05_FatherREF.PlaceAtMe(FXDragonPriestSmallExplosion)
	MAGIllusionCharm.Play(FS_NQR05_FatherREF)
	FS_NQR05_FatherREF.EvaluatePackage()
	Wait(2)
	FS_NQR05_BossfightOnGoing.SetValueInt(1)
	SetUpBossfight()
	FS_NQR05_TharaelREF.EvaluatePackage()
	FS_NQR05_FatherREF.EvaluatePackage()
	FS_NQR05_FatherREF.SetGhost(False)
	FS_NQR05_TharaelREF.SetGhost(False)
	; FS_NQR05_TharaelREF.SetActorValue("Aggression", 2)
	; FS_NQR05_FatherREF.SetActorValue("Aggression", 2)
	FS_NQR05_FatherREF.StartCombat(FS_NQR05_TharaelREF)
	FS_NQR05_TharaelREF.StartCombat(FS_NQR05_FatherREF)
	FS_NQR05_TharaelREF.GetActorBase().SetInvulnerable(True)
	FS_NQR05_FatherREF.GetActorBase().SetInvulnerable(True)
	Game.EnablePlayerControls()
	FS_NQR03_LethoREF.EnableAI(True)
	Game.RequestAutoSave()

	If _00E_FS_NQR05_TharaelTrickedByFather.GetValueInt() == 1
		(Tharael as _00E_FS_NQR05_Bossfight_TharaelSC).SideAgainstTharael()
	EndIf
	
	Wait(1)
	
	FS_NQR05_FatherREF.StartCombat(FS_NQR05_TharaelREF)
	FS_NQR05_TharaelREF.StartCombat(FS_NQR05_FatherREF)
	
EndFunction

Function Stab()

	FS_NQR05_FatherREF.PlayIdle(IdleHandsBehindBack)
	bAnimationFired = false
	TharaelScream()
	FS_NQR03_LethoREF.SetMotionType(4, false)
 
	RegisterForAnimationEvent(FS_NQR05_TharaelREF, "PowerAttack_Start_End")
	Debug.SendAnimationEvent(FS_NQR05_TharaelREF, "attackPowerStartForward")
	
	RegisterForSingleUpdate(0.05)
	Wait(0.2)
	
EndFunction

Function SetUpBossfight()

	FS_NQR05_FatherREF.SetAV("Health", 2000)
	FS_NQR05_FatherREF.SetAV("Magicka", 1000)
	FS_NQR05_FatherREF.SetAV("Stamina", 300)
	FS_NQR05_TharaelREF.SetAV("Health", 1000)
	FS_NQR05_TharaelREF.SetAV("Magicka", 250)
	FS_NQR05_TharaelREF.SetAV("Stamina", 300)
	
EndFunction

Function SideWithCharacter(Actor akActor)
	; lets the player decide who to fight with, if tharael wasn't tricked by the father
	If (akActor	== FS_NQR05_TharaelREF)
	
		;SetObjectiveCompleted(110, True) that's so utterly useless
		;SetObjectiveFailed(115)
		;SetObjectiveDisplayed(110, True, True)
		SetObjectiveDisplayed(110, false)
		SetObjectiveDisplayed(115, false)
		SetObjectiveDisplayed(110, true)
		FS_NQR05_FatherREF.setGhost(false)
		FS_NQR05_FatherREF.getActorBase().setEssential(false)
		FS_NQR05_FatherREF.SetActorValue("Aggression", 3)
		FS_NQR05_FatherREF.AddToFaction(PlayerEnemyFaction)
		FS_NQR05_FatherREF.SetActorValue("Health", 2500)
		FS_NQR05_FatherREF.RestoreAV("Magicka", 2500)
		FS_NQR05_FatherREF.RestoreAV("Magicka", 2500)
		FS_NQR05_FatherREF.startCombat(PlayerREF)
		_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_TharaelREF, True, 550, 500, 100)
	Else
		;SetObjectiveCompleted(115, True)
		;SetObjectiveFailed(110)
		;SetObjectiveDisplayed(115, True, True)
		SetObjectiveDisplayed(110, false)
		SetObjectiveDisplayed(115, false)
		SetObjectiveDisplayed(117, true)
		
		FS_NQR05_TharaelREF.setGhost(false)
		FS_NQR05_TharaelREF.SetActorValue("Health", 2500)
		FS_NQR05_TharaelREF.SetActorValue("Aggression", 3)
		FS_NQR05_TharaelREF.AddToFaction(PlayerEnemyFaction)
		FS_NQR05_TharaelREF.RestoreAV("Magicka", 2500)
		FS_NQR05_TharaelREF.RestoreAV("Magicka", 2500)
		FS_NQR05_TharaelREF.startCombat(PlayerREF)
		_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_FatherREF, True, 800, 700, 400)
	EndIf
	
	SetUpBossfight()
	FS_NQR05_TharaelREF.GetActorBase().SetInvulnerable(False)
	FS_NQR05_FatherREF.GetActorBase().SetInvulnerable(False)
	
EndFunction

Function KillTharaelCombat()

	FS_NQR05_TharaelREF.getActorBase().setEssential(false)
	FS_NQR05_TharaelREF.Kill(PlayerREF)

EndFunction

Function StopMusic()

	FS_NQR05_BossfightOnGoing.SetValueInt(0)
	_00E_FS_Music_Special_BattleOfTheFleshless.Remove()
	FS_NQR05_TharaelREF.EvaluatePackage()
	FS_NQR05_FatherREF.EvaluatePackage()
	FS_NQR05_TharaelREF.StopCombat()
	FS_NQR05_TharaelREF.StopCombatAlarm()
	FS_NQR05_FatherREF.StopCombat()
	FS_NQR05_FatherREF.StopCombatAlarm()

EndFunction

;==================================/CINEMATIC===================================================

Function PlayFatherDeathFX()

	FS_NQR03_LethoREF.Disable()
	FS_NQR05_FatherDyingREF.SetPosition(FS_NQR05_FatherREF.GetPositionX(), FS_NQR05_FatherREF.GetPositionY(), FS_NQR05_FatherDyingREF.GetPositionZ())
	FXAlduinSoulEscapeEffect.Play(FS_NQR05_FatherREF, -1.0, FS_NQR05_FatherDyingREF)
	_00E_FS_NQR05_FatherDeadM.Play(FS_NQR05_FatherREF)
	
EndFunction

Function UpdateObjectives13()

	If FS_NQR05_SidedWithFather.GetValueInt() == 1
	
		SetObjectiveCompleted(115)
		SetObjectiveCompleted(117)
		SetObjectiveDisplayed(120)
		_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_FatherREF, False)
		TeleportFather()
		FS_NQR05_SC30_FatherSided.ForceStart()
		
	Else
	
		FS_NQR05_SC20_TharaelEnding.ForceStart()
		
		SetObjectiveCompleted(110)
		FS_NQR05_FatherREF.RemoveFromAllFactions()
		PlayFatherDeathFX()
		_00E_QuestFunctions.SetNPCAsCompanion(FS_NQR05_TharaelREF, False)
		FS_NQR05_SC04_BrotherSorrowREF.Disable()
		FS_NQR05_BrotherSorrow_DecapREF.Enable()
		TharaelSwitchToWeaponSet("None")
		FS_NQR05_TharaelREF.SetGhost(True)
		Game.ShakeCamera(afStrength = 0.5, afDuration = 30.0)
		
	EndIf

EndFunction

Function FatherFloatDown()

	MAGIllusionCharm.Play(FS_NQR05_FatherREF)
	FS_NQR05_FatherREF.PlaceAtMe(FXDragonPriestSmallExplosion)
	FS_NQR05_FatherREF.SetAV("Aggression", 0)
	FS_NQR05_FatherREF.SetGhost(True)
	FS_NQR05_FatherREF.Reset()
	FS_NQR05_FatherREF.SetAlpha(0.0)
	FS_NQR05_FatherREF.MoveTo(FS_NQR05_SC21_FatherAppearMarkerREF)
	MAGIllusionCharm.Play(FS_NQR05_FatherREF)
	Wait(3)
	Debug.SendAnimationEvent(FS_NQR05_FatherREF, "IdleNocturnalEnter")
	Wait(1)
	Debug.SendAnimationEvent(FS_NQR05_FatherREF, "IdleNocturnal_Rise")
	Wait(1)
	FS_NQR05_FatherREF.SetAlpha(1.0)
	FS_NQR05_FatherREF.PlaceAtMe(FXDragonPriestSmallExplosion)
	MAGIllusionCharm.Play(FS_NQR05_FatherREF)
	FS_NQR05_FatherREF.TranslateToRef(FS_NQR05_SC21_FatherPortMarkerREF, 50.0, 50.0)

EndFunction

Function KnockOutPlayer()
	
	Game.DisablePlayerControls(true, true, true, true, true, false, true, false)
	Game.ForceFirstPerson()
	PlayerREF.PlayIdle(TG05_KnockOut)

EndFunction

Function CastStunSpell()

	Game.DisablePlayerControls(true, true, true, true, true, false, true, false)
	Game.ForceFirstPerson()
	; the player needs to be transformed back for the idle to play properly
	_FS_TheriantrophistControlQuest.TransformBackIfTransformed()
	_FS_Phasmalist_ControlQuest.UnsummonApparitionIfExists()
	MAGIllusionCharge500SDM.Play(PlayerREF)
	ReanimateFXShaderRed.Play(FS_NQR05_FatherREF)
	Wait(2)
	KnockOutPlayer()
	FS_NQR05_FatherREF.PlaceAtMe(ExplosionIllusionMassiveDark01)
	Game.ShakeCamera(afStrength = 1.0)
	FS_NQR05_DustParent.Activate(FS_NQR05_TharaelREF)
	MAGIllusionFearExplosionSDM.Play(PlayerREF)
	FXExplosionCatapultNearM.Play(PlayerREF)
	IllusionDarkMassiveImod.Apply()
	FS_NQR05_TharaelREF.Kill(FS_NQR05_FatherREF)
	Wait(3.2)
	_00E_NPCKillBodyfall.Play(PlayerREF)
	FadeToBlackHoldImod.Apply()
	Wait(5.0)
	FS_NQR05_TharaelREF.GetActorBase().SetEssential(False)
	FS_NQR05_TharaelREF.KillEssential(FS_NQR05_FatherREF)
	SetObjectiveCompleted(140)
	StartRhalaimLeaveSceneFather()

EndFunction

Function TeleportFather()

	Wait(1.0)
	FS_NQR05_FatherREF.PlaceAtMe(FXDragonPriestSmallExplosion)
	FS_NQR05_FatherREF.StopCombat()
	FS_NQR05_FatherREF.StopCombatAlarm()
	FS_NQR05_FatherREF.SetActorValue("Aggression", 0)
	FS_NQR05_FatherREF.MoveTo(FS_NQR05_SC30_FatherMarkerREF)
	FS_NQR05_FatherREF.PlayIdle(idleForceDefaultState)
	FS_NQR05_FatherREF.PlaceAtMe(FXDragonPriestSmallExplosion)
	FS_NQR05_TharaelREF.PlaceAtMe(FXDragonPriestSmallExplosion)
	FS_NQR05_TharaelREF.Disable()
	FS_NQR05_SC30_TharaelCorpseREF.PlaceAtMe(FXDragonPriestSmallExplosion)
	FS_NQR05_SC30_TharaelCorpseREF.Enable()
	_00E_QuestFunctions.WaitForReferenceToLoad(FS_NQR05_SC30_TharaelCorpseREF)
	FS_NQR05_SC30_TharaelCorpseREF.SetMotionType(4)
	_00E_BloodyFXShader.Play(FS_NQR05_SC30_TharaelCorpseREF)
	
EndFunction


Function stunPlayer()

	SetObjectiveCompleted(120)
	Game.DisablePlayerControls(true, true, true, true, true, false, true, false)
	Game.ForceFirstPerson()
	; the same as above
	_FS_TheriantrophistControlQuest.TransformBackIfTransformed()
	_FS_Phasmalist_ControlQuest.UnsummonApparitionIfExists()
	; lowered the sound volume, even with 0.2 its really loud
	int iEarRippingSound = _00E_FS_NQR05_FatherSleepSpellM.Play(PlayerREF)
	Sound.SetInstanceVolume(iEarRippingSound, 0.2)
	_00E_FS_NQR05_SC30_FatherPoisonIMOD.Apply()
	Wait(10.9)
	Game.GetPlayer().PlayIdle(TG05_KnockOut)
	Wait(3.2)
	FadeToBlackHoldImod.Apply()
	_00E_NPCKillBodyfall.Play(PlayerREF)
	
	Wait(6.0)
	SetStage(330)
	
Endfunction

Function UpdateObjectives14()

	FS_NQR05_FatherShadowREF.Enable()
	SetObjectiveCompleted(125)
	
EndFunction

Function AssumeOwnership()
	
	; add the horsefute to the player by starting the quest when interacting with the gift of the father
	If NQ06_Freda.GetStage() < 5
		NQ06_Freda.SetStage(5)
	EndIf
	
	NQ06.AddHorseFlute()
	
	NPCWerewolfGrowlSDM.Play(FS_NQR05_FatherShadowREF)
	
	FS_NQR05_FathersShadow.ForceRefTo(FS_NQR05_FatherShadowREF)
	FS_NQR05_FatherShadowREF.SetActorOwner(PlayerREF.GetActorBase())	
	
	NQ06.SetFatherShadowName()
	
	If _00E_AchievementsEnabled.GetValueInt() == 1
		Game.UnlockAchievement("END_MOUNT_01")
	EndIf
	
EndFunction

Function StartSC20()
	SetObjectiveCompleted(110)
	FS_NQR05_SC20_TharaelEnding.ForceStart()
	wait(2)
	; DissolveReappearFather()
EndFunction

Function ParalysePlayer()
	PlayerREF.setAV("Paralysis", 1)
Endfunction

Function StartRhalaimLeaveSceneFather()

	Game.DisablePlayerControls(true, true, true, true, true, false, true, false)
	FS_NQR05_FatherREF.Enable()
	FS_NQR05_SC20_PlayerCollisionBox.Enable()
	PlayerREF.MoveTo(FS_NQR05_SC20_PlayerKnockoutREF)
	FadeToBlackHoldImod.ApplyCrossFade()
	PlayerREF.PlayIdle(TG05_KnockOut)
	FS_NQR05_FatherREF.Reset()
	FS_NQR05_FatherREF.moveto(FS_NQR05_SC20_FatherMarkerREF)
	SC20_Rasha.forceRefTo(FS_NQR05_SC20_RashaREF)
	FS_NQR05_SC20_RashaREF.enable()
	FS_NQR05_SC20_RashaREF.EquipItem(_00E_FS_NQR05_RhalaimTorch)
	FS_NQR05_SC20_RashaREF.moveto(FS_NQR05_SC20_RashaMarkerREF)
	FS_NQR05_SC20_SceneReady.SetValueInt(1)
	
	; moving all Rhalaim in place for the last scene with the father
	int index = FS_NQR05_SC20_RhalaimList.GetSize()
	
	While index > 0
		index -= 1
		Actor akRhalaim = FS_NQR05_SC20_RhalaimList.GetAt(index) as Actor
		akRhalaim.Enable() 
		akRhalaim.MoveTo(FS_NQR05_SC20_RhalaimMarkers.GetAt(index) as ObjectReference)
		akRhalaim.EvaluatePackage()
	EndWhile
	
	FS_NQR05_BossfightFireParent.Disable()
	If !FS_NQR05_SC20_TharaelEnding.IsPlaying()
		FS_NQR05_SC20_TharaelEnding.ForceStart()
	EndIf
	FS_NQR05_RoomOfPaintingsDoorREF.SetOpen(True)
	
	Wait(3)

EndFunction

Function FadeBackRhalaim()

	FadeToBlackHoldImod.Remove()
	_00E_FS_NQR05_WakeUp.ApplyCrossFade()
	Wait(2.5)
	_00E_FS_NQR05_WakeUpHal.ApplyCrossFade()
	
EndFunction

Function AddGoodbyeMusic()

	_00E_FS_Music_Special_RhalataGoodbye.Add()

EndFunction

Function FatherRhalaimLeave()

	FS_NQR05_SC20_SceneReady.SetValueInt(2)
	Wait(1)
	; making the rhalaim leave one after the other
	int index = FS_NQR05_SC20_RhalaimList.GetSize()
	
	While index > 0
		index -= 1
		Actor akRhalaim = FS_NQR05_SC20_RhalaimList.GetAt(index) as Actor
		akRhalaim.EvaluatePackage()
	EndWhile
	
EndFunction	

Function CleanUpRhalaim()
	
	; cleaning up all unused actors and starting the respective functions for the endings
	FadeToBlackIMOD.Apply()
	FadeToBlackHoldIMOD.ApplyCrossFade()
	Wait(3)
	
	int index = FS_NQR05_SC20_RhalaimList.GetSize()
	
	While index > 0
		index -= 1
		Actor akRhalaim = FS_NQR05_SC20_RhalaimList.GetAt(index) as Actor
		akRhalaim.Disable() 
		akRhalaim.Delete()
	EndWhile
	
	FS_NQR05_SC20_RashaREF.UnequipItem(_00E_FS_NQR05_RhalaimTorch)
	FS_NQR05_SC20_RashaREF.disable()
	FS_NQR05_SC20_RashaREF.delete()
	FS_NQR05_FatherREF.disable()
	FS_NQR05_FatherREF.delete()
	Wait(5)
	
	If FS_NQR05_SidedWithFather.GetValueInt() == 1
		SetUpEndingFather()
	Else
		SetUpEndingTharael()
	EndIf
	
EndFunction

Function WakeUp()

	; FadeToBlackHoldIMOD.Remove()
	; _FS_TheriantrophistControlQuest.TransformBackIfTransformed() already done earlier
	FS_NQR05_SC20_PlayerCollisionBox.Disable()
	FS_NQR05_Room_Hallway_IntactREF.Disable()
	PlayerREF.MoveTo(FS_NQR05_SC20_WakeUpREF)
	PlayerREF.PlayIdle(TG05_GetUp)
	Wait(0.25)
	_00E_WakeUp.ApplyCrossFade()
	Wait(3)
	Game.enablePlayerControls()

EndFunction

Function SetUpEndingFather()

	Timescale.SetValue(0.1)
	Levelsystem.SkipTimeToHour(15.0)
	FS_NQR05_FatherHelmetREF.Enable()
	FS_NQR05_SwordREF.Disable()
	FatherMask.ForceRefTo(FS_NQR05_FatherHelmetREF)
	WakeUp()
	SetObjectiveDisplayed(125)

EndFunction

Function SetUpEndingTharael()
	
	; set up tharael near the cliff, setting a time for good lighting
	Game.RequestAutoSave()
	Timescale.SetValue(0.1)
	Levelsystem.SkipTimeToHour(15.0)
	Game.enablePlayerControls()
	FS_NQR05_TharaelREF.UnequipItem(_00E_FS_NQR_TharaelsBow, true)
	FS_NQR05_TharaelREF.RemoveItem(_00E_FS_NQR_TharaelsBow, 1, true)
	FS_NQR05_TharaelREF.RemoveItem(_00E_FS_NQR_TharaelsArrows, 55, true)
	FS_NQR05_TharaelREF.SetOutfit(_00E_FS_NQR_Rhalata_Voice_OutfitNoHood)
	FS_NQR05_TharaelREF.Enable()
	; again in case the AI stuck bug happened, maybe related to calling Reset() earlier,
	; already noted above in the same breath with the abnormality
	FS_NQR05_TharaelREF.Resurrect()
	TharaelSwitchToWeaponSet("None")
	FS_NQR05_BrotherSorrow_DecapREF.Disable()
	FS_NQR05_TharaelREF.moveto(FS_NQR05_SC21_TharaelSitMarker)
	FS_NQR05_SC21_LethoStitched.Enable()
	FS_NQR05_SC21_LethoStitched.moveto(FS_NQR05_SC21_LethoSitMarker)
	Utility.wait(1.0)
	_00E_BloodyFXShader.Play(FS_NQR05_TharaelREF)
	FS_NQR05_SC21_TharaelAtChasm.forcestart()
	
EndFunction

Function Continue()

	Self.SetStage(350)
	_00E_BloodyFXShader.Play(FS_NQR05_TharaelREF)
	FS_NQR05_SC21_LethoStitched.EnableAI(False)
	WakeUp()
	SetObjectiveDisplayed(135)

EndFunction

Function AddDeathMusic()

	_00E_FS_Music_Special_Character_TharaelDeath.Add()

EndFunction

Function AddKey()
	
	; add keys for tharael chest, gets called from three different dialogue fragments
	PlayerREF.AddItem(_00E_FS_NQR05_TharaelKey, 1)

EndFunction
	
Function KillTharael()
	
	; tharael suicide, player controls already got disabled earlier in the scene
	; that prevents the player from getting closer to tharael in an unfortunate angle
	; what sometimes resulted in tharael not jumping
	FS_NQR05_SC21_CollisionREF.Disable()
	FS_NQR05_TharaelREF.getActorBase().setEssential(false)
	FS_NQR05_TharaelREF.setGhost(false)
	FS_NQR05_TharaelREF.playIdle(_00E_IdleSuicide)
	Wait(0.65)
	PlayerREF.AddSpell(_00E_FS_NQR05_SlowMotionSP, False)
	Wait(9)
	PlayerREF.RemoveSpell(_00E_FS_NQR05_SlowMotionSP)
	Wait(3)
	FS_NQR05_TharaelREF.kill()
	FS_NQR05_TharaelREF.Disable()
	FS_NQR05_TharaelCorpseREF.Enable()
	Wait(5)
	SetStage(370)
	FS_NQR05_SC21_CollisionREF.Enable()
	_00E_Questfunctions.PlayerAIWalkStop()
	
Endfunction

Function SetPossibleRefugesGlobal()
	; 0 -> frostcliff tavern
	; 1 -> house in Ark
	If (CapitalCityPlayerHouseUpper.getActorOwner() == PlayerREF.GetActorBase())
		usePlayerHouseUpper = true
		_00E_FS_NQR05_D24_PossibleRefuges.setValue(1)
	ElseIf (CapitalCityPlayerHouse.getActorOwner() == PlayerREF.GetActorBase())
		usePlayerHouseUpper = false
		_00E_FS_NQR05_D24_PossibleRefuges.setValue(1)
	Else
		_00E_FS_NQR05_D24_PossibleRefuges.setValue(0)
	EndIf
Endfunction

Function TeleportToRefuge()

	_00E_BloodyFXShader.Stop(FS_NQR05_TharaelREF)
	FS_NQR05_TharaelREF.Disable()
	FS_NQr05_AfterRhalataTharael.Enable()
	Tharael.ForceRefTo(FS_NQr05_AfterRhalataTharael)

	If (_00E_FS_NQR05_TharaelInFrostCliff.GetValueInt() == 1)
		_00E_FS_NQR05_D24_PossibleRefuges.setValue(0)
		FS_NQr05_AfterRhalataTharael.moveto(FS_NQR05_D24_RailLeanREF)
	Else
		_00E_FS_NQR05_D24_PossibleRefuges.setValue(1)
		If (usePlayerHouseUpper)
			FS_NQr05_AfterRhalataTharael.moveto(FS_NQR05_D24_TharaelUpperHouseMarkeREF)
		Else
			FS_NQr05_AfterRhalataTharael.moveto(FS_NQR05_D24_TharaelWallREF)
		EndIf
	EndIf
	
	If _00E_AchievementsEnabled.GetValueInt() == 1
		Game.UnlockAchievement("END_THARAEL_NO_SUICIDE_01")
	EndIf
Endfunction

Function GiveSecretReward()
	
	; gicen by the first seer in a dialgoue fragment
	_00E_FS_NQR05_SecretRewardTaken.SetValueInt(1)
	PlayerREF.AddItem(Gold001, 450)

EndFunction

Function FinishUp()
	
	; clean up all NPCs, clear the player from the alias
	If _00E_FS_NQR05_NPCsToDisable == None
		_00E_FS_NQR05_NPCsToDisable = Game.GetForm(0x0102E6E8) as Formlist
	EndIf

	int iIndex = _00E_FS_NQR05_NPCsToDisable.GetSize()
	
	While iIndex > 0
		iIndex -= 1
		ObjectReference objToDisable = _00E_FS_NQR05_NPCsToDisable.GetAt(iIndex) as ObjectReference
		objToDisable.Disable()
	EndWhile
	
	iIndex = FS_NQR05_RhalataSiteNPCs.GetSize()
	
	While iIndex > 0
		iIndex -= 1
		ObjectReference objToDisable = FS_NQR05_RhalataSiteNPCs.GetAt(iIndex) as ObjectReference
		objToDisable.Disable()
	EndWhile
	
	CompleteAllObjectives()
	Weather.ReleaseOverride()
	Levelsystem.RemoveSilence()
	Levelsystem.RemoveCombatSoundtracks()
	FS_NQR03_BrotherGreedREF.Disable()
	FS_NQR05_SiteCampfireParentREF.Disable()
	FS_NQR05_SC04_BrotherSorrowREF.Disable()
	Timescale.SetValue(10)
	Levelsystem.SetAllowIdleChatter(True)
	akFakeCompanion.getActorbase().SetEssential(true)
	_00E_TeleportGlobal.SetValueInt(0)
	Levelsystem.GiveEP(iRewardEXP)
	UnregisterForSleep()
	; just in case
	UnregisterForUpdate()
	RegisterForSingleUpdateGameTime(0.5)
	
EndFunction

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

int iRewardEXP = 2500
int iPortalSound

bool bAnimationFired
bool bAnimationFired_02

ObjectReference returnFurniture

Actor akFakeCompanion
Actor[] sc20Rhalaim

bool usePlayerHouseUpper = false

_00E_QuestFunctions Property Levelsystem Auto
_00E_Game_Playerhouse_BoardSC Property Playerhouse_Market_BoardREF Auto
_00E_Game_Playerhouse_BoardSC Property Playerhouse_Noble_BoardREF Auto

bool Property bJespar Auto Hidden Conditional

Ammo Property _00E_FS_NQR_TharaelsArrows Auto

Idle Property IdleHandsBehindBack Auto

Static Property XMarker Auto

Spell Property _00E_FS_NQR05_SlowMotionSP Auto

_00E_FS_NQR05_Bossfight_FatherSC Property Father Auto

ImageSpaceModifier Property _00E_FS_NQR05_TharaelTeleportShock Auto

GlobalVariable Property FS_NQR05_BossfightOnGoing Auto

Activator Property DefaultAshPileGhostBlack Auto

Actor Property PlayerREF Auto
Actor Property FS_NQR05_SC01_FakeFatherREF Auto
Actor Property FS_NQR05_TharaelREF Auto
Actor Property FS_NQR03_LethoREF Auto
Actor Property FS_NQR05_FatherREF Auto
Actor Property FS_NQR05_SC04_BrotherSorrowREF Auto
Actor Property FS_NQR03_BrotherGreedREF Auto
Actor Property FS_NQR05_ZaraahREF Auto
Actor Property FS_NQR05_SC07_FatherREF Auto
Actor Property FS_NQR05_FatherShadowREF Auto
Actor Property FS_NQR05_SC12_Jespar_REF Auto
Actor Property FS_NQR05_SC12_Calia_REF Auto
Actor Property FS_NQR05_SC16_BrotherHatredREF Auto
Actor Property FS_NQR05_SC20_RashaREF Auto
Actor Property FS_NQR05_SisterLust Auto
Actor Property FS_NQR05_SC08_Mercenary_Ewah Auto
Actor Property FS_NQR05_SC08_Mercenary_Kaylan Auto
Actor Property FS_NQR05_SC21_LethoStitched Auto
Actor Property FS_NQr05_AfterRhalataTharael Auto
Actor Property FS_NQR05_TharaelCorpseREF Auto

MiscObject Property Gold001 Auto

ActorBase Property _00E_FS_NQR05_SC20_GenericRhalaim Auto

Idle Property pa_1HMSneakKillBackA Auto
Idle Property _00E_IdleStomp Auto
Idle Property idleForceDefaultState Auto
Idle Property giantKnockDown Auto
Idle Property giantGetUp Auto
Idle Property IdleNocturnalEnter Auto
Idle Property IdleNocturnal_Rise Auto
Idle Property IdleNocturnalExit Auto

Scene Property FS_NQR05_SC01_Dream Auto
Scene Property FS_NQR05_SC02_Father Auto
Scene Property FS_NQR05_SC03_TharaelPreparation Auto
Scene Property FS_NQR05_SC05_Zaraah Auto
Scene Property FS_NQR05_SC06_FatherArrival Auto
Scene Property FS_NQR05_SC07_FatherPlanning Auto
Scene Property FS_NQR05_SC08_Preparation Auto
Scene Property FS_NQR05_SC09_EnterScene Auto
Scene Property FS_NQR05_SC10_SisterLustGroup Auto
Scene Property FS_NQR05_SC11_EntranceScene Auto
Scene Property FS_NQR05_SC12_Temple_01 Auto
Scene Property FS_NQR05_SC13_Temple_02 Auto
Scene Property FS_NQR05_SC14_Temple_03 Auto
Scene Property FS_NQR05_SC15_Temple_04 Auto
Scene Property FS_NQR05_SC16_Temple_05 Auto
Scene Property FS_NQR05_SC17_AfterBossfight Auto
Scene Property FS_NQR05_SC18a_FatherRhalataMistrustTooHigh Auto
Scene Property FS_NQR05_SC18b_FatherRhalataMistrustSmallEnough Auto
Scene Property FS_NQR05_SC19_FatherStory Auto
Scene Property FS_NQR05_SC20_TharaelEnding Auto
Scene Property FS_NQR05_SC21_TharaelAtChasm Auto
Scene Property FS_NQR05_SC_Bossfight Auto
Scene Property FS_NQR05_SC19_02_Cinematic Auto
Scene Property FS_NQR05_SC30_FatherSided Auto

GlobalVariable Property Timescale Auto
GlobalVariable Property _00E_TeleportGlobal Auto
GlobalVariable Property CaliaRomance Auto
GlobalVariable Property JesparRomance Auto
GlobalVariable Property SympathyJespar Auto
GlobalVariable Property SympathyCalia Auto
GlobalVariable Property _00E_FS_NQR_RhalataMistrust Auto
GlobalVariable Property _00E_FS_NQR05_D24_PossibleRefuges Auto
GlobalVariable Property FS_NQR05_SidedWithTharael Auto
GlobalVariable Property FS_NQR05_SidedWithFather Auto
GlobalVariable Property _00E_FS_NQR05_SpokenToTharael Auto
GlobalVariable Property _00E_FS_NQR05_RhalataMistrustTooHight Auto
GlobalVariable Property FS_NQR05_SC20_SceneReady Auto
GlobalVariable Property _00E_MountGlobal Auto
GlobalVariable Property _00E_FS_NQR05_SecretRewardTaken Auto
GlobalVariable Property _00E_FS_NQR05_TharaelTrickedByFather Auto
GlobalVariable Property _00E_FS_NQR05_TharaelInFrostCliff Auto
GlobalVariable Property FS_NQR05_SC19_LethoKilled Auto
GlobalVariable Property _00E_AchievementsEnabled Auto

Explosion Property FXDragonPriestSmallExplosion Auto
Explosion Property TG08BShockwaveExplosion Auto
Explosion Property ExplosionShockMassNoEffectsSmall Auto
Explosion Property _00E_FS_PsionicExplosionSmallNoEffects Auto
Explosion Property _00E_FS_NQR05_BloodGeysir_Big Auto
Explosion Property _00E_FS_NQR05_BloodGeysir Auto
Explosion Property _00E_FS_NQR05_SC20_FatherDissolve Auto
Explosion Property _00E_FS_NQR05_SC20_FatherReappear Auto
Explosion Property _00E_FS_NQR05_FireStormAbnormality Auto
Explosion Property _00E_FS_NQR05_FireStormAbnormalityDeath Auto
Explosion Property _00E_A2_GhostwalkImpactExplosion Auto
Explosion Property _00E_FS_NQR05_Abnormality_EXP_02 Auto
Explosion Property ExplosionIllusionMassiveDark01 Auto
Explosion Property _00E_NPCOorbayaTeleportExplosionBlue Auto
Explosion Property _00E_FS_NQR05_PerversionExp Auto
Explosion Property ExplosionRuneShockSmallNoEffects Auto
ObjectReference Property FS_NQR05_Abnormality_Egg_Marker Auto

Weapon Property _00E_FS_NQR05_Tharael_Dagger Auto
Weapon Property _00E_FS_NQR05_GrotesqueHammer Auto
Weapon Property _00E_FS_NQR_TharaelsBow Auto
Weapon Property _00E_FS_NQR05_ZarAhSabre Auto

ReferenceAlias Property Player Auto
ReferenceAlias Property SC12_Enemy Auto
ReferenceAlias Property FatherMask Auto
ReferenceAlias Property SC20_Rasha Auto
ReferenceAlias Property Tharael Auto
ReferenceAlias Property SC_Abnormality Auto
ReferenceAlias Property FS_NQR05_FathersShadow Auto

Quest Property MQ05 Auto
Quest Property NQ06_Freda Auto
_00E_NQ06_Functions Property NQ06 Auto

FS_NQR05_BossfightAbnormalitySC Property FS_NQR05_Abnormality Auto
ObjectReference Property FS_NQR05_BattleLinkerREF Auto
ObjectReference Property FS_NQR05_DreamStartMarkerREF Auto
ObjectReference Property FS_NQR05_DustParent Auto
ObjectReference Property _00E_FS_NQR05_SC17_TharaelMarker Auto
ObjectReference Property FS_NQR03_BrotherGriefMarkerREF Auto
ObjectReference Property FS_NQR05_RuneMarkerREF Auto
ObjectReference Property FS_NQR05_SC01_FatherMarkerREF Auto
ObjectReference Property FS_NQR05_SC02_DissolveWallREF Auto
ObjectReference Property FS_NQR05_FatherStartMarker Auto
ObjectReference Property FS_NQR05_SC02_FatherChairREF Auto
ObjectReference Property FS_NQR03_SC01_TharaelMarkerREF Auto
ObjectReference Property FS_NQR03_SC03_SecretDoorREF Auto
ObjectReference Property FS_NQR05_SC03_TriggerREF Auto
ObjectReference Property FS_NQR05_TharaelMarkerREF Auto
ObjectReference Property FS_NQR05_SC04_BrotherSorrowMarker Auto
ObjectReference Property FS_NQR05_SC05_GateREF Auto
ObjectReference Property FS_NQR05_SC06_ActivationTriggerREF Auto
ObjectReference Property FS_NQR05_SC06_WallMarkerREF Auto
ObjectReference Property FS_NQR05_SC06_ZaraahMarker Auto
ObjectReference Property FS_NQR05_FatherPortal_Outside_REF Auto
ObjectReference Property FS_NQR05_SC08_FatherArrivalMarker Auto
ObjectReference Property FS_NQR05_Dust_TriggerREF Auto
ObjectReference Property FS_NQR05_NPCSpawnmarkerREF Auto
ObjectReference Property FS_NQR05_SC09_TharaelMarker Auto
ObjectReference Property FS_NQR05_SC09_CollisionParentREF Auto
ObjectReference Property FS_NQR05_SC08_BoxingMarker Auto
ObjectReference Property FS_NQR05_SC06_SpectatorMarker_001 Auto
ObjectReference Property FS_NQR05_TempleDoorREF Auto
ObjectReference Property FS_NQR05_SC11_PlayerDoorREF Auto
ObjectReference Property FS_NQR05_SC13_DoorREF Auto
ObjectReference Property FS_NQR05_SC15_TharaelShootMarker Auto
ObjectReference Property FS_NQR05_HeartREF Auto
ObjectReference Property FS_NQR05_EggsacREF Auto
ObjectReference Property FS_NQR05_ZaraahSoulREF Auto
ObjectReference Property FS_NQR05_ElkREF Auto
ObjectReference Property FS_NQR05_BarrierREF Auto
ObjectReference Property FS_NQR05_GateGuardianREF Auto
ObjectReference Property FS_NQR05_ExitDoor Auto
ObjectReference Property FS_NQR05_SC16_BloodDecalREF Auto
ObjectReference Property FS_NQR05_FatherPortal Auto
ObjectReference Property FS_NQR05_SC17_BrotherSorrowMarker Auto
ObjectReference Property FS_NQR05_SC20_FatherReappearMarker Auto
ObjectReference Property FS_NQR05_SC20_RhalaimMarker Auto
ObjectReference Property FS_NQR05_SC20_PlayerWatchDepartureMarker Auto
ObjectReference Property FS_NQR05_SC21_TharaelSitMarker Auto
ObjectReference Property FS_NQR05_SC08_SisterAddiction_GroupMarker003 Auto
ObjectReference Property FS_NQR05_D24_FrostcliffTavernChair Auto
ObjectReference Property FS_NQR05_D24_RailLeanREF Auto
ObjectReference Property FS_NQR05_D24_ArkNobleHouseChair Auto
ObjectReference Property FS_NQR05_D24_ArkMerchantHouseChair Auto
ObjectReference Property FS_NQR05_BossfightFireParent Auto
ObjectReference Property FS_NQR05_SC08_BrotherWrath_Group_Zaraah Auto
ObjectReference Property FS_NQR05_SC10_SisterLustWaitMarker Auto
ObjectReference Property FS_NQR05_HeartSwirlREF Auto
ObjectReference Property FS_NQR05_BeamZarah Auto
ObjectReference Property FS_NQR05_BeamHeart Auto
ObjectReference Property FS_NQR05_KneelTharael Auto
ObjectReference Property FS_NQR05_AbnormalityStartingPOS Auto
ObjectReference Property FS_NQR05_Abnormality_Explosion_01 Auto
ObjectReference Property FS_NQR05_Abnormality_Explosion_02 Auto
ObjectReference Property FS_NQR05_Abnormality_Explosion_03 Auto
ObjectReference Property FS_NQR05_Abnormality_Explosion_04 Auto
ObjectReference Property FS_NQR05_Abnormality_Egg_Parent_01 Auto
ObjectReference Property FS_NQR05_Abnormality_Egg_Parent_02 Auto
ObjectReference Property FS_NQR05_Abnormality_Egg_Parent_03 Auto
ObjectReference Property FS_NQR05_Abnormality_Egg_Parent_04 Auto
ObjectReference Property FS_NQR05_SC17_FatherMarker Auto
ObjectReference Property FS_NQR05_SC17_LethoMarker Auto
ObjectReference Property FS_NQR05_Cinematic_TeleportMarkerREF003 Auto
ObjectReference Property FS_NQR05_SC19_02_TharaelStabMarker Auto
ObjectReference Property FS_NQR05_SC19_02_FatherPrepareMarker Auto
ObjectReference Property FS_NQR05_Portal_Rune_002 Auto
ObjectReference Property FS_NQR05_Portal_Rune_003 Auto
ObjectReference Property FS_NQR05_Portal_Rune_004 Auto
ObjectReference Property FS_NQR05_Portal_Rune_005 Auto
ObjectReference Property FS_NQR05_Portal_Rune_006 Auto
ObjectReference Property FS_NQR05_Portal_Rune_007 Auto
ObjectReference Property FS_NQR05_Portal_Rune_008 Auto
ObjectReference Property FS_NQR05_Portal_Rune_009 Auto
ObjectReference Property FS_NQR05_Portal_Rune_010 Auto
ObjectReference Property FS_NQR05_Portal_Rune_011 Auto
ObjectReference Property FS_NQR05_Portal_Rune_012 Auto
ObjectReference Property FS_NQR05_Portal_Rune_013 Auto
ObjectReference Property FS_NQR05_Portal_Rune_014 Auto
ObjectReference Property FS_NQR05_PortalLightNew002 Auto
ObjectReference Property FS_NQR05_SC16_TharaelKillLethoREF Auto
ObjectReference Property FS_NQR05_SC16_LethoDeathMarker Auto
ObjectReference Property FS_NQR05_SC30_FatherMarkerREF Auto
ObjectReference Property FS_NQR05_SC30_TharaelCorpseREF Auto
ObjectReference Property FS_NQR05_SC20_PlayerKnockoutREF Auto
ObjectReference Property FS_NQR05_Room_Hallway_BrokenREF Auto
ObjectReference Property FS_NQR05_Room_Hallway_IntactREF Auto
ObjectReference Property FS_NQR05_SC20_FatherMarkerREF Auto
ObjectReference Property FS_NQR05_SC20_RashaMarkerREF Auto
ObjectReference Property FS_NQR05_RoomOfPaintingsDoorREF Auto
ObjectReference Property FS_NQR05_SC20_PlayerCollisionBox Auto
ObjectReference Property FS_NQR05_FatherHelmetREF Auto
ObjectReference Property FS_NQR05_BrotherSorrow_DecapREF Auto
ObjectReference Property FS_NQR05_SC21_FatherAppearMarkerREF Auto
ObjectReference Property FS_NQR05_SC21_FatherPortMarkerREF Auto
ObjectReference Property FS_NQR05_SC21_LethoSitMarker Auto
ObjectReference Property FS_NQR05_SwordREF Auto
ObjectReference Property FS_NQR05_D24_TharaelUpperHouseMarkeREF Auto
ObjectReference Property FS_NQR05_D24_TharaelWallREF Auto
ObjectReference Property FS_NQR05_Barrier02REF Auto
ObjectReference Property FS_NQR05_GlyphLightREF Auto
ObjectReference Property FS_NQR05_SC12_DevourSoundREF Auto
ObjectReference Property FS_NQR05_SC12_DustDropREF Auto
ObjectReference Property FS_NQR05_Abnormality_CollisionParentREF Auto
ObjectReference Property FS_NQR05_Abnormality_HeartbeatREF Auto
ObjectReference Property FS_NQR05_Portal_ExplosionREF Auto
ObjectReference Property FS_NQR05_SiteCampfireParentREF Auto
ObjectReference Property FS_NQR05_SiteWorkingAmbREF Auto
ObjectReference Property FS_NQR05_FatherDyingREF Auto
ObjectReference Property FS_NQR05_SC20_WakeUpREF Auto
ObjectReference Property FS_NQR05_SC21_CollisionREF Auto
ObjectReference Property FS_NQR05_FatherVoiceREF Auto
ObjectReference Property FS_NQR05_FatherVoiceSourceREF Auto

Weather Property _00E_FS_NQR05_SiteWeatherSnow Auto

MusicType Property _00E_SilenceTransitionLowPriority Auto
MusicType Property _00E_FS_NQR05_FatherArrival Auto
MusicType Property _00E_FS_Music_Special_Character_Tharael Auto
MusicType Property _00E_FS_Music_Explore_RhalataTempleSingle Auto
MusicType Property _00E_FS_Music_Special_BlackWaltz Auto
MusicType Property _00E_FS_Music_Special_BattleOfTheFleshless Auto
MusicType Property _00E_FS_Music_Special_RhalataGoodbye Auto
MusicType Property _00E_FS_Music_Special_Character_TharaelDeath Auto

Spell Property _00E_FakeArrowSP Auto
Spell Property _00E_NPCSpellLifeAbsorbtion Auto
Spell Property _00E_FS_NQR05_TharaelSummon Auto
Spell Property _00E_FS_NQR05_SlowMotionLessSP Auto

Key Property _00E_FS_NQR05_TharaelKey Auto

VisualEffect Property WerewolfExtractVFX Auto
VisualEffect Property FXAlduinSoulEscapeEffect Auto

ImageSpaceModifier Property FadeToBlackIMOD Auto
ImageSpaceModifier Property FadeToBlackBackIMOD Auto
ImageSpaceModifier Property FadeToBlackHoldIMOD Auto
ImageSpaceModifier Property _00E_MQ09KnockOutLong Auto
ImageSpaceModifier Property MAGShockExpImod Auto
ImageSpaceModifier Property _00E_WakeUp Auto 
ImageSpaceModifier Property _00E_FS_NQR05_HeartIMOD Auto 
ImageSpaceModifier Property MAGFireStormImod Auto
ImageSpaceModifier Property _00E_FS_NQR05_BanishTharaelIMOD Auto
ImageSpaceModifier Property IllusionDarkMassiveImod Auto
ImageSpaceModifier Property _00E_FS_NQR05_WakeUpHal Auto
ImageSpaceModifier Property _00E_FS_NQR05_WakeUp Auto
ImageSpaceModifier Property _00E_FS_NQR05_SC30_FatherPoisonIMOD Auto
  
Sound Property MAGIllusionReleaseAimedSDM Auto
Sound Property _00E_A2_Ghostwalk_TeleportDoneSound Auto
Sound Property QSTMS06PotemaBanishExplosion Auto
Sound Property MAGConjurePortalOpenM Auto
Sound Property OBJEyeofMagnusVanishM Auto
Sound Property QSTDA02ShrineActivateLPMM Auto
Sound Property MAGIllusionCharm Auto
Sound Property AMBRumbleShake Auto
Sound Property WPNImpactArrowVsFlesh Auto
Sound Property _00E_FS_NQR05_Absorb_StartM Auto
Sound Property _00E_FS_NQR05_Absorb_StopM Auto
Sound Property _00E_Male_PlayerHitM Auto
Sound Property _00E_NPCKillBodyfall Auto
Sound Property _00E_FS_NQR05_RoarM Auto
Sound Property FXExplosionCatapultNearM Auto
Sound Property ITMGenericClothingDown Auto
Sound Property MAGShoutSlowTimeActive02LP Auto
Sound Property MAGShockFFFire Auto
Sound Property _00E_FS_NQR05_SlowMotion_IntroM Auto
Sound Property _00E_FS_NQR05_SlowMotion_OutroM Auto
Sound Property MAGEnchantedUnsheatheOtherM Auto
Sound Property MAGIllusionFireLP Auto
Sound Property MAGIllusionCharge100SDM Auto
Sound Property MAGIllusionCharge500SDM Auto
Sound Property NPCWerewolfGrowlSDM Auto
Sound Property MAGIllusionFearExplosionSDM Auto
Sound Property _00E_FS_NQR05_Temple_AbsorbRoarMarker Auto
Sound Property _00E_FS_NQR05_BrotherSorrowDeathM Auto
Sound Property _00E_FS_NQR05_FatherSleepSpellM Auto
Sound Property _00E_FS_NQR05_FatherDeadM Auto

Perk Property _00E_A1_RocksolidPerk Auto

Formlist Property FS_NQR05_RhalataSiteNPCs Auto
Formlist Property FS_NQR05_Group_BrotherHatred Auto
Formlist Property FS_NQR05_Group_SisterAddiction Auto
Formlist Property FS_NQR05_SC20_RhalaimMarkers Auto
Formlist Property FS_NQR05_SC20_RhalaimList Auto
Formlist Property _00E_FS_NQR05_NPCsToDisable Auto

Idle Property takeOfMask Auto
Idle Property pa_2HMKillMoveDualWieldDecap Auto
Idle Property TG05_KnockOut Auto
Idle Property TG05_GetUp Auto
Idle Property _00E_IdleSuicide Auto

Cell Property CapitalCityPlayerHouseUpper Auto
Cell Property CapitalCityPlayerhouse Auto
Cell Property FS_NQR05_Temple_03 Auto

Topic Property FS_NQR05_D99_TharaelScreamTopic Auto
Topic Property FS_NQR05_FatherLastWordsTopic Auto
Topic Property FS_NQR05_D99_TharaelKillLethoTopic Auto

Light Property _00E_FS_NQR05_RhalaimTorch Auto

SoundCategory Property AudioCategorySFX Auto

EffectShader Property _00E_MQ07b_DissolvePlatformFXS Auto
EffectShader Property FireFXShader Auto
EffectShader Property _00E_TeleportReappearShader Auto
EffectShader Property _00E_A2_GhostwalkReappear Auto
EffectShader Property _00E_FS_NQR05_Father_Materializer Auto
EffectShader Property _00E_BloodyFXShader Auto
EffectShader Property _00E_HighOnesDisintegrate Auto
EffectShader Property EnchRedFXShader Auto
EffectShader Property _00E_DissolveInFlames Auto
EffectShader Property ReanimateFXShaderRed Auto

Faction Property PlayerEnemyFaction Auto

Outfit Property _00E_FS_TharaelOutfit Auto
Outfit Property _00E_MC_Calia_Outfit Auto
Outfit Property FarmClothesOutfit03 Auto
Outfit Property _00E_FS_NQR_Rhalata_Voice_OutfitNoHood Auto

Armor Property _00E_FS_Rhalata_Voice_Hood Auto
Armor Property _00E_FS_NQR05_FatherHelmet Auto

Static Property XMarkerHeading Auto

Message Property _00E_FS_NQR05_ChooseSide Auto