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

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/

Event OnEffectStart(Actor akTarget, Actor akCaster)
	if akTarget == playerRef
		;ent/ Variables
		int pHa = Math.Floor(SuH_PCSspermhvalue.GetValue())
		int pMa = Math.Floor(SuH_PCSspermmvalue.GetValue())
		int pSa = Math.Floor(SuH_PCSspermsvalue.GetValue())
		int XP = Math.Floor(SuH_PCSheartXP.GetValue())
		int pH = Math.Floor(playerRef.GetBaseActorValue("health"))
		int pM = Math.Floor(playerRef.GetBaseActorValue("magicka"))
		int pS = Math.Floor(playerRef.GetBaseActorValue("stamina"))
		float XPgain = SuH_PCSheartXPgain.GetValue()
		int plvl = playerRef.GetLevel()
		int statCapUp = Math.Floor(SuH_PCScapup.GetValue())
		int statCap = Math.Floor(100+(5*plvl)+(statCapUp))
		;end/
		;ent/ Absorb Effect
		int hxpUP = Math.Floor(10*XPgain*0.01)
		XP += hxpUP
		SuH_PCSheartXP.SetValue(XP)
		debug.Notification("+"+hxpUP+" HeartXP")
		
		int h = pH+pHa
		int m = pM+pMa
		int s = pS+pSa
		int eUP = 0
		int x = 0
		
		if h <= statCap
			playerRef.SetActorValue("health", h)
		elseIf pH > statCap
			eUP += pHa
		else
			x = h - statCap
			eUP += x
			playerRef.SetActorValue("health", statCap)
		endIf
		
		if m <= statCap
			playerRef.SetActorValue("magicka", m)
		elseIf pM > statCap
			eUP += pMa
		else
			x = m - statCap
			eUP += x
			playerRef.SetActorValue("magicka", statCap)
		endIf
		
		if s <= statCap
			playerRef.SetActorValue("stamina", s)
		elseIf pS > statCap
			eUP += pSa
		else
			x = s - statCap
			eUP += x
			playerRef.SetActorValue("stamina", statCap)
		endIf
		int essence = Math.Floor(SuH_skill_essence.GetValue())
		SuH_skill_essence.SetValue(essence+eUP)
		
		;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)
		int cH = Math.Floor(akTarget.GetBaseActorValue("health"))
		int cS = Math.Floor(akTarget.GetBaseActorValue("stamina"))
		int cM = Math.Floor(akTarget.GetBaseActorValue("magicka"))
		int cL = akTarget.GetLevel()
		int cA = Math.Floor(1+(cL*0.1))
		int statCap = Math.Floor(100+(5*cL))
		;end/
		int h = cH+cA
		int m = cM+cA
		int 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