ScriptName SuH_NPCsnattackerScript extends ActiveMagicEffect

GlobalVariable Property SuH_SETdrainattacker auto
GlobalVariable Property SuH_SETdrainkill auto

actor c

int cHd
int cMd
int cSd
int cL
int cA
int statCap

float aMOD

Event OnEffectStart(Actor akTarget, Actor akCaster)
	c = akTarget
	cL = c.GetLevel()
	cA = Math.Floor(1+(cL*0.2))
	aMOD = SuH_SETdrainattacker.GetValue()
	
	RegisterForSingleUpdate(5.0)
EndEvent

Event OnUpdate()
	cHd += cA
	cMd += cA
	cSd += cA
	RegisterForSingleUpdate(5.0)
endEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	int cH = Math.Floor(c.GetBaseActorValue("health"))
	int cS = Math.Floor(c.GetBaseActorValue("stamina"))
	int cM = Math.Floor(c.GetBaseActorValue("magicka"))
	statCap = Math.Floor(100+(5*cL))
	int SETdrainkill = Math.Floor(SuH_SETdrainkill.GetValue())
	
	int h = cH + Math.Floor(cHd*aMOD)
	int m = cM + Math.Floor(cMd*aMOD)
	int s = cS + Math.Floor(cSd*aMOD)
	int x = 0
	
	if s <= cS
		c.SetActorValue("stamina", s)
	else
		x = s - cS
		cHd += x
		c.SetActorValue("stamina", 0)
	endIf
	
	if m <= cM
		c.SetActorValue("magicka", m)
	else
		x = m - cM
		cHd += x
		c.SetActorValue("magicka", 0)
	endIf
	
	if h <= cH
		c.SetActorValue("health", h)
	else
		c.SetActorValue("health", 0)
	endIf
	
	cH = Math.Floor(c.GetBaseActorValue("health"))
	if SETdrainkill == 1
		if cH < 1
			c.DamageActorValue("health", 1.0)
		endIf
	endIf
endEvent