ScriptName SuH_SuccubusDelight extends ActiveMagicEffect

;ent/ Globals
GlobalVariable Property SuH_PCSheartXP auto
GlobalVariable Property SuH_PCSheartXPgain auto
GlobalVariable Property SuH_PCSspermhvalue auto
GlobalVariable Property SuH_PCSspermmvalue auto
GlobalVariable Property SuH_PCSspermsvalue auto
GlobalVariable Property SuH_PCSseductionpoints auto
GlobalVariable Property SuH_skill_essence auto
GlobalVariable Property SuH_PCScapup auto
GlobalVariable Property SuH_SEThcap auto
GlobalVariable Property SuH_SETmcap auto
GlobalVariable Property SuH_SETscap auto
GlobalVariable Property SuH_PCSspermstacks auto
GlobalVariable Property SuH_PCSmaxspermstacks auto

MagicEffect property SuH_sp_healthydelightseffect auto
MagicEffect property SuH_sp_shiningdelightseffect auto
MagicEffect property SuH_sp_sugarydelightseffect auto
MagicEffect property SuH_sp_healthydelights2effect auto
MagicEffect property SuH_sp_shiningdelights2effect auto
MagicEffect property SuH_sp_sugarydelights2effect auto
MagicEffect property SuH_sp_seductivedelightseffect auto
MagicEffect property SuH_NPCsuccubuseffect auto
MagicEffect property SuH_sp_spermlovereffect auto

Actor Property playerRef Auto
;end/

;ent/ Variables
	int pHa
	int pMa
	int pSa
	int XP
	int pH
	int pM
	int pS
	int XPgain
	int plvl
	int statCapUp
	int statCap
	int h
	int m
	int s
	int x
	int eUP
	int essence
	int cH
	int cM
	int cS
	int cA
	int cL
	int hxpUP
	int SETh
	int SETm
	int SETs
;end/

Event OnEffectStart(Actor akTarget, Actor akCaster)
	if akTarget == playerRef
		;ent/ Variables
		pHa = SuH_PCSspermhvalue.GetValue() as int
		pMa = SuH_PCSspermmvalue.GetValue() as int
		pSa = SuH_PCSspermsvalue.GetValue() as int
		SETh = SuH_SEThcap.GetValue() as int
		SETm = SuH_SETmcap.GetValue() as int
		SETs = SuH_SETscap.GetValue() as int
		XP = SuH_PCSheartXP.GetValue() as int
		pH = playerRef.GetBaseActorValue("health") as int
		pM = playerRef.GetBaseActorValue("magicka") as int
		pS = playerRef.GetBaseActorValue("stamina") as int
		XPgain = SuH_PCSheartXPgain.GetValue() as int
		plvl = playerRef.GetLevel()
		statCapUp = SuH_PCScapup.GetValue() as int
		statCap = Math.Floor(100+(5*plvl)+(statCapUp))
		;end/
		;ent/ Absorb Effect
		hxpUP = Math.Floor(20+(plvl*0.5)*XPgain*0.01)
		XP += hxpUP
		SuH_PCSheartXP.SetValue(XP)
		debug.Notification("+"+hxpUP+" HeartXP")
		
		h = pH+pHa
		m = pM+pMa
		s = pS+pSa
		eUP = 0
		x = 0
		
		if SETh == 0
			if h <= statCap
				playerRef.SetActorValue("health", h)
			elseIf pH > statCap
				eUP += pHa
			else
				x = h - statCap
				eUP += x
				playerRef.SetActorValue("health", statCap)
			endIf
		else
			if h <= SETh
				playerRef.SetActorValue("health", h)
			elseIf pH > SETh
				eUP += pHa
			else
				x = h - SETh
				eUP += x
				playerRef.SetActorValue("health", SETh)
			endIf
		endIf
		
		if SETm == 0
			if m <= statCap
				playerRef.SetActorValue("magicka", m)
			elseIf pM > statCap
				eUP += pMa
			else
				x = m - statCap
				eUP += x
				playerRef.SetActorValue("magicka", statCap)
			endIf
		else
			if m <= SETm
				playerRef.SetActorValue("magicka", m)
			elseIf pM > SETm
				eUP += pMa
			else
				x = m - SETm
				eUP += x
				playerRef.SetActorValue("magicka", SETm)
			endIf
		endIf
		
		if SETs == 0
			if s <= statCap
				playerRef.SetActorValue("stamina", s)
			elseIf pS > statCap
				eUP += pSa
			else
				x = s - statCap
				eUP += x
				playerRef.SetActorValue("stamina", statCap)
			endIf
		else
						if s <= SETs
				playerRef.SetActorValue("stamina", s)
			elseIf pS > SETs
				eUP += pSa
			else
				x = s - SETs
				eUP += x
				playerRef.SetActorValue("stamina", SETs)
			endIf
		endIf
		
		essence = SuH_skill_essence.GetValue() as int
		SuH_skill_essence.SetValue(essence+eUP)
		;end/
		;ent/ Sperm Stacks
		int sS = SuH_PCSspermstacks.GetValue() as int
		int maxsS = SuH_PCSmaxspermstacks.GetValue() as int
		if sS < maxsS
			sS += 1
			SuH_PCSspermstacks.SetValue(sS)
		endIf
		;end/
		;ent/ Passive Effects
		if playerRef.HasMagicEffect(SuH_sp_spermlovereffect)
			float cstamina = playerRef.GetActorValue("stamina")
			float heal = Math.Floor((pS - cstamina)*0.3)
			playerRef.RestoreActorValue("stamina",heal)
		endIf
		;end/
	elseIf akTarget.HasMagicEffect(SuH_NPCsuccubuseffect)
		cH = akTarget.GetBaseActorValue("health") as int
		cS = akTarget.GetBaseActorValue("stamina") as int
		cM = akTarget.GetBaseActorValue("magicka") as int
		cL = akTarget.GetLevel()
		cA = Math.Floor(1+(cL*0.1))
		statCap = Math.Floor(100+(5*cL))
		
		h = cH+cA
		m = cM+cA
		s = cS+cA
		
		if h <= statCap
			akTarget.SetActorValue("health", h)
		elseIf cH < statCap
			akTarget.SetActorValue("health", statCap)
		endIf
		
		if m <= statCap
			akTarget.SetActorValue("magicka", m)
		elseIf cM < statCap
			akTarget.SetActorValue("magicka", statCap)
		endIf
		
		if s <= statCap
			akTarget.SetActorValue("stamina", s)
		elseIf cS < statCap
			akTarget.SetActorValue("stamina", statCap)
		endIf
	endIf
endEvent