Scriptname SuH_Fun extends Quest  

SuH_Status property _s auto
Actor property PlayerRef auto
DialogueFollowerScript Property DialogueFollower Auto
Quest Property pDialogueFollower  Auto
;ent/ Script Variables
int trackConfirm
int trackValue
string trackString
actor seducedNPC
string seducedType
;end/
;ent/ OnInit
Event OnInit()
	InitProperties()
endEvent
;end/
;ent/ Init Properties
Function InitProperties()
	_s = Game.GetFormFromFile(0x16E496, "Succubus Heart.esp") as SuH_Status
	PlayerRef = _s.PlayerRef
	DialogueFollower = _s.DialogueFollower
	pDialogueFollower = _s.pDialogueFollower
endFunction
;end/

;ent/ Tracking
Function trackSet(int trackCost, string trackName)
	trackValue = trackCost
	trackString = trackName
	trackConfirm = 1
endFunction
;end/
;ent/ Perk
		;Perk List
			;orgasm = Have Orgasm +12 BDSM
			;absorb = Absorb status in a sex act +1% XP Gain
			;sperm/milk = Consume sperm/milk +5 Health Cap
			;x Saving Essence = Trigger Saving Essence +5 Health/Stamina Cap
Function perkcalc(string perkName, int value=0)
	if perkName == "orgasm"
		_s.SuH_perk_orgasm += 1
		int y = Math.Floor((((_s.SuH_perk_orgasml * 0.3) * 200) * 0.2) + 5)
		if _s.SuH_perk_orgasm > y
			_s.SuH_PCScapstamina += 2
			_s.SuH_PCScapstaminaitem += 2
			_s.SuH_perk_orgasml += 1
			debug.Notification("Succubus Heart : 'Have Orgasm' Perk Level-up! +2 Stamina Cap")
		endIf
	elseif perkName == "absorb"
		_s.SuH_perk_absorb += 1
		int y = Math.Floor((((_s.SuH_perk_absorbl * 0.35) * 800) * 0.3) + 20)
		if _s.SuH_perk_absorb > y
			_s.SuH_PCScapmagicka += 2
			_s.SuH_PCScapmagickaitem += 2
			_s.SuH_perk_absorbl += 1
			debug.Notification("Succubus Heart : 'Absorb Status' Perk Level-up! +2 Magicka Cap")
		endIf
	elseif perkName == "sperm"
		_s.SuH_perk_sperm += 1
		int y = Math.Floor((((_s.SuH_perk_sperml * 0.3) * 400) * 0.22) + 10)
		if _s.SuH_perk_sperm > y
			_s.SuH_PCSxp += 500
			_s.SuH_perk_sperml += 1
			debug.Notification("Succubus Heart : 'Consume Sperm' Perk Level-up! +500 HeartXP")
		endIf
	elseif perkName == "milk"
		_s.SuH_perk_milk += 1
		int y = Math.Floor((((_s.SuH_perk_milkl * 0.3) * 400) * 0.22) + 10)
		if _s.SuH_perk_milk > y
			_s.SuH_PCSxp += 500
			_s.SuH_perk_milkl += 1
			debug.Notification("Succubus Heart : 'Consume Milk' Perk Level-up! +500 HeartXP")
		endIf
	elseif perkName == "allyorgasm"
		_s.SuH_perk_allyorgasm += 1
		int y = Math.Floor((((_s.SuH_perk_allyorgasml * 0.3) * 140) * 0.18) + 5)
		if _s.SuH_perk_allyorgasm > y
			_s.SuH_PCSxp += 1000
			_s.SuH_perk_allyorgasml += 1
			debug.Notification("Succubus Heart : 'Bring Ally To Orgasm' Perk Level-up! +1000 HeartXP")
		endIf
	elseif perkName == "killdrain"
		_s.SuH_perk_killdrain += 1
		int y = Math.Floor((((_s.SuH_perk_killdrainl * 0.3) * 140) * 0.14) + 3)
		if _s.SuH_perk_killdrain > y
			_s.SuH_PCScaphealth += 2
			_s.SuH_PCScaphealthitem += 2
			_s.SuH_perk_killdrainl += 1
			debug.Notification("Succubus Heart : 'Drain Them To Death' Perk Level-up! +2 Health Cap")
		endIf
	endIf
endFunction
;end/
;ent/ Passive Reset
Function PassiveReset(int freereset=0)
	int passiveresetcost = Math.Floor(500 * _s.playerRef.GetLevel())
	if freereset != 0 || _s.SuH_SETfreepassivereset
		passiveresetcost = 0
	endIf
	if _s.SuH_PCSxp >= passiveresetcost
		_s.SuH_PCSxp -= passiveresetcost
		_s.SuH_PCSbpoint = Math.Floor((_s.SuH_PCScaphealth - 100)+((_s.SuH_PCSabsorbhealth - 1)*5)+((_s.SuH_PCSspermhealth - 1)*2)+((_s.SuH_PCSmilkhealth - 1)*2)+(_s.SuH_rank_bdsm * 5))
		_s.SuH_PCSdpoint = Math.Floor(((_s.SuH_PCSstackmaxsex+_s.SuH_PCSstackmaxsperm+_s.SuH_PCSstackmaxmilk+(_s.SuH_PCSxpgain- 100) - 3)*5)+(_s.SuH_rank_bdsm * 5))
		_s.SuH_PCSspoint = Math.Floor((_s.SuH_PCScapstamina - 100)+((_s.SuH_PCSabsorbstamina - 1)*5)+((_s.SuH_PCSspermstamina - 1)*2)+((_s.SuH_PCSmilkstamina - 1)*2)+(_s.SuH_rank_bdsm * 5))
		_s.SuH_PCSmpoint = Math.Floor((_s.SuH_PCScapmagicka - 100)+((_s.SuH_PCSabsorbmagicka - 1)*5)+((_s.SuH_PCSspermmagicka - 1)*2)+((_s.SuH_PCSmilkmagicka - 1)*2)+(_s.SuH_rank_bdsm * 5))
		_s.SuH_PCSbdsm = (_s.SuH_PCSbpoint+_s.SuH_PCSdpoint+_s.SuH_PCSspoint+_s.SuH_PCSmpoint)
		_s.SuH_rank_masochist = 0
		_s.SuH_rank_masochist2 = 0
		_s.SuH_rank_perfectorgasm = 0
		_s.SuH_rank_perfectorgasm2 = 0
		_s.SuH_rank_giftedconsent = 0
		_s.SuH_rank_lusciousliquids = 0
		_s.SuH_rank_lusciousliquids2 = 0
		_s.SuH_rank_forcemaster = 0
		_s.SuH_rank_savingessence = 0
		_s.SuH_rank_savingessence2 = 0
		_s.SuH_rank_valuestacker = 0
		_s.SuH_rank_selfstacker = 0
		_s.SuH_rank_deviouspartner = 0
		_s.SuH_rank_deviouspartner2 = 0
		_s.SuH_rank_regalglow = 0
		_s.SuH_rank_formalbeauty = 0
		_s.SuH_rank_formalbeauty2 = 0
		_s.SuH_rank_violence = 0
		_s.SuH_rank_violence2 = 0
		_s.SuH_rank_violence3 = 0
		_s.SuH_rank_seducer = 0
		_s.SuH_rank_healthyabsorber = 0
		_s.SuH_PCScaphealthdown = 0
		_s.SuH_PCScapmagickadown = 0
		_s.SuH_PCScapstaminadown = 0
		_s.playerRef.UnequipItem(_s.SuH_armor_regalglow, abSilent=true)
		debug.MessageBox("Passives have been reset to Level 0 and BDSM Rating has been re-calculated.")
	else
		
	endIf
