Scriptname __LALLJourneyHomeScript2 extends Quest conditional
{Seriously, fuck you creation kit}

Weather Property BlizzardWeather  Auto  

;Actors
Actor Property PlayerRef Auto
Actor Property Feria Auto
Actor Property Oengul Auto
Actor Property Ambarys Auto

;Minigame vars
Int Property OengulSeduced Auto Conditional Hidden
Int Property OengulAiTweak Auto Conditional Hidden
Int Property OengulQuestComplete Auto Conditional Hidden
Int Property NiranyeQuest Auto Conditional Hidden
Int Property NiranyeQuestComplete Auto Conditional Hidden
Int Property HilleviQuest Auto Conditional Hidden
Int Property HelleviQuestComplete Auto Conditional Hidden
Int Property FoodItemCounter Auto hidden
Int Property MomTalked Auto Conditional Hidden
Int Property DadTalked Auto Conditional Hidden



;Quest Ref
SexlabFramework Property SexLab Auto
Quest Property ArthLALChargenQuest Auto
;Arth_Lal_StartQuest Property ArthLAL Auto
DialogueFollowerScript Property FollowerQuest Auto

;Object References
ObjectReference Property PlayerShackle Auto
ObjectReference Property FeriaShackle Auto
ObjectReference Property SafeKeepingChest Auto
ObjectReference Property DreamSequenceMoveTo Auto
ObjectReference Property DragonLandingPerch Auto
ObjectReference Property AmbarysTo Auto
ObjectReference Property DreamExitMarker Auto
ObjectReference Property FeriaDreamMoveToMarker Auto
Actor Property DreamDragon Auto

;Equipment and spells
Outfit Property DragonslayerSet Auto
Weapon Property DragonboneSword Auto
Perk Property DreamPlayerImmunityPerk Auto
Formlist Property FoodFormlist Auto


Scene Property AmbarysScene Auto
Armor Property WinterCoat Auto
Outfit Property FeriaCoatOutfit Auto


Idle Property SleepNod Auto
Quest Property ThisQuest Auto


Weapon Property FeriaWeaponReward Auto

ImageSpaceModifier Property Blackscreen  Auto  
ObjectReference Property MapMarkerHome Auto
Message Property HelgenMSG Auto



; 0 - not talked. 1 - going to hall 2 - in hall 3 - after hall
Int Property OengulStage Auto Conditional Hidden

Function TalkedToParent(int which)
if which == 1
;mom
MomTalked = 1
elseif which == 2
;dad
DadTalked = 1
endif
EndFunction

;Fix for Feria getting seperated during split scene
Function CheckFeriaDistance()
if Feria.GetDistance(PlayerRef) > 10000
Feria.MoveTo(PlayerRef)
endif

EndFunction

Function HomeMapMarker(bool tf)
MapMarkerHome.EnableFastTravel(tf)
EndFunction


Function SecondDreamEnter()
;nuuuu
EndFunction

Function SecondDreamExit()
;nuuuu
EndFunction

Function FeriaUnfollow()
FollowerQuest.DismissFollower()
EndFunction

Function AtHomeSleepThoughts()
Game.FadeOutGame(true,true,0.1,3)
;add imod
Blackscreen.Apply(1)
debug.messagebox("You collapse into your bed, tired from the journey.")
utility.wait(2.0)
debug.messagebox("Listening to the sound of the blizzard outside, it's a miracle you made it home at all.")
utility.wait(4.0)
debug.messagebox("You fall into a gentle and warm sleep.")
utility.wait(4.0)
Game.FadeOutGame(false,true,0.1,3)
Blackscreen.Remove()

debug.messagebox("I wonder how Feria is doing? And mom and dad?")
EndFunction

Function BlackOutScene()
Game.ForceFirstPerson()
Game.DisablePlayerControls(true,true,false,false,true,true,true,false)
Blackscreen.Apply()
debug.messagebox("I... I'm getting sleepy...")
utility.wait(5.0)
ThisQuest.SetStage(40)
EndFunction

Function ComeBackScene()
debug.messagebox("I... I... I hear... noise? Nearby? I have to go check it out...!")
Game.FadeOutGame(false,true,0.1,4)
Blackscreen.Remove()
Game.EnablePlayerControls(true,true,true,true,true,true,true,true)
utility.wait(5.0)
debug.messagebox("Feria...? Where did... you go...?")
debug.messagebox("I have to press on.")

EndFunction


Function DreamSequenceEnter()
;Tell Feria to wait up so she doesnt follow us
FollowerQuest.FollowerWait()

Game.FadeOutGame(true,true,0.1,3)
;Place player's items in safekeeping chest
PlayerRef.RemoveAllItems(SafeKeepingChest)
PlayerRef.AddPerk(DreamPlayerImmunityPerk)
Feria.MoveTo(FeriaDreamMoveToMarker)
DreamDragon.SetForcedLandingMarker(DragonLandingPerch)
;Equip dragonstuff armor
Form Item1 = DragonslayerSet.GetNthPart(0)
Form item2 = DragonslayerSet.GetNthPart(1)
Form Item3 = DragonslayerSet.GetNthpart(2)
Form Item4 = DragonslayerSet.GetNthPart(3)
Form item5 = DragonslayerSet.GetNthPart(4)
PlayerRef.EquipItem(Item1)
PlayerRef.EquipItem(Item2)
PlayerRef.EquipItem(Item3)
PlayerRef.EquipItem(Item4)
PlayerRef.EquipItem(Item5)
PlayerRef.EquipItem(DragonboneSword)
PlayerRef.MoveTo(DreamSequenceMoveTo)

