ScriptName DfSV_Main extends Quest
{Dragon from Succubus Valley}

;#Include
SexLabFramework property SexLab auto
	
	;Spells
	Spell Property DfSV_PCSsubmit auto
	Spell Property DfSV_PCStraining auto
	Spell Property DfSV_PCSmastery auto
	Spell Property DfSV_NPCsvictim auto
	Spell Property DfSV_NPCsattacker auto
	Spell Property DfSV_NPCsconsent auto
	
	;Function Items
	Ingredient Property DfSVSpermSticky auto
	Ingredient Property DfSVSpermSweet auto
	Ingredient Property DfSVSpermThick auto
	Ingredient Property DfSVSpermWarm auto
	
	;Function Actors
	Actor Property PlayerRef Auto

	;Global
	GlobalVariable Property DfSV_PCSheartForce auto
	GlobalVariable Property DfSV_PCSheartForceMAX auto
	
	;integers
	int maleActs = 0
	
	;Initialization
Event OnInit()
	RegisterForModEvent("AnimationStart","DanisManage")
	RegisterForModEvent("AnimationEnd","DanieManage")
	RegisterForModEvent("OrgasmStart","DorgsManage")
	RegisterForModEvent("OrgasmEnd","DorgeManage")
	
	Debug.Notification("The Dragon from Succubus Valley has awoken")
EndEvent

Event DanisManage(string eventName, string argString, float argNum, form sender)
	sslThreadController Thread = SexLab.HookController(argString)
	
	if Thread.HasPlayer
		actor victim = SexLab.HookVictim(argString)
		if victim != none
			if Thread.IsVictim(playerRef)
				actor[] rapeActor = SexLab.HookActors(argString)
				int i = 0
				while i < rapeActor.Length
					if rapeActor[i] == playerRef
						DfSV_PCSsubmit.cast(rapeActor[i],rapeActor[i])
					else
						DfSV_NPCsattacker.cast(rapeActor[i],rapeActor[1])
					endIf
				i += 1
				endWhile
			else
				actor[] rapeActor = SexLab.HookActors(argString)
				int i = 0
				while i < rapeActor.Length
					if rapeActor[i] == playerRef
						DfSV_PCSmastery.cast(rapeActor[i],rapeActor[i])
					else
						DfSV_NPCsvictim.cast(rapeActor[i],rapeActor[1])
					endIf
				i += 1
				endWhile
			endIf
		else
			actor[] consActor = SexLab.HookActors(argString)
			int i = 0
			while i < consActor.Length
				if consActor[i] == playerRef
					DfSV_PCStraining.cast(consActor[i],consActor[i])
				else
					DfSV_NPCsconsent.cast(consActor[i],consActor[i])
				endIf
				i += 1
			endWhile
		endIf
	endIf
endEvent

Event DorgsManage(string eventName, string argString, float argNum, form sender)
	sslThreadController Thread = SexLab.HookController(argString)
	
	actor[] orgaActor = SexLab.HookActors(argString)
	if orgaActor.Length != 1 && orgaActor.Length != 0
		int malePres = 0
		int i = 0
		while i < orgaActor.Length
			int Agender = SexLab.GetGender(orgaActor[i])
			if Agender == 1
			else
				malePres += 1
			endIf
		i += 1
		endWhile
		if malePres > 0
			i = 0
			while i < orgaActor.Length
				actor Bactor = orgaActor[i]
				i += 1
				int Bgender = SexLab.GetGender(Bactor)
				If Bgender == 1
					int K = 0
					while K < malePres
						int random = Utility.RandomInt(0, 28)
						if random == 0 || random == 1 || random == 2 || random == 3 || random == 4 || random == 5
							Bactor.AddItem(DfSVSpermSticky, 2, true)
							Bactor.EquipItem(DfSVSpermSticky, false, true)
						elseIf random == 6
							Bactor.AddItem(DfSVSpermSticky, 3, true)
							Bactor.EquipItem(DfSVSpermSticky, false, true)
							if Bactor == playerRef
								debug.Notification("That was quite the load...")
							endIf
						elseIf random == 7 || random == 8 || random == 9 || random == 10 || random == 11 || random == 12
							Bactor.AddItem(DfSVSpermSweet, 2, true)
							Bactor.EquipItem(DfSVSpermSweet, false, true)
						elseIf random == 13
							Bactor.AddItem(DfSVSpermSweet, 3, true)
							Bactor.EquipItem(DfSVSpermSweet, false, true)
							if Bactor == playerRef
								debug.Notification("That was quite the load...")
							endIf
						elseIf random == 14 || random == 15 || random == 16 || random == 17 || random == 18 || random == 19
							Bactor.AddItem(DfSVSpermThick, 2, true)
							Bactor.EquipItem(DfSVSpermThick, false, true)
						elseIf random == 20
							Bactor.AddItem(DfSVSpermThick, 3, true)
							Bactor.EquipItem(DfSVSpermThick, false, true)
							if Bactor == playerRef
								debug.Notification("That was quite the load...")
							endIf
						elseIf random == 21 || random == 22 || random == 23 || random == 24 || random == 25 || random == 26
							Bactor.AddItem(DfSVSpermWarm, 2, true)
							Bactor.EquipItem(DfSVSpermWarm, false, true)
						elseIf random == 27
							Bactor.AddItem(DfSVSpermWarm, 3, true)
							Bactor.EquipItem(DfSVSpermWarm, false, true)
							if Bactor == playerRef
								debug.Notification("That was quite the load...")
							endIf
						else
							if Bactor == playerRef
								debug.Notification("Seems this one's dry...")
							endIf
						endIf
					K += 1
					endWhile
				endIf
			i += 1
			endWhile
		endIf
	endIf
endEvent

Event DanieManage(string eventName, string argString, float argNum, form sender)
	sslThreadController Thread = SexLab.HookController(argString)
	
	actor[] endActor = SexLab.HookActors(argString)
	int i = 0
	
	while i < endActor.Length
		endActor[i].DispelSpell(DfSV_PCSsubmit)
		endActor[i].DispelSpell(DfSV_PCStraining)
		endActor[i].DispelSpell(DfSV_PCSmastery)
		endActor[i].DispelSpell(DfSV_NPCsvictim)
		endActor[i].DispelSpell(DfSV_NPCsconsent)
		endActor[i].DispelSpell(DfSV_NPCsattacker)
		if endActor[i] != playerRef
			endActor[i].DamageActorValue("health", 1.0)
		endIf
	i += 1
	endWhile
endEvent





