Jump to content

Sexlab Animation blocking behavior in scripts


Recommended Posts

Folks, doing a bit of tinkering with sexlab on my mod and basically I want the following script fragment to execute

    sslBaseAnimation[] anims = SexLab.GetAnimationsByTag(2, "Anal", "Aggressive")


    SexLab.StartSex(sexActors, anims, sexActors[0], allowbed=false)
    getowningquest().setstage(90)

What I want to happen: Sexlab will kick off the sex, after the sex is finished it will then set the quest stage to 90.

 

What is currently happening: Sexlab kicks off the sex and immediately sets the quest stage to 90

 

How can I set it so that I can get the behavior I want - as I understanding sexlab kicks off a new thread and proceeds asynchronously while it returns to my script fragment and continues to execute. I guess what I want to do is pause until sexlab is able to - total guesswork here - tell me when the scene is finished and then to execute the rest of the script

 

How can I get my script to wait until the sex scene has finished before moving onto the next line of code. Potentially what I will want to do is in a single script.

 

Is anyone able to give me any pointers on how I can get this done. Just as a foreword I haven't tinkered with asyncronous scripts in the CK or understand many advanced concepts with papyrus yet so a basic explanation/code snippet or a link would be just as helpful as a full answer to get what I need. Reference Pseudocode below

;PSEUDOCODE
StartSex() ; with one set of animations
StartSex() ; with another set of anims AFTER the previous animations/sexscenes have finished playing
StartSex() ; with a THIRD sexlab scene AFTER the previous one has finished
SetQuestStage(90);after the previous scene has finished
Link to comment

You need to register for sexlab events.

Better if you use sslThreadController and not the quick StartSex()

 

And then you will set your stage when the animation is ended, inside the Event function you attach to the Hook of the ThreadController.

Link to comment

Was able to work through a solution with CPU, massive massive thanks.

 

Here's the working script for code discovery sake including debug test messageboxes when animations end.

 

The below code is put into my Quest Script where I have the dialog/sex scenes

Function do3SexActs(Actor[] Positions)
  doSexAct(Positions, "sgsAnimEnd1", "Anal")
EndFunction


event sgsAnimEnd1(int tid, bool hasPlayer)
 Debug.messagebox("AnimEnd1")
  sslThreadController tc = SexLab.GetController(tid)
tc.RemoveHook("SGSFuckTraining")
  UnRegisterForModEvent("HookAnimationEnding_SGSFuckTraining")
  Actor[] Positions = tc.Positions
  ; Start the second anim
  doSexAct(Positions, "sgsAnimEnd2", "Vaginal")
endEvent


event sgsAnimEnd2(int tid, bool hasPlayer)
 Debug.messagebox("AnimEnd2")
  sslThreadController tc = SexLab.GetController(tid)
  tc.RemoveHook("SGSFuckTraining")
  UnRegisterForModEvent("HookAnimationEnding_SGSFuckTraining")
  Actor[] Positions = tc.Positions
  ; Start the third anim
  doSexAct(Positions, "sgsAnimEnd3", "Dirty")
endEvent


event sgsAnimEnd3(int tid, bool hasPlayer)
 Debug.messagebox("AnimEnd3")
  sslThreadController tc = SexLab.GetController(tid)
  UnRegisterForModEvent("HookAnimationEnding_SGSFuckTraining")
  tc.RemoveHook("SGSFuckTraining")
  SGSSlaveTrainingQuest.setstage(90)
endEvent


Function doSexAct(Actor[] Positions, String stageEvent, String animTags)
utility.wait(1.5)
  sslThreadController tc = None
  sslThreadModel t = SexLab.NewThread()
  if t
    if t.AddActor(Positions[0]) != -1 && t.AddActor(Positions[1]) != -1
      RegisterForModEvent("HookAnimationEnding_SGSFuckTraining", stageEvent)
      t.SetHook("SGSFuckTraining")
      sslBaseAnimation[] anims = SexLab.GetAnimationsByTag(2, animTags, "Aggressive")
      t.SetForcedAnimations(anims)
      t.DisableBedUse(true)
      tc = t.StartThread()
      if !tc
        debug.trace("SGS: error in starting the animation")
      endIf
    else
      debug.trace("SGS: error in adding the actors")
    endIf
  else
    debug.trace("SGS: error in claiming a SexLab Thread")
  endIf
EndFunction 
   In the Dialog where I am calling the sexlab from I have the following Quest Fragment including properties where the portion of code in between the begin code and end code are just a normal papyrus fragment with a reference to Sexlab and my SlaveTrainingQuest Script
 
;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 4
Scriptname SGS_TIF__0801020F Extends TopicInfo Hidden


;BEGIN FRAGMENT Fragment_3
Function Fragment_3(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
actor[] sexActors = new actor[2]
  sexActors[0] = game.getPlayer()
  sexActors[1] = Alias_Raina.getref() as actor
  sgsmq.do3SexActs(sexActors)
;END CODE
EndFunction
;END FRAGMENT


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


SexLabFramework Property SexLab  Auto  


ReferenceAlias Property Alias_Raina  Auto  
SGS_QF_SGSSlaveTrainingQuest_08010126 Property sgsmq Auto
Huge thanks for the help. Hope this helps someone else looking for how to implement blocking sexlab scripts
 
 
 
Link to comment

Archived

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

  • Recently Browsing   0 members

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