Scriptname _00E_MQP03_Functions extends Quest  

Import Utility
Import Game


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

Event OnUpdate()

	If (Self.GetStage() < 20) && _00E_DisableMenuTutorials.GetValueInt() == 0
		If UsingGamepad()
			Message.ResetHelpMessage("Empty")
			_00E_MQP03_Tutorial_LeaveMenuHintConsole.ShowAsHelpMessage("Empty", 5, 1, 1)
		Else
			Message.ResetHelpMessage("Empty")
			_00E_MQP03_Tutorial_LeaveMenuHint.ShowAsHelpMessage("Empty", 5, 1, 1)
		EndIf
		RegisterForSingleUpdate(15)
	Else
		; Nothing
	EndIf

EndEvent

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

Function MovePlayerToStart()
	
	Debug.SendAnimationEvent(PlayerREF, "returnToDefault")
	_00E_SilenceAbruptHighPriority.Add()
	_00E_QuestFunctions.PlayerAIWalkStop()
	FadeToBlackHoldIMOD.Apply()
	ForceFirstPerson()
	DisablePlayerControls(false, true, true, false, true, false, false, true)
	PlayerREF.SetAlpha(0.0)
	PlayerREF.MoveTo(_00E_ClassMenuOrigin)
	Self.SetStage(10)
	
EndFunction

Function ShowVisionBinkMovie()
	
	If _00E_VideoSkip.GetValueInt() == 0
		Game.PlayBink("MQP03NearDeathExperience.bik")
	EndIf
	Wait(2)
	FadeToBlackHoldIMOD.PopTo(_00E_MQP03_WakeUpIMOD)
	Wait(4)
	_00E_SilenceAbruptHighPriority.Remove()
	PlayerREF.AddShout(_00E_Class_Meditate)
	Game.UnlockWord(_00E_Class_ClassMenuWord)
	Game.TeachWord(_00E_Class_ClassMenuWord)
	_00E_MQP03_sMemoryPointGained.Show(1)
	TalentPoints.SetValueInt(1)
	PlayerREF.SetAV("dragonsouls", TalentPoints.GetValueInt())
	Message.ResetHelpMessage("Empty")
	_00E_MQP03_Thoughts01.ShowAsHelpMessage("Empty", 5, 1, 1)
	RegisterForSingleUpdate(20)
	
EndFunction

Function StrandingCutscene()

	Timescale.SetValue(10)
	AudioCategoryAMB.Unmute() 
	AudioCategoryAMB2x.Unmute() 
	AudioCategoryAMBr.Unmute() 
	Levelsystem.RemoveAllItemsSafeVersion(None)	; Debug only!
	PlayerREF.AddItem(ClothesPrisonerRags, 1, True); Debug only!
	PlayerREF.EquipItem(ClothesPrisonerRags, false, true); Debug only!
	PlayerREF.MoveTo(MQP03_PlayerStrandingMarker)
	FadeToBlackHoldIMOD.Apply()
	DisablePlayerControls(True, True, True, True, True, True, True)
	PlayerREF.PlayIdle(Idle_1stPersonWoozyGetUpFromBed)
	FadeToBlackHoldIMOD.PopTo(_00E_WakeUp)
	Wait(9)
	_00E_WakeUp.PopTo(_00E_VisionHeadacheShort)
	PlayerREF.AddSpell(_00E_MQP03_MagicFeverSpell, False)
	MAGVampireSunlight.Play(PlayerREF)
	Game.EnablePlayerControls()
	_00E_MQP03_sFeelDizzy.Show()
	Wait(1)
	Self.SetStage(25)
	
EndFunction

Function ShowThoughtBox()

	AudioCategoryAMB.Unmute() 
	AudioCategoryAMB2x.Unmute() 
	AudioCategoryAMBr.Unmute() 
	Message.ResetHelpMessage("Empty")
	_00E_MQP03_Thoughts03.ShowAsHelpMessage("Empty", 5, 1, 1)

EndFunction

Function ShowEPTutorial()
	If _00E_DisableQuestTutorials.GetValueInt() == 0
		_00E_MQP03_Tutorial_EPSystem.Show()
	EndIf
EndFunction

Function ShowSkillbookTutorial()
	If _00E_DisableMenuTutorials.GetValueInt() == 0
		Message.ResetHelpMessage("Empty")
		_00E_MQP03_Tutorial_Skillbooks.ShowAsHelpMessage("Empty", 4, 1, 1)
	EndIf
	Lernpunkte.SetValueInt(1)
	_00E_MQP03_sLearningPointGained.Show(1)
	Wait(6)
	If _00E_DisableMenuTutorials.GetValueInt() == 0
		Message.ResetHelpMessage("Empty")
		_00E_MQP03_Tutorial_Skillbooks2.ShowAsHelpMessage("Empty", 4, 1, 1)
	EndIf
