Scriptname _00E_MQ12b_Functions extends Quest Conditional

Import Utility

Int CurScriptVersion = 0
Int Property LATEST_SCRIPT_VERSION = 2 AutoReadOnly

int function _GetScriptVersion() Global
    return 1
endFunction

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

Function SetUp()

	CurScriptVersion		= LATEST_SCRIPT_VERSION
	
	iCrimeGoldBeforeMQ12bNonViolent = A_CrimeFaction.GetCrimeGoldNonViolent()
	iCrimeGoldBeforeMQ12bViolent = A_CrimeFaction.GetCrimeGoldViolent()
	
	A_CrimeFaction.SetCrimeGold(0)
	A_CrimeFaction.SetCrimeGoldViolent(0)
	_00E_MC_JorrekRef.Disable()
	_00E_MC_TealorREF.EquipItem(_01E_20Hueterschwert, true, true)
	_00E_MC_YuslanRef.Disable()
	_00E_SilenceLongTransitionHighPriority.Add()
	MQ03_SC1_CastleWorldDoor.BlockActivation(True)
	_00E_SouthQuarter_UndercityDoorREF.BlockActivation(True)
	MQ12b_SC4_BarracksDoorREF.BlockActivation(True)
	MQ12b_SC5_HarborDoorREF.BlockActivation(True)
	CapitalCity_UpperCityToMarket01.BlockActivation(True)
	CapitalCity_UpperCityToMarket02.BlockActivation(True)
	MQ12b_Market_CastleCollisionREF.Enable()
	MQ12b_DisableThisDudeHeIsAnnoyingREF.Disable()
	_00E_TeleportGlobal.SetValueInt(1)
	PlayerREF.AddToFaction(MQ12b_TemporarySiegeFaction)
	PlayerREF.AddPerk(_00E_ArkSiegeLockedGatesPerk)
	Ordenshueter.GetReference().Enable()
	Ordenshueter.GetReference().MoveTo(MQ12b_SC1_Orderguard01)
	Ordenshueterin.GetReference().MoveTo(MQ12b_SC1_Orderguard02)

	bArkUnderAttackPrelude = True

	SkyrimOvercastRain.SetActive(True)
	_00E_MC_LexREF.EvaluatePackage()

	AdjustTime()
	
EndFunction

Function BlockDoors()

	int iIndex = MQ12b_SC01_ArkDoors.GetSize()
	
	While iIndex > 0
		iIndex -= 1
		ObjectReference objDoorToBlock = MQ12b_SC01_ArkDoors.GetAt(iIndex) as ObjectReference
		objDoorToBlock.BlockActivation(True)
	EndWhile
	
EndFunction

Function StartSC02Failsave()

	iCrimeGoldBeforeMQ12bNonViolent = A_CrimeFaction.GetCrimeGoldNonViolent()
	iCrimeGoldBeforeMQ12bViolent = A_CrimeFaction.GetCrimeGoldViolent()
	
	If Self.GetCurrentStageID() < 15
		Self.SetCurrentStageID(15)
	EndIf
	
	If _00E_MC_LeoraREF.IsDisabled()
		_00E_MC_LeoraREF.Enable()
	EndIf

	If _00E_MC_YuslanRef.IsDisabled()
		_00E_MC_YuslanRef.Enable()
	EndIf
	
	Utility.Wait(0.25)

	_00E_MC_LeoraREF.MoveTo(MQ12b_SC2_LeoraMarker002)
	_00E_MC_YuslanRef.MoveTo(MQ12b_SC2_ShaRimMarker002)
	
	If !MQ12b_SC2_Attack.IsPlaying()
		MQ12b_SC2_Attack.ForceStart()
	EndIf
	
EndFunction

Function StartSC02()

	If _00E_MC_LeoraREF.IsDisabled()
		_00E_MC_LeoraREF.Enable()
	EndIf

	If _00E_MC_YuslanRef.IsDisabled()
		_00E_MC_YuslanRef.Enable()
	EndIf
	
	SkyrimOvercastRain.SetActive(True)
	_00E_MC_LeoraREF.MoveTo(MQ12b_SC2_LeoraMarker002)
	_00E_MC_YuslanRef.MoveTo(MQ12b_SC2_ShaRimMarker002)
	MQ12b_SC2_Attack.ForceStart()
	
EndFunction

Function TealorAppears()
	
	If _00E_MC_TealorRef.IsDisabled()
		_00E_MC_TealorREF.Enable()
	EndIf
	
	_00E_SilenceLongTransitionHighPriority.Add()
	AllowIdleChatter.SetValue(0)
	_00E_MC_TealorREF.MoveTo(MQ12b_SC2_TealorStartMarker005)
	
	Utility.Wait(0.5)
	
	If _00E_MC_TealorREF.GetWorldSpace() == PlayerREF.GetWorldSpace()
		_00E_MC_TealorREF.MoveTo(MQ12b_SC2_TealorStartMarker005)
	EndIf

EndFunction

Function SC02_TealorFailsave()

	; Failsave to move Tealor to the scene in the upper quarters
	; where Yuslan is arguing with Leora about the magical blockade.

	If _00E_MC_TealorREF.GetDistance(_00E_MC_YuslanRef) > 198
		Wait(1)
		If _00E_MC_TealorREF.GetDistance(_00E_MC_YuslanRef) > 198
			_00E_MC_TealorREF.MoveTo(MQ12b_SC2_ShaRimMarker002)
		Endif
	EndIf

EndFunction

Function StartSC03()

	_00E_SilenceLongTransitionHighPriority.Remove()
	_00E_Music_Combat_BonehunterNoCond.Add()
	
	If _00E_MC_LeoraREF.IsDisabled()
		_00E_MC_LeoraREF.Enable()
	EndIf

	If _00E_MC_YuslanRef.IsDisabled()
		_00E_MC_YuslanRef.Enable()
	EndIf
	
	If _00E_MC_TealorRef.IsDisabled()
		_00E_MC_TealorREF.Enable()
	EndIf
	
	MQ12b_SC3_CityGuardREF.Enable()
	MQ12b_SC3_CityGuardREF.MoveTo(MQ12b_SC3_CityGuardStartMarker)

	MQ12b_SC3_CatapultAttack.ForceStart()

	AMBrCivilWarCatapultsDistantM.Play(PlayerREF)
	ObjectReference CatapultStrike = MQ12b_SC3_CatapultStrikeMarker002.PlaceAtMe(CWCatapultStrike)
	
	_00E_MC_TealorREF.SetLookAt(CatapultStrike)
	_00E_MC_LeoraREF.SetLookAt(CatapultStrike)
	_00E_MC_YuslanRef.SetLookAt(CatapultStrike)
	
	Wait(4)
	
	_00E_Ability_StaggerSelfSpell.Cast(_00E_MC_YuslanRef,_00E_MC_YuslanRef)
	_00E_Ability_StaggerSelfSpell.Cast(_00E_MC_LeoraREF,_00E_MC_LeoraREF)
	MQ12b_SC3_BarrierREF002.Enable()
	MQ12b_SC3_TealorBarrierMarkerREF.Enable()
	
	Wait(1)
	
	LaunchCityAttack()
	