endFunction
;end/
;ent/ Make Essential
Function INVact(actor char)
	int charG = _s.SexLab.GetGender(char)
	if char.GetActorBase().IsEssential()
		;do nothing
	elseif charG == 0
		if _s.SuH_SETinvactmale > 0
			char.AddSpell(_s.SuH_CHAinvact)
			char.GetActorBase().SetEssential(true)
		endIf
	elseif charG == 1
		if _s.SuH_SETinvactfemale > 0
			char.AddSpell(_s.SuH_CHAinvact)
			char.GetActorBase().SetEssential(true)
		endIf
	elseif charG == 2
		if _s.SuH_SETinvactmalecreature > 0
			char.AddSpell(_s.SuH_CHAinvact)
			char.GetActorBase().SetEssential(true)
		endIf
	elseif charG == 3
		if _s.SuH_SETinvactfemalecreature > 0
			char.AddSpell(_s.SuH_CHAinvact)
			char.GetActorBase().SetEssential(true)
		endIf
	endIf
endFunction
;end/
;ent/ Set Seduced / apply seduction cost
		;charNPC : Set the reference/target actor
		;actType : Set aggressive or consent
		; setNPC : 0=proc effect 1=setting npc for future use
Function seducedNPCSet(actor charNPC, string actType, int setNPC)
	if setNPC == 1
		seducedNPC = charNPC
		seducedType = actType
	elseif setNPC == 0
		if seducedNPC == charNPC && seducedNPC != _s.PlayerRef
			if seducedType == actType
				int seducecost = Math.Floor(90 - (_s.SuH_rank_seducer*10))
				if seducecost > 0
					int phealth = _s.PlayerRef.GetBaseActorValue("Health") as int
					int pmagicka = _s.PlayerRef.GetBaseActorValue("Magicka") as int
					int pstamina = _s.PlayerRef.GetBaseActorValue("Stamina") as int
					int nphealth = Math.Floor(phealth - (phealth * (seducecost * 0.01)))
					int npmagicka = Math.Floor(pmagicka - (pmagicka * (seducecost * 0.01)))
					int npstamina = Math.Floor(pstamina - (pstamina * (seducecost * 0.01)))
					_s.PlayerRef.SetActorValue("health", nphealth)
					_s.PlayerRef.SetActorValue("magicka", npmagicka)
					_s.PlayerRef.SetActorValue("stamina", npstamina)
				endIf
			else
				seducedNPC = _s.PlayerRef
			endIf
		else
			seducedNPC = _s.PlayerRef
		endIf
	endIf
endFunction
;end/
;ent/ XPcalc : Calculate XP gained
		; *aPreset : Defines defaults for common actions
		; *aMOD : Active Modifier that adds to XPgain percentage
		; *XPearn : Set XP earned (aPreset overwrites this value) 0=use default
		; *lvlS : Level Scaling, Bonus XP earned per-level [lvlS * playerLevel]
Function XPcalc(string aPreset="none", float aMOD=0.0, int XPearn=0, float lvlS=0.0) 
	If aPreset != "none"
		if aPreset == "PCmastery" ; Mastery Sex Act (Player as aggressor)
			int desireCost = Math.Floor(_s.SuH_PCSdesire * 0.05)
			_s.SuH_PCSdesire -= desireCost
			XPearn = (XPearn + desireCost + _s.SuH_PCSxpearn)
			aMOD = 0.2
			lvlS = 5.0
		elseIf aPreset == "PCtraining" ; Consent Sex Act (Player with consent)
			int desireCost = Math.Floor(_s.SuH_PCSdesire * 0.05)
			_s.SuH_PCSdesire -= desireCost
			XPearn = (XPearn + desireCost + _s.SuH_PCSxpearn)
			aMOD = 0.0
			lvlS = 5.0
		elseIf aPreset == "PCsubmit" ; Submit Sex Act (Player as victim)
			int desireCost = Math.Floor(_s.SuH_PCSdesire * 0.05)
			_s.SuH_PCSdesire -= desireCost
			XPearn = (XPearn + desireCost + _s.SuH_PCSxpearn)
			aMOD = -0.2
			lvlS = 5.0
		elseIf aPreset == "PCsperm" ; Consume Sperm
			aMOD = 0.0
			XPearn = (XPearn + _s.SuH_PCSxpearn)
			lvlS = 5.0
		elseIf aPreset == "PCmilk" ; Consume Milk
			aMOD = 0.0
			XPearn = (XPearn + _s.SuH_PCSxpearn)
			lvlS = 5.0
		elseIf aPreset == "PCorgasm"
			aMOD = 0.0
			lvlS = 0.0
			int desireCost = Math.Floor(_s.SuH_PCSdesire * 0.8)
			_s.SuH_PCSdesire -= desireCost
			XPearn = (XPearn + desireCost + _s.SuH_PCSxpearn)
		else
			debug.trace("SuH ERROR : XPcalc aPreset was invalid", 2)
		endIf
	endIf
		if XPearn == 0
			XPearn = _s.SuH_PCSxpearn
		endIf
		float eMOD = aMOD + (_s.SuH_PCSxpgain*0.01)
		float effectMulti = _s.SuH_PCSeffectmulti
		int PClevel = PlayerRef.GetLevel()
		int x = Math.Floor(((XPearn+(PClevel*lvlS))*(eMOD*effectMulti)))
		int z = x+_s.SuH_PCSxp
		If z < 2000000000 || z > -1
			_s.SuH_PCSxp += x
		elseif z > 2000000000
			_s.SuH_PCSxp = 2000000000
		endIf
		if trackConfirm == 1
			if z > trackValue
				debug.Notification(trackString+" can now be increased!")
				trackConfirm = 0
			endIf
		endIf
