ScriptName SuH_NPCssubmitScript extends ActiveMagicEffect

GlobalVariable Property SuH_SETmultivictim auto

actor c

int hUP
int mUP
int sUP
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_SETmultivictim.GetValue()
	
	RegisterForSingleUpdate(5.0)
EndEvent

Event OnUpdate()
	hUP += cA
	mUP += cA
	sUP += 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 h = cH + Math.Floor(hUP*aMOD)
	int m = cM + Math.Floor(mUP*aMOD)
	int s = cS + Math.Floor(sUP*aMOD)
	
	if h <= statCap
		c.SetActorValue("health", h)
	elseIf cH < statCap
		c.SetActorValue("health", statCap)
	endIf
	
	if m <= statCap
		c.SetActorValue("magicka", m)
	elseIf cM < statCap
		c.SetActorValue("magicka", statCap)
	endIf
	
	if s <= statCap
		c.SetActorValue("stamina", s)
	elseIf cS < statCap
		c.SetActorValue("stamina", statCap)
	endIf
endEvent