EndFunction

Function LaunchCityAttack()

	Game.RequestAutoSave()
	SendModEvent("ArkSiegeStarted")
	iBellSound = _00E_BellLoop.Play(PlayerREF)
	MQ03_SC1_CastleWorldDoor.BlockActivation(True)
	MQ12b_SC4_BarracksDoorREF.BlockActivation(True)
	_00E_SouthQuarter_UndercityDoorREF.BlockActivation(True)
	MQ12b_SC5_HarborDoorREF.BlockActivation(True)
	MQ12b_SC5_LowerDistrictMarketDoor01REF.BlockActivation(True)
	MQ12b_SC5_LowerDistrictMarketDoor02REF.BlockActivation(True)
	EnableMarketProps()
	
	SkyrimOvercastRain.SetActive(True)
	_00E_SilenceLongTransitionHighPriority.Remove()
	_00E_Music_Combat_BonehunterNoCond.Add()
	_00E_MQ12b_SC3_ScreamM.Play(MQ12b_SC3_ScreamMarker)
	AMBCivilWarBattleStartDistant.Play(PlayerREF)
	MQ12b_SC3_PanicTriggerboxREF.Enable()
	MQ12b_StayDisabledLinker.Disable()
	MQ12b_SC3_UpperCityLinker01.Enable()
	MQ12b_SC3_CatapultFireController.PlaceAtMe(CWCatapultStrikeNoDmg)
	StrikeSpawner = MQ12b_SC3_CatapultFireController
	bArkUnderAttack = True
	MQ12b_ArkUnderAttack.SetValueInt(1)
	RegisterForSingleUpdate(3)
	GoToState("SiegeUpperCity")
	Wait(1)
	MQ12b_SC3_BattleSoundMarker.Enable()
	
EndFunction

Function SoldierFailsave()

	if MQ12b_SC3_CityGuardREF.GetDistance(MQ12b_SC3_CityGuardRunToMarker) >= 350
		MQ12b_SC3_CityGuardREF.MoveTo(MQ12b_SC3_CityGuardRunToMarker)
	EndIf

EndFunction

Function StartSC04()

	If _00E_MC_TealorRef.IsDisabled()
		_00E_MC_TealorREF.Enable()
	EndIf

	_00E_Func_SetNPCAsCompanion.SetNPCAsCompanion(_00E_MC_TealorREF, True, 600, 700, 200)

	MQ12b_SC3_BarrierREF002.PlayAnimation("TransitionAnim")
	MQ12b_SC4_TealorTravelToMistDistrict.ForceStart()

	MQ12b_SC3_TealorBarrierMarkerREF.Disable()
	CapitalCity_UpperCityToMarket01.BlockActivation(False)
	CapitalCity_UpperCityToMarket02.BlockActivation(False)
	
EndFunction

Function TeleportYuslan()

	_00E_PlayerFunctions.GetTeleportControl().TeleportNPC(_00E_MC_YuslanRef, MQ07a_SC14_YoungMageMarker001)

EndFunction

Function UnblockHarborDoor()

	MQ12b_SC5_HarborDoorREF.BlockActivation(False)

EndFunction

Function EnableMarketProps()

	MQ12b_SC4_Market_Linker.Enable()

EndFunction

Function StartSC05()

	_00E_Func_SetNPCAsCompanion.SetNPCAsCompanion(_00E_MC_TealorREF, False)
	MQ12b_SC3_CityGuardREF.Disable()

	_00E_MC_TealorREF.MoveTo(MQ12b_SC4_TealorBenchmark01)
	
	MQ12b_SC5_TealorLowerDistrict.ForceStart()
	
	EnableLowerCityProps()
	
EndFunction

Function EnableLowerCityProps()

	MQ12b_SC5_LowerDistrictLinkMarker.Enable()
	MQ12b_SC5_HarlejanLinker.Enable()
	
EndFunction

Function StartSC06()
	
	Sound.StopInstance(iBellSound)
	MQ12b_SC11_GateREF.Enable()
	
	_00E_Func_SetNPCAsCompanion.SetNPCAsCompanion(_00E_MC_TealorREF, True, 600, 700, 200)
	
	If MQ12b_SC11_GateREF.GetOpenState() != 1
		MQ12b_SC11_GateREF.SetOpen(True)
	EndIf
	
	MQ12b_SC6_HarborLinker.Enable()
	MQ12c_GuardLinker.Disable()
	MQ12b_SC5_HarlejanLinker.Enable()
	MQ12b_SC6_NehrimeseGateLinker.Enable()
	MQ12b_SC6_HarborProp045.Enable()
	_00E_MC_TealorREF.MoveTo(MQ12b_SC5_TealorBenchmark02)
	
	MQ12b_SC5_HarlejanGuardNaraREF.MoveTo(DebugMarker001)
	MQ12b_SC5_HarlejanGuardYoungREF.MoveTo(DebugMarker002)
	MQ12b_SC5_HarlejanGuardGidonREF.MoveTo(DebugMarker003)

	MQ12b_SC5_SergeantHarlejanREF.MoveTo(DebugMarker004)

	MQ12b_SC6_BattleInHarborDistrict.ForceStart()
	
	; need to disable these guards: if the player ignored them, tealor might aggro them even in the harbor
	MQ12b_SC4_Market_Linker.Disable()

	GypsyMinstrelsControl.TriggerUpdate()
	
EndFunction

Function EnableArchers()

	MQ12b_SC6_ArcherMarker.Enable()
  
EndFunction

Function EnableGateFoes()

	MQ12b_SC6_NehrimeseGateLinker.Enable()

EndFunction

Function SC07_Failsave()

	MQ12b_SC5_HarlejanGuardYoungREF.MoveTo(MQ12b_SC11_TealorSpawnMarker)

EndFunction

Function StartSC07()

	_00E_Func_SetNPCAsCompanion.SetNPCAsCompanion(_00E_MC_TealorREF, False)
	
	SetObjectiveCompleted(10)
	MQ12b_SC5_HarlejanGuardNaraREF.ResetHealthAndLimbs()
	MQ12b_SC5_HarlejanGuardYoungREF.ResetHealthAndLimbs()
	MQ12b_SC5_HarlejanGuardGidonREF.ResetHealthAndLimbs()
	MQ12b_SC5_SergeantHarlejanREF.ResetHealthAndLimbs()
	
	Wait(1)
	
	MQ12b_SC7_GateDiscussion.ForceStart()

EndFunction