endFunction
;end/
;ent/ STATcalc : Calculate Absorption
	; eChar : effected Character
	; *aPreset : defaults for common values [PCmastery PCtraining PCsubmit PCsperm PCmilk]
	; *Stat : Stat to effect "All"=health/magicka/stamina "Health" "Magicka" "Stamina"
	; *aMOD : Active Modifier, Percentage added to the effect
	; *aEffect : Override default absorption values [set to anything that isn't 0.0 to ignore Absorption Stats]
Function STATcalc(Actor eChar, string aPreset="none",string stat="All", float aMOD=0.0,float aEffect=0.0)
		If aPreset != "none"
			if aPreset == "PCmastery" ; Mastery Sex Act
				aMOD = 0.2
				aEffect = 0.0
				perkcalc("absorb")
			elseif aPreset == "PCtraining" ; Consent Sex Act
				aMOD = 0.0
				aEffect = 0.0
				perkcalc("absorb")
			elseif aPreset == "PCsubmit" ; Submit Sex Act
				aMOD = -0.2
				aEffect = 0
				perkcalc("absorb")
			elseif aPreset == "PCsperm" ; Consume Sperm
				aMOD = 0.0
				aEffect = 0.0
				perkcalc("sperm")
			elseif aPreset == "PCmilk" ; Consume Milk
				aMOD = 0.0
				aEffect = 0.0
				perkcalc("milk")
			else
				debug.trace("SuH ERROR : STATcalc aPreset was invalid", 2)
			endIf
		endIf
		if eChar == PlayerRef ; if character is the player
			; Absorb Heal Rate (Recovery per-drained point, defaults to 1.0 [100%])
			float perkabsorbheal = (1.0 + (_s.SuH_rank_healthyabsorber *0.25))
			if Stat == "All" || Stat == "Health" ; Earn Health 
				float effectMulti = _s.SuH_PCSeffectmulti
				float eMOD = (1.0+aMOD)*effectMulti ; Set Multiplier
				float cS = eChar.GetBaseActorValue("health") ; Get Base Stat
				float cScap = 0
				if _s.SuH_ORcaphealth > 0
					cScap = _s.SuH_ORcaphealth
				else
					int plvl = PlayerRef.GetLevel() as int
					cScap = Math.Floor((_s.SuH_PCScaphealth+(plvl*4)) - _s.SuH_PCScaphealthdown) ; Get Stat Cap
				endIf
				float k = 0.0 ; Set-up Absorption Variable
				if aEffect == 0 ; if aEffect is set to default
					if aPreset == "PCsperm" ; Check if preset is PCsperm
						k = _s.SuH_PCSspermhealth ; set to default
					elseIf aPreset == "PCmilk" ; Check if preset is PCmilk
						k = _s.SuH_PCSmilkhealth ; set to default
					else ; Set to general absorption stat
						if _s.SuH_ORabsorbhealth > 0
							k = _s.SuH_ORabsorbhealth
						else
							k = _s.SuH_PCSabsorbhealth
						endIf
					endIf
				else ; If aEffect isn't default
					k = aEffect ; Set absorption calculation to k
				endIf
				if cS >= cScap ; Check if Stat is capped
					int x = Math.Floor(k*eMOD) ; Find total absorption
					_s.playerRef.RestoreActorValue("Health", x * perkabsorbheal)
					if _s.playerRef.GetActorValue("Health") >= cScap
						_s.SuH_PCSforce += x ; Set Force
					endIf
				else ; If stat wasn't capped
					int x = Math.Floor(k*eMOD) ; Find total absorption
					int y = Math.Floor(x+cS) ; Find result stat
					_s.playerRef.RestoreActorValue("Health", x * perkabsorbheal)
					if y <= cScap ; If result is below cap
						eChar.SetActorValue("health", y) ; Set Stat
					else ; If result was above cap
						eChar.SetActorValue("health", cScap) ; Set Stat to cap
						int j = Math.Floor(x-cScap) ; Find absorbed value
						if _s.playerRef.GetActorValue("Health") >= cScap
							_s.SuH_PCSforce += y ; Set Force
						endIf
					endIf
				endIf
			endIf
			if Stat == "All" || Stat == "Magicka" ; Earn Magicka
				float effectMulti = _s.SuH_PCSeffectmulti
				float eMOD = (1.0+aMOD)*effectMulti
				float cS = eChar.GetBaseActorValue("magicka")
				float cScap = 0
				if _s.SuH_ORcapmagicka > 0
					cScap = _s.SuH_ORcapmagicka
				else
					int plvl = _s.PlayerRef.GetLevel()
					cScap = Math.Floor((_s.SuH_PCScapmagicka+(plvl*3)) - _s.SuH_PCScapmagickadown) ; Get Stat Cap
				endIf
				float k = 0.0
				if aEffect == 0
					if aPreset == "PCsperm"
						k = _s.SuH_PCSspermmagicka
					elseIf aPreset == "PCmilk"
						k = _s.SuH_PCSmilkmagicka
					else
						if _s.SuH_ORabsorbmagicka > 0
							k = _s.SuH_ORabsorbmagicka
						else
							k = _s.SuH_PCSabsorbmagicka
						endIf
					endIf
				else
					k = aEffect
				endIf
				if cS >= cScap
					int x = Math.Floor(k*eMOD)
					_s.playerRef.RestoreActorValue("magicka", x * perkabsorbheal)
						if _s.playerRef.GetActorValue("Magicka") >= cScap
							_s.SuH_PCSforce += x
						endIf
				else
					int x = Math.Floor(k*eMOD)
					int y = Math.Floor(x+cS)
					if y <= cScap
						eChar.SetActorValue("magicka", y)
					else
						eChar.SetActorValue("magicka", cScap)
						int j = Math.Floor(x-cScap)
						if _s.playerRef.GetActorValue("Magicka") >= cScap
							_s.SuH_PCSforce += y
						endIf
					endIf
					playerRef.RestoreActorValue("magicka", x * perkabsorbheal)
				endIf
			endIf
			if Stat == "All" || Stat == "Stamina" ; Earn Stamina
				float effectMulti = _s.SuH_PCSeffectmulti
				float eMOD = (1.0+aMOD)*effectMulti
				float cS = eChar.GetBaseActorValue("Stamina")
				float cScap = 0
				if _s.SuH_ORcapstamina > 0
					cScap = _s.SuH_ORcapstamina
				else
					int plvl = PlayerRef.GetLevel() as int
					cScap = Math.Floor((_s.SuH_PCScapstamina+(plvl*3)) - _s.SuH_PCScapstaminadown) ; Get Stat Cap
				endIf
				float k = 0
				if aEffect == 0
					if aPreset == "PCsperm"
						k = _s.SuH_PCSspermstamina
					elseIf aPreset == "PCmilk"
						k = _s.SuH_PCSmilkstamina
					else
						if _s.SuH_ORabsorbstamina > 0
							k = _s.SuH_ORabsorbstamina
						else
							k = _s.SuH_PCSabsorbstamina
						endIf
					endIf
				else
					k = aEffect
				endIf
				if cS >= cScap
					int x = Math.Floor(k*eMOD)
					playerRef.RestoreActorValue("stamina", x)
						if playerRef.GetActorValue("Stamina") >= cScap
							_s.SuH_PCSforce += x
						endIf
				else
					int x = Math.Floor(k*eMOD)
					int y = Math.Floor(x+cS)
					playerRef.RestoreActorValue("stamina", x * perkabsorbheal)
					if y <= cScap
						eChar.SetActorValue("stamina", y)
					else
						eChar.SetActorValue("stamina", cScap)
						int j = Math.Floor(x-cScap)
						if playerRef.GetActorValue("Stamina") >= cScap
							_s.SuH_PCSforce += y
						endIf
					endIf
				endIf
			endIf
		elseif _s.SuH_SETnpcabsorb ; if character isn't the player
			int confirmdrain = 0
			if eChar.GetFactionRank(_s.CurrentFollowerFaction) >= 0
				if _s.SuH_SETdrainally
					confirmdrain = 1
				else
					confirmdrain = 0
				endIf
			else
				confirmdrain = 1
			endIf				
			if confirmdrain == 1
				if Stat == "All" || Stat == "Health"
					if aEffect == 0
						if _s.SuH_ORabsorbhealth > 0
							aEffect = _s.SuH_ORabsorbhealth
						else
							aEffect = _s.SuH_PCSabsorbhealth
						endIf
					endIf
					float effectMulti = _s.SuH_PCSeffectmulti
					float eMOD = (1.0+aMOD)*effectMulti
					float cS = eChar.GetBaseActorValue("health")
					int x = Math.Floor(aEffect*eMOD)
					if x >= cS
						eChar.SetActorValue("health",0)
					else
						int y = Math.Floor(cS-x)
						eChar.SetActorValue("health",y)
					endIf
				endIf
				if Stat == "All" || Stat == "Magicka"
					if aEffect == 0
						if _s.SuH_ORabsorbmagicka > 0
							aEffect = _s.SuH_ORabsorbmagicka
						else
							aEffect = _s.SuH_PCSabsorbmagicka
						endIf
					endIf
					float effectMulti = _s.SuH_PCSeffectmulti
					float eMOD = (1.0+aMOD)*effectMulti
					float cS = eChar.GetBaseActorValue("magicka")
					int x = Math.Floor(aEffect*eMOD)
					if x >= cS
						eChar.SetActorValue("magicka",0)
					else
						int y = Math.Floor(cS-x)
						eChar.SetActorValue("magicka",y)
					endIf
				endIf
				if Stat == "All" || Stat == "Stamina"
					if aEffect == 0
						if _s.SuH_ORabsorbstamina > 0
							aEffect = _s.SuH_ORabsorbstamina
						else
							aEffect = _s.SuH_PCSabsorbstamina
						endIf
					endIf
					float effectMulti = _s.SuH_PCSeffectmulti
					float eMOD = (1.0+aMOD)*effectMulti
					float cS = eChar.GetBaseActorValue("stamina")
					int x = Math.Floor(aEffect*eMOD)
					if x >= cS
						eChar.SetActorValue("stamina",0)
					else
						int y = Math.Floor(cS-x)
						eChar.SetActorValue("stamina",y)
					endIf
				endIf
			endIf
		endIf
endFunction
;end/
;ent/ BDSMcalc : Add BDSM Rating... easily
	; BDSMtype : Which value to increase [b d s m]
	; value : Value to add
Function BDSMcalc(string BDSMtype, int value)
	if BDSMtype == "b"
		_s.SuH_PCSbpoint += value
		_s.SuH_PCSbdsm += value
	elseif BDSMtype == "d"
		_s.SuH_PCSdpoint += value
		_s.SuH_PCSbdsm += value
	elseif BDSMtype == "s"
		_s.SuH_PCSspoint += value
		_s.SuH_PCSbdsm += value
	elseif BDSMtype == "m"
		_s.SuH_PCSmpoint += value
		_s.SuH_PCSbdsm += value
	endIf			
endFunction
;end/
;ent/ ANIMcalc : Calculate animations to start using Succubus Heart's variables
	; sentActor : Actors to animate [only supports an array of 1-2 actors]
	; *victimActor : Set victim Actor, and flags act as aggressive [defaults to no victim]
Function ANIMcalc(actor[] sentActor, actor victimActor=none)
	if sentActor.Length == 2
		actor a0 = sentActor[0]
		actor a1 = sentActor[1]
		int a0g = _s.SexLab.GetGender(a0)
		int a1g = _s.SexLab.GetGender(a1)
		if a0g == 1 ; 0 female
			if a1g == 0 ; 1 male
				bool a0v = True
				bool a1v = True
				if a0.HasSpell(_s.SuH_sex_inact)
					a0v = false
				else
					a0v = _s.SexLab.IsValidActor(a0)
				endIf
				if a1.HasSpell(_s.SuH_sex_inact)
					a1v = false
				else
					a1v = _s.SexLab.IsValidActor(a1)
				endIf
				if a0v == TRUE && a1v == TRUE ; if valid
					actor[] animActor = new actor[2]
					animActor[0] = a0
					animActor[1] = a1
					if victimActor != none ; if aggressive
						if victimActor == a0 ; if female victim
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
						else ; if male victim
							if _s.SuH_SETrestrictact > 0
								sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"Cowgirl", "Lesbian", requireAll=true)
								_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
							else
								sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
								_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
							endIf
						endIf
					else ; if non-aggressive
						sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
						_s.SexLab.StartSex(animActor, animSET)
					endIf
				endIf
			elseIf a1g == 2 ; 1 male creature
				bool a0v = True
				bool a1v = True
				if a0.HasSpell(_s.SuH_sex_inact)
					a0v = false
				else
					a0v = _s.SexLab.IsValidActor(a0)
				endIf
				if a1.HasSpell(_s.SuH_sex_inact)
					a1v = false
				else
					a1v = _s.SexLab.IsValidActor(a1)
				endIf
				if a0v == TRUE && a1v == TRUE ; if valid
					actor[] animActor = new actor[2]
					animActor[0] = a0
					animActor[1] = a1
					if victimActor != none ; if aggressive
						sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "", requireAll=true)
						_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
					else ; if non-aggressive
						sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "", requireAll=true)
						_s.SexLab.StartSex(animActor, animSET)
					endIf
				endIf
			elseif _s.SuH_SETallowfemalehomo > 0
				if a1g == 1 ; 1 female
					bool a0v = True
					bool a1v = True
					if a0.HasSpell(_s.SuH_sex_inact)
						a0v = false
					else
						a0v = _s.SexLab.IsValidActor(a0)
					endIf
					if a1.HasSpell(_s.SuH_sex_inact)
						a1v = false
					else
						a1v = _s.SexLab.IsValidActor(a1)
					endIf
					if a0v == TRUE && a1v == TRUE ; if valid
						actor[] animActor = new actor[2]
						animActor[0] = a0
						animActor[1] = a1
						if victimActor != none ; if aggressive
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"Lesbian", "", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
						else ; if non-aggressive
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET)
						endIf
					endIf
				elseIf a1g == 3 ; 1 female creature
					bool a0v = True
					bool a1v = True
					if a0.HasSpell(_s.SuH_sex_inact)
						a0v = false
					else
						a0v = _s.SexLab.IsValidActor(a0)
					endIf
					if a1.HasSpell(_s.SuH_sex_inact)
						a1v = false
					else
						a1v = _s.SexLab.IsValidActor(a1)
					endIf
					if a0v == TRUE && a1v == TRUE ; if valid
						actor[] animActor = new actor[2]
						animActor[0] = a0
						animActor[1] = a1
						if victimActor != none ; if aggressive
							if _s.SuH_SETrestrictact > 0
								sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"Cowgirl", "Lesbian", requireAll=true)
								_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
							else
								sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
								_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
							endIf
						else ; if non-aggressive
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET)
						endIf
					endIf
				endIf
			endIf
		elseIf a0g == 0 ; 0 male
			if a1g == 1 ; 1 female
					bool a0v = True
					bool a1v = True
					if a0.HasSpell(_s.SuH_sex_inact)
						a0v = false
					else
						a0v = _s.SexLab.IsValidActor(a0)
					endIf
					if a1.HasSpell(_s.SuH_sex_inact)
						a1v = false
					else
						a1v = _s.SexLab.IsValidActor(a1)
					endIf
				if a0v == TRUE && a1v == TRUE ; if valid
					actor[] animActor = new actor[2]
					animActor[0] = a1
					animActor[1] = a0
					if victimActor != none ; if aggressive
							if victimActor == a1 ; if female victim
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
						else ; if male attacker
							if _s.SuH_SETrestrictact > 0
								sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"Cowgirl", "Lesbian", requireAll=true)
								_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
							else
								sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
								_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
							endIf
						endIf
					else ; if non-aggressive
						sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
						_s.SexLab.StartSex(animActor, animSET)
					endIf
				endIf
			elseif a1g == 3 ; 1 female creature
					bool a0v = True
					bool a1v = True
					if a0.HasSpell(_s.SuH_sex_inact)
						a0v = false
					else
						a0v = _s.SexLab.IsValidActor(a0)
					endIf
					if a1.HasSpell(_s.SuH_sex_inact)
						a1v = false
					else
						a1v = _s.SexLab.IsValidActor(a1)
					endIf
				if a0v == TRUE && a1v == TRUE ; if valid
					actor[] animActor = new actor[2]
					animActor[0] = a1
					animActor[1] = a0
					if victimActor != none ; if aggressive
						sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "", requireAll=true)
						_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
					else ; if non-aggressive
						sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
						_s.SexLab.StartSex(animActor, animSET)
					endIf
				endIf
			elseIf _s.SuH_SETallowmalehomo > 0
				if a1g == 0 ; 1 male
					bool a0v = True
					bool a1v = True
					if a0.HasSpell(_s.SuH_sex_inact)
						a0v = false
					else
						a0v = _s.SexLab.IsValidActor(a0)
					endIf
					if a1.HasSpell(_s.SuH_sex_inact)
						a1v = false
					else
						a1v = _s.SexLab.IsValidActor(a1)
					endIf
					if a0v == TRUE && a1v == TRUE ; if valid
						actor[] animActor = new actor[2]
						animActor[0] = a1
						animActor[1] = a0
						if victimActor != none ; if aggressive
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
						else ; if non-aggressive
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET)
						endIf
					endIf
				elseif a1g == 2 ; male creature
					bool a0v = True
					bool a1v = True
					if a0.HasSpell(_s.SuH_sex_inact)
						a0v = false
					else
						a0v = _s.SexLab.IsValidActor(a0)
					endIf
					if a1.HasSpell(_s.SuH_sex_inact)
						a1v = false
					else
						a1v = _s.SexLab.IsValidActor(a1)
					endIf
					if a0v == TRUE && a1v == TRUE ; if valid
						actor[] animActor = new actor[2]
						animActor[0] = a1
						animActor[1] = a0
						if victimActor != none ; if aggressive
							if _s.SuH_SETrestrictact > 0
								sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"Cowgirl", "Lesbian", requireAll=true)
								_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
							else
								sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
								_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
							endIf
						else ; if non-aggressive
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET)
						endIf
					endIf
				endIf
			endIf
		elseIf a0g == 2 ; 0 male creature
			if a1g == 1 ; 1 female
					bool a0v = True
					bool a1v = True
					if a0.HasSpell(_s.SuH_sex_inact)
						a0v = false
					else
						a0v = _s.SexLab.IsValidActor(a0)
					endIf
					if a1.HasSpell(_s.SuH_sex_inact)
						a1v = false
					else
						a1v = _s.SexLab.IsValidActor(a1)
					endIf
				if a0v == TRUE && a1v == TRUE ; if valid
					actor[] animActor = new actor[2]
					animActor[0] = a1
					animActor[1] = a0
					if victimActor != none ; if aggressive
						sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "", requireAll=true)
						_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
					else ; if non-aggressive
						sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
						_s.SexLab.StartSex(animActor, animSET)
					endIf
				endIf
			elseIf _s.SuH_SETallowmalehomo > 0
				if a1g == 0 ; 1 male
					bool a0v = True
					bool a1v = True
					if a0.HasSpell(_s.SuH_sex_inact)
						a0v = false
					else
						a0v = _s.SexLab.IsValidActor(a0)
					endIf
					if a1.HasSpell(_s.SuH_sex_inact)
						a1v = false
					else
						a1v = _s.SexLab.IsValidActor(a1)
					endIf
					if a0v == TRUE && a1v == TRUE ; if valid
						actor[] animActor = new actor[2]
						animActor[0] = a1
						animActor[1] = a0
						if victimActor != none ; if aggressive
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
						else ; if non-aggressive
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET)
						endIf
					endIf
				endIf
			endIf
		elseIf a0g == 3 ; 0 female creature
			if a1g == 0 ; 1 male
					bool a0v = True
					bool a1v = True
					if a0.HasSpell(_s.SuH_sex_inact)
						a0v = false
					else
						a0v = _s.SexLab.IsValidActor(a0)
					endIf
					if a1.HasSpell(_s.SuH_sex_inact)
						a1v = false
					else
						a1v = _s.SexLab.IsValidActor(a1)
					endIf
				if a0v == TRUE && a1v == TRUE ; if valid
					actor[] animActor = new actor[2]
					animActor[0] = a0
					animActor[1] = a1
					if victimActor != none ; if aggressive
						sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "", requireAll=true)
						_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
					else ; if non-aggressive
						sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
						_s.SexLab.StartSex(animActor, animSET)
					endIf
				endIf
			elseIf _s.SuH_SETallowfemalehomo > 0
				if a1g == 1 ; 1 female
					bool a0v = True
					bool a1v = True
					if a0.HasSpell(_s.SuH_sex_inact)
						a0v = false
					else
						a0v = _s.SexLab.IsValidActor(a0)
					endIf
					if a1.HasSpell(_s.SuH_sex_inact)
						a1v = false
					else
						a1v = _s.SexLab.IsValidActor(a1)
					endIf
					if a0v == TRUE && a1v == TRUE ; if valid
						actor[] animActor = new actor[2]
						animActor[0] = a0
						animActor[1] = a1
						if victimActor != none ; if aggressive
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET, victim=victimActor)
						else ; if non-aggressive
							sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByTags(2,"", "Lesbian", requireAll=true)
							_s.SexLab.StartSex(animActor, animSET)
						endIf
					endIf
				endIf
			endIf
		endIf
		if a0 == playerRef || a1 == playerRef
			_s.SuH_CHKcsprocessing = 0
		endIf
	elseif sentActor.Length == 1
		bool c0valid = _s.SexLab.IsValidActor(sentActor[0])
		if c0valid == TRUE ; If actor is valid
			int c0g = _s.SexLab.GetGender(sentActor[0])
			if c0g == 1 ;female
				sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByType(1, 0, 1)
				_s.SexLab.StartSex(sentActor, animSET)
			elseif c0g == 0 ;male
				sslBaseAnimation[] animSET = _s.SexLab.GetAnimationsByType(1, 1, 0)
				_s.SexLab.StartSex(sentActor, animSET)
			endIf
		endIf
	endIf
