Scriptname _00E_MQ05Prologue_Functions extends Quest  

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

Function GiveGold()

	PlayerREF.AddItem(Gold001,150)

EndFunction

Function GiveSkillbook()

	PlayerREF.AddItem(_00E_Lehrbuch_Plus2Skillpoints, 1)

EndFunction

Function SetUpNatara()

	If _00E_MC_NataraREF == None
		_00E_MC_NataraREF = Game.GetForm(0x000CE143) as Actor
	EndIf
	
	If _00E_MC_NataraREF == None
		_00E_MC_NataraREF = Game.GetForm(0x00098CAC) as Actor
	EndIf
	
	_00E_MC_NataraREF.Enable()
	_00E_MC_TealorREF.Enable()
	_00E_MC_NataraREF.MoveTo(MQ07a_SC13_PlayerStand)
	_00E_MC_TealorREF.MoveTo(_00E_MQ08aPrologue_TeaorThrone)

EndFunction

Function GiveTreasureMap()

	PlayerREF.AddItem(__Config_Reward_TreasureMap, 1)

EndFunction

Function StartDiscussionScene()

	_00E_SilenceLongTransitionHighPriority.Add()
	SkyrimOvercastRain.ForceActive(True)
	MQ05Prologue_SC1.ForceStart()

EndFunction

Function StartExplanationScene()
	
	_00E_MC_TealorREF.SetActorValue("speedmult", 135)
	MQ05Prologue_SC2.ForceStart()

EndFunction

Function StartTealorDialogueMusic()

	_00E_SilenceLongTransitionHighPriority.Remove()
	_00E_Music_Special_Character_Tealor.Add()

EndFunction

Function StopTealorDialogueMusic()

	Weather.ReleaseOverride()
	_00E_Music_Special_Character_Tealor.Remove()
	_00E_SilenceLongTransitionHighPriority.Remove()
	_00E_MC_TealorREF.SetActorValue("speedmult", 100)
		
EndFunction

Function FinishUpAndStartMQ05()
	
	; Since SC1 in MQ06 can't be force started (= kicking the aliases / actors out of every scene which is currently running to force the new scene) even when Begin On Quest Start is unchecked, 
	; the scene must be started with exactly this checkbox. This interferes with both scenes from MQ05Prologue which are most likely still running at the end of MQ05 (for whatever reason)
	; fixes issue 1589
	MQ05Prologue_SC1.Stop()
	MQ05Prologue_SC2.Stop()
	
	_00E_MC_YuslanRef.Enable()
	_00E_MC_TealorREF.RemoveItem(_00E_MQ05_BartarrPackage, 1, false, PlayerREF)
	Weather.ReleaseOverride()
	MQ05.Start()
	LishariDialogue.SetStage(5)
	_00E_Music_Special_Character_Tealor.Remove()
	_00E_SilenceLongTransitionHighPriority.Remove()
	_00E_MC_TealorREF.SetActorValue("speedmult", 100)
	
EndFunction

Function FillTealorProperty()
	;backwards compatibility fix for Tealor alias that was set to unique actor but the actor had two refs, sometimes it filled it with the wrong one
	Tealor.ForceRefTo(_00E_MC_TealorREF)
EndFunction

Function FillEmptyAliasesFailsafe()
	; failsafe for issue 1536, fills empty aliases
	If Self.GetStage() == 5
		Tealor.ForceRefIfEmpty(_00E_MC_TealorREF)
		Konstantin.ForceRefIfEmpty(_00E_MC_KonstantinREF)
		Natara.ForceRefIfEmpty(_00E_MC_NataraREF)
		Templeguard.ForceRefIfEmpty(MQ05Prologue_EmporiumKeeper)
		Player.ForceRefIfEmpty(PlayerREF)
	EndIf
EndFunction
	
;=====================================================================================
;              							PROPERTIES                  					 
;=====================================================================================

ReferenceAlias Property Tealor Auto
ReferenceAlias Property Player Auto
ReferenceAlias Property Natara Auto
ReferenceAlias Property Konstantin Auto
ReferenceAlias Property Templeguard Auto

Book Property __Config_Reward_TreasureMap Auto

Potion Property _00E_Lehrbuch_Plus2Skillpoints Auto

Quest Property LishariDialogue Auto

MiscObject Property Gold001 Auto
MiscObject Property _00E_MQ05_BartarrPackage Auto

Actor Property PlayerREF Auto
Actor Property _00E_MC_NataraREF Auto
Actor Property _00E_MC_TealorREF Auto
Actor Property _00E_MC_YuslanRef Auto
Actor Property MQ05Prologue_EmporiumKeeper Auto
Actor Property _00E_MC_KonstantinREF Auto

MusicType Property _00E_Music_Special_Character_Tealor Auto
MusicType Property _00E_SilenceLongTransitionHighPriority Auto

Scene Property MQ05Prologue_SC1 Auto
Scene Property MQ05Prologue_SC2 Auto

Weather Property SkyrimOvercastRain Auto

ObjectReference Property MQ07a_SC13_PlayerStand Auto
ObjectReference Property _00E_MQ08aPrologue_TeaorThrone Auto

Quest Property MQ05 Auto