Scriptname __LALLSeekingFeria1Script extends Quest conditional

Actor Property PlayerRef Auto
sexLabFramework Property sexLab auto
Quest Property ThisQuest Auto
Actor Property Feria Auto
GlobalVariable Property FeriaGLB Auto
Outfit Property FeriaServerOutfit Auto
ObjectReference Property FeriaMarker Auto
Outfit Property CoatOutfit Auto
Spell Property FriendshipBracelet Auto
Actor Property Haelga Auto
MiscObject Property Gold001 Auto
Actor Property Bjorlam Auto
ObjectReference Property RiftenMarker Auto
Int Property BjorlamHadSex Auto Conditional


;Haelgas stuff
Int Property GoldPaid Auto Hidden Conditional
ReferenceAlias Property CustomerAlias Auto

String Property LastTag Auto Hidden

Function ChangeFeriaOutfit()
Feria.SetOutfit(CoatOutfit)
PlayerRef.AddSpell(FriendshipBracelet)
EndFunction

Function HaelgaBribeSex()
;For if player wants to bribe Haelga instead of working it off. For when she's standing near her bed.
SexLab.QuickStart(PlayerRef,Haelga,none,none,none,none,"HaelgaSex",getRandomTag())
RegisterForModEvent("AnimationEnding_HaelgaSex","AfterHaelgaSex")
PlayerRef.RemoveItem(Gold001,3500)
EndFunction


Function SexWithBjorlam()
sexlab.QuickStart(Bjorlam,PlayerRef,none,none,none,none,"MyHook",getRandomTag())
RegisterForModEvent("AnimationEnding_MyHook","BjorlamSexEnded")
EndFunction


Function BringMeToRiften()
PlayerRef.MoveTo(RiftenMarker)
ThisQuest.SetObjectiveCompleted(10)
EndFunction



Event BjorlamSexEnded(string eventname, string argstring, float argNum, form sender)
BjorlamHadSex = 1
UnregisterForModEvent("BjorlamSexEnded")
EndEvent


;Preps her for the bunkhouse scene
Function PrepareFeria()
;This will disable her old ai - leave this on from here on out
FeriaGLB.SetValue(1)
Feria.SetOutfit(FeriaServerOutfit)
Feria.MoveTo(FeriaMarker)
EndFunction

Message[] Property M Auto

Function Stage0Thoughts()
utility.wait(10.0)
m[0].Show()
m[1].Show()
m[2].Show()
;debug.messagebox("I wonder where Feria went? I haven't seen her since we got seperated near darkwater crossing.")
;debug.messagebox("It doesn't look like she's been home - or at least didn't stick around if she did come here.")
;debug.messagebox("Maybe I can pick up a rumor about her at an inn somewhere?")
ThisQuest.SetStage(10)
EndFunction

Function FeriaPayRandomAmt()
int random = Utility.RandomInt(100,250)
GoldPaid = GoldPaid + random
debug.notification("Feria paid " + random + " gold towards her debt")
EndFunction


Function SetCustomer()
ObjectReference ThisCustomer = Game.GetCurrentCrosshairRef()
CustomerAlias.ForceRefTo(ThisCustomer)
EndFunction


Function HaveSex()
Actor Tgt = CustomerAlias.GetActorReference()
sexLab.QuickStart(PlayerRef,Tgt,none,none,none,none,"MyHook",getRandomTag())
RegisterForModEvent("AnimationEnding_MyHook","SexAnimEnded")
EndFunction

;Because when sexlab hooks stop working randomly
Function HaveSex2()
Actor Tgt = CustomerAlias.GetActorReference()
sslThreadModel Thread = Sexlab.newThread()
Thread.AddActor(PlayerRef)
Thread.AddActor(Tgt)
Thread.SetAnimations(sexlab.GetAnimationsByTags(2,getRandomTag(),"",false))
Thread.SetHook("BunkhouseSex")
RegisterForModEvent("HookAnimationEnd_BunkhouseSex","SexAnimEnded")
Thread.StartThread()
EndFunction

string function getRandomTag()
int random = utility.randomint(0,2)
if random == 0
return "vaginal"
LastTag = "vaginal"
elseif random == 1
return "oral"
LastTag = "Oral"
elseif random == 2
return "anal"
LastTag = "Anal"
endif
EndFunction

Event OnUpdateGameTime()
FeriaPayRandomAmt()
EndEvent

Function QueryHaelgaDebt()
debug.messagebox("You worked off " + GoldPaid + " of your 3500 septim debt for Feria.")
EndFunction

int Function FriendBonus()
if CustomerAlias.GetActorReference().GetRelationshipRank(PlayerRef) >= 1
return 65
else
return 0
endif
EndFunction

Function MoveToRiften()
;Ya protestant fuckbucket
PlayerRef.MoveTo(RiftenMarker)
EndFunction

Event SexAnimEnded(int tid, bool HasPlayer)
sslThreadController Thread = SexLab.GetController(tid)
;Player just had sex with an npc in riften
Int Random = Utility.RandomInt(25,100)
Int Total = 250 + FriendBonus() + Random
GoldPaid = GoldPaid + Total
debug.notification("The client paid Haelga " + total + " gold for your services.")
CustomerAlias.TryToClear()
UnregisterForModEvent("SexAnimEnded")
EndEvent

;Called when bribing Haelga
Event AfterHaelgaSex(string eventname, string argstring, float argnum, form sender)
ThisQuest.SetStage(55)
EndEvent