Scriptname _00E_FS_NQ05_Functions extends Quest  

Import Utility
Import Game
Import _00E_QuestFunctions
_00E_QuestFunctions Property Levelsystem Auto

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

Function GivePlayerRecipe()

	Mirell.RemoveItem(_00E_FS_NQ05_Rezept, 1, false, PlayerREF)
	
	If FS_NQ05_Posting01REF.IsEnabled()
		FS_NQ05_Posting01REF.Disable()
		FS_NQ05_Posting02REF.Disable()
	EndIf
	
EndFunction

Function UpdateGlobals()

	_00E_FS_NQ05_GarlicCountGlobal.Value = PlayerREF.GetItemCount(Garlic)
	_00E_FS_NQ05_MothWingMonarchCountGlobal.Value = PlayerREF.GetItemCount(MothWingMonarch)
	_00E_FS_NQ05_SkeeverTailCountGlobal.Value = PlayerREF.GetItemCount(SkeeverTail)
	_00E_FS_NQ05_VynrootCountGlobal.Value = PlayerREF.GetItemCount(Vynroot)

	wait(0.5)

	UpdateCurrentInstanceGlobal(_00E_FS_NQ05_VynrootCountGlobal)
	UpdateCurrentInstanceGlobal(_00E_FS_NQ05_SkeeverTailCountGlobal)
	UpdateCurrentInstanceGlobal(_00E_FS_NQ05_MothWingMonarchCountGlobal)
	UpdateCurrentInstanceGlobal(_00E_FS_NQ05_GarlicCountGlobal)

	Wait(0.5)

	SetObjectiveDisplayed(36)
	SetObjectiveDisplayed(37)
	SetObjectiveDisplayed(38)
	SetObjectiveDisplayed(39)

	wait(1.5)

	ModObjectiveGlobal(0, _00E_FS_NQ05_SkeeverTailCountGlobal, 36, 1, true, true, false)
	ModObjectiveGlobal(0, _00E_FS_NQ05_GarlicCountGlobal, 37, 1, true, true, false)
	ModObjectiveGlobal(0, _00E_FS_NQ05_MothWingMonarchCountGlobal, 38, 1, true, true, false)
	ModObjectiveGlobal(0, _00E_FS_NQ05_VynrootCountGlobal, 39, 1, true, true, false)

EndFunction

Function TestFunction() ;DELETE FOR RELEASE

	PlayerREF.AddItem(Vynroot, 1)
	PlayerREF.AddItem(SkeeverTail, 1)
	PlayerREF.AddItem(MothWingMonarch, 1)
	PlayerREF.AddItem(Garlic, 1)

EndFunction

Function MoveMirellStandby()

	Tochter.RemoveItem(FS_NQ05_Elixier, 1, false, PlayerREF)
	FS_NQ05_SceneGoAway.ForceStart()
	FS_NQ05_Haustuer.Lock(false)

EndFunction

Function MoveMirellStandby2()

	Mirell.MoveTo(FS_NQ05MirellStandbyMarker)
	Mirell.EvaluatePackage()

EndFunction

Function PrepareKeller()

	wait(3)
	_00E_FS_NQ05_FemaleMumblingM.Play(PlayerREF)
	FS_NQ05_CollisionsBox.Disable()
	FS_NQ05AushangStatic.Disable()
	Wait(2)
	SetStage(60)
	FS_NQ05_SceneTochter.ForceStart()

EndFunction

Function Warten()

	Levelsystem.FadeToBlack()
	wait(3)
	Mirell.MoveTo(FS_NQ05MirellWohnzimmerMarker)
	Levelsystem.FadeToBlackBack()
	SetStage(75)

EndFunction

Function KellerScene()

	Mirell.EvaluatePackage()
	FS_NQ05_SceneKeller.ForceStart()

EndFunction

Function DayTimer()

	RegisterForUpdateGameTime(24)
	GameDay = GameDaysPassed.GetValue() as Int

EndFunction

Function GiveMirellElixir()

	PlayerREF.RemoveItem(FS_NQ05_Elixier, 1)
	PlayerREF.AddItem(FS_NQ05_Amulett, 1)
	Levelsystem.GiveEP(300)

EndFunction

Function PrepareEnde1()

	FS_NQ05Jaildoor.Lock(false)
	FS_NQ05Jaildoor.PlayGamebryoAnimation("Open")
	Mirell.MoveTo(FS_NQ05MirellTodMarker)
	Tochter.MoveTo(FS_NQ05TochterTodMarker)
	Mirell.Kill()
	Tochter.Kill()
	FS_NQ05_Blutspray2.Enable()
	FS_NQ05_Blutspray3.Enable()

EndFunction

