Scriptname SuH_spellES_vitaldrain_love extends activemagiceffect  

SuH_Fun property _Fun auto

GlobalVariable Property SuH_PCSstacksex auto
GlobalVariable Property SuH_PCSstacksperm auto
GlobalVariable Property SuH_PCSstackmilk auto

actor property PlayerRef auto

Event OnEffectStart(actor akTarget, actor akCaster)
	if akCaster == PlayerRef
		int sex = SuH_PCSstacksex.GetValue() as int
		int sperm = SuH_PCSstacksperm.GetValue() as int
		int milk = SuH_PCSstackmilk.GetValue() as int
		
		if sex < sperm && sex < milk
			if sex!= 0
				float h = akTarget.GetActorValue("health")
				float m = akTarget.GetActorValue("magicka")
				float s = akTarget.GetActorValue("stamina")
				float x = sex * 0.025
				float xh = Math.Floor(h*x)
				float xm = Math.Floor(m*x)
				float xs = Math.Floor(s*x)
				akTarget.SetActorValue("health", h-xh)
				akTarget.SetActorValue("magicka", m-xm)
				akTarget.SetActorValue("stamina", s-xs)
				_Fun.STATcalc(akCaster, FALSE, "0", "health", FALSE, 0.0, xh, FALSE)
				_Fun.STATcalc(akCaster, FALSE, "0", "magicka", FALSE, 0.0, xm, FALSE)
				_Fun.STATcalc(akCaster, FALSE, "0", "stamina", FALSE, 0.0, xs, FALSE)
				sperm -= sex
				milk -= sex
				sex = 0
				SuH_PCSstacksex.SetValue(sex)
				SuH_PCSstacksperm.SetValue(sperm)
				SuH_PCSstackmilk.SetValue(milk)
				debug.Notification("Absorbed "+xh+" Health "+xm+" Magicka "+xs+" Stamina")
			else
				debug.Notification("Vital Drain Failed : Not Enough Stacks")
			endIf
		elseIf sperm < milk && sperm < sex
			if sperm!= 0
				float h = akTarget.GetActorValue("health")
				float m = akTarget.GetActorValue("magicka")
				float s = akTarget.GetActorValue("stamina")
				float x = sperm * 0.025
				float xh = Math.Floor(h*x)
				float xm = Math.Floor(m*x)
				float xs = Math.Floor(s*x)
				akTarget.SetActorValue("health", h-xh)
				akTarget.SetActorValue("magicka", m-xm)
				akTarget.SetActorValue("stamina", s-xs)
				_Fun.STATcalc(akCaster, FALSE, "0", "health", FALSE, 0.0, xh, FALSE)
				_Fun.STATcalc(akCaster, FALSE, "0", "magicka", FALSE, 0.0, xm, FALSE)
				_Fun.STATcalc(akCaster, FALSE, "0", "stamina", FALSE, 0.0, xs, FALSE)
				sex -= sperm
				milk -= sperm
				sperm = 0
				SuH_PCSstacksex.SetValue(sex)
				SuH_PCSstacksperm.SetValue(sperm)
				SuH_PCSstackmilk.SetValue(milk)
				debug.Notification("Absorbed "+xh+" Health "+xm+" Magicka "+xs+" Stamina")
			else
				debug.Notification("Vital Drain Failed : Not Enough Stacks")
			endIf
		elseif milk < sex && milk < sperm
			if sex!= 0
				float h = akTarget.GetActorValue("health")
				float m = akTarget.GetActorValue("magicka")
				float s = akTarget.GetActorValue("stamina")
				float x = sex * 0.025
				float xh = Math.Floor(h*x)
				float xm = Math.Floor(m*x)
				float xs = Math.Floor(s*x)
				akTarget.SetActorValue("health", h-xh)
				akTarget.SetActorValue("magicka", m-xm)
				akTarget.SetActorValue("stamina", s-xs)
				_Fun.STATcalc(akCaster, FALSE, "0", "health", FALSE, 0.0, xh, FALSE)
				_Fun.STATcalc(akCaster, FALSE, "0", "magicka", FALSE, 0.0, xm, FALSE)
				_Fun.STATcalc(akCaster, FALSE, "0", "stamina", FALSE, 0.0, xs, FALSE)
				sex -= milk
				sperm -= milk
				milk = 0
				SuH_PCSstacksex.SetValue(sex)
				SuH_PCSstacksperm.SetValue(sperm)
				SuH_PCSstackmilk.SetValue(milk)
				debug.Notification("Absorbed "+xh+" Health "+xm+" Magicka "+xs+" Stamina")
			else
				debug.Notification("Vital Drain Failed : Not Enough Stacks")
			endIf
		endIf
	endIf
endEvent