ScriptName SuH_PCSmasteryScript extends ActiveMagicEffect

;ent/ Global Variables
GlobalVariable Property SuH_PCSheartXP auto
GlobalVariable Property SuH_PCShpabsorb auto
GlobalVariable Property SuH_PCSmpabsorb auto
GlobalVariable Property SuH_PCSspabsorb auto
GlobalVariable Property SuH_PCSheartXPgain auto
GlobalVariable Property SuH_NPChdry auto
GlobalVariable Property SuH_NPCmdry auto
GlobalVariable Property SuH_NPCsdry auto
GlobalVariable Property SuH_NPCgenders auto
;end/
;ent/ Magic Effects
MagicEffect Property SuH_sp_humandesireseffect auto
MagicEffect Property SuH_sp_animaldesireseffect auto
;end/
;ent/ Actors
Actor Property playerRef Auto
;end/

int hxpUP
int hUP
int mUP
int sUP

Event OnEffectStart(Actor akTarget, Actor akCaster)
	RegisterForSingleUpdate(5.0)
EndEvent

Event OnUpdate()
	;ent/ Variables
	float playerhpa = SuH_PCShpabsorb.GetValue()
	float playermpa = SuH_PCSmpabsorb.GetValue()
	float playerspa = SuH_PCSspabsorb.GetValue()
	float playerHeartXP = SuH_PCSheartXP.GetValue()
	float playerHealth = playerRef.GetBaseActorValue("health")
	float playerStamina = playerRef.GetBaseActorValue("stamina")
	float playerMagicka = playerRef.GetBaseActorValue("magicka")
	float heartXPgain = SuH_PCSheartXPgain.GetValue()
	int charLevel = playerRef.GetLevel()
	float statCap = 101+(10*charLevel)
	int NPCgenders = Math.Floor(SuH_NPCgenders.GetValue())
	float baseHXPmod = 1.0
	;end/
	;ent/ HeartXP
	If playerRef.HasMagicEffect(SuH_sp_humandesireseffect)
		if NPCgenders >= 1 && NPCgenders <= 2 || NPCgenders == 12
			baseHXPmod += 0.5
		endIf
	endIf
	If playerRef.HasMagicEffect(SuH_sp_animaldesireseffect) && NPCgenders == 3
		baseHXPmod += 0.5
	endIf
	playerHeartXP += Math.Floor(10*baseHXPmod*heartXPgain*0.01)
	hxpUP += Math.Floor(10*baseHXPmod*heartXPgain*0.01)
	;end/
	;ent/ Absorb
	playerHealth += Math.Floor(playerhpa*1)
	hUP += Math.Floor(playerhpa*1)
	playerMagicka += Math.Floor(playermpa*1)
	mUP += Math.Floor(playermpa*1)
	playerStamina += Math.Floor(playerspa*1)
	sUP += Math.Floor(playerspa*1)
	;end/
	SuH_PCSheartXP.SetValue(playerHeartXP)
	playerRef.SetActorValue("health", playerHealth)
	playerRef.SetActorValue("stamina", playerStamina)
	playerRef.SetActorValue("magicka", playerMagicka)
	RegisterForSingleUpdate(5.0)
endEvent

Event onEffectFinish(Actor akTarget, Actor akCaster)
	debug.Notification("Act earned "+hxpUP+"hxp "+hUP+"h "+mUP+"m "+sUP+"s")
endEvent