Scriptname SuH_SuQuest extends Quest

SuH_Fun property _Fun auto
DialogueFollowerScript Property DialogueFollower Auto
Quest Property pDialogueFollower  Auto

ObjectReference Property SuH_realm_petreturn Auto 
ObjectReference Property SuH_realm_petreturnbear Auto 
ObjectReference Property SuH_realm_petreturnbristle Auto 
ObjectReference Property SuH_realm_petreturndog Auto 
ObjectReference Property SuH_realm_petreturndraugr Auto 
ObjectReference Property SuH_realm_petreturnfalmer Auto 
ObjectReference Property SuH_realm_petreturnfamiliar Auto 
ObjectReference Property SuH_realm_petreturngargoyle Auto 
ObjectReference Property SuH_realm_petreturnhorker Auto 
ObjectReference Property SuH_realm_petreturnhorse Auto 
ObjectReference Property SuH_realm_petreturnhusky Auto 
ObjectReference Property SuH_realm_petreturnwolf Auto 
ObjectReference Property SuH_realm_petreturnskeever Auto 
ObjectReference Property SuH_realm_petreturnnetch Auto 
ObjectReference Property SuH_realm_petreturnriekling Auto 
ObjectReference Property SuH_realm_petreturnsabrecat Auto 
ObjectReference Property SuH_realm_petreturnseeker Auto 
ObjectReference Property SuH_realm_petreturnspriggan Auto 
ObjectReference Property SuH_realm_petreturntroll Auto 

GlobalVariable Property SuH_PCSdesire auto
GlobalVariable Property SuH_PCSforce auto
GlobalVariable Property SuH_PCSdesiregain auto
GlobalVariable Property SuH_PCSstacksex auto
GlobalVariable Property SuH_PCSstacksperm auto
GlobalVariable Property SuH_PCSstackmilk auto
GlobalVariable Property SuH_PCSbdsmspecial auto
GlobalVariable Property SuH_SETdesiredrain auto
GlobalVariable Property SuH_SETspecialdeath auto
GlobalVariable Property SuH_SETdesirecap auto
GlobalVariable Property SuH_SETrecoverbleed auto
GlobalVariable Property SuH_CHKsdinact auto
GlobalVariable Property SuH_PETactive auto
GlobalVariable Property SuH_PETactivedog auto
GlobalVariable Property SuH_PETactivewolf auto
GlobalVariable Property SuH_PETactivehorse auto
GlobalVariable Property SuH_PETactiveskeever auto
GlobalVariable Property SuH_PETactivefamiliar auto
GlobalVariable Property SuH_PETactivebear auto
GlobalVariable Property SuH_PETactivesabrecat auto
GlobalVariable Property SuH_PETactivedraugr auto
GlobalVariable Property SuH_PETactivetroll auto
GlobalVariable Property SuH_PETactivespriggan auto
GlobalVariable Property SuH_PETactivehorker auto
GlobalVariable Property SuH_PETactivefalmer auto
GlobalVariable Property SuH_PETdogdesire auto
GlobalVariable Property SuH_PETdoglevel auto
GlobalVariable Property SuH_PETwolfdesire auto
GlobalVariable Property SuH_PETwolflevel auto
GlobalVariable Property SuH_PEThorsedesire auto
GlobalVariable Property SuH_PEThorselevel auto
GlobalVariable Property SuH_PETskeeverdesire auto
GlobalVariable Property SuH_PETskeeverlevel auto
GlobalVariable Property SuH_PETfamiliardesire auto
GlobalVariable Property SuH_PETfamiliarlevel auto
GlobalVariable Property SuH_PETbeardesire auto
GlobalVariable Property SuH_PETbearlevel auto
GlobalVariable Property SuH_PETsabrecatdesire auto
GlobalVariable Property SuH_PETsabrecatlevel auto
GlobalVariable Property SuH_PETdraugrdesire auto
GlobalVariable Property SuH_PETdraugrlevel auto
GlobalVariable Property SuH_PETtrolldesire auto
GlobalVariable Property SuH_PETtrolllevel auto
GlobalVariable Property SuH_PETspriggandesire auto
GlobalVariable Property SuH_PETsprigganlevel auto
GlobalVariable Property SuH_PEThorkerdesire auto
GlobalVariable Property SuH_PEThorkerlevel auto
GlobalVariable Property SuH_PETfalmerdesire auto
GlobalVariable Property SuH_PETfalmerlevel auto
GlobalVariable Property SuH_rank_savingessenceCD auto
GlobalVariable Property SuH_rank_savingessence2 auto
GlobalVariable Property SuH_rank_formalbeauty auto
GlobalVariable Property SuH_rank_formalbeauty2 auto
GlobalVariable Property SuH_rank_regalglow auto
GlobalVariable Property SuH_rank_violenceCD auto