Function PlayStuckSound()

	_00E_MQ12b_SC6_GateCrankStuckM.Play(MQ12b_SC7_CrankREF)

EndFunction


;=====================================Repair gate crank sequence ====================================

Function StartSC08()
	
	_00E_Func_SetNPCAsCompanion.SetNPCAsCompanion(_00E_MC_TealorREF, True, 600, 700, 200)
	
	MQ12b_SC8_GateDoorREF.Lock(False)
	MQ12b_SC8_FollowTealorToWallEntrance.ForceStart()
	
EndFunction

Function ChangeMusic()

	SetObjectiveCompleted(15)
	_00E_MC_TealorREF.MoveTo(PlayerREF)
	_00E_Music_Combat_BonehunterNoCond.Remove()
	
EndFunction

Function StartSC09()
	
	bArkUnderAttackPrelude = False ; stop disabling NPCs
	
	_00E_Func_SetNPCAsCompanion.SetNPCAsCompanion(_00E_MC_TealorREF, False)

	MQ12b_SC9_PlayerRepairsMechanism.ForceStart()
	MQ12b_SC9_Door.Lock(False)

EndFunction

Function CallVision()

	MQ12b_SC09_PlayerVisionMarker = PlayerREF.PlaceAtMe(XMarker, 1)
	_00E_PlayerFunctions.GetVisionControl().VisionEffectTimestop()

EndFunction

Function EndVision()

	_00E_PlayerFunctions.GetVisionControl().VisionEffectTimestopStop()
	PlayerREF.MoveTo(MQ12b_SC09_PlayerVisionMarker)
	
EndFunction

Function FireCannon()

	FXExplosionCatapultFarM.Play(PlayerREF)

EndFunction

Function StartSC10()

	MQ12b_SC10_PlayerRepairsMechanismPart02.ForceStart()

EndFunction

Function EnableAssassin()

	MQ12b_SC10_WayOut.BlockActivation(False)
	InitializeCoordinates(PlayerREF)
	MQ12b_SC10_NehrimeseAssassin.Enable()
	_00E_A2_Ghostwalk_TeleportSound.Play(PlayerREF)
	_00E_A2_GhostwalkTeleportReappearVFX.Play(MQ12b_SC10_NehrimeseAssassin)
	MQ12b_SC10_NehrimeseAssassin.PlaceAtMe(_00E_A2_GhostwalkImpactExplosion, 1)
	MQ12b_SC10_NehrimeseAssassin.MoveTo(PlayerREF, EndLocX, EndLocY, EndLocZ)
	MQ12b_SC10_NehrimeseAssassin.SetAngle(TargetAngleX, TargetAngleY, TargetAngleZ)
	_00E_A2_GhostwalkTeleportVFX.Play(MQ12b_SC10_NehrimeseAssassin)
	_00E_A2_GhostwalkTeleportReappearVFX.Stop(MQ12b_SC10_NehrimeseAssassin)
	MQ12b_SC10_NehrimeseAssassin.StartCombat(PlayerREF)
	
EndFunction

Function InitializeCoordinates(Actor TargetVictim)

	EndLocX = (-100*Math.Sin(TargetVictim.GetAngleZ()))
	EndLocY = (-100*Math.Cos(TargetVictim.GetAngleZ()))
	EndLocZ = 0

	TargetAngleX = TargetVictim.GetAngleX()
	TargetAngleY = TargetVictim.GetAngleY()
	TargetAngleZ = TargetVictim.GetAngleZ()

EndFunction

;=====================================Samael Gate Scene ============================================

Function EnableDefenseTroop()

	AudioCategoryAMB.SetVolume(0.7)
	Weather.ReleaseOverride()
	SkyrimStormRain.ForceActive(True)
	bArkUnderAttackFinalScene = True
	MoveUnwantedNPCs()
	
	MQ12b_SC11_CannonREF.Enable()
	MQ12b_SC6_HarborProp045.Disable()
	
	If _00E_MC_TealorREF.IsDisabled()
		_00E_MC_TealorREF.Enable() 
	EndIf
	
	_00E_MC_TealorREF.MoveTo(MQ12b_SC11_TealorSpawnMarker)
	MQ12b_SC5_HarlejanGuardGidonREF.MoveTo(MQ12b_SC11_GidonCannonMarker)
	MQ12b_SC5_HarlejanGuardNaraREF.MoveTo(MQ12b_SC11_NaraCannonMarker)
	MQ12b_SC5_SergeantHarlejanREF.MoveTo(MQ12b_SC11_HarlejanCannonMarker)
	MQ12b_SC5_HarlejanGuardYoungREF.MoveTo(MQ12b_SC11_YoungGuardCannonMarker)
	MQ12b_SC11_SamaelREF.MoveTo(MQ12b_SC11_SamaelMarker)
	MQ12b_SC11_SamaelREF.Enable()
	MQ12b_SC11_SamaelREF.SetAlpha(0.0)
	MQ12b_SC11_CollisionMarker.Enable()
	MQ12b_SC11_HarborGateScene.ForceStart()
	_00E_SilenceLongTransitionHighPriority.Add()

EndFunction

Function MoveUnwantedNPCs()

	int iNPCIndex = MQ12b_SC11_NPCsRef.GetSize()
	
	While iNPCIndex > 0
	
		iNPCIndex -= 1

		Actor RefToMove = MQ12b_SC11_NPCsRef.GetAt(iNPCIndex) as Actor
		
		If !RefToMove.IsDisabled() && !(RefToMove.IsDead())
			RefToMove.SetGhost(True)
			RefToMove.MoveTo(MQ12b_SC11_GuardDumpMarker)
		EndIf
	
	EndWhile
	
	Return

EndFunction

Function FadeInSamael()

	_00E_SilenceLongTransitionHighPriority.Remove()
	_00E_Music_Dungeon_Hideout.Remove()
	_00E_Music_Special_MQ12b_Samael.Add()
	TimeFadeIn01FXS.Play(MQ12b_SC11_SamaelREF)
	MQ12b_SC11_SamaelREF.MoveTo(MQ12b_SC11_SamaelMarker)
	Debug.sendAnimationEvent(MQ12b_SC11_SamaelREF, "IdleWebEnterInstant")
	MQ12b_SC11_SamaelREF.setActorValue("Variable03", 5)
	TimeFadeOut01FXS.Stop(MQ12b_SC11_SamaelREF)
	TimeFadeIn01FXS.Play(MQ12b_SC11_SamaelREF)
	MQ12b_SC11_SamaelBarrierREF.Enable()
	_00E_MAGEldritchExplosionImod.Apply()
	Game.ShakeCamera(afStrength = 0.1)
	_00E_Func_WaitForRef.WaitForReferenceToLoad(MQ12b_SC11_SamaelBarrierREF)
	MAGConjurePortal.Play(MQ12b_SC11_SamaelBarrierREF)
	MQ12b_SC11_SamaelBarrierREF.PlayAnimation("playanim02")
	bBarrierFailsave = True
	RegisterForSingleUpdate(2)
	_00E_MQ12b_SC11_BarrierLightREF.Enable()	
	