debug.messagebox("Mmmnn.. H..Hey? This sure is a very vivid dream.")
debug.messagebox("Ooo! A dragonslaying dream!")
EndFunction

Function DreamSequenceExit()
Utility.Wait(7.0)
PlayerRef.RemovePerk(DreamPlayerImmunityPerk)
Game.DisablePlayerControls(true,true,true,false,true,false,true,false)
PlayerRef.RemoveAllitems()
SafekeepingChest.RemoveAllitems(PlayerRef)
PlayerRef.MoveTo(DreamExitMarker)
Game.FadeOutGame(true,true,0.1,5)
debug.sendAnimationEvent(PlayerRef,"IdleLaydown")
Utility.Wait(2.0)
debug.messagebox("Wow! What an epic dream!")
debug.messagebox("Oh.. I still have my journey with Feria to undertake. I should find her and let her know I'm awake.")
debug.sendAnimationEvent(PlayerRef,"IdleLaydown_Exit")
PlayerRef.PlayIdle(SleepNod)
Game.EnablePlayerControls(true,true,true,true,true,true,true,true)
EndFunction

Function FeriaFollowAgain()
FollowerQuest.FollowerFollow()
EndFunction

Function NiranyeReward()
NiranyeQuest = 4
NiranyeQuestComplete = 1
Form Item1 = FeriaCoatOutfit.GetNthPart(0)
Form Item2 = FeriaCoatOutfit.GetNthPart(1)
Form Item3 = FeriaCoatOutfit.GetNthPart(2)
Form Item4 = FeriaCoatOutfit.GetNthPart(3)
PlayerRef.AddItem(Item1,1)
PlayerRef.AddItem(Item2,1)
PlayerRef.AddItem(Item3,1)
Feria.SetOutfit(FeriaCoatOutfit)
Ambarys.Resurrect()
CheckAllObjectives()
EndFunction

Function HilleviReward()
HelleviQuestComplete = 1
HilleviQuest = 4
Give25FoodItems()
CheckAllObjectives()
EndFunction

Function Give25FoodItems()
if FoodItemCounter <= 25
PlayerRef.AddItem(PickFoodItem(),1)
FoodItemCounter = FoodItemCounter + 1
Give25FoodItems()
endif
EndFunction

Form Function PickFoodItem()
int random = Utility.RandomInt(0,10)
return FoodFormlist.GetAt(random)
EndFunction

Function SetNiranyeQuest(int to)
NiranyeQuest = to
CheckAllObjectives()
EndFunction

Function SetHilleviQuest(int to)
HilleviQuest = to
CheckAllObjectives()
EndFunction

Function ShacklePlayerAndFeria()
Game.FadeOutGame(true,true,0.1,3)
PlayerRef.MoveTo(PlayerShackle)
Feria.MoveTo(FeriaShackle)
AmbarysScene.Start()
NiranyeQuest = 2
Ambarys.MoveTo(AmbarysTo)
Game.ForceFirstPerson()
Game.DisablePlayerControls(true,true,true,false,true,true,true,true)
debug.messagebox("Ugh... that drink must've knocked me out.")
EndFunction

Function PlayerBreaksFree()
debug.messagebox("My arm slipped free from the shackle! I'm free now. I should help Feria.")
Game.EnablePlayerControls(true,true,true,true,true,true,true,true)
ThisQuest.SetObjectiveDisplayed(13)
EndFunction


Function OengulScene()
Sexlab.QuickStart(PlayerRef,Oengul,Feria,none,none,none,none,"threesome")
OengulSeduced = 1
EndFunction





Function AlwaysBadWeather()
if Weather.GetCurrentWeather() != BlizzardWeather
BlizzardWeather.SetActive()
endif


EndFunction

Function SetOengulAI(int to)
OengulAiTweak = to
if to == 2
OengulQuestComplete = 1
Feria.AddItem(FeriaWeaponReward,1)
CheckAllObjectives()
endif
endFunction

Function OengulStage(int to)
OengulStage = to
CheckAllObjectives()
EndFunction

Event OnUpdate()
AlwaysBadWeather()



EndEvent

Function CheckAllObjectives()
if OengulQuestComplete == 1 && HelleviQuestComplete == 1 && NiranyeQuestComplete == 1
ThisQuest.SetObjectiveDisplayed(19)
endif
EndFunction

Function AskHelgen(int aiButton = 9)
aiButton = HelgenMSG.Show()
if aiButton == 0
;ArthLAL.SetAddonQuestStage(47,ThisQuest)
;ArthLALChargenQuest.SetStage(30)
ThisQuest.SetObjectiveCompleted(40)
ThisQuest.SetObjectiveDisplayed(45)
elseif aiButton == 1
;Go through Helgen
ThisQuest.SetStage(50)
ThisQuest.SetObjectiveCompleted(40)
ThisQuest.SetObjectiveDisplayed(45)
endif
EndFunction



Function Stage10Thoughts()
debug.messagebox("Feria's right. We're going to need winter coats if we're going to survive the trip back to whiterun.")
debug.messagebox("At least now me and her have good 'bartering skills.' Maybe I should talk to some people in town to see what we can find.")
debug.messagebox("We're going to need 2 coats and some travel supplies. Food would be nice, too.")
EndFunction

Function FoundBurnedHome()
debug.messagebox("Wh... what happened to my house!? Where are mom and dad!?")
EndFunction

Function FoundBurnedHome2()
debug.messagebox("It... it looks like mom and dad died inside of the house. I... I'm an orphan now.")
debug.messagebox("It looks like I'm on my own. The dragons... I'll get my revenge on them! I'll get my revenge on them all!")
EndFunction