GlobalVariable Property SuH_PETactivehusky auto
GlobalVariable Property SuH_PEThuskydesire auto
GlobalVariable Property SuH_PEThuskylevel auto
GlobalVariable Property SuH_PETactivebristle auto
GlobalVariable Property SuH_PETbristledesire auto
GlobalVariable Property SuH_PETbristlelevel auto
GlobalVariable Property SuH_PETactiveseeker auto
GlobalVariable Property SuH_PETseekerdesire auto
GlobalVariable Property SuH_PETseekerlevel auto
GlobalVariable Property SuH_PETactivegargoyle auto
GlobalVariable Property SuH_PETgargoyledesire auto
GlobalVariable Property SuH_PETgargoylelevel auto
GlobalVariable Property SuH_PETactivenetch auto
GlobalVariable Property SuH_PETnetchdesire auto
GlobalVariable Property SuH_PETnetchlevel auto
GlobalVariable Property SuH_PETactiveriekling auto
GlobalVariable Property SuH_PETrieklingdesire auto
GlobalVariable Property SuH_PETrieklinglevel auto

Actor Property PlayerRef auto
Actor Property SuH_actor_dog auto
Actor Property SuH_actor_wolf auto
Actor Property SuH_actor_horse auto
Actor Property SuH_actor_skeever auto
Actor Property SuH_actor_familiar auto
Actor Property SuH_actor_bear auto
Actor Property SuH_actor_sabrecat auto
Actor Property SuH_actor_draugr auto
Actor Property SuH_actor_troll auto
Actor Property SuH_actor_spriggan auto
Actor Property SuH_actor_horker auto
Actor Property SuH_actor_falmer auto
Actor Property SuH_actor_husky auto
actor property SuH_actor_bristle auto
actor property SuH_actor_seeker auto
actor property SuH_actor_gargoyle auto
actor property SuH_actor_netch auto
actor property SuH_actor_riekling 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
Spell property SuH_sex_inact auto
Armor property SuH_armor_regalglow auto

int drainMessage
int desireDelay
int sdDelay
int petDelay
int sexstackDelay
int spermstackDelay
int milkstackDelay
int savingessenseDelay
int formalbeautyDelay
int violenceDelay
int regalglowarmor

Event OnInit()
	PlayerRef.AddSpell(SuH_dyna_player, FALSE) ; Add dynamic player script
	RegisterForSingleUpdate(5.0) ; Tick in 5 seconds, giving time to initialize other scripts
endEvent

Event OnUpdate()
	dynamicScriptApply()
	deathOverrideCalc()
	desireCalc()
	regalGlowCalc()
	formalBeautyCalc()
	soulPetCalc()
	stackDecay()
	savingEssenseCalc()
	violenceCalc()
	;if SuH_SETrecoverbleed.GetValue()
	;	If PlayerRef.IsBleedingOut() == True
	;		PlayerRef.RestoreAV("Health", 100)
	;	endIf
	;endIf
	RegisterForSingleUpdate(1.0) ; Tick in 1 seconds
endEvent

;Dynamics
function dynamicScriptApply()
	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
endFunction

;Death Override Calculations
function deathOverrideCalc()
	if SuH_CHKsdinact.GetValue() && sdDelay == 0
		PlayerRef.SetNoBleedoutRecovery(true)
		;sdDelay += 1
		;if sdDelay > 3
			_Fun.SDrespawn()
			sdDelay = 0
		;endIf
	elseIf PlayerRef.IsBleedingOut() == True
		if SuH_SETspecialdeath.GetValue()
			SuH_CHKsdinact.SetValue(1)
			PlayerRef.SetNoBleedoutRecovery(true)
			sdDelay += 1
			if sdDelay > 4
				_Fun.SDrespawn()
				sdDelay = 0
			endIf
		endIf
	else
		sdDelay = 0
	endIf
endFunction

