Jump to content

Can't get AnimationEnd hook event to work


Recommended Posts

Posted

Hello, I'm hoping someone can help me. I'm kind of a novice to Papyrus scripting so I might be overlooking something simple, but I've been at this for a couple days on and off and nothing I try seems to work.

 

I'm trying to create a mod with a bard named Jasmine who can put on a sex performance with another NPC when the player requests it. Basically she has a dialogue option to request a performance, which then starts a brief scene where she says a couple lines of dialogue for the audience before starting the sex with the partner NPC. The player is not involved in the actual sex scene.

 

I've managed to get it working up to that point just fine. Basically the dialogue runs a quick script that enables the partner NPC and moves him to her position, then the scene has a couple lines of dialogue, the last one runs a fragment that calls the JasmineScene01 function to start, which is what actually handles the sex.

 

The problem I'm having is that I want to then run a bit of cleanup once the sex ends by disabling the partner NPC again. I'm trying to use the AnimationEnd hook as documented in the Sexlab Framework, but I cannot get the resulting event to fire. Right now I'm just trying to debug it by having a message box pop up to confirm it's working. The sex scene between Jasmine and the partner NPC starts without any problems, but once the animation finishes, no message box at all. I can't figure out why. Here's the script I have:

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname JasmineScene01Script Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
JasmineScene01()
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

ReferenceAlias Property Jasmine01  Auto  

ReferenceAlias Property JasminePartner01  Auto  

SexLabFramework Property SexLab  Auto

Function JasmineScene01()
	SexLab.TrackActor(Jasmine01.GetActorReference(), "JasmineScene01Hook")
	RegisterForModEvent("HookAnimationEnd_JasmineScene01Hook", "DisableJasminePartnerEvent")
	SexLab.QuickStart(Jasmine01.GetActorReference(), JasminePartner01.GetActorReference(), none, none, none, none, "JasmineScene01Hook", "")
EndFunction

Event DisableJasminePartnerEvent()
	Debug.MessageBox("The animation has ended.")
EndEvent

 

Posted
9 minutes ago, Kaloshnikovaskii said:
DisableJasminePartnerEvent(string eventName, string strArg, float numArg, form sender)

 

 

Two issues here:

 

1) In my experience with this, you actually need to list the follow-on info for a receive mod event.  You can add debug info to make sure it is receiving.

 

2) the real problem is that you need something to receive that will be active when the sexlab event ends.  A TopicInfo won't do it; the script unregisters for the event when it closes out (end of the dialogue).  Needs to be something that hangs around like a quest or activemagiceffect.  Generally this would be a quest since you can monitor it from console easily enough.

Posted
23 hours ago, Seijin8 said:

 

Two issues here:

 

1) In my experience with this, you actually need to list the follow-on info for a receive mod event.  You can add debug info to make sure it is receiving.

 

2) the real problem is that you need something to receive that will be active when the sexlab event ends.  A TopicInfo won't do it; the script unregisters for the event when it closes out (end of the dialogue).  Needs to be something that hangs around like a quest or activemagiceffect.  Generally this would be a quest since you can monitor it from console easily enough.

 

That makes a lot of sense, seems like a silly mistake in hindsight. I figured calling the function in the same script as the dialogue that started it would make sense, but I didn't realize that the script closed out once the dialogue was finished. I moved the functions over to the quest's main script and that seems to have fixed it, everything is working properly now as far as I can tell. I was able to get the message box to pop up in my initial test, and I've updated it so it now properly disables the partner actor when the scene finishes.

 

I don't quite understand what that follow-on info you included in the parentheses does, why is that necessary for it to work? What do those variables do? Sorry if that's a novice question, I'm still learning how this stuff works.

 

Thank you for the help, it's much appreciated.

Posted
15 hours ago, Kaloshnikovaskii said:

I don't quite understand what that follow-on info you included in the parentheses does, why is that necessary for it to work? What do those variables do?

 

The variables just align with incoming data to make sure it syncs up (I think).  You can use them for specific things, such as monitoring which sexlab thread sent the event (sendmodevent sends it to everything that is set to receive; if two things might send during the same scene, need to have a way to differentiate which is which, so that data can help).

 

Largely, the data is variable to whatever you want.  A lot of times, I'll use the "strArg" to name a variable for why it is being sent:

  • For a fluid controller, might be "add", "reduce", "cleanup", etc
  • For a sex start event, this might be a string list of tags to look for

I usually use "numArg" to ID either the actor the event is being sent to, or the thread from which it is being sent.  That way if multiple scripts receive the event, they can look to see if it is meant for them and ignore it if not.

Archived

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

  • Recently Browsing   0 members

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