ScriptName SuH_PCSmasteryScript extends ActiveMagicEffect

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

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

Event OnUpdate()
	float hdry = SuH_NPChdry.GetValue()
	float mdry = SuH_NPCmdry.GetValue()
	float sdry = SuH_NPCsdry.GetValue()
	float playerhpa = SuH_PCShpabsorb.GetValue()
	float playermpa = SuH_PCSmpabsorb.GetValue()
	float playerspa = SuH_PCSspabsorb.GetValue()
	float playerHeartXP = SuH_PCSheartXP.GetValue()
	float playerHealth = Game.GetPlayer().GetBaseActorValue("health")
	float playerStamina = Game.GetPlayer().GetBaseActorValue("stamina")
	float playerMagicka = Game.GetPlayer().GetBaseActorValue("magicka")
	float heartXPgain = SuH_PCSheartXPgain.GetValue()
	int charLevel = Game.GetPlayer().GetLevel()
	float statCap = 101+(10*charLevel)
	
	playerHeartXP += Math.Floor(10*heartXPgain*0.01)
	
	if hdry == 0
		if(playerHealth < statCap)
			playerHealth += Math.Floor((playerhpa*1)*1.5)
		else
			playerHealth += Math.Floor(playerhpa*1)
		endIf
	endIf
	
	if mdry == 0
		if(playerMagicka < statCap)
			playerMagicka += Math.Floor((playermpa*1)*1.5)
		else
			playerMagicka += Math.Floor(playermpa*1)
		endIf
	endIf
	
	if sdry == 0
		if(playerStamina < statCap)
			playerStamina += Math.Floor((playerspa*1)*1.5)
		else
			playerStamina += Math.Floor(playerspa*1)
		endIf
	endIf
	
	SuH_PCSheartXP.SetValue(playerHeartXP)
	Game.GetPlayer().SetActorValue("health", playerHealth)
	Game.GetPlayer().SetActorValue("stamina", playerStamina)
	Game.GetPlayer().SetActorValue("magicka", playerMagicka)
	RegisterForSingleUpdate(5.0)
endEvent