endFunction
;end/
;ent/ Death Override
Function SDrespawn()
	bool notinact = _s.SexLab.IsValidActor(playerRef)
	if notinact == True
			_s.SuH_CHKsdinact = 0
			_s.SuH_CHKdied = 1
			PlayerRef.SetNoBleedoutRecovery(false)
			float cstat = (playerRef.GetActorValue("Health") / playerRef.GetBaseActorValue("Health")) * playerRef.GetBaseActorValue("Health")
			float statrec =(PlayerRef.GetBaseActorValue("Health") * 0.3) - cstat
			if statrec > 0
				playerRef.RestoreActorValue("Health", statrec)
			else
				playerRef.DamageActorValue("Health", statrec)
			endIf
			cstat = (playerRef.GetActorValue("Magicka") / playerRef.GetBaseActorValue("Magicka")) * playerRef.GetBaseActorValue("Magicka")
			statrec = (PlayerRef.GetBaseActorValue("Magicka") * 0.3) - cstat
			if statrec > 0
				playerRef.RestoreActorValue("Magicka", statrec)
			else
				playerRef.DamageActorValue("Magicka", statrec)
			endIf
			cstat = (playerRef.GetActorValue("Stamina") / playerRef.GetBaseActorValue("Stamina")) * playerRef.GetBaseActorValue("Stamina")
			statrec = (PlayerRef.GetBaseActorValue("Stamina") * 0.3) - cstat
			if statrec > 0
				playerRef.RestoreActorValue("Stamina", statrec)
			else
				playerRef.DamageActorValue("Stamina", statrec)
			endIf
			_s.SuH_sd_returnpoint.MoveTo(PlayerRef)
			PlayerRef.MoveTo(_s.SuH_sevaspawn)
			_s.SuH_sd_lostchest.RemoveItem(_s.Gold001, 999999)
			if _s.SuH_SETsdloseequip > 0
				;Destroy Equipped
				Form leftHand = PlayerRef.GetEquippedObject(0)
				Form rightHand = PlayerRef.GetEquippedObject(1)
				if (leftHand)
					PlayerRef.RemoveItem(leftHand, 1, true, _s.SuH_sd_goldchest)
				endIf
				if (rightHand)
					PlayerRef.RemoveItem(rightHand, 1, true, _s.SuH_sd_goldchest)
				endIf
				int slotsChecked
				slotsChecked += 0x00100000
				slotsChecked += 0x00200000 ;ignore reserved slots
				slotsChecked += 0x80000000
				int thisSlot = 0x01
				while (thisSlot < 0x80000000)
					if(Math.LogicalAnd(slotsChecked, thisSlot) != thisSlot) ;Only check un-checked lots
						Armor thisArmor = PlayerRef.GetWornForm(thisSlot) as Armor
						if (thisArmor)
							slotsChecked += thisArmor.GetSlotMask() ;add slots to slotsChecked
							PlayerRef.RemoveItem(thisArmor, 1, true, _s.SuH_sd_goldchest)
						else ; No armor found
							slotsChecked += thisSlot
						endIf
					endIf
					thisSlot *= 2;double number and move to the next slot
				endWhile
			endIf
			if _s.SuH_SETsdloseitems > 0
				if _s.SuH_SETsdlosegold > 0
					PlayerRef.RemoveItem(_s.Gold001, 999999, true)
					PlayerRef.RemoveAllItems(_s.SuH_sd_lostchest, true)
				else
					PlayerRef.RemoveItem(_s.Gold001, 999999, true, _s.SuH_sd_goldchest)
					PlayerRef.RemoveAllItems(_s.SuH_sd_lostchest, true)
					_s.SuH_sd_goldchest.RemoveItem(_s.Gold001, 999999, true, PlayerRef)
				endIf
			elseif _s.SuH_SETsdlosegold
				PlayerRef.RemoveItem(_s.Gold001, 999999, true)
			endIf
		PlayerRef.SetNoBleedoutRecovery(true)
	else
		_s.SuH_CHKsdinact = 4
	endIf
