NismoMan Posted August 18, 2025 Posted August 18, 2025 What's needed: A way to start a scene between the PC with a loaded random character(s) listed in either a faction or a formlist. Scenes go from 2P all the way to 6P. I tried to set up a dialogue to choose the size of the scene (2P, 3P.. etc.), but I need a way to randomize the selection of the NPC's involved when the scene is triggered, I want those NPCs to be pulled from either a formlist or a specific faction, but I couldn't get any of that to work. The way I tried to go about it is to create a functions script to trigger the scenes and use dialogue fragments to call the functions. Spoiler ;###################################################################### ;############################# Properties ################################# ;###################################################################### SexLabFramework Property SexLab Auto ; SexLabFramework Actor Property PlayerRef Auto ; PlayerRef FormList Property ParticipantsList Auto ; FormList including the NPC's to be pulled from. ObjectReference Property SceneMarker Auto; A marker where the scene would take place ;###################################################################### ;############################### 3P #################################### ;### Called with: " (GetOwningQuest() as _SL_Scenes).ThreePFunction() " ;###################################################################### ; Function for a 3-actor scene (Player + 2 NPCs) Function ThreePFunction() if ParticipantsList.GetSize() < 2 Debug.Notification("Not enough NPCs in ParticipantsList for a 3P scene.") return endif sslThreadModel Thread = SexLab.NewThread() Thread.AddActor(PlayerRef) ; Create an array to store selected indices to avoid duplicates int[] SelectedIndices = new int[2] int ListSize = ParticipantsList.GetSize() int i = 0 ; Select 2 unique random NPCs while i < 2 int RandomIndex = Utility.RandomInt(0, ListSize - 1) bool IndexUsed = false int j = 0 while j < i if SelectedIndices[j] == RandomIndex IndexUsed = true endif j += 1 endwhile if !IndexUsed Actor NPC = ParticipantsList.GetAt(RandomIndex) as Actor Thread.AddActor(NPC) SelectedIndices = RandomIndex i += 1 endif endwhile sslBaseAnimation[] Animations = SexLab.GetAnimationsByTags(3, "MMF,FMM") Thread.SetAnimations(Animations) Thread.CenterOnObject(SceneMarker) Thread.StartThread() EndFunction Sexlab seems to be running into an issue and isn't able to add the actors to the scene and eventually fails to run. / Error: Thread[0] - Fatal - AddActor[None]: Failed to add actor". Any help here would be really appreciated!
wareware Posted August 18, 2025 Posted August 18, 2025 It doesn't seem like you're populating the formlist with anything
NismoMan Posted August 18, 2025 Author Posted August 18, 2025 29 minutes ago, wareware said: It doesn't seem like you're populating the formlist with anything The formlist is prepopulated, it's not dynamic, just a set of named NPC's residing next to the marker.
LittleWhiteNeko Posted August 18, 2025 Posted August 18, 2025 (edited) I have several guesses 1. Since there are two AddActor function and it is not clear which is failing, there is a possibility you forgot to define one of them, but this is unlikely 2. The actors are not loaded/persistent, as stated in CK wiki Quote A created reference does not become persistent by virtue of being added to a FormList. If you try to retrieve the reference from the FormList when it is not loaded and not persistent, you will get an incorrect result or no result. 3. The actor added is not valid Although, looking at SexLab code, it should have given more info on the Error if !ActorRef Fatal("Failed to add actor -- Actor is a figment of your imagination", "AddActor(NONE)") return -1 elseIf ActorCount >= 5 Fatal("Failed to add actor -- Thread has reached actor limit", "AddActor("+ActorRef.GetLeveledActorBase().GetName()+")") return -1 elseIf Positions.Find(ActorRef) != -1 Fatal("AddActor("+ActorRef.GetLeveledActorBase().GetName()+") -- Failed to add actor -- They have been already added to this thread", "AddActor("+ActorRef.GetLeveledActorBase().GetName()+")") return -1 elseIf ActorLib.ValidateActor(ActorRef) < 0 Fatal("AddActor("+ActorRef.GetLeveledActorBase().GetName()+") -- Failed to add actor -- They are not a valid target for animation", "AddActor("+ActorRef.GetLeveledActorBase().GetName()+")") return -1 endIf sslActorAlias Slot = PickAlias(ActorRef) if !Slot || !Slot.SetActor(ActorRef) Fatal("AddActor("+ActorRef.GetLeveledActorBase().GetName()+") -- Failed to add actor -- They were unable to fill an actor alias", "AddActor("+ActorRef.GetLeveledActorBase().GetName()+")") return -1 endIf Also, if your quest is already running when you update the mod and load the game, there is a possibility that the properties arent updated properly. Have you tried restarting the quest or using new save? Edited August 18, 2025 by LittleWhiteNeko 1
NismoMan Posted August 18, 2025 Author Posted August 18, 2025 2 minutes ago, LittleWhiteNeko said: I have several guesses 1. Since there are two AddActor function and it is not clear which is failing, there is a possibility you forgot to define one of them, but this is unlikely 2. The actors are not loaded/persistent, as stated in CK wiki 3. The actor added is not valid Although, looking at SexLab code, it should have given more info on the Error if !ActorRef Fatal("Failed to add actor -- Actor is a figment of your imagination", "AddActor(NONE)") return -1 elseIf ActorCount >= 5 Fatal("Failed to add actor -- Thread has reached actor limit", "AddActor("+ActorRef.GetLeveledActorBase().GetName()+")") return -1 elseIf Positions.Find(ActorRef) != -1 Fatal("AddActor("+ActorRef.GetLeveledActorBase().GetName()+") -- Failed to add actor -- They have been already added to this thread", "AddActor("+ActorRef.GetLeveledActorBase().GetName()+")") return -1 elseIf ActorLib.ValidateActor(ActorRef) < 0 Fatal("AddActor("+ActorRef.GetLeveledActorBase().GetName()+") -- Failed to add actor -- They are not a valid target for animation", "AddActor("+ActorRef.GetLeveledActorBase().GetName()+")") return -1 endIf sslActorAlias Slot = PickAlias(ActorRef) if !Slot || !Slot.SetActor(ActorRef) Fatal("AddActor("+ActorRef.GetLeveledActorBase().GetName()+") -- Failed to add actor -- They were unable to fill an actor alias", "AddActor("+ActorRef.GetLeveledActorBase().GetName()+")") return -1 endIf You're absolutely on point here; I'm actually getting this guy "Failed to add actor -- Actor is a figment of your imagination". And of the 3 guesses you've listed, I'm almost certain it's number 2. Any suggestions on how to amend this? I was planning on randomizing NPC's from a Faction, but I was told it's not feasible and won't work. I was trying to avoid complicating the script and wanted to keep it simple... but I guess it ain't that simple in the end >.<;
LittleWhiteNeko Posted August 18, 2025 Posted August 18, 2025 5 minutes ago, NismoMan said: You're absolutely on point here; I'm actually getting this guy "Failed to add actor -- Actor is a figment of your imagination". And of the 3 guesses you've listed, I'm almost certain it's number 2. Any suggestions on how to amend this? I was planning on randomizing NPC's from a Faction, but I was told it's not feasible and won't work. I was trying to avoid complicating the script and wanted to keep it simple... but I guess it ain't that simple in the end >.<; If you are okay with adding Papyrus Extender, it has a function to get all actors belonging to a faction https://github.com/powerof3/PapyrusExtenderSSE/wiki/Faction Unless your desired faction is massive, like Bandit faction, I think this is possible. Just get all actors, and iterate through it, or find random index. Otherwise, I usually just add Actor[] property, or ReferenceAlias[] property if the actors do not exists yet, and assign them to respective ReferenceAlias before the adding them to SexLab thread. No idea about getting all actors from a faction without PO3 extender, though 1
NismoMan Posted August 18, 2025 Author Posted August 18, 2025 3 minutes ago, LittleWhiteNeko said: If you are okay with adding Papyrus Extender, it has a function to get all actors belonging to a faction https://github.com/powerof3/PapyrusExtenderSSE/wiki/Faction Unless your desired faction is massive, like Bandit faction, I think this is possible. Just get all actors, and iterate through it, or find random index. Otherwise, I usually just add Actor[] property, or ReferenceAlias[] property if the actors do not exists yet, and assign them to respective ReferenceAlias before the adding them to SexLab thread. No idea about getting all actors from a faction without PO3 extender, though Got it. I'll look into using Po3's Papyrus Extender. I hope I'll be able to get this sorted out without issues, I've never used PE before and kinda barely managed to get around to scripting in the first place, lol. Is it as simple as just having the mod enabled or do I have to do some voodoo work to get things working?
LittleWhiteNeko Posted August 18, 2025 Posted August 18, 2025 8 minutes ago, NismoMan said: Got it. I'll look into using Po3's Papyrus Extender. I hope I'll be able to get this sorted out without issues, I've never used PE before and kinda barely managed to get around to scripting in the first place, lol. Is it as simple as just having the mod enabled or do I have to do some voodoo work to get things working? Install it, and you're done. You don't even need to import the scripts, they're global function. Just PO3_SKSEFunctions.<function here>. PO3 is a powerful library, go check the other functions, maybe some will be useful. 1
NismoMan Posted August 18, 2025 Author Posted August 18, 2025 4 minutes ago, LittleWhiteNeko said: Install it, and you're done. You don't even need to import the scripts, they're global function. Just PO3_SKSEFunctions.<function here>. PO3 is a powerful library, go check the other functions, maybe some will be useful. I really appreciate your help. I hope I could get this out of my system and move onto something new. Thanks again and I'll update as I move forward.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now