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

Actor Property PlayerRef Auto
Actor char

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

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	UnregisterForUpdate()
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()
		if char.HasMagicEffect(SuH_csGraceeffect) || attChar.HasMagicEffect(SuH_csGraceeffect) || char == attChar
		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)
						;;; 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)
						;;; 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)
						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)
						;;; 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)\
						;;; 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)
						endIf
					endIf
				endIf
			endIf
		endIf
	endIf
	;end/
	;ent/ Masochist
	if char.HasMagicEffect(SuH_sp_masochisteffect)
		int x = Math.Floor(SuH_PCSheartXP.GetValue())
		int y = Math.Floor(SuH_PCSheartXPgain.GetValue())
		SuH_PCSheartXP.SetValue(x+1*y*0.01)
	endIf
	;end/
endEvent