endFunction
;end/
;ent/ Pet SumXP
Function PetSumXP(int xpgain=0)
	if xpgain <= 0
		xpgain = 5
	endIf
	_s.SuH_petskillxp += xpgain
	int xpcost = Math.Floor((_s.SuH_petskill * 1.8) * 40 + 20)
	if _s.SuH_petskillxp >= xpcost
		_s.SuH_petskillxp -= xpcost
		_s.SuH_petskill += 1
		Debug.Notification("Soul Pets : Skill Level Increased!")
	endIf
endFunction
;end/
;ent/ PetXP
Function PetXP(int petslot, int xpgain=0)
	if xpgain <= 0
		xpgain = 5
	endIf
	xpgain = Math.Floor(xpgain * ((_s.SuH_petskill * 0.1) + 1))
	_s.SuH_petxps[petslot] = _s.SuH_petxps[petslot] + xpgain
	int xpcost = Math.Floor((_s.SuH_petlevels[petslot] * 2) * 30 + 20)
	if  _s.SuH_petxps[petslot] >= xpcost
		_s.SuH_petxps[petslot] = (_s.SuH_petxps[petslot] + xpgain) - xpcost
		_s.SuH_petlevels[petslot] = (_s.SuH_petlevels[petslot] + 1)
		PetSumXP((1 + (_s.SuH_petlevels[petslot] * 2)))
		Debug.Notification("Soul Pets : Pet Level Increased!")
	endIf
