SAC Posted May 25, 2017 Posted May 25, 2017 Hi, I am working on my mod (see sig) which requires NPCs to sit still in (a sequence of) furnitures. Problem is that many times the NPC enters the furniture, sits for a couple of seconds, then exits and continues its sandbox. I did a test with a dumbed-down NPC (removed all AI packages from CK) and they seem docile enough for my purpose, i.e. they never break the sequence, just sit in furniture and follow my script. Removing packages in CK is easy enough, what I cannot figure out is how to remove the AI packages from a specific NPC via script, in-game (using a magic effect). Any suggestions? Thanks!
Roggvir Posted May 25, 2017 Posted May 25, 2017 I would probably make some kind of DoNothing package, and add it to an alias on a new quest i would also make for this purpose. Then i would use that magic effect script of yours (or any other suitable means) to add the desired NPC into that alias, which will make the NPC run the package assigned to that alias. Just make sure the quest priority is set high enough (not sure how much - you'll have to experiment - try 100 if you want to be sure your package will run no mater what), because the order of packages in stack/queue depends on this. You may also need to run EvaluatePackage() on the NPC after you add him into the alias, though i do not recall any situation when i really had to do that. When you are done with that NPC, just clear that alias, so the NPC can resume "normal operation".
SAC Posted May 26, 2017 Author Posted May 26, 2017 Thank you. I understand the concept, but I've never set up a quest, or a package, before, so I don't know how to actually implement the concept. So, any details as to how to do this would help. In the meantime, I'll start googling for quest tutorials. As for removing the alias, in this particular mod the assigned NPC does not get to resume "normal operation"
SAC Posted May 26, 2017 Author Posted May 26, 2017 Did some reading today. Apparently you cannot use an "alias" on two+ NPCs at the same time. So how would I override two NPCs simultaneously?
Roggvir Posted May 27, 2017 Posted May 27, 2017 Did some reading today. Apparently you cannot use an "alias" on two+ NPCs at the same time. So how would I override two NPCs simultaneously?Obviously not the SAME alias, but nothing prevents you from having multiple aliases.
SAC Posted May 28, 2017 Author Posted May 28, 2017 Haven't started the quest solution yet, but I noticed some strange stuff about the sandboxing: - if I place the furniture and then direct the NPC (console setcommandstate 1) to sit in the furniture, it works great, no interruptions - if I place the furniture by script and then I script the NPC to "activate" the furniture, it doesn't seem to do anything, although the debug returns "true" - if I place the furniture by script and the script the NPC to "snapintointerraction", it sits in the furniture for a second but then breaks animation and sandboxes away - if I script the NPC unconscious and then snapintointerraction, then it _seems_ to stay in the furniture, but with eyes closed I need to test more, but I don't understand the difference between "sit", "activate" and "snapintointerraction". Is there another "sit" command available for scripting?
Guest Posted May 28, 2017 Posted May 28, 2017 There's a mod I use from nexus that is supposed to freeze an NPC's A-I in bed (So she stays there). Everyone seems happy with the mod, so I'm assuming whatever the script does works, but most of the time (8 out of ten?) times the NPC is seen climbing out of bed on my PC, just before the mod starts up. ONCE in a while it actually works perfectly, and the NPC lays there still, waiting for the mod to begin its little routine. I keep thinking "It Must be me", something about my load order or some master script overriding the mod. Anyway if you're interested in other people's scripts, google "Immersive Embrace" on Nexus. I hope it helps you.
dagobaking Posted December 29, 2017 Posted December 29, 2017 On 5/28/2017 at 3:28 AM, SAC said: Thank you! I'll take a look Did you have any luck? I'm having a very similar issue. I can't seem to get packages to run consistently. Would be curious to hear if you ever found a solution?
SAC Posted December 29, 2017 Author Posted December 29, 2017 2 hours ago, dagobaking said: Did you have any luck? I'm having a very similar issue. I can't seem to get packages to run consistently. Would be curious to hear if you ever found a solution? Nope, but, to be honest, I haven't really tried that hard since then. I use "setunconscious 1" and it's been sufficient for my purposes. But if you ever find a way, I'd like to hear about it.
dagobaking Posted December 29, 2017 Posted December 29, 2017 Ok. Yeah. I found that unconscious method as well. But, having closed eyes and no expression is a big cost. I haven't tested all of the ideas that came up here. But, I just found this thread with new info: https://forums.nexusmods.com/index.php?/topic/5484442-workshop-script-canceling-out-npcs-ai-packages/
SAC Posted December 30, 2017 Author Posted December 30, 2017 On 12/29/2017 at 9:57 AM, dagobaking said: Ok. Yeah. I found that unconscious method as well. But, having closed eyes and no expression is a big cost. I haven't tested all of the ideas that came up here. But, I just found this thread with new info: https://forums.nexusmods.com/index.php?/topic/5484442-workshop-script-canceling-out-npcs-ai-packages/ So, I got a stubborn NPC which I wasn't able to control either with "workshopnopackage", or with setunconscious (it's true that it's a chain of scripts, so I couldn't fault her for being confused). So I was forced to try the quest alias way, and it seems to work. Some screens from the quest, as a pointer, and the relevant script. The workflow was: 1. open (pre-existing) quest 2. quest aliases tab 3. right click => new reference alias (note I checked "in loaded area only", we shall see if that's the proper way to do it) 4. name the alias, right click in the packages section => new package 5. brain dead / dumb down the package down to basic "able to sit furniture" 6. edit the spell script accordingly (add reference alias property, populate it in CK to point to the crxinitquest quest, and then to the new alias) Scriptname SACCRXEffectScript extends activemagiceffect ReferenceAlias Property crxalias Auto Const ;<bla bla other stuff> Event OnEffectStart(Actor akTarget, Actor akCaster) caster = akCaster target = akTarget crxalias.forcerefto(target) ;<bla bla other stuff> activationsuccess=target.snapintointeraction(FurnitureStage1Ref) endEvent It seems to work with multiple NPCs too, even though I am reusing the same reference alias. Let me know if it works for you too. I'll keep testing.
SAC Posted December 30, 2017 Author Posted December 30, 2017 LE: you also need to remove their keywords at the start. For example, I had an NPC with AO_Type_WorkshopAlarm [KYWD:001B5CB8], nothing would settle it down until I removed it. Of course, I cannot find any function like "removeallkeywords", you need to specify them individually, or find a way to list them in an array, or some other shit. I swear, I've got no idea why they did this whole scripting shit so difficult, it's like almost on purpose... <very frustrated>
dagobaking Posted December 31, 2017 Posted December 31, 2017 11 hours ago, SAC said: LE: you also need to remove their keywords at the start. For example, I had an NPC with AO_Type_WorkshopAlarm [KYWD:001B5CB8], nothing would settle it down until I removed it. Of course, I cannot find any function like "removeallkeywords", you need to specify them individually, or find a way to list them in an array, or some other shit. I swear, I've got no idea why they did this whole scripting shit so difficult, it's like almost on purpose... <very frustrated> Thank you for the detailed breakdown! I was hoping to avoid messing with the existing keywords because I don't want my mod to interfere with any vanilla game mechanics. But, it looks like that's where the solution is. I will need to serialize out their existing keywords, remove them all, then put them back when I'm finished running my package. Ugh. FYI - There is an F4SE function for getting a list of keywords: https://www.creationkit.com/fallout4/index.php?title=GetKeywords_-_Form But, the helpfulness of that is a bit limited since you still have to go through many steps to figure out what keywords they are and whether or not you want to keep/remove them, what systems they relate to, etc. It's an example of why I think the keyword system was a lazy solution. It's the same as having a bunch of untyped variables and functions. It would have been better to just add handler functions for all of these various flags and nuances. More organizing work for their coders. But, it would have been much easier to follow and document for anyone using the system. Will let you know if I get it working.
Veladarius Posted January 4, 2018 Posted January 4, 2018 What is the priority of your quest? If you have not changed it then set it to 100. As for the package you need to set an alias for the furniture you want them in then fill it. There was a command in Skyrim, GetCurrentCrosshairRef that would give you the id of whatever your crosshair was on but I can't find it in FO4's commands. This would have let you select the piece of furniture and force it into the alias. The AI would then have them use the item and you could set a condition that based on a variable on whether they would stay or could get up. I would have set it so the alias would be cleared when they had gotten up. I have not found an equivalent of the command in FO4 though.
SAC Posted May 8, 2019 Author Posted May 8, 2019 Kind of necroing this thread: the solution above seems to work (mostly), but only on one NPC at a time. Apparently you cannot populate one alias with two (or more) NPCs at a time (which is probably logical). I don't know how to extend this solution to work on more than one NPC at the same time
EgoBallistic Posted May 12, 2019 Posted May 12, 2019 On 5/8/2019 at 1:00 PM, SAC said: Kind of necroing this thread: the solution above seems to work (mostly), but only on one NPC at a time. Apparently you cannot populate one alias with two (or more) NPCs at a time (which is probably logical). I don't know how to extend this solution to work on more than one NPC at the same time If you want to force multiple NPCs to sit in multiple furnitures, you can do it using a RefCollectionAlias for the actors and linked references for the furniture. Make a refCollectionAlias that has whatever conditions you need (actors only, loaded area, etc). Add a condition that requires the actor to have a linked ref with a certain keyword. In this example, I wanted a bunch of actors to sit and watch an event, so my refCollectionAlias is called "Audience". Put a package on the RefCollectionAlias that makes them sit in a furniture which is a linked reference with the above keyword. When you want to force the NPC to sit, do actor.setLinkedRef(furnitureRef, yourKeyword) and then do refCollectionAlias.AddRef(actor).
SAC Posted May 12, 2019 Author Posted May 12, 2019 5 hours ago, EgoBallistic said: If you want to force multiple NPCs to sit in multiple furnitures, you can do it using a RefCollectionAlias for the actors and linked references for the furniture. Yes, this is exactly what I am looking for, making multiple NPCs sit in different furnitures and ignore everything else (including their sandboxing) I think I understood, I'll get to work testing it. Did you put anything in the package flags? Thank you!
EgoBallistic Posted May 12, 2019 Posted May 12, 2019 18 minutes ago, SAC said: Did you put anything in the package flags? I have four that are checked: Ignore Combat, No Combat Alert, Allow Idle Chatter, and Load Into Furniture. The idea with these guys is they sit and watch combat happen, so I have to make sure they don't react to it. With this setup, they completely stay put and play their booing/cheering idles that are listed in the package's "Idles" tab. Allow Idle Chatter is just for some background noise, it's safe to uncheck that one.
Reginald_001 Posted May 12, 2019 Posted May 12, 2019 On 5/25/2017 at 4:29 PM, SAC said: Hi, I am working on my mod (see sig) which requires NPCs to sit still in (a sequence of) furnitures. Problem is that many times the NPC enters the furniture, sits for a couple of seconds, then exits and continues its sandbox. I did a test with a dumbed-down NPC (removed all AI packages from CK) and they seem docile enough for my purpose, i.e. they never break the sequence, just sit in furniture and follow my script. Removing packages in CK is easy enough, what I cannot figure out is how to remove the AI packages from a specific NPC via script, in-game (using a magic effect). Any suggestions? Thanks! I had this exact challenge with Ivy. Make a scene inside a (new or existing) quest with a referencealias linked to your NPC (click 'Unique Actor' or choose a reference from another quest, or better yet fill the reference dynamically). Call it 'stay_seated_scene'. Add 2 phases (a third optional one for extra packages) with a package (stayatselfscene) or another package of your choosing that doesn't do anything. You can make the second package with a package designed to use the furniture (e.g. attach a script to the package). Make sure you keep the second phase running until YOUR conditions are met (in this case as an example I added a StageDone but this can be any conditional) by setting the 'end on condition' property in phase 2. In the scene editor, go to 'Edit Actor Flags' and enable 'Only Scene Packages'. You can also disable player activation here so that they get the message 'this individual is busy' if you want. Now as long as phase 2 runs (and your conditionals aren't met), the NPC will stay where they are. You can expand actor behaviors, e.g. pause the scene during combat, or end it after combat, or disable/enable player dialogue etc..etc.. By clicking on the 'Actor Behavior Flags' button.
SAC Posted May 12, 2019 Author Posted May 12, 2019 19 minutes ago, EgoBallistic said: I have four that are checked: Ignore Combat, No Combat Alert, Allow Idle Chatter, and Load Into Furniture. The idea with these guys is they sit and watch combat happen, so I have to make sure they don't react to it. With this setup, they completely stay put and play their booing/cheering idles that are listed in the package's "Idles" tab. Allow Idle Chatter is just for some background noise, it's safe to uncheck that one. Perfect! I'll get to it as soon as I finish the initially disabled spawn, that one seems easier... of course, that is until CK CTDs as soon as I CTRL-V some code (buggy piece of shit, no way they actually make games with that crap)
SAC Posted May 12, 2019 Author Posted May 12, 2019 14 hours ago, EgoBallistic said: I have four that are checked: Ignore Combat, No Combat Alert, Allow Idle Chatter, and Load Into Furniture. The idea with these guys is they sit and watch combat happen, so I have to make sure they don't react to it. With this setup, they completely stay put and play their booing/cheering idles that are listed in the package's "Idles" tab. Allow Idle Chatter is just for some background noise, it's safe to uncheck that one. Ok, first iteration doesn't work The furniture has the NooseLinkedKW keyword. The script says noosevictimcollalias.addref(target) debug.notification(noosevictimcollalias.getcount()) The ref collection alias gets filled, because the count goes up as I "shoot" other NPCs, but they just sit there, they do not sit in the furniture. Am I supposed to add a snapintointeraction step? Also - how did you manage to insert small pics into your post? I don't like that I post large images but I don't know how to make them small(er)
EgoBallistic Posted May 12, 2019 Posted May 12, 2019 41 minutes ago, SAC said: The ref collection alias gets filled, because the count goes up as I "shoot" other NPCs, but they just sit there, they do not sit in the furniture. Am I supposed to add a snapintointeraction step? I didn't do a snapintointeraction step, but you may need to do an evaluatePackage() on them. Also the quest needs to be fairly high priority so its packages will win. But I wonder if there is something going on with your package. What is noosevictim used for in your package? I have a refalias in my package that I used for headtracking (since they are an audience, I want them to look at the fighting) but what are you doing with yours? Also, when you said "The furniture has the NooseLinkedKW keyword" did you do a target.setLinkedRef( furnitureRef, NooseLinkedKW) ? The furniture itself doesn't need to have the keyword, the keyword is used to identify the link. You need to do that before you add target to the refcollalias. 41 minutes ago, SAC said: Also - how did you manage to insert small pics into your post? I don't like that I post large images but I don't know how to make them small(er) Double-click the picture while you are posting or editing the post, and you can set the size. I usually use 300 pixels horizontal.
Reginald_001 Posted May 12, 2019 Posted May 12, 2019 I don't think you need to fiddle too much with your package, in order for your NPC to remain sitting, all you need to do is set the proper scene flags as I showed above. With just a simple package with ignore combat and no combat alert checked, and these flags set properly, they'll always stay put until you tell them otherwise.
SAC Posted May 13, 2019 Author Posted May 13, 2019 11 hours ago, EgoBallistic said: But I wonder if there is something going on with your package. What is noosevictim used for in your package? I have a refalias in my package that I used for headtracking (since they are an audience, I want them to look at the fighting) but what are you doing with yours? No idea monkey does as monkey sees - you had one so I figured I needed one, it's not like I really understand what I'm doing. Removed it 11 hours ago, EgoBallistic said: Also, when you said "The furniture has the NooseLinkedKW keyword" did you do a target.setLinkedRef( furnitureRef, NooseLinkedKW) ? The furniture itself doesn't need to have the keyword, the keyword is used to identify the link. You need to do that before you add target to the refcollalias. Yep. Forgot about doing the target.setlinkedref Added it and now it works (some of the NPCs even keep idling on savegame load, which is a bonus, however some don't). They even go and sit by themselves, with some caveats: - sitting doesn't seem to activate the furniture script (onactivate event), while snapintointeraction does - no idea why - sitting is a bit awkward in my case, because I tend to scatter my "furnitures" all over the place (mostly vertical), so they assume the furn idle position and just slowly glide towards the noose, which is not "immersive" - I still have an use case which doesn't work, when they are currently sitting in a "standby" furniture (like a hostage marker) and I want them to transition into a noose furniture - they just keep sitting in the marker and I couldn't find any function to snap them out - the only solution I found was to make them unconscious, snap them into the noose, then set unconscious 0 again when they start idling (as to avoid having them eyes closed) So far so good, keeping snapintointeraction but adding the setlinkedref (plus all the quest stuff to keep them stable) seems to do the trick, I will need to test more, but TYVM indeed for all your help! 11 hours ago, EgoBallistic said: Double-click the picture while you are posting or editing the post, and you can set the size. I usually use 300 pixels horizontal. Cool, will keep that in mind!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.