Function MirellAttacksPlayer()
	
	Mirell.RemoveFromAllFactions()
	Mirell.setAv("Aggression", 2)
	Mirell.AddItem(FS_NQ05_Amulett, 1)
	Mirell.SetGhost(false)
	wait(0.1)
	Mirell.StartCombat(PlayerREF)

EndFunction

Function PrepareEnde2()

	Levelsystem.GiveEP(350)
	Tochter.SetGhost(false)
	Tochter.setAv("Aggression", 2)
	Tochter.RemoveFromAllFactions()

EndFunction

Function CloseDoorAfterEnde2()

	FS_NQ05_Haustuer.Lock(255)

EndFunction

Function PrepareEnde3()

	FS_NQ05Jaildoor.Lock(false)
	FS_NQ05Jaildoor.PlayGamebryoAnimation("Open")
	Mirell.MoveTo(FS_NQ05MirellGrabMarker)
	FS_NQ05_Grabstein.Enable()
	FS_NQ05_GrabsteinMarker.Enable()
	Mirell.EvaluatePackage()
	Tochter.Disable()
	FS_NQ05_Blutspray1.Disable()
	FS_NQ05_Ratte.Disable()

EndFunction

Function GivePlayerBelohnung()

	PlayerREF.RemoveItem(FS_NQ05_Elixier, 1)
	PlayerREF.AddItem(FS_NQ05_Amulett, 1)
	Levelsystem.GiveEP(400)

EndFunction

Function PrepareEnde4()

	FS_NQ05_Haustuer.Lock(255)
	Mirell.MoveTo(FS_NQ05MirellKuratoriumMarker)
	Mirell.EvaluatePackage()
	Tochter.MoveTo(FS_NQ05TochterKuratoriumMarker)
	Tochter.EvaluatePackage()
	Tochter.BlockActivation(True)

EndFunction

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

Event OnUpdateGameTime() ; because of how we registered, this event occurs every 30 minutes of game time    
	if (GameDaysPassed.GetValue() + 1 >= GameDay && GetStage() == 80)
		SetStage(90)
		UnregisterForUpdateGameTime()
	Elseif (GameDaysPassed.GetValue() + 1 >= GameDay && GetStage() == 150)
		SetStage(160)
		UnregisterForUpdateGameTime()
	Elseif (GameDaysPassed.GetValue() + 1 >= GameDay && GetStage() == 180)
		SetStage(190)
		UnregisterForUpdateGameTime()
	Endif
EndEvent

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

int GameDay

Actor Property Mirell Auto
Actor Property Tochter Auto
Actor Property PlayerREF Auto
Actor Property FS_NQ05_Ratte Auto

Armor Property FS_NQ05_Amulett Auto

Book Property _00E_FS_NQ05_Rezept Auto

GlobalVariable Property GameDaysPassed Auto
GlobalVariable Property _00E_FS_NQ05_VynrootCountGlobal Auto
GlobalVariable Property _00E_FS_NQ05_SkeeverTailCountGlobal Auto
GlobalVariable Property _00E_FS_NQ05_MothWingMonarchCountGlobal Auto
GlobalVariable Property _00E_FS_NQ05_GarlicCountGlobal Auto

Ingredient Property Vynroot Auto
Ingredient Property SkeeverTail Auto
Ingredient Property MothWingMonarch Auto
Ingredient Property Garlic Auto

MiscObject Property FS_NQ05_Elixier Auto

ObjectReference Property FS_NQ05Trapdoor Auto
ObjectReference Property FS_NQ05_Haustuer Auto
ObjectReference Property FS_NQ05AushangStatic Auto
ObjectReference Property FS_NQ05MirellStandbyMarker Auto
ObjectReference Property FS_NQ05Jaildoor Auto
ObjectReference Property FS_NQ05MirellTodMarker Auto
ObjectReference Property FS_NQ05TochterTodMarker Auto
ObjectReference Property FS_NQ05MirellWohnzimmerMarker Auto
ObjectReference Property FS_NQ05_Blutspray1 Auto
ObjectReference Property FS_NQ05_Blutspray2 Auto
ObjectReference Property FS_NQ05_Blutspray3 Auto
ObjectReference Property FS_NQ05MirellGrabMarker Auto
ObjectReference Property FS_NQ05MirellKuratoriumMarker Auto
ObjectReference Property FS_NQ05TochterKuratoriumMarker Auto
ObjectReference Property FS_NQ05_Grabstein Auto
ObjectReference Property FS_NQ05_GrabsteinMarker Auto
ObjectReference Property FS_NQ05_CollisionsBox Auto
ObjectReference Property FS_NQ05_Posting01REF Auto
ObjectReference Property FS_NQ05_Posting02REF Auto

Scene Property FS_NQ05_SceneKeller Auto
Scene Property FS_NQ05_SceneTochter Auto
Scene Property FS_NQ05_SceneGoAway Auto

Sound Property _00E_FS_NQ05_FemaleMumblingM Auto