endFunction
;end/
;ent/ Pet Death
Function PetDeath(int petslot)
	;int x = petslot
	;if x == _s.SuH_petactive
	;	SoulPetDeSummon()
	;endIf
	SoulPetRemove(petslot)
endFunction
;end/
;ent/ SoulPetPosition
Function SoulPetPosition()
	if _s.SuH_actor_activepet != none
		if _s.SuH_actor_activepet.HasSpell(_s.SuH_sex_inact)
		elseif (_s.SuH_actor_activepet.GetWorldSpace() != playerRef.GetWorldSpace())
			_s.SuH_actor_activepet.MoveTo(PlayerRef)
		endIf
	endIf
endFunction
;end/
;ent/ SoulPetAdd
Function SoulPetAdd(Actor repactor, bool bccost=false)
	if repactor.IsInFaction(_s.SuH_petfaction)
		Debug.MessageBox(": Soul Pets : \n Character is already registered as a pet!")
	elseif repactor.IsInFaction(_s.CurrentFollowerFaction)
		Debug.MessageBox(": Soul Pets : \n Followers can't be registered as a pet.")
	elseif repactor.IsInFaction(_s.PlayerPotentialAnimalFaction)
		Debug.MessageBox(": Soul Pets : \n Followers can't be registered as a pet.")
	else
		ActorBase makepetbase = repactor.GetActorBase()
		if makepetbase.IsUnique()
			Debug.MessageBox(": Soul Pets : \n Unique NPCs can't be registered as a pet.")
		else
			int k = 0
			int x = 0
			while k == 0
				if x > 24
					k = 1
				elseif makepetbase != _s.SuH_petactorbases[x]
					x += 1
				else
					k = 2
				endIf
			endWhile
			if k == 1
				int i = 0
				x = 0
				While i == 0
					if _s.SuH_petactorbases[x] == none
						bool createpet = true
						if bccost == true
							if PlayerRef.GetItemCount(_s.SuH_misc_bloodchip) < 50
								createpet = false
								Debug.MessageBox(": Soul Pets : \n Not Enough Blood Chips")
							else
								PlayerRef.RemoveItem(_s.SuH_misc_bloodchip, 50)
							endIf
						endIf
						if createpet == true
							_s.SuH_petactorbases[x] = makepetbase
							_s.SuH_petlevels[x] = 0
							_s.SuH_petxps[x] = 0
							_s.SuH_peteffects[x] = 0
							_s.SuH_petstrengths[x] = 0
							int y = (x + 1)
							string petname = makepetbase.GetName()
							Debug.MessageBox(": Soul Pets : \n "+petname+" Soul Replicated into slot "+y+".")
						endIf
						i = 1
					else
						x += 1
					endIf
					if x > 24
						Debug.MessageBox(": Soul Pets : \n No available slots found!")
						i = 1
					endIf
				endWhile
				_s.SuH_petactorbases
			else
				Debug.MessageBox(": Soul Pets : \n Soul of this type already registered!")
			endIf
		endIf
	endIf
