ScriptName SuH_NPCstrainingScript extends ActiveMagicEffect

SexLabFramework property SexLab auto

GlobalVariable Property SuH_SETmulticonsent auto

Spell Property SuH_NPCstraining auto

actor c

int hUP
int mUP
int sUP
int cL
int cA
int statCap
int switch
int invalid

float aMOD

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

Event OnUpdate()
	hUP += cA
	mUP += cA
	sUP += cA
	switch += 1
	if switch >= 6
		if SexLab.IsValidActor(c)
			invalid = 1
			c.RemoveSpell(SuH_NPCstraining)
		else
			switch = 0
		endIf
	endIf
	RegisterForSingleUpdate(5.0)
endEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
if invalid == 0
	int cH = c.GetBaseActorValue("health") as int
	int cS = c.GetBaseActorValue("stamina") as int
	int cM = c.GetBaseActorValue("magicka") as int
	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
endIf
endEvent