EndFunction

Function ExplosionSamael()

	MQ12b_SC11_SamaelREF.playidle(WebIdleExit)
	Wait(1)
	TimeFadeIn01FXS.Stop(MQ12b_SC11_SamaelREF)
	MQ12b_SC11_SamaelREF.setActorValue("Variable03", 0) 
	MQ12b_SC11_SamaelREF.PlaceAtMe(_00E_MAGEldritchShockExplosion, 1)
	_00E_MAGEldritchExplosionM.Play(MQ12b_SC11_SamaelREF)
	_00E_Ability_StaggerSelfSpell.Cast(MQ12b_SC5_HarlejanGuardYoungREF, MQ12b_SC5_HarlejanGuardYoungREF)
	_00E_Ability_StaggerSelfSpell.Cast(MQ12b_SC5_SergeantHarlejanREF, MQ12b_SC5_SergeantHarlejanREF)
	MQ12b_SC11_SamaelREF.SetAlpha(1)
	MQ12b_SC11_SamaelREF.PushActorAway(MQ12b_SC5_HarlejanGuardGidonREF, 5)
	MQ12b_SC5_HarlejanGuardGidonREF.GetActorBase().SetEssential(False)
	MQ12b_SC5_HarlejanGuardGidonREF.Kill(MQ12b_SC11_SamaelREF)
	MQ12b_SC11_SamaelREF.PushActorAway(MQ12b_SC5_HarlejanGuardNaraREF, 5)
	MQ12b_SC5_HarlejanGuardNaraREF.GetActorBase().SetEssential(False)
	MQ12b_SC5_HarlejanGuardNaraREF.Kill(MQ12b_SC11_SamaelREF)
	
EndFunction

Function SamaelLevitateHarlejanAndGuard()

	_00E_FXEldritchShader03.Play(MQ12b_SC5_SergeantHarlejanREF)
	_00E_FXEldritchShader03.Play(MQ12b_SC5_HarlejanGuardYoungREF)
	Debug.SendAnimationEvent(MQ12b_SC5_HarlejanGuardYoungREF, "returnToDefault")
	Debug.SendAnimationEvent(MQ12b_SC5_SergeantHarlejanREF, "returnToDefault")
	Debug.SendAnimationEvent(MQ12b_SC5_HarlejanGuardYoungREF, "IdleDA02BoethiahPostEnter")
	Debug.SendAnimationEvent(MQ12b_SC5_SergeantHarlejanREF, "IdleDA02BoethiahPostEnter")
	
	Wait(4)
	_00E_A1_DevourSoul_DisintegrateFXS.Play(MQ12b_SC5_SergeantHarlejanREF)
	_00E_A1_DevourSoul_DisintegrateFXS.Play(MQ12b_SC5_HarlejanGuardYoungREF)
	
EndFunction

Function KillHarlejanAndGuard()

	Game.ShakeCamera(afStrength = 0.5)
	ObjectReference KillMarkerHarlejan = MQ12b_SC5_SergeantHarlejanREF.PlaceAtMe(XMarker)
	ObjectReference KillMarkerGuardYoung = MQ12b_SC5_HarlejanGuardYoungREF.PlaceAtMe(XMarker)
	KillMarkerGuardYoung.MoveTo(MQ12b_SC5_SergeantHarlejanREF, 0.0, 0.0, 200)
	KillMarkerHarlejan.MoveTo(MQ12b_SC5_HarlejanGuardYoungREF, 0.0, 0.0, 200)
	_00E_A1_DevourSoul_DisintegrateFXS.Stop(MQ12b_SC5_SergeantHarlejanREF)
	_00E_A1_DevourSoul_DisintegrateFXS.Stop(MQ12b_SC5_HarlejanGuardYoungREF)
	_00E_FXEldritchShader03.Stop(MQ12b_SC5_HarlejanGuardYoungREF)
	_00E_FXEldritchShader03.Stop(MQ12b_SC5_HarlejanGuardYoungREF)
	MQ12b_SC5_HarlejanGuardYoungREF.SetAlpha(0.0)
	MQ12b_SC5_SergeantHarlejanREF.SetAlpha(0.0)
	
	KillMarkerHarlejan.PlaceAtMe(_00E_MAGEldritchShockExplosion)
	KillMarkerHarlejan.PlaceAtMe(_00E_FS_MAGGoreExplosion)
	KillMarkerGuardYoung.PlaceAtMe(_00E_MAGEldritchShockExplosion)
	KillMarkerGuardYoung.PlaceAtMe(_00E_FS_MAGGoreExplosion)

	_00E_A1_DevourSoulScreamM.Play(KillMarkerGuardYoung)
	_00E_A1_DevourSoulScreamM.Play(KillMarkerHarlejan)
		
EndFunction

Function CloseGate()

	MQ12b_SC11_GateREF.SetOpen(False)

EndFunction

Function SamaelTeleportAway()

	_00E_Music_Combat_BonehunterNoCond.Remove()
	_00E_SilenceTransitionHighPriority.Add()
	MQ12b_SC5_HarlejanLinker.Disable()
	;MQ12b_SC5_SergeantHarlejanREF.Disable()
	;MQ12b_SC5_HarlejanGuardYoungREF.Disable()
	_00E_MC_TealorREF.StopCombat()
	_00E_MC_TealorREF.StopCombatAlarm()
	_00E_A1_DevourSoul_DisintegrateFXS.Play(MQ12b_SC11_SamaelREF)
	Utility.Wait(1)
	MQ12b_SC11_SamaelREF.PlaceAtMe(_00E_MAGEldritchShockExplosion, 1)
	MQ12b_SC11_SamaelREF.Disable()

EndFunction

;=====================================Taranor Gate Scene ============================================

Function SetUpSC12()

	Game.RequestAutoSave()

	; need to disable these guards: if the player ignored them / they got stuck somewhere, tealor & yuslan might aggro them even in the harbor
	; is also called in StartSC06() but needs to be here for save compatibility
	MQ12b_SC4_Market_Linker.Disable()
	
	MQ12b_SC12_FacadeSoldierNehrim01.GetActorBase().SetEssential(false)
	MQ12b_SC12_FacadeSoldierEnderal01.PlayIdleWithTarget(pa_1HMKillMoveShortB, MQ12b_SC12_FacadeSoldierNehrim01)
	MQ12b_SC6_HarborProp023.PlayIdleWithTarget(pa_1HMKillMoveShortB, MQ12b_SC6_HarborProp046)
	MQ12b_SC6_HarborProp047.Kill(MQ12b_SC6_HarborProp047)
	MQ12b_SC6_HarborProp022.PlayIdleWithTarget(pa_1HMKillMoveShortB, MQ12b_SC12_FacadeSoldierEnderal02)
	
	_00E_MC_TealorREF.StopCombat()
	_00E_MC_TealorREF.StopCombatAlarm()
	
	_00E_MC_YuslanRef.Enable()
	
	If !_00E_MC_TaranorREF.IsEnabled()
		_00E_MC_TaranorREF.Enable()
	EndIf
	
	If _00E_MC_TaranorREF.IsDead()
		_00E_MC_TaranorREF.Resurrect()
	EndIf
	
	If !_00E_SC_AlmaREF.IsEnabled()
		_00E_SC_AlmaREF.Enable()
	EndIf

	If _00E_SC_AlmaREF.IsDead()
		_00E_SC_AlmaREF.Resurrect()
	EndIf
	
	MQ12b_SC12_ConversationWithTaranor.ForceStart()
	
