Scriptname SuH_dynaES_active extends activemagiceffect  

SuH_Fun property _Fun auto
Faction Property SuH_Tracker auto
Actor Property PlayerRef auto

GlobalVariable Property SuH_SETcombatseduction auto
GlobalVariable Property SuH_SETnpc2npchealth auto
GlobalVariable Property SuH_SETnpc2pchealth auto

actor char

Event OnEffectStart(Actor akTarget, Actor akCaster)
	char = akTarget
	char.AddToFaction(SuH_Tracker)
EndEvent

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
	Actor attChar = akAggressor as Actor ; Set Attacker as usable actor reference
	if attChar != char
	if SuH_SETcombatseduction.GetValue()
		if attChar == PlayerRef
			float charHealthPercent = (char.GetActorValue("health") / char.GetBaseActorValue("health"))
			if charHealthPercent <= SuH_SETnpc2pchealth.GetValue()
				actor[] animActor = new actor[2] ; Create Array of actors
				animActor[0] = attChar ; Set char As Aggressor
				animActor[1] = char ; Set attChar As Victim
				_Fun.ANIMcalc("0", animActor, TRUE) ; Send aggressive act to SuH_Fun
			endIf
		else
			float charHealthPercent = (char.GetActorValue("health") / char.GetBaseActorValue("health"))
			if charHealthPercent <= SuH_SETnpc2npchealth.GetValue()
				actor[] animActor = new actor[2] ; Create Array of actors
				animActor[0] = attChar ; Set char As Aggressor
				animActor[1] = char ; Set attChar As Victim
				_Fun.ANIMcalc("0", animActor, TRUE) ; Send aggressive act to SuH_Fun
			endIf
		endIf
	endIf
	endIF
endEvent

Event OnDying(Actor akKiller)
	if akKiller == PlayerRef
		_Fun.XPcalc("0", 0.0, 100, 0.0, False)
	endIf
endEvent