endFunction
;end/
;ent/ SoulPetRemove
Function SoulPetRemove(int petslot)
	if _s.SuH_petactorbases[petslot] != none || _s.SuH_petlevels[petslot] > 0
		if petslot == _s.SuH_petactive
			SoulPetDeSummon()
		endIf
		string petname = _s.SuH_petactorbases[petslot].GetName()
		int x = (_s.SuH_petlevels[petslot] * 5)
		PlayerRef.AddItem(_s.SuH_misc_bloodchip, x, true)
		_s.SuH_petactorbases[petslot] = none
		_s.SuH_petxps[petslot] = 0
		_s.SuH_petlevels[petslot] = 0
		_s.SuH_peteffects[petslot] = 0
		_s.SuH_petstrengths[petslot] = 0
		Debug.MessageBox(": Soul Pets : \n "+petname+" Pet Removed! "+x+" Blood Chips Harvested.")
	endIf
endFunction
;end/
;ent/ SoulPetDeSummon
Function SoulPetDeSummon(int slotnum=-1)
	debug.Notification("Desum called")
	if _s.SuH_actor_activepet != none
		string petname = _s.SuH_actor_activepet.GetBaseObject().GetName()
		;(pDialogueFollower as DialogueFollowerScript).DismissFollower()
		_s.SuH_actor_activepet.RemoveAllItems(PlayerRef, false, true)
		_s.SuH_actor_activepet.MoveTo(_s.SuH_realm_petinitspawn)
		_s.SuH_actor_activepet.Disable()
		_s.SuH_actor_activepet.Delete()
		_s.SuH_actor_activepet = none
		_s.SuH_petactive = -1
		Debug.Notification("Soul Pets : "+petname+" has been returned.")
	endIf
