ScriptName SuH_NPCsattackerScript extends ActiveMagicEffect

;ent/ Global Variables
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
GlobalVariable Property SuH_SETdrainattacker auto
;end/

actor c

int pHa
int pMa
int pSa
int cHd
int cMd
int cSd

float aMOD

Event OnEffectStart(Actor akTarget, Actor akCaster)
	c = akTarget
	aMOD = SuH_SETdrainattacker.GetValue()
	pHa = Math.Floor(SuH_PCShpabsorb.GetValue())
	pMa = Math.Floor(SuH_PCSmpabsorb.GetValue())
	pSa = Math.Floor(SuH_PCSspabsorb.GetValue())
	
	RegisterForSingleUpdate(5.0)
endEvent

Event OnUpdate()
	;ent/ cXd
	cHd += pHa
	cMd += pMa
	cSd += pSa
	;end/
	RegisterForSingleUpdate(5.0)
endEvent

Event onEffectFinish(Actor akTarget, Actor akCaster)
	int cH = Math.Floor(c.GetBaseActorValue("health"))
	int cM = Math.Floor(c.GetBaseActorValue("magicka"))
	int cS = Math.Floor(c.GetBaseActorValue("stamina"))
	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 || SETdrainkill == 2
		if cH < 1
			c.DamageActorValue("health", 1.0)
		endIf
	endIf
endEvent