ScriptName SuH_NPCsvictimScript 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

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
		SuH_NPChdry.SetValue(0)
		eActorH -= Math.Floor(playerhpa)
	else
		SuH_NPChdry.SetValue(1)
	endIf
	if eActorM > 1
		SuH_NPCmdry.SetValue(0)
		eActorM -= Math.Floor(playermpa)
	elseIf eActorH > 1
		SuH_NPCmdry.SetValue(0)
		eActorH -= Math.Floor(playermpa)
	else
		SuH_NPCmdry.SetValue(1)
	endIf
	if eActorM > 1
		SuH_NPCmdry.SetValue(0)
		eActorS -= Math.Floor(playerspa)
	elseIf eActorH > 1
		SuH_NPCmdry.SetValue(0)
		eActorH -= Math.Floor(playerspa)
	else
		SuH_NPCsdry.SetValue(1)
	endIf
	
	eActor.SetActorValue("health", eActorH)
	eActor.SetActorValue("stamina", eActorS)
	eActor.SetActorValue("magicka", eActorM)
	RegisterForSingleUpdate(5.0)
endEvent