Jump to content

Help understanding hooks


Recommended Posts

Posted

I'm having a hard time figuring out how to use hooks, especially with the GitHub tutorial down, and I'm still not getting it through the documentation in the psc hook section. Is there a more comprehensive tutorial on how to use these correctly?

 

I don't actually need much in the way of complexity at the moment. I'm trying to register for AnimationStart and AnimationEnd hooks. I just want to detect whether any given animation that starts within my trigger volume contains either a victim or an actor with a certain perk. At the moment, I have the following:

ScriptName _SexMagic_RitualHandler extends ObjectReference
;goes on trigger volume

SexLabFramework Property SexLab auto
_SexMagic_Ritual_Resources Property Ritual auto
Perk Property UnwillingPerk auto

		
Event OnTriggerEnter(ObjectReference akActionRef)

	If akActionRef == Game.GetPlayer()
		Ritual.IsInRitualChamber = True
		RegisterForModEvent("AnimationStart", "RapeStart")
	EndIf
EndEvent

Event OnTriggerLeave(ObjectReference akActionRef)
	If akActionRef == Game.GetPlayer()
		UnregisterForModEvent("AnimationStart")
		Ritual.IsInRitualChamber = False
		Ritual.RitualInProgress = False
		Ritual.TurnOnRitualLights(False)
		Ritual.TurnOnCandleLights(True)
	EndIf
EndEvent

Event RapeStart(Int tid, Bool HasPlayer)
	Debug.Notification("RapeStart event")
    sslThreadController Thread = SexLab.GetController(tid)
	Actor[] Positions = Thread.Positions
	Actor[] Victims 
	
	Bool HasVictim = False
	Int iIndex = 0
	While iIndex < Positions.Length
		If SexLab.IsVictim(tid, Positions[iIndex]) || Positions[iIndex].HasPerk(UnwillingPerk)
			HasVictim = True
			Debug.Notification("Victim detected: " + Positions[iIndex].GetActorBase().GetName())
		EndIf
		iIndex += 1
	EndWhile
	
	If HasVictim
		If !Ritual.RitualInProgress
			Ritual.RitualInProgress = True
			Ritual.TurnOnRitualLights(True)
			Ritual.TurnOnCandleLights(False)
			Debug.Notification("Ritual Started")
		EndIf
	EndIf
	
EndEvent
 

The event simply doesn't fire. Please help me figure out what I'm doing wrong. And if there's a more detailed explanation than the psc (preferably with examples), please link me to it. Thanks!

 

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...