Scriptname JR_CidhnaMineQuestScript extends Quest  

SexLabFramework Property SexLab Auto  
Bool Property LastRaped Auto
GlobalVariable Property JR_PreventForceGreet Auto
Float Property OldDAsChance Auto

Event OnInit()
	LastRaped = false
	JR_PreventForceGreet.SetValue(0)
endEvent

Function StartRape(Actor akActor)
	JR_PreventForceGreet.SetValue(1)

	if Game.GetModByName("SexLabDefeat.esp") < 255
		Actor[] tmpActor = new Actor[1]
		tmpActor[0] = akActor
		if DefeatUtil.StartScene(tmpActor, ForceAutoResist = true)
			OldDAsChance = DefeatUtil.GetDefeat().McmConfig.DAsChance
			DefeatUtil.GetDefeat().McmConfig.DAsChance = 0
			LastRaped = true
			Stop()
			return
		endif
	endif

	int i = 10
	sslBaseAnimation[] anims
	while !anims && i
		i -= 1
		anims = SexLab.GetAnimationsByType(2, Males = 1, Females = 1, Aggressive = true)
		if anims
			anims = SexLab.RemoveTagged(anims, "Guro,Necro,Sleeping")
		endif
	endWhile

	Actor player = Game.GetPlayer()
	Actor[] positions = SexLabUtil.MakeActorArray(player, akActor)
	if SexLab.StartSex(positions, anims, Victim = positions[0]) != -1
		LastRaped = true
	endif
	
	Stop()
endFunction

