Scriptname aHH0KederekScript extends Quest  

Function ShowKederekChoice()
	Debug.notification("Kederek is proposing his choice")
	Button = aHHKederekChoiceMessage.show()
	if Button == 0
		aHHKederekChoiceSubmitMessage.show()
		aHH0.setstage(471)
	ElseIf Button == 1
		aHHKederekChoiceResistMessage.show()
		aHH0.setstage(470)
	ElseIf Button == 2
		aHHKederekChoiceRitualMessage.show()
		aHH0.setstage(490)
	EndIf			
Endfunction

Function CthonianArrival()
	aHH0CthonianVine1REF.enable()
	utility.wait(1)
	aHH0CthonianVine2REF.enable()
	aHH0CthonianVine3REF.enable()
	utility.wait(1)
	aHH0CthonianVine4REF.enable()
	utility.wait(1)
	aHH0CthonianVine5REF.enable()
	utility.wait(1)
	aHHKederekRef.RemoveFromFaction(aHHAzathothServantFaction)
	aHHCthonianTegothREF.moveto(aHH0CthonianTegothKederekSpotREF)
EndFunction

Function Killgirls()
	aHH0SariREF.getactorbase().setessential(false)
	aHH0SariREF.kill()
	aHH0AelaREF.getactorbase().setessential(false)
	aHH0AelaREF.kill()
EndFunction


Function StartRapeElizabeth()
    actor[] sexActors = new actor[3]
    int sslid = 0
    sexActors[0] = aHH0JeanneREF
    sexActors[1] = aHH0SariREF
    sexActors[2] = aHH0AelaREF
    sslBaseAnimation[] anims = SL.GetAnimationsByTags(3, "vag", "Aggressive")
    RegisterForModEvent("AnimationEnd_HHAfterElizabethRaped", "AfterElizabethRapedHandler")
    sslid = SL.StartSex(sexActors, anims, victim = aHH0JeanneREF, centeron = aHH0ElizabethRapeSpotREF, allowbed=false, hook="HHAfterElizabethRaped")
    if sslid < 0
        sslid = SL.StartSex(sexActors, anims, centeron = aHH0ElizabethRapeSpotREF, allowbed=false, hook="HHAfterElizabethRaped")
    endif
    if sslid < 0
        Debug.notification("Animation failed; Skip Sex Animation")
        UnregisterForModEvent("AnimationEnd_HHAfterElizabethRaped")
        Debug.notification("Start aHH0Temple2Scene")
        aHH0Temple2Scene.start()
    endif
EndFunction

event AfterElizabethRapedHandler(string eventName, string argString, float argNum, form sender)
    UnregisterForModEvent("AnimationEnd_HHAfterElizabethRaped")
    aHH0Temple2Scene.start()
endEvent



Message Property aHHKederekChoiceMessage  Auto  

Message Property aHHKederekChoiceSubmitMessage  Auto  

Message Property aHHKederekChoiceResistMessage  Auto  

Message Property aHHKederekChoiceRitualMessage  Auto  

int Button

Quest property aHH0 auto

Objectreference property aHH0CthonianVine1REF auto
Objectreference property aHH0CthonianVine2REF auto
Objectreference property aHH0CthonianVine3REF auto
Objectreference property aHH0CthonianVine4REF auto
Objectreference property aHH0CthonianVine5REF auto
Objectreference property aHHCthonianTegothREF auto
Objectreference property  aHH0CthonianTegothKederekSpotREF auto

Actor property aHH0SariREF auto
Actor property aHH0AelaREF auto
Actor property aHH0JeanneREF auto
Sexlabframework property SL auto
Objectreference property aHH0ElizabethRapeSpotREF auto
Scene property aHH0Temple2Scene auto
Actor property aHHKederekREF auto
Faction property aHHAzathothServantFaction auto