Scriptname SuH_ss_creatureclaimScript 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

Actor Property playerRef Auto

Event OnEffectStart(Actor cTarget,Actor cCaster)
	if cCaster == playerRef && cTarget != none
		int Agender = SexLab.GetGender(cTarget)
		if playerRef.HasMagicEffect(SuH_PCSmasteryeffect) || playerRef.HasMagicEffect(SuH_PCSsubmiteffect) || playerRef.HasMagicEffect(SuH_PCStrainingeffect)
		elseIf Agender == 2
			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-Plvl*5))*1.5*0.6)
			
			if Scost <= Spoints
				sslThreadController Thread = SexLabUtil.QuickStart(cCaster, cTarget)
				if Thread != none
					Spoints -= Scost
					SuH_PCSseductionpoints.SetValue(Spoints)
				else
					Debug.Notification("Seduction Failed : Target Not Valid")
				endIf
					
			else
				Debug.Notification("Seduction Failed : Not Seductive Enough! ("+Spoints+"/"+Scost+")")
			endIf
		else
			Debug.Notification("Creature Claim only works on creatures!")
		endIf
	else
		sslThreadController Thread = SexLabUtil.QuickStart(cCaster, cTarget)
		if Thread == none
		Debug.Notification("Seduction Spell Failed")
		endIf
	endIf
endEvent