Scriptname aHHChestMimicScript extends ObjectReference  

Event OnActivate(ObjectReference akActionRef)
	if akactionref == playerref
		debug.notification("The chest is raping you!")
		MimicPlayer()
	EndIf
EndEvent

Function MimicPlayer()
		bool success = aHHInvokeEstrusEffect(Game.GetPlayer(), 2, 0, 0)
		if (!success)
			int sslid = 0
			actor[] sexActors = new actor[1]   ;its an 2 actor anim
			sexActors[0] = Game.GetPlayer()
			sslBaseAnimation[] anims = SL.GetAnimationsByTags(1, "double") 
			RegisterForModEvent("AnimationEnd_AFS", "AFS")   ;this is for hooks.
			sslid = SL.StartSex(sexActors, anims, victim = playerref, allowbed=false, hook="AFS")
			if sslid < 0
				debug.notification("Failed to start animation:" + sslid)
				sslid = SL.StartSex(sexActors, anims, allowbed=false, hook="AFS")
			endif
			if sslid < 0
				debug.notification("Failed to start animation again:" + sslid)
				debug.notification("Sorry, animation failed")
			endif
		endif
EndFunction

;;
;; EffectType : 2:Estrus Self
;; AnimType ::  0:random, 1:Estrus Tentacle, 2:Estrus Etc, 3:Estrus Machine
;;
bool function aHHInvokeEstrusEffect(Actor akTarget, Int EffectType = 1, Int AnimType = 0, Int AnimPattern = 0)

	ObjectReference zzEstrusMarker = game.GetFormFromFile(0x01016c51, "zzEstrus.esp") as ObjectReference
	if (zzEstrusMarker == none)
		return false
	endif
	Spell zzEstrusEffectForAPI = game.GetFormFromFile(0x010166e6, "zzEstrus.esp") as spell
	Spell zzEstrusEffectSelfForAPI = game.GetFormFromFile(0x01016c55, "zzEstrus.esp") as spell
	Spell zzEstrusUndressForAPI = game.GetFormFromFile(0x01016c56, "zzEstrus.esp") as spell
	Miscobject zzEstrusToken = game.GetFormFromFile(0x01012b95, "zzEstrus.esp") as Miscobject
	Actor rPlayer = Game.GetForm(0x14) as Actor
	Spell rAPI;

	if(akTarget.getItemCount(zzEstrusToken) > 0)
		akTarget.SetAnimationVariableInt("EstrusStop",1);
		return false
	EndIf

	akTarget.SetAnimationVariableInt("EstrusType",AnimType);
	akTarget.SetAnimationVariableInt("EstrusSet" ,AnimPattern);
	
	if(EffectType == 1)
		rAPI = zzEstrusEffectForAPI
	elseIf(EffectType == 2)
		rAPI = zzEstrusEffectSelfForAPI
	elseif(EffectType == 3)
		rAPI = zzEstrusUndressForAPI
	else
		return false
	EndIf

	zzEstrusMarker.MoveTo(akTarget)
	if((EffectType == 1 && akTarget != rPlayer) || (EffectType == 2 && akTarget == rPlayer))
		rAPI.cast(zzEstrusMarker,akTarget)
		Utility.wait(2)
	Elseif(EffectType == 0)
		rAPI.cast(zzEstrusMarker,akTarget)
		Utility.wait(2)
	Else
		return false
	EndIf
	
	akTarget.SetAnimationVariableInt("EstrusType",0);
	akTarget.SetAnimationVariableInt("EstrusSet" ,0);
	akTarget.SetAnimationVariableInt("EstrusStop",0);
	
	return true
EndFunction

Actor akactionRef
Actor property Playerref auto
SexLabFramework Property SL  Auto 