ScriptName SuH_NPCsattackerScript extends ActiveMagicEffect

GlobalVariable Property SuH_PCShpabsorb auto
GlobalVariable Property SuH_PCSmpabsorb auto
GlobalVariable Property SuH_PCSspabsorb auto
GlobalVariable Property SuH_NPChdry auto
GlobalVariable Property SuH_NPCmdry auto
GlobalVariable Property SuH_NPCsdry auto
GlobalVariable Property SuH_SETdrainkill auto

actor eActor

Event OnEffectStart(Actor akTarget, Actor akCaster)
	eActor = akTarget
	
	RegisterForSingleUpdate(5.0)
endEvent

Event OnUpdate()
	float playerhpa = SuH_PCShpabsorb.GetValue()
	float playermpa = SuH_PCSmpabsorb.GetValue()
	float playerspa = SuH_PCSspabsorb.GetValue()
	float eActorH = eActor.GetBaseActorValue("health")
	float eActorS = eActor.GetBaseActorValue("stamina")
	float eActorM = eActor.GetBaseActorValue("magicka")
	
	if eActorH > 1
		eActorH -= Math.Floor(playerhpa*0.2)
	endIf
	if eActorM > 1
		eActorM -= Math.Floor(playermpa*0.2)
	else
		eActorH -= Math.Floor(playermpa*0.2)
	endIf
	if eActorS > 1
		eActorS -= Math.Floor(playerspa*0.2)
	else
		eActorH -= Math.Floor(playerspa*0.2)
	endIf
	
	eActor.SetActorValue("health", eActorH)
	eActor.SetActorValue("stamina", eActorS)
	eActor.SetActorValue("magicka", eActorM)
	RegisterForSingleUpdate(5.0)
endEvent

Event onEffectFinish(Actor akTarget, Actor akCaster)
	float eActorH = eActor.GetBaseActorValue("health")
	int SETdrainkill = Math.Floor(SuH_SETdrainkill.GetValue())
	if SETdrainkill == 1 || SETdrainkill == 2
		if eActorH
			eActor.DamageActorValue("health", 1.0)
		endIf
	endIf
endEvent