Scriptname SuH_dyna_playerScript extends activemagiceffect  

SexLabFramework property SexLab auto

GlobalVariable Property SuH_SETcombatseduction auto
GlobalVariable Property SuH_SETalwaysgive auto
GlobalVariable Property SuH_SETcsNPChmax auto
GlobalVariable Property SuH_SETcsNPChmin auto
GlobalVariable Property SuH_SETcsPCShmax auto
GlobalVariable Property SuH_SETcsPCShmin auto
GlobalVariable Property SuH_SETcsPCSNhmax auto
GlobalVariable Property SuH_SETcsPCSNhmin auto
GlobalVariable Property SuH_SETcsMaleHomo auto
GlobalVariable Property SuH_SETcsFemaleHomo auto
GlobalVariable Property SuH_SETcsMaleAttack auto
GlobalVariable Property SuH_SETcsFemaleAttack auto
GlobalVariable Property SuH_SETcsCreatureAttack auto
GlobalVariable Property SuH_SETcsCreatureWMale auto
GlobalVariable Property SuH_SETcsCreatureWFemale auto
GlobalVariable Property SuH_SETcsPlayerAttack auto
GlobalVariable Property SuH_SETcsPlayerSubmit auto
GlobalVariable Property SuH_PCSheartXP auto
GlobalVariable Property SuH_PCSheartXPgain auto

MagicEffect Property SuH_CHAinacteffect auto
MagicEffect Property SuH_csGraceeffect auto
MagicEffect Property SuH_sp_masochisteffect auto

Spell Property SuH_dyna_ability auto

Actor Property PlayerRef Auto
Actor char

int csActive

Event OnEffectStart(Actor akTarget, Actor akCaster)
	char = akTarget
endEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	UnregisterForUpdate()
endEvent

Event OnUpdate()
	csActive = 0
endEvent

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
	Actor attChar = akAggressor as Actor
	
	;ent/ Combat Seduction
	;;; Combat Seduction check SET ,,,
	if SuH_SETcombatseduction.GetValue() as bool
		if csActive != 1
			csActive = 1
			RegisterForSingleUpdate(1.0)
			if char == attChar
				csActive = 0
				UnregisterForUpdate()
			else ;;; If not self or in grace period ,,,
				float chp = ((char.GetActorValue("Health"))/(char.GetBaseActorValue("Health")))
				If SuH_SETcsPlayerSubmit.GetValue() && chp > 0 && chp <= SuH_SETcsPCShmax.GetValue()
					bool charV = SexLab.IsValidActor(char)
					bool attCharV = SexLab.IsValidActor(attChar)
					if charV == true && attCharV == true
						int charG = SexLab.GetGender(char)
						int attCharG = SexLab.GetGender(attChar)
						if charG == 1 ;;; Female Char ,,,
							;;; Female Attacker ,,,
							if attCharG == 1 && SuH_SETcsFemaleAttack.GetValue() && SuH_SETcsFemaleHomo.GetValue()
								Actor[] aniActors = new actor[2]
								aniActors[0] = char
								aniActors[1] = attChar
								sslBaseAnimation[] animSET = SexLab.GetAnimationsByTags(2,"Lesbian", "", requireAll=true)
								SexLab.StartSex(aniActors, animSET, victim=char, allowbed=false)
								csActive = 0
								UnregisterForUpdate()
							;;; Male Attacker ,,,
							elseIf attCharG == 0 && SuH_SETcsMaleAttack.GetValue()
								Actor[] aniActors = new actor[2]
								aniActors[0] = char
								aniActors[1] = attChar
								sslBaseAnimation[] animSET = SexLab.GetAnimationsByTags(2,"Aggressive", "Lesbian", requireAll=true)
								SexLab.StartSex(aniActors, animSET, victim=char, allowbed=false)
								csActive = 0
								UnregisterForUpdate()
							;;; Creature Attacker ,,,
							elseIf attCharG >= 2 && SuH_SETcsCreatureAttack.GetValue() && SuH_SETcsCreatureWFemale.GetValue()
								Actor[] aniActors = new actor[2]
								aniActors[0] = char
								aniActors[1] = attChar
								sslBaseAnimation[] animSET = SexLab.GetAnimationsByTags(2,"", "", requireAll=true)
								SexLab.StartSex(aniActors, animSET, victim=char, allowbed=false)
								csActive = 0
								UnregisterForUpdate()
							else
								csActive = 0
								UnregisterForUpdate()
							endIf
						elseIf charG == 0 ;;; Male Char ,,,
							;;; Female Attacker ,,,
							if attCharG == 1 && SuH_SETcsFemaleAttack.GetValue()
								Actor[] aniActors = new actor[2]
								aniActors[0] = attChar
								aniActors[1] = char
								sslBaseAnimation[] animSET = SexLab.GetAnimationsByTags(2,"Cowgirl", "", requireAll=true)
								SexLab.StartSex(aniActors, animSET, victim=char, allowbed=false)
								csActive = 0
								UnregisterForUpdate()
							;;; Male Attacker ,,,
							elseIf attCharG == 0 && SuH_SETcsMaleAttack.GetValue() && SuH_SETcsMaleHomo.GetValue()
								Actor[] aniActors = new actor[2]
								aniActors[0] = char
								aniActors[1] = attChar
								sslBaseAnimation[] animSET = SexLab.GetAnimationsByTags(2,"Aggressive", "Lesbian", requireAll=true)
								SexLab.StartSex(aniActors, animSET, victim=char, allowbed=false)
								csActive = 0
								UnregisterForUpdate()
							;;; Creature Attacker ,,,
							elseIf attCharG >= 2 && SuH_SETcsCreatureAttack.GetValue() && SuH_SETcsCreatureWMale.GetValue()
								Actor[] aniActors = new actor[2]
								aniActors[0] = char
								aniActors[1] = attChar
								sslBaseAnimation[] animSET = SexLab.GetAnimationsByTags(2,"", "", requireAll=true)
								SexLab.StartSex(aniActors, animSET, victim=char, allowbed=false)
								csActive = 0
								UnregisterForUpdate()
							else
								csActive = 0
								UnregisterForUpdate()
							endIf
						else
							csActive = 0
							UnregisterForUpdate()
						endIf
					else
						csActive = 0
						UnregisterForUpdate()
					endIf
				else
					csActive = 0
					UnregisterForUpdate()
				endIf
			endIf
		endIf
	endIf
	;end/
	;ent/ Masochist
	if char.HasMagicEffect(SuH_sp_masochisteffect)
		SuH_PCSheartXP.SetValue(SuH_PCSheartXP.GetValue()+1*SuH_PCSheartXPgain.GetValue()*0.01)
	endIf
	;end/
endEvent