Scriptname SuH_sexES_NPCconsent extends activemagiceffect  

SuH_Fun property _f auto
SuH_Status property _s auto

int devious
Actor char

Event OnInit()
	_f = Game.GetFormFromFile(0x814, "Succubus Heart.esp") as SuH_Fun
	_s = Game.GetFormFromFile(0x16E496, "Succubus Heart.esp") as SuH_Status
endEvent

Event OnEffectStart(Actor akTarget, Actor akCaster)
	if akTarget == _s.PlayerRef
		debug.trace("SuH ERROR : NPCattacker set on PC - NULL Effect", 2) ;Error report to log
	else
		char = akTarget
		RegisterForSingleUpdate(5.0)
	endIf
	devious = _s.SuH_rank_deviouspartner
endEvent

Event OnUpdate()
	int x = _s.SuH_rank_giftedconsent
	if x > 0
		int h = Math.Floor(x + char.GetBaseActorValue("health"))
		int m = Math.Floor(x + char.GetBaseActorValue("magicka"))
		int s = Math.Floor(x + char.GetBaseActorValue("stamina"))
		char.SetActorValue("health", h)
		char.SetActorValue("magicka", m)
		char.SetActorValue("stamina", s)
	endIf	
	; Call functions from SuH_Fun
	if _s.SuH_SETconsentdrain > 0
		_f.STATcalc(char, aPreset="PCtraining", stat="All")
	endIf
	if devious > 0
		devious = math.floor(devious * 2)
		char.RemoveItem(_s.Gold001, devious, true, _s.PlayerRef)
	endIf
	RegisterForSingleUpdate(5.0)
endEvent