endFunction
;end/
;ent/ SoulPetSummon
Function SoulPetSummon(int slotnum=-1, ActorBase petbase=none)
	int slottosummon = -1
	if slotnum >= 0 && slotnum < 25 ; Use Slot Number
		if slotnum < 25 && _s.SuH_petactorbases[slotnum] != none
			slottosummon = slotnum
		endIf
	elseif petbase != none ; Use ActorBase
		int i = 0
		while i < 25
			if petbase == _s.SuH_petactorbases[i]
				slottosummon = i
				i = 25
			endIf
			i += 1
		endWhile
	endIf
	if slottosummon >= 0
		if _s.SuH_actor_activepet != none
			SoulPetDeSummon()
		endIf
		_s.SuH_petactive = slottosummon
		int levelmod = 4
		if _s.SuH_petlevels[slottosummon] < 3
			levelmod = 0
		elseif _s.SuH_petlevels[slottosummon] < 8
			levelmod = 1
		elseif _s.SuH_petlevels[slottosummon] < 15
			levelmod = 2
		elseif _s.SuH_petlevels[slottosummon] < 25
			levelmod = 3
		endIf
		_s.SuH_actor_activepet = _s.SuH_realm_petinitspawn.PlaceActorAtMe(_s.SuH_petactorbases[slottosummon], levelmod)
		_s.SuH_actor_activepet.RemoveFromAllFactions()
		_s.SuH_actor_activepet.RemoveAllItems()
		_s.SuH_actor_activepet.AddToFaction(_s.CurrentFollowerFaction)
		_s.SuH_actor_activepet.SetFactionRank(_s.CurrentFollowerFaction, -1)
		_s.SuH_actor_activepet.AddToFaction(_s.PotentialFollowerFaction)
		_s.SuH_actor_activepet.AddToFaction(_s.SuH_petfaction)
		_s.SuH_actor_activepet.AddSpell(_s.SuH_spell_pet)
		_s.SuH_actor_activepet.MoveTo(PlayerRef)
		(pDialogueFollower as DialogueFollowerScript).SetFollower(_s.SuH_actor_activepet)
		string petname = _s.SuH_actor_activepet.GetBaseObject().GetName()
		Debug.Notification("Soul Pets : "+petname+" has been summoned.")
	endIf
endFunction
;end/ 
;ent/ Forge Set Analysis
Function ForgeAnaCalc(string itemtype,form itemtoana)
	if itemtype == "Misc"
		
	endif
endFunction
;end/
;ent/ Forge Item
Function ForgeItemCalc()
	
endFunction
;end/