EndFunction

Function SC12_ComeOutTaranor()
	; Sometimes, Taranor fails to come to the gate when needed in SC12
	; (see http://sureai.net:9898/browse/ERB-2130 ).
	; This failsave teleports him.
	If _00E_MC_TaranorREF.GetDistance(MQ12b_SC12_TaranorWalkMarker001) > 200
		_00E_MC_TaranorREF.MoveTo(MQ12b_SC12_TaranorWalkMarker001)
	EndIf
EndFunction

Function TeleportYuslanToGate()
	Wait(2)
	_00E_MC_YuslanRef.SetActorValue("Variable03", 5)
	_00E_Func_SafeMove.SafeMoveTo(_00E_MC_YuslanRef, MQ12b_SC12_YuslanTeleportMarker)
	_00E_Func_WaitForRef.WaitForReferenceToLoad(_00E_MC_YuslanRef)
	Debug.sendAnimationEvent(_00E_MC_YuslanRef, "IdleWebEnterInstant")
	TimeFadeIn01FXS.Play(_00E_MC_YuslanRef)
	Game.ShakeCamera(afStrength = 0.1)
	Debug.sendAnimationEvent(_00E_MC_YuslanRef, "IdleWebExit")
	MQ12b_SC12_YuslanTeleportMarker.PlaceAtMe(_00E_MAGEldritchShockExplosionTeleport, 1)  
	Utility.Wait(1.5)
	TimeFadeIn01FXS.Stop(_00E_MC_YuslanRef)
	_00E_MC_YuslanRef.SetActorValue("Variable03", 0)
	
	_00E_MC_TaranorREF.MoveTo(MQ12b_SC12_TaranorEnableMarker)
	_00E_SC_AlmaREF.MoveTo(MQ12b_SC12_AlmaMarkerREF)
EndFunction

Function SetUpSC13()

	PlayerREF.AddItem(_01E_TeleportrolleSonnentempel, 1)

	_00E_MQ12b_SC11_BarrierLightREF.Disable()
	
	EnableArcanistsAndGuard()
	AllowIdleChatter.SetValue(0)
	
	Wait(1)
	
	MQ12b_SC13_TempleScene.ForceStart()

	MQ12b_SC11_SamaelBarrierREF.PlayAnimation("playanim01")
	
	_00E_MC_YaelaREF.MoveTo(MQ12a_SC15_YaelaStandMarker)
	MQ12b_SC14_SiegeTempleMarker.Enable()
	_00E_MQ12b_SC15_Novice.MoveTo(MQ12b_SC15_NoviceMarkerREF)

	MQ12b_SC14_TempleGuardWoundedREF.Enable()
	MQ12b_SC14_HarborGuardREF.MoveTo(MQ12b_SC14_OrderGuardMarker)
	
	_00E_MC_LeoraREF.Enable()
	_00E_MC_LeoraREF.SetAlpha(1)
	
	_00E_MC_JorrekRef.Disable()
	
	MQ12b_SC14_JorrekREF.Enable()

	MQ12b_SC14_ApothekariusREF.Enable()
	MQ12b_SC14_ApothekariusREF.MoveTo(MQ12b_SC14_GuardMarkerREF)
	_00E_MC_LeoraREF.MoveTo(MQ12b_SC14_LeoraMarkerREF)
	_00E_MC_NataraREF.MoveTo(MQ12b_SC14_NataraMarkerREF)
	
EndFunction

Function EnableArcanistsAndGuard()

	MQ12b_SC12_HarborArcanist02REF.Enable()
	BerserkerFXS.Play(MQ12b_SC12_YoungGuardREF)
	Return
	
EndFunction

Function EnableArcanistFX()

	_00E_MagicProtectionLoop02M.Play(MQ12b_SC12_HarborArcanist01REF)
	MQ12b_SC12_HarborArcanist02REF.AddSpell(_00E_ABEldritchDrainSelfWithFX)
	MQ12b_SC12_HarborArcanist01REF.AddSpell(_00E_ABEldritchDrainSelfWithFX)
	_00E_MC_YuslanRef.AddSpell(_00E_ABEldritchDrainSelfWithFX)

EndFunction

Function MoveTealorWeatherFailsave()
	
	If _00E_MC_TealorREF.IsDisabled()
		_00E_MC_TealorREF.Enable()
	EndIf
	
	_00E_MC_TealorREF.MoveTo(MQ12b_SC14_TealorMarkerREF)
	SkyrimStormRain.ForceActive(True)
	
EndFunction

Function SetUpSC14()

	SkyrimStormRain.ForceActive(True)
	MQ16_StubbornGuardREF.MoveTo(MQ12b_SC16_Flavour_Keeper_Female)
	MQ12b_Flavour_Novice.MoveTo(MQ12b_SC16_Flavour_Novice)
	MQ05Prologue_EmporiumKeeper.MoveTo(MQ12b_SC16_Flavour_Keeper_01)
	Game.RequestAutoSave()
	MQ12b_SC14_JorrekREF.Enable()
	MQ12b_SC14_JorrekREF.SetOutfit(_25E_HolyOrder_WardenOutfit)
	MQ12b_SC13_TempleScene.Stop()
	
	If _00E_MC_TealorREF.IsDisabled()
		_00E_MC_TealorREF.Enable()
	EndIf
			
	If MQ12b_SC13_TempleScene.IsPlaying()
		MQ12b_SC13_TempleScene.Stop()
	EndIf
	
	_00E_MC_TealorREF.MoveTo(MQ12b_SC14_TealorMarkerREF)
	_00E_MC_NataraREF.MoveTo(MQ12b_SC14_NataraMarkerREF)

	MQ12b_SC16_Flavor.ForceStart()
	
	MQ12b_SC14_TempleScene02.ForceStart()
	
EndFunction

Function SetUpSC15()

	_00E_MC_LexREF.MoveTo(MQ12a_SC0_DebugLexStart)
	_00E_MC_YaelaREF.MoveTo(MQ12a_SC15_YaelaStandMarker)

	MQ12b_SC15_TempleScene03.ForceStart()

EndFunction

Function CompleteQuestAndStartMQ12c()

	If MQ12b_SC16_Flavor.IsPlaying()
		MQ12b_SC16_Flavor.Stop()
	EndIf
	
	A_CrimeFaction.SetCrimeGold(iCrimeGoldBeforeMQ12bNonViolent)
	A_CrimeFaction.SetCrimeGoldViolent(iCrimeGoldBeforeMQ12bViolent)
	
	MQ12b_SC12_HarborArcanist02REF.Disable()
	MQ12b_Market_CastleCollisionREF.Disable()
	MQ12b_SC12_YoungGuardREF.Disable()
	AudioCategoryAMB.SetVolume(1.0)
	PlayerREF.RemovePerk(_00E_ArkSiegeLockedGatesPerk)
	PlayerREF.RemoveFromFaction(MQ12b_TemporarySiegeFaction)
	MQ12b_SC14_JorrekREF.Disable()
	; the following line is called twice before, that was inserted later, see description of bug above, still needs to be called here for save compatibility
	MQ12b_SC4_Market_Linker.Disable()
	MQ12b_SC3_UpperCityLinker01.Disable()
	MQ12b_SC5_LowerDistrictLinkMarker.Disable()
	MQ12b_SC5_HarlejanLinker.Disable()
	MQ12b_SC6_HarborLinker.Disable()
	MQ12b_SC6_ArcherMarker.Disable()
	MQ12b_SC3_BattleSoundMarker.Disable()
	MQ12b_SC6_NehrimeseGateLinker.Disable()
	Ark_MyradRef.MoveToMyEditorLocation()
	MQ12b_DisableThisDudeHeIsAnnoyingREF.Enable()
	bArkUnderAttackPrelude = False ; also disabled earlier in StartSC07()
	bArkUnderAttack = False
	bArkUnderAttackFinalScene = False
	Weather.ReleaseOverride()
	_00E_SilenceTransitionHighPriority.Remove()
	_00E_TeleportGlobal.SetValueInt(0) 
	TimeScale.SetValue(fTimeScaleBefore)
	MQ03_SC1_CastleWorldDoor.BlockActivation(False)
	MQ12b_SC4_BarracksDoorREF.BlockActivation(False)
	MQ12b_SC5_HarborDoorREF.BlockActivation(False)
	_00E_SouthQuarter_UndercityDoorREF.BlockActivation(False)
	MQ12b_SC5_LowerDistrictMarketDoor01REF.BlockActivation(False)
	MQ12b_SC5_LowerDistrictMarketDoor02REF.BlockActivation(False)
	UnregisterForUpdate()
	_00E_EPHandler.GiveEP(__Config_RewardEXP)
	AllowIdleChatter.SetValue(1)
	Self.CompleteQuest()
	DisablePanicTriggerbox()
	MQ12c.SetCurrentStageID(5)
	GoToState("Aftermath")
	RegisterForSingleUpdateGameTime(24)
	
	Steam.UnlockAchievement("END_SIEGE_01")
	
	SiegeNPCControl.ReEnableNPCs()
	
EndFunction

Function DisablePanicTriggerbox() ;extra function because it gets also called from _00E_PlayerSetUpScript
	MQ12b_SC3_PanicTriggerboxREF.Disable()
EndFunction

Function StartSC01Failsave()

	If !MQ12b_SC01_LexilExplains.IsPlaying()
		MQ12b_SC01_LexilExplains.ForceStart()
	EndIf
	
EndFunction

;=====================================================================================
;									   ADJUST GAME TIME							 
;=====================================================================================

Function AdjustTime()

	float fGameHour = GameHour.GetValue()
	
	fTimeScaleBefore = TimeScale.GetValue()
	
	If (fGameHour <= 4 || fGameHour >= 21)
		TimeScale.SetValue(0.1)
	Else
		GoToState("WaitForNight")
	EndIf

EndFunction

State WaitForNight

	Event OnBeginState()

		TimeScale.SetValue(100)
		RegisterForSingleUpdate(5)
		
	EndEvent

	Event OnUpdate()

		If (GameHour.GetValue() <= 4 || GameHour.GetValue() >= 21)
			TimeScale.SetValue(0.1)
			GoToState("")
		Else
			RegisterForSingleUpdate(5)
		EndIf
		
	EndEvent

EndState

;=====================================================================================
;										SIEGE EFFECTS									   
;=====================================================================================

Function UpdateCatapultStrikes(String sStrikeLocation)

	sCurrentStrikeLocation = sStrikeLocation

EndFunction

State Aftermath

	Event OnUpdateGameTime()
		MQ12b_SC14_SiegeTempleMarker.Disable()

	EndEvent

EndState

State SiegeUpperCity

Event OnUpdate()

; Valid location names are:
; "Market"
; "UpperCity"
; "LowerDistrict"
; "HarborDistrict"

	
	if bBarrierFailsave
		bBarrierFailsave = False
		MQ12b_SC11_SamaelBarrierREF.PlayGamebryoAnimation("AnimIdle02")
	EndIf
	
	If !bArkUnderAttackFinalScene
		if ! PlayerREF.IsInInterior()
			If sCurrentStrikeLocation == "Market"
				MQ12b_SC4_StrikeSpawnerMarket.CallCatapultStrike()
			ElseIf sCurrentStrikeLocation == "UpperCity"
				MQ12b_SC3_CatapultFireController.CallCatapultStrike()
			ElseIf sCurrentStrikeLocation == "LowerDistrict"
				MQ12b_SC4_StrikeSpawnerLowerDistrict.CallCatapultStrike()
			ElseIf sCurrentStrikeLocation == "HarborDistrict"
				MQ12b_SC4_StrikeSpawnerHarborDistrict.CallCatapultStrike()
			EndIf
		endif
		
		If (GameHour.GetValue() <= 4 || GameHour.GetValue() >= 21) && TimeScale.GetValue() > 1.0
			TimeScale.SetValue(0.1)
		EndIf
		
		
		RegisterForSingleUpdate(5)
	EndIf
		
EndEvent

EndState

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

bool bBarrierFailsave

float fTimeScaleBefore

float EndLocX
float EndLocY
float EndLocZ

float TargetAngleX
float TargetAngleY
float TargetAngleZ

int Property iCrimeGoldBeforeMQ12bViolent Auto Hidden
int Property iCrimeGoldBeforeMQ12bNonViolent Auto Hidden

; TELEPORT GLOBAL; WEATHER; MUSIK ZURÜCKSETZEN! BLOCKIERTE TÜREN WIEDER ZURÜCKSETZEN!

; UNWANTED NPCs ZURÜCKSETZEN! FLEE VARIABLES ZURÜCKSETZEN!!

GlobalVariable Property AllowIdleChatter Auto

String sCurrentStrikeLocation = "UpperCity"

int Property __Config_RewardEXP Auto

int iBarrierSound
int iBellSound

bool Property bArkUnderAttack Auto Hidden Conditional
bool Property bArkUnderAttackPrelude Auto Hidden Conditional
bool Property bArkUnderAttackFinalScene Auto Hidden Conditional

Actor Property _00E_MC_LexREF Auto
Actor Property _00E_MC_YuslanRef Auto
Actor Property _00E_MC_LeoraREF Auto
Actor Property _00E_MC_TealorREF Auto
Actor Property _00E_MC_TaranorREF Auto
Actor Property _00E_MC_JorrekRef Auto 
Actor Property _00E_MC_NataraREF Auto 
Actor Property PlayerREF Auto
Actor Property MQ12b_DisableThisDudeHeIsAnnoyingREF Auto
Actor Property MQ12b_SC3_CityGuardREF Auto
Actor Property MQ12b_SC5_HarlejanGuardNaraREF Auto
Actor Property MQ12b_SC5_HarlejanGuardYoungREF Auto
Actor Property MQ12b_SC5_HarlejanGuardGidonREF Auto
Actor Property MQ12b_SC5_SergeantHarlejanREF Auto
Actor Property MQ12b_SC10_NehrimeseAssassin Auto
Actor Property MQ12b_SC11_SamaelREF Auto
Actor Property MQ12b_SC12_FacadeSoldierNehrim01 Auto
Actor Property MQ12b_SC12_FacadeSoldierEnderal01 Auto
Actor Property MQ12b_SC12_FacadeSoldierEnderal02 Auto
Actor Property MQ12b_SC6_HarborProp022 Auto
Actor Property MQ12b_SC6_HarborProp023 Auto
Actor Property MQ12b_SC6_HarborProp046 Auto
Actor Property MQ12b_SC6_HarborProp047 Auto
Actor Property _00E_SC_AlmaREF Auto
Actor Property MQ12b_SC12_YoungGuardREF Auto
Actor Property MQ12b_SC12_HarborArcanist01REF Auto
Actor Property MQ12b_SC12_HarborArcanist02REF Auto
Actor Property MQ12b_SC14_ApothekariusREF Auto
Actor Property _00E_MQ12b_SC15_Novice Auto
Actor Property MQ12b_SC14_JorrekREF Auto
Actor Property MQ12b_SC14_HarborGuardREF Auto
Actor Property _00E_MC_YaelaREF Auto
Actor Property MQ05Prologue_EmporiumKeeper Auto
Actor Property MQ12b_Flavour_Novice Auto
Actor Property MQ16_StubbornGuardREF Auto Hidden

Quest Property MQ12c Auto

ImageSpaceModifier Property _00E_MAGEldritchExplosionImod Auto

MusicType Property _00E_Music_Combat_BonehunterNoCond Auto
MusicType Property _00E_SilenceLongTransitionHighPriority Auto
MusicType Property _00E_SilenceTransitionHighPriority Auto
MusicType Property _00E_Music_Dungeon_Hideout Auto
MusicType Property _00E_Music_Special_MQ12b_Samael Auto

GlobalVariable Property _00E_TeleportGlobal Auto
GlobalVariable Property MQ12b_ArkUnderAttack Auto
GlobalVariable Property GameHour Auto
GlobalVariable Property TimeScale Auto

Outfit Property _25E_HolyOrder_WardenOutfit Auto

ObjectReference Property MQ12b_SC1_Orderguard01 Auto
ObjectReference Property MQ12b_SC1_Orderguard02 Auto
ObjectReference Property MQ12a_SC0_DebugLexStart Auto
ObjectReference Property MQ12b_SC2_LeoraMarker002 Auto
ObjectReference Property MQ12b_SC2_ShaRimMarker002 Auto
ObjectReference Property MQ12b_SC2_TealorStartMarker005 Auto
ObjectReference Property MQ12b_SC3_CatapultStrikeMarker002 Auto
ObjectReference Property MQ12b_SC3_BarrierREF002 Auto
ObjectReference Property MQ12b_SC3_UpperCityLinker01 Auto
ObjectReference Property MQ12b_SC3_PanicTriggerboxREF Auto
ObjectReference Property MQ12b_SC3_ScreamMarker Auto
ObjectReference Property MQ12b_SC3_BattleSoundMarker Auto
ObjectReference Property MQ12b_SC3_CityGuardStartMarker Auto
ObjectReference Property MQ07a_SC14_YoungMageMarker001 Auto
ObjectReference Property MQ12b_SC3_TealorBarrierMarkerREF Auto
ObjectReference Property MQ12b_SC4_Market_Linker Auto
ObjectReference Property MQ12b_SC4_BarracksDoorREF Auto
ObjectReference Property MQ03_SC1_CastleWorldDoor Auto
ObjectReference Property MQ12b_SC5_LowerDistrictLinkMarker Auto
ObjectReference Property MQ12b_SC4_TealorBenchmark01 Auto
ObjectReference Property MQ12b_SC5_TealorBenchmark02 Auto
ObjectReference Property MQ12b_SC5_HarborDoorREF Auto
ObjectReference Property MQ12b_SC5_LowerDistrictMarketDoor01REF Auto
ObjectReference Property MQ12b_SC5_LowerDistrictMarketDoor02REF Auto
ObjectReference Property MQ12b_SC5_HarlejanLinker Auto
ObjectReference Property MQ12b_SC6_HarborLinker Auto
ObjectReference Property MQ12b_SC6_NehrimeseGateLinker Auto
ObjectReference Property MQ12b_SC6_ArcherMarker Auto
ObjectReference Property MQ12b_SC7_CrankREF Auto
ObjectReference Property _00E_SouthQuarter_UndercityDoorREF Auto
ObjectReference Property MQ12b_SC8_GateDoorREF Auto
ObjectReference Property MQ12b_SC9_Door Auto
ObjectReference Property MQ12b_SC11_CannonREF Auto
ObjectReference Property MQ12b_SC11_NaraCannonMarker Auto
ObjectReference Property MQ12b_SC11_YoungGuardCannonMarker Auto
ObjectReference Property MQ12b_SC11_GidonCannonMarker Auto
ObjectReference Property MQ12b_SC11_HarlejanCannonMarker Auto
ObjectReference Property MQ12b_SC11_SamaelMarker Auto
ObjectReference Property MQ12b_SC11_SamaelBarrierREF Auto
ObjectReference Property MQ12b_SC11_TealorSpawnMarker Auto
ObjectReference Property MQ12b_SC6_HarborProp045 Auto
ObjectReference Property _00E_MQ12b_SC11_BarrierLightREF Auto
ObjectReference Property MQ12b_SC11_GuardDumpMarker Auto
ObjectReference Property MQ12b_SC11_CollisionMarker Auto
ObjectReference Property MQ12b_SC11_GateREF Auto
ObjectReference Property MQ12b_SC12_YuslanTeleportMarker Auto
ObjectReference Property MQ12b_SC12_TaranorEnableMarker Auto
ObjectReference Property MQ12b_SC12_TaranorWalkMarker001 Auto
ObjectReference Property MQ12b_SC12_AlmaMarkerREF Auto
ObjectReference Property MQ12b_SC14_TempleGuardWoundedREF Auto
ObjectReference Property MQ12b_SC14_LeoraMarkerREF Auto
ObjectReference Property MQ12b_SC14_NataraMarkerREF Auto
ObjectReference Property MQ12b_SC14_GuardMarkerREF Auto
ObjectReference Property MQ12b_SC14_SiegeTempleMarker Auto
ObjectReference Property MQ12b_SC15_NoviceMarkerREF Auto
ObjectReference Property MQ12b_SC14_TealorMarkerREF Auto
ObjectReference Property MQ12a_SC15_YaelaStandMarker Auto
ObjectReference Property MQ12b_SC14_OrderGuardMarker Auto
ObjectReference Property MQ12b_SC09_PlayerVisionMarker Auto Hidden
ObjectReference Property MQ12b_StayDisabledLinker Auto Hidden
ObjectReference Property MQ12b_SC10_WayOut Auto Hidden
ObjectReference Property MQ12b_Market_CastleCollisionREF Auto Hidden
ObjectReference Property MQ12b_SC16_Flavour_Keeper_01 Auto Hidden
ObjectReference Property MQ12b_SC16_Flavour_Keeper_Female Auto Hidden
ObjectReference Property MQ12b_SC16_Flavour_Novice Auto Hidden
ObjectReference Property MQ12c_GuardLinker Auto Hidden
ObjectReference Property MQ12b_SC3_CityGuardRunToMarker Auto Hidden
ObjectReference Property Ark_MyradRef Auto
ObjectReference Property CapitalCity_UpperCityToMarket01 Auto
ObjectReference Property CapitalCity_UpperCityToMarket02 Auto

ObjectReference Property DebugMarker004 Auto
ObjectReference Property DebugMarker003 Auto
ObjectReference Property DebugMarker002 Auto
ObjectReference Property DebugMarker001 Auto

Faction Property MQ12b_TemporarySiegeFaction Auto
Faction Property A_CrimeFaction Auto

CWCatapultStrikeSpawnerScript Property StrikeSpawner Auto Hidden
CWCatapultStrikeSpawnerScript Property MQ12b_SC3_CatapultFireController Auto
CWCatapultStrikeSpawnerScript Property MQ12b_SC4_StrikeSpawnerMarket Auto
CWCatapultStrikeSpawnerScript Property MQ12b_SC4_StrikeSpawnerLowerDistrict Auto
CWCatapultStrikeSpawnerScript Property MQ12b_SC4_StrikeSpawnerHarborDistrict Auto

Static Property XMarker Auto

SoundCategory Property AudioCategoryAMB Auto

Formlist Property MQ12b_SC11_NPCsRef Auto
Formlist Property MQ12b_SC01_ArkDoors Auto
Formlist Property MQ12b_SiegeNPCs Auto
Formlist Property MQ12b_AllDisabledNPCs Auto
Formlist Property MQ12b_UnGhostNPCs_OnVersionUpdate1580 Auto

Activator Property CWCatapultStrike Auto
Activator Property CWCatapultStrikeNoDmg Auto

Sound Property AMBrCivilWarCatapultsDistantM Auto
Sound Property AMBCivilWarBattleStartDistant Auto
Sound Property _00E_MQ12b_SC3_ScreamM Auto
Sound Property _00E_MQ12b_SC6_GateCrankStuckM Auto
Sound Property FXExplosionCatapultFarM Auto
Sound Property _00E_A2_Ghostwalk_TeleportSound Auto
Sound Property MAGConjurePortal Auto
Sound Property _00E_A1_DevourSoulScreamM Auto
Sound Property _00E_MAGEldritchExplosionM Auto
Sound Property _00E_MagicProtectionLoop02M Auto
Sound Property _00E_BellLoop Auto

Weather Property SkyrimOvercastRain Auto
Weather Property SkyrimStormRain Auto

Idle Property WebIdleExit Auto
Idle Property pa_1HMKillMoveShortB Auto

Spell Property _00E_Ability_StaggerSelfSpell Auto
Spell Property _00E_ABEldritchDrainSelfWithFX Auto

Scene Property MQ12b_SC01_LexilExplains Auto
Scene Property MQ12b_SC2_Attack Auto
Scene Property MQ12b_SC3_CatapultAttack Auto
Scene Property MQ12b_SC4_TealorTravelToMistDistrict Auto
Scene Property MQ12b_SC5_TealorLowerDistrict Auto
Scene Property MQ12b_SC6_BattleInHarborDistrict Auto
Scene Property MQ12b_SC7_GateDiscussion Auto
Scene Property MQ12b_SC8_FollowTealorToWallEntrance Auto
Scene Property MQ12b_SC9_PlayerRepairsMechanism Auto
Scene Property MQ12b_SC10_PlayerRepairsMechanismPart02 Auto
Scene Property MQ12b_SC11_HarborGateScene Auto
Scene Property MQ12b_SC12_ConversationWithTaranor Auto
Scene Property MQ12b_SC13_TempleScene Auto
Scene Property MQ12b_SC14_TempleScene02 Auto
Scene Property MQ12b_SC15_TempleScene03 Auto
Scene Property MQ12b_SC16_Flavor Auto

Scroll Property _01E_TeleportrolleSonnentempel Auto

Weapon Property _01E_20Hueterschwert Auto

ReferenceAlias Property Ordenshueter Auto
ReferenceAlias Property Ordenshueterin Auto

Explosion Property _00E_A2_GhostwalkImpactExplosion Auto
Explosion Property _00E_MAGEldritchShockExplosion Auto
Explosion Property _00E_FS_MAGGoreExplosion Auto
Explosion Property _00E_MAGEldritchShockExplosionTeleport Auto

VisualEffect Property _00E_A2_GhostwalkTeleportReappearVFX Auto
VisualEffect Property _00E_A2_GhostwalkTeleportVFX Auto

EffectShader Property TimeFadeIn01FXS Auto
EffectShader Property TimeFadeOut01FXS Auto
EffectShader Property _00E_FXEldritchShader03 Auto
EffectShader Property _00E_A1_DevourSoul_DisintegrateFXS Auto
EffectShader Property BerserkerFXS Auto

_00E_GypsyMinstrelsControlScript Property GypsyMinstrelsControl Auto

Perk Property _00E_ArkSiegeLockedGatesPerk  Auto  

_00E_MQ12b_NPCControl Property SiegeNPCControl  Auto