Bratty Cheeks - RMCW Posted September 13, 2020 Posted September 13, 2020 NO LONGER NEED HELP BUT SEE MY POST BELOW IF YOU ARE HAVING TROUBLE WITH NPC ORGASM DETECTION. I have been writing a script today to detect partner orgasm during consensual sex scenes using SexLab. I just can't work out why my callback event is not working, or how to debug it. I found the comments in SexLabFramework.psc and followed instructions. Here is an abstract of my code: RegisterForModEvent("PartnersTrack_Orgasm", "OnPartnerOrgasm") ; THIS RUNS AND I HAVE CHECKED IN MCM THAT IT EXECUTES ============================ SexLab.TrackActor(Actors[actors_i], "PartnersTrack") ; THIS RUNS FINE AND I HAVE A SEPERATE LOOP TO UNTRACK ACTOR WHEN NOT NEEDED ALSO WORKING FINE ============================ Event OnPartnerOrgasm(Form FormRef, int tid) PrintConsole("DSL: Detected "+(FormRef as Actor).GetDisplayname()+" orgasm.") LoseSkills(dslConfig.PartnerOrgasmSkillsGained, "partnerOrgasm") EndEvent ; THIS DOESN'T RUN ON ORGASM FOR SOME REASON ============================ As you can see above, my problem is that OnPartnerOrgasm never executes. It did on one test but I have no idea why. I have no errors in Papyrus logs. I'm going to have another crack at it tomorrow but if anyone can help that would be awesome.
Pamatronic Posted September 13, 2020 Posted September 13, 2020 Probably a parameter mismatch? assuming you are using the generic modevent, rather than a self-defined, the engine would expect the this: For the modevent Call: Form.SendModEvent(string eventName, string strArg, float numArg) / yellow being optionals and the callback Event would have to look like this: Event OnPartnerOrgasm(string eventName, string strArg, float numArg, Form sender) ;Do Stuff EndEvent
Bratty Cheeks - RMCW Posted September 13, 2020 Author Posted September 13, 2020 5 hours ago, Pamatronic said: Probably a parameter mismatch? assuming you are using the generic modevent, rather than a self-defined, the engine would expect the this: For the modevent Call: Form.SendModEvent(string eventName, string strArg, float numArg) / yellow being optionals and the callback Event would have to look like this: Event OnPartnerOrgasm(string eventName, string strArg, float numArg, Form sender) ;Do Stuff EndEvent Nah, thanks though. The mod event is supposed to be sent by SexLab but it wouldn't work for whatever reason. Fortunately SexLab also provides a non-hook event which works fine for me. If anyone else has same issue see below SexLabFramework.psc: ;# SexLabOrgasm - Sent when an actor has an orgasm. The parameters of the event are: the actor, the enjoyment, and the num of orgasms # You can use this as such: RegisterForModEvent("SexLabOrgasm", "OnSexLabOrgasm") ; Where "OnSexLabOrgasm" is your event. event OnSexLabOrgasm(Form FormRef, int enjoyment, int number_of_orgasms) ;Debug.MessageBox((FormRef as Actor).GetDisplayname() + " had orgasm. Total orgasms: " + number_of_orgasms + ". Enjoyment: " + enjoyment) sslThreadController Thread = SexLab.GetActorController(FormRef as Actor) if Thread == SexLab.GetPlayerController() ;Detected orgasm in player scene. else ;Detected orgasm but player isn't in scene, returning. return endif if playerRef == FormRef as Actor ;Detected player orgasm else ;Detected another actor in player scene orgasm endif endevent
Seijin8 Posted September 13, 2020 Posted September 13, 2020 7 minutes ago, RMCW said: if playerRef == FormRef as Actor ;Detected player orgasm endif ;Detected another actor in player scene orgasm endif endevent should be else
Bratty Cheeks - RMCW Posted September 13, 2020 Author Posted September 13, 2020 1 hour ago, Seijin8 said: should be else Thanks updated the example
Ashal Posted September 20, 2020 Posted September 20, 2020 On 9/12/2020 at 10:06 PM, RMCW said: SexLab.TrackActor(Actors[actors_i], "PartnersTrack") ; THIS RUNS FINE AND I HAVE A SEPERATE LOOP TO UNTRACK ACTOR WHEN NOT NEEDED ALSO WORKING FINE As a suggested possibility as to why TrackActor() is failing. You have to start tracking the actor BEFORE a scene is setup. Once an animation scene is setup, as part of the startup process it caches whether or not the actor is tracked. So if TrackActor() is called on an active scene, it's to late as sexlab has already done it's checks for whether or not the actor should be sending tracked events or not. That's my best guess as to why it's failing in any case. Without seeing the full code it's hard to say more. Also as a side note. If you only care about the player in this case, the player is ALWAYS set to be tracked with a special "PlayerTrack_<Hook>" event. RegisterForModEvent("PlayerTrack_Orgasm", "OnPlayerOrgasm") event OnPlayerOrgasm(Form FormRef, int tid) ; // Player orgasm detected endEvent
Bratty Cheeks - RMCW Posted September 20, 2020 Author Posted September 20, 2020 7 hours ago, Ashal said: As a suggested possibility as to why TrackActor() is failing. You have to start tracking the actor BEFORE a scene is setup. That's the problem I had, I was running TrackActor on scene start. Nice one - thanks for confirming that.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.