Scriptname SuH_SuQuest extends Quest

SuH_Fun property _Fun auto

GlobalVariable Property SuH_PCSdesire auto
GlobalVariable Property SuH_PCSforce auto
GlobalVariable Property SuH_PCSdesiregain auto
GlobalVariable Property SuH_SETdesiredrain auto
Actor Property PlayerRef auto
Spell Property SuH_dyna_ability auto
Spell Property SuH_dyna_player auto
Spell Property SuH_spell_sexualenrage auto
Spell Property SuH_spell_sexualentice auto

Event OnInit()
	PlayerRef.AddSpell(SuH_dyna_player, FALSE) ; Add dynamic player script
	RegisterForSingleUpdate(5.0) ; Tick in 5 seconds
endEvent

Event OnUpdate()
	If PlayerRef.HasSpell(SuH_dyna_ability) ; If dynamic script is applying
		PlayerRef.RemoveSpell(SuH_dyna_ability) ; Remove dynamic run script
	else ; if dynamic script is not applying
		PlayerRef.AddSpell(SuH_dyna_ability, FALSE) ; AddSpell dynamic run script
	endIf
	float desireV = (SuH_PCSdesiregain.GetValue()*5) + SuH_PCSdesire.GetValue()
	SuH_PCSdesire.SetValue(desireV)
	if desireV >= 1200 && SuH_SETdesiredrain.GetValue()
		float h = PlayerRef.GetBaseActorValue("health")
		float m = PlayerRef.GetBaseActorValue("magicka")
		float s = PlayerRef.GetBaseActorValue("stamina")
		float x = 0.0
		if h > 1.0
			PlayerRef.SetActorValue("health", h - 1.0)
			x += 1.0
		endIf
		if m > 1.0
			PlayerRef.SetActorValue("magicka", m - 1.0)
			x += 1.0
		endIf
		if s > 1.0
			PlayerRef.SetActorValue("stamina", s - 1.0)
			x += 1.0
		endIf
		float y = SuH_PCSforce.GetValue()
		SuH_PCSforce.SetValue(y+x)
		PlayerRef.AddSpell(SuH_spell_sexualentice)
		PlayerRef.AddSpell(SuH_spell_sexualenrage)
	elseif desireV >= 300
		PlayerRef.AddSpell(SuH_spell_sexualentice)
		PlayerRef.AddSpell(SuH_spell_sexualenrage)
	elseif desireV >= 120
		PlayerRef.AddSpell(SuH_spell_sexualenrage)
		PlayerRef.RemoveSpell(SuH_spell_sexualentice)
	else
		PlayerRef.RemoveSpell(SuH_spell_sexualenrage)
		PlayerRef.RemoveSpell(SuH_spell_sexualentice)
	endIf
	RegisterForSingleUpdate(5.0) ; Tick in 5 seconds
endEvent