Scriptname SuH_ss_sexualenrageScript extends ActiveMagicEffect  

;#Include
SexLabFramework property SexLab auto

GlobalVariable Property SuH_PCSseductionpoints auto

MagicEffect Property SuH_PCSsubmiteffect auto
MagicEffect Property SuH_PCStrainingeffect auto
MagicEffect Property SuH_PCSmasteryeffect auto

GlobalVariable Property SuH_SETalwaysgive auto
GlobalVariable Property SuH_SETallowseduce auto

Actor Property playerRef Auto

Event OnEffectStart(Actor cTarget,Actor cCaster)
	int Tsex = SexLab.GetGender(cTarget)
	int SETalwaysgive = Math.Floor(SuH_SETalwaysgive.GetValue())
	int SETallowseduce = Math.Floor(SuH_SETallowseduce.GetValue())
	
	if cCaster == playerRef && cTarget != none
		if SETallowseduce == 0 || SETallowseduce == 1 && Tsex == 1 || SETallowseduce == 2 && Tsex == 0
			if playerRef.HasMagicEffect(SuH_PCSmasteryeffect) || playerRef.HasMagicEffect(SuH_PCSsubmiteffect) || playerRef.HasMagicEffect(SuH_PCStrainingeffect)
			else
				;ent/ Calculate Cost
				float Thea = cTarget.GetBaseActorValue("health")
				float Tmag = cTarget.GetBaseActorValue("magicka")
				float Tsta = cTarget.GetBaseActorValue("stamina")
				int Tlvl = cTarget.GetLevel()
				int Plvl = playerRef.GetLevel()
				int Spoints = Math.FLoor(SuH_PCSseductionpoints.GetValue())
				int Scost = Math.Floor((((Thea+Tmag+Tsta)/10)+(Tlvl*15))*1.5)
				;end/
				
				if Scost <= Spoints 
					if SETalwaysgive == 0
						sslThreadController Thread = SexLabUtil.QuickStart(cCaster, cTarget, victim=cCaster)
						if Thread != none
							Spoints -= Scost
							SuH_PCSseductionpoints.SetValue(Spoints)
						else
							Debug.Notification("Seduction Failed : Target Not Valid")
						endIf
					else
						sslThreadController Thread = SexLabUtil.QuickStart(cTarget, cCaster, victim=cCaster)
						if Thread != none
							Spoints -= Scost
							SuH_PCSseductionpoints.SetValue(Spoints)
						else
							Debug.Notification("Seduction Failed : Target Not Valid")
						endIf
					endIf	
				else
					Debug.Notification("Seduction Failed : Not Seductive Enough! ("+Spoints+"/"+Scost+")")
				endIf
			endIf
		else
			Debug.Notification("Seduction Spell Failed")
		endIf
	else
		sslThreadController Thread = SexLabUtil.QuickStart(cCaster, cTarget)
	endIf
endEvent