EndFunction

Function ShowSleepTutorial()
	If _00E_DisableOtherTutorials.GetValueInt() == 0
		Message.ResetHelpMessage("Empty")
		_00E_MQP03_Tutorial_Rest.ShowAsHelpMessage("Empty", 5, 1, 1)
	EndIf
EndFunction


Function ShowThoughtBox05()

	Message.ResetHelpMessage("Empty")
	_00E_MQP03_Thoughts05.ShowAsHelpMessage("Empty", 5, 1, 1)

EndFunction

Function ShowThoughtBox06()

	Message.ResetHelpMessage("Empty")
	_00E_MQP03_Thoughts06.ShowAsHelpMessage("Empty", 5, 1, 1)

EndFunction

Function PrepareSoundAndWeather()

	_00E_SilenceAbruptHighPriority.Add()
	_00E_SuncoastSunrise.ForceActive()

EndFunction

Function FinishQuestAndStartMQ01()

	FXCameraAttachEmbersHeavyEffects.Stop(PlayerREF)
	FXCameraAttachEmbersEffect.Stop(PlayerREF)
	_00E_MQP03_Blendung_10.Apply()
	_00E_SilenceAbruptHighPriority.Remove()
	_00E_Music_Special_Act1Theme.Add()
	Self.SetObjectiveCompleted(5)
	MQ01.Start()
	MQ01.SetStage(5)
	Wait(1)
	If _00E_DisableOtherTutorials.GetValueInt() == 0
		_00E_MQ01_Tutorial_FoodAndMushrooms.ShowAsHelpMessage("Empty", 5, 1, 1)
	EndIf
	
EndFunction

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

Actor Property PlayerREF Auto
_00E_QuestFunctions Property Levelsystem Auto

SoundCategory Property AudioCategoryAMB Auto
SoundCategory Property AudioCategoryAMB2x Auto
SoundCategory Property AudioCategoryAMBr Auto

MusicType Property _00E_Music_Special_Act1Theme Auto
MusicType Property _00E_SilenceAbruptHighPriority Auto

GlobalVariable Property _00E_DisableMenuTutorials Auto
GlobalVariable Property _00E_DisableQuestTutorials Auto
GlobalVariable Property _00E_DisableOtherTutorials Auto
GlobalVariable Property _00E_VideoSkip Auto
Weather Property _00E_SuncoastSunrise Auto

Message Property _00E_MQP03_sMemoryPointGained Auto
Message Property _00E_MQP03_sLearningPointGained Auto
Message Property _00E_MQP03_Tutorial_LeaveMenuHint Auto
Message Property _00E_MQP03_Tutorial_LeaveMenuHintConsole Auto
Message Property _00E_MQP03_Thoughts01 Auto
Message Property _00E_MQP03_Thoughts03 Auto
Message Property _00E_MQP03_Thoughts05 Auto
Message Property _00E_MQP03_sFeelDizzy Auto
Message Property _00E_MQP03_Thoughts06 Auto
Message Property _00E_MQP03_Tutorial_EPSystem Auto
Message Property _00E_MQP03_Tutorial_Rest Auto
Message Property _00E_MQ01_Tutorial_FoodAndMushrooms Auto
Message Property _00E_MQP03_Tutorial_Skillbooks Auto
Message Property _00E_MQP03_Tutorial_Skillbooks2 Auto
Idle Property Idle_1stPersonWoozyGetUpFromBed Auto

Armor Property ClothesPrisonerRags Auto

ImageSpaceModifier Property _00E_MQP03_Blendung_10 Auto

ObjectReference Property _00E_ClassMenuOrigin Auto
ObjectReference Property MQP03_PlayerStrandingMarker Auto

Quest Property MQ01 Auto

Sound Property MAGVampireSunlight Auto

GlobalVariable Property TalentPoints Auto
GlobalVariable Property Lernpunkte Auto
GlobalVariable Property Timescale Auto

Spell Property _00E_MQP03_MagicFeverSpell Auto

ImageSpaceModifier Property _00E_MQP03_WakeUpIMOD Auto
ImageSpaceModifier Property FadeToBlackHoldIMOD Auto
ImageSpaceModifier Property _00E_WakeUp Auto
ImageSpaceModifier Property _00E_VisionHeadacheShort Auto

WordOfPower Property _00E_Class_ClassMenuWord Auto
Shout Property _00E_Class_Meditate Auto

VisualEffect Property FXCameraAttachEmbersHeavyEffects Auto
VisualEffect Property FXCameraAttachEmbersEffect Auto