;Desire Calculations
function desireCalc()
	desireDelay += 1
	if desireDelay > 4
		float desireV = (SuH_PCSdesiregain.GetValue()) + SuH_PCSdesire.GetValue()
		SuH_PCSdesire.SetValue(desireV)
		if desireV >= SuH_SETdesirecap.GetValue() && SuH_SETdesiredrain.GetValue()
			if drainMessage == 0
				debug.notification("Succubus Heart : Desire has begun to drain status!")
				drainMessage = 1
			endIf
			float h = PlayerRef.GetBaseActorValue("health")
			float m = PlayerRef.GetBaseActorValue("magicka")
			float s = PlayerRef.GetBaseActorValue("stamina")
			float x = 0.0
			if h > 10.0
				PlayerRef.SetActorValue("health", h - 1.0)
				x += 1.0
			endIf
			if m > 10.0
				PlayerRef.SetActorValue("magicka", m - 1.0)
				x += 1.0
			endIf
			if s > 10.0
				PlayerRef.SetActorValue("stamina", s - 1.0)
				x += 1.0
			endIf
			float y = SuH_PCSforce.GetValue()
			SuH_PCSforce.SetValue(y+x)
		endIf
		desireDelay = 0
	endIf
endFunction

;Regal Glow Calculations
function regalGlowCalc()
	int bodySlot = 0x00000004
	Armor bodyArmor = playerRef.GetWornForm(bodySlot) as Armor
	int RGarmor = Math.Floor(2 * SuH_rank_regalglow.GetValue())
	if RGarmor > 0
		if bodyArmor == SuH_armor_regalglow ;Regal Glow Active Already
			if RGarmor != regalglowarmor
				bodyArmor.SetArmorRating(RGarmor)
				playerRef.UnequipItem(SuH_armor_regalglow, abSilent=true)
				playerRef.equipitem(SuH_armor_regalglow, false, true)
				regalglowarmor = RGarmor
			endIf
		elseif (bodyArmor) ;Body Armor Found
			regalglowarmor = 0
		else ;no body armor
			playerRef.equipitem(SuH_armor_regalglow, false, true)
			SuH_armor_regalglow.SetArmorRating(RGarmor)
			playerRef.UnequipItem(SuH_armor_regalglow, abSilent=true)
			playerRef.equipitem(SuH_armor_regalglow, false, true)
			regalglowarmor = RGarmor
		endIf
	endIf
endFunction

;Formal Beauty Calculations
	; Stack Effects
		; Sex Stacks = Health
		; Sperm Stacks = Magicka
		; Milk Stacks = Stamina
function formalBeautyCalc()
	int fb = SuH_rank_formalbeauty.GetValue() as int
	int fb2 = SuH_rank_formalbeauty2.GetValue() as int
	int bdsmspecial = SuH_PCSbdsmspecial.GetValue() as int
	int fbDelay = 30 - (fb2*2)
	if fb > 0
		if formalbeautyDelay > fbDelay
			float multi = 1.0
			if bdsmspecial == 2 ; Boosted by Desire Specialty
				multi = 1.2
			endIf
			int sex = Math.Floor(SuH_PCSstacksex.GetValue() * fb * multi)
			_Fun.STATcalc(playerRef, stat="Health", aEffect=sex)
			int sperm = Math.Floor(SuH_PCSstacksex.GetValue() * fb * multi)
			_Fun.STATcalc(playerRef, stat="Magicka", aEffect=sperm)
			int milk = Math.Floor(SuH_PCSstacksex.GetValue() * fb * multi)
			_Fun.STATcalc(playerRef, stat="Stamina", aEffect=milk)
			formalbeautyDelay = 0
		else
			formalbeautyDelay += 1
		endIf
	endIf
endFunction

;Pet Calculations
function soulPetCalc()
	petDelay += 1
	if petDelay > 4
		int x = SuH_PETactive.GetValue() as int
		If x > 0
			if SuH_PETactivedog.GetValue()	
				int dogd = SuH_PETdogdesire.GetValue() as int
				if SuH_actor_dog.HasSpell(SuH_sex_inact)
				else
					if dogd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_dog.MoveTo(SuH_realm_petreturndog)
						SuH_PETactivedog.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Dog [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_dog.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_dog.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivewolf.GetValue()	
				int wolfd = SuH_PETwolfdesire.GetValue() as int
				if SuH_actor_wolf.HasSpell(SuH_sex_inact)
				else
					if wolfd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_wolf.MoveTo(SuH_realm_petreturnwolf)
						SuH_PETactivewolf.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Wolf [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_wolf.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_wolf.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivehorse.GetValue()	
				int horsed = SuH_PEThorsedesire.GetValue() as int
				if SuH_actor_horse.HasSpell(SuH_sex_inact)
				else
					if horsed < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_horse.MoveTo(SuH_realm_petreturnhorse)
						SuH_PETactivehorse.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Horse [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_horse.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_horse.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactiveskeever.GetValue()	
				int skeeverd = SuH_PETskeeverdesire.GetValue() as int
				if SuH_actor_skeever.HasSpell(SuH_sex_inact)
				else
					if skeeverd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_skeever.MoveTo(SuH_realm_petreturnskeever)
						SuH_PETactiveskeever.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Skeever [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_skeever.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_skeever.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivefamiliar.GetValue()	
				int familiard = SuH_PETfamiliardesire.GetValue() as int
				if SuH_actor_familiar.HasSpell(SuH_sex_inact)
				else
					if familiard < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_familiar.MoveTo(SuH_realm_petreturnfamiliar)
						SuH_PETactivefamiliar.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Flame Familiar [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_familiar.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_familiar.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivebear.GetValue()	
				int beard = SuH_PETbeardesire.GetValue() as int
				if SuH_actor_bear.HasSpell(SuH_sex_inact)
				else
					if beard < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_bear.MoveTo(SuH_realm_petreturnbear)
						SuH_PETactivebear.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Bear [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_bear.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_bear.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivesabrecat.GetValue()	
				int sabrecatd = SuH_PETsabrecatdesire.GetValue() as int
				if SuH_actor_sabrecat.HasSpell(SuH_sex_inact)
				else
					if sabrecatd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_sabrecat.MoveTo(SuH_realm_petreturnsabrecat)
						SuH_PETactivesabrecat.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Sabre Cat [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_sabrecat.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_sabrecat.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivedraugr.GetValue()	
				int draugrd = SuH_PETdraugrdesire.GetValue() as int
				if SuH_actor_draugr.HasSpell(SuH_sex_inact)
				else
					if draugrd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_draugr.MoveTo(SuH_realm_petreturndraugr)
						SuH_PETactivedraugr.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Draugr [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_draugr.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_draugr.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivetroll.GetValue()	
				int trolld = SuH_PETtrolldesire.GetValue() as int
				if SuH_actor_troll.HasSpell(SuH_sex_inact)
				else
					if trolld < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_troll.MoveTo(SuH_realm_petreturntroll)
						SuH_PETactivetroll.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Troll [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_troll.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_troll.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivespriggan.GetValue()	
				int spriggand = SuH_PETspriggandesire.GetValue() as int
				if SuH_actor_spriggan.HasSpell(SuH_sex_inact)
				else
					if spriggand < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_spriggan.MoveTo(SuH_realm_petreturnspriggan)
						SuH_PETactivespriggan.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Spriggan [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_spriggan.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_spriggan.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivehorker.GetValue()	
				int horkerd = SuH_PEThorkerdesire.GetValue() as int
				if SuH_actor_horker.HasSpell(SuH_sex_inact)
				else
					if horkerd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_horker.MoveTo(SuH_realm_petreturnhorker)
						SuH_PETactivehorker.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Horker [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_horker.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_horker.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivefalmer.GetValue()	
				int falmerd = SuH_PETfalmerdesire.GetValue() as int
				if SuH_actor_falmer.HasSpell(SuH_sex_inact)
				else
					if falmerd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_falmer.MoveTo(SuH_realm_petreturnfalmer)
						SuH_PETactivefalmer.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Falmer [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_falmer.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_falmer.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivehusky.GetValue()	
				int huskyd = SuH_PEThuskydesire.GetValue() as int
				if SuH_actor_husky.HasSpell(SuH_sex_inact)
				else
					if huskyd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_husky.MoveTo(SuH_realm_petreturnhusky)
						SuH_PETactivehusky.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("Husky [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_husky.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_husky.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivebristle.GetValue()	
				int bristled = SuH_PETbristledesire.GetValue() as int
				if SuH_actor_bristle.HasSpell(SuH_sex_inact)
				else
					if bristled < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_bristle.MoveTo(SuH_realm_petreturnbristle)
						SuH_PETactivebristle.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("bristle [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_bristle.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_bristle.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactiveseeker.GetValue()	
				int seekerd = SuH_PETseekerdesire.GetValue() as int
				if SuH_actor_seeker.HasSpell(SuH_sex_inact)
				else
					if seekerd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_seeker.MoveTo(SuH_realm_petreturnseeker)
						SuH_PETactiveseeker.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("seeker [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_seeker.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_seeker.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivegargoyle.GetValue()	
				int gargoyled = SuH_PETgargoyledesire.GetValue() as int
				if SuH_actor_gargoyle.HasSpell(SuH_sex_inact)
				else
					if gargoyled < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_gargoyle.MoveTo(SuH_realm_petreturngargoyle)
						SuH_PETactivegargoyle.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("gargoyle [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_gargoyle.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_gargoyle.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactivenetch.GetValue()	
				int netchd = SuH_PETnetchdesire.GetValue() as int
				if SuH_actor_netch.HasSpell(SuH_sex_inact)
				else
					if netchd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_netch.MoveTo(SuH_realm_petreturnnetch)
						SuH_PETactivenetch.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("netch [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_netch.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_netch.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			elseif SuH_PETactiveriekling.GetValue()	
				int rieklingd = SuH_PETrieklingdesire.GetValue() as int
				if SuH_actor_riekling.HasSpell(SuH_sex_inact)
				else
					if rieklingd < 1
						(pDialogueFollower as DialogueFollowerScript).DismissAnimal()
						SuH_actor_riekling.MoveTo(SuH_realm_petreturnriekling)
						SuH_PETactiveriekling.SetValue(0)
						x -= 1
						SuH_PETactive.SetValue(x)
						debug.Notification("riekling [Incubus] has run out of Desire and has returned to the Succubus Realm")
					else
						if (SuH_actor_riekling.GetWorldSpace() != playerRef.GetWorldSpace())
							SuH_actor_riekling.MoveTo(PlayerRef)
						endIf
					endif
				endIf
			endIf
		endIf
		
		int dogd = SuH_PETdogdesire.GetValue() as int
		int wolfd = SuH_PETwolfdesire.GetValue() as int
		int horsed = SuH_PEThorsedesire.GetValue() as int
		int skeeverd = SuH_PETskeeverdesire.GetValue() as int
		int familiard = SuH_PETfamiliardesire.GetValue() as int
		int beard = SuH_PETbeardesire.GetValue() as int
		int sabrecatd = SuH_PETsabrecatdesire.GetValue() as int
		int draugrd = SuH_PETdraugrdesire.GetValue() as int
		int trolld = SuH_PETtrolldesire.GetValue() as int
		int spriggand = SuH_PETspriggandesire.GetValue() as int
		int horkerd = SuH_PEThorkerdesire.GetValue() as int
		int falmerd = SuH_PETfalmerdesire.GetValue() as int
		int huskyd = SuH_PEThuskydesire.GetValue() as int
		int bristled = SuH_PETbristledesire.GetValue() as int
		int seekerd = SuH_PETseekerdesire.GetValue() as int
		int gargoyled = SuH_PETgargoyledesire.GetValue() as int
		int netchd = SuH_PETnetchdesire.GetValue() as int
		int rieklingd = SuH_PETrieklingdesire.GetValue() as int
		
		int dogl = SuH_PETdoglevel.GetValue() as int
		int wolfl = SuH_PETwolflevel.GetValue() as int
		int horsel = SuH_PEThorselevel.GetValue() as int
		int skeeverl = SuH_PETskeeverlevel.GetValue() as int
		int familiarl = SuH_PETfamiliarlevel.GetValue() as int
		int bearl = SuH_PETbearlevel.GetValue() as int
		int sabrecatl = SuH_PETsabrecatlevel.GetValue() as int
		int draugrl = SuH_PETdraugrlevel.GetValue() as int
		int trolll = SuH_PETtrolllevel.GetValue() as int
		int sprigganl = SuH_PETsprigganlevel.GetValue() as int
		int horkerl = SuH_PEThorkerlevel.GetValue() as int
		int falmerl = SuH_PETfalmerlevel.GetValue() as int
		int huskyl = SuH_PEThuskylevel.GetValue() as int
		int bristlel = SuH_PETbristlelevel.GetValue() as int
		int seekerl = SuH_PETseekerlevel.GetValue() as int
		int gargoylel = SuH_PETgargoylelevel.GetValue() as int
		int netchl = SuH_PETnetchlevel.GetValue() as int
		int rieklingl = SuH_PETrieklinglevel.GetValue() as int
		
		int dogc = (100*dogl)+100
		int wolfc = (100*wolfl)+100
		int horsec = (100*horsel)+100
		int skeeverc = (100*skeeverl)+100
		int familiarc = (100*familiarl)+100
		int bearc = (100*bearl)+100
		int sabrecatc = (100*sabrecatl)+100
		int draugrc = (100*draugrl)+100
		int trollc = (100*trolll)+100
		int sprigganc = (100*sprigganl)+100
		int horkerc = (100*horkerl)+100
		int falmerc = (100*falmerl)+100
		int huskyc = (100*huskyl)+100
		int bristlec = (100*bristlel)+100
		int seekerc = (100*seekerl)+100
		int gargoylec = (100*gargoylel)+100
		int netchc = (100*netchl)+100
		int rieklingc = (100*rieklingl)+100
		
		if dogd <= dogc
			SuH_PETdogdesire.SetValue(dogd + 1)
		endIf
		if wolfd <= wolfc
			SuH_PETwolfdesire.SetValue(wolfd + 1)
		endIf
		if horsed <= horsec
			SuH_PEThorsedesire.SetValue(horsed + 1)
		endIf
		if skeeverd <= skeeverc
			SuH_PETskeeverdesire.SetValue(skeeverd + 1)
		endIf
		if familiard <= familiarc
			SuH_PETfamiliardesire.SetValue(familiard + 1)
		endIf
		if beard <= bearc
			SuH_PETbeardesire.SetValue(beard + 1)
		endIf
		if sabrecatd <= sabrecatc
			SuH_PETsabrecatdesire.SetValue(sabrecatd + 1)
		endIf
		if draugrd <= draugrc
			SuH_PETdraugrdesire.SetValue(draugrd + 1)
		endIf
		if trolld <= trollc
			SuH_PETtrolldesire.SetValue(trolld + 1)
		endIf
		if spriggand <= sprigganc
			SuH_PETspriggandesire.SetValue(spriggand + 1)
		endIf
		if horkerd <= horkerc
			SuH_PEThorkerdesire.SetValue(horkerd + 1)
		endIf
		if falmerd <= falmerc
			SuH_PETfalmerdesire.SetValue(falmerd + 1)
		endIf
		if huskyd <= huskyc
			SuH_PEThuskydesire.SetValue(huskyd + 1)
		endIf
		if bristled <= bristlec
			SuH_PETbristledesire.SetValue(bristled + 1)
		endIf
		if seekerd <= seekerc
			SuH_PETseekerdesire.SetValue(seekerd + 1)
		endIf
		if gargoyled <= gargoylec
			SuH_PETgargoyledesire.SetValue(gargoyled + 1)
		endIf
		if netchd <= netchc
			SuH_PETnetchdesire.SetValue(netchd + 1)
		endIf
		if rieklingd <= rieklingc
			SuH_PETrieklingdesire.SetValue(rieklingd + 1)
		endIf
	petDelay = 0
	endIf
endFunction

;Stack Decay Function
function stackDecay()
	sexstackDelay += 1
	if sexstackDelay > 299
		int cstack = SuH_PCSstacksex.GetValue() as int
		if cstack > 0
			SuH_PCSstacksex.SetValue(cstack - 1)
		endIf
		sexstackDelay = 0
	endIf
	spermstackDelay += 1
	if spermstackDelay > 59
		int cstack = SuH_PCSstacksperm.GetValue() as int
		if cstack > 0
			SuH_PCSstacksperm.SetValue(cstack - 1)
		endIf
		spermstackDelay = 0
	endIf
	milkstackDelay += 1
	if milkstackDelay > 59
		int cstack = SuH_PCSstackmilk.GetValue() as int
		if cstack > 0
			SuH_PCSstackmilk.SetValue(cstack - 1)
		endIf
		milkstackDelay = 0
	endIf
endFunction

;Saving Essence Function
function savingEssenseCalc()
	int se = SuH_rank_savingessenceCD.GetValue() as int
	int ser2 = Math.Floor(1200 - (SuH_rank_savingessence2.GetValue()*60 ))
	if se > 0
		savingessenseDelay += 1
		if savingessenseDelay > ser2
			SuH_rank_savingessenceCD.SetValue(0)
			debug.Notification("Saving Essence can activate again.")
			savingessenseDelay = 0
		endIf
	else
		savingessenseDelay = 0
	endIf
endFunction

;Violence Function
function violenceCalc()
	int se = SuH_rank_violenceCD.GetValue() as int
	if se > 0
		violenceDelay += 1
		if violenceDelay > 4
			SuH_rank_violenceCD.SetValue(0)
			violenceDelay = 0
		endIf
	else
		violenceDelay = 0
	endIf
endFunction