FuryoftheStars Posted January 14, 2021 Share Posted January 14, 2021 (edited) Hi, so I'm working on a mod that overhauls and changes some things regarding the bed arrangements in the BYOH homes (Lakeview Manor, etc) and I was wondering if it was possible via script (even if SKSE was needed) to change the "Base Object" of a placed object (Reference in CK?)?Specifically, I want to make it possible for the player to "upgrade" the looks of their beds in the houses. Have all beds built start as the Common variant, then can upgrade to Upper, then Noble 01, and finally Noble 02.I have figured out how to do this via actual separate objects, however, there are a number of other objects that have their enable state tied to the original, as well as AI packages and even quests that have references to these beds, and so this is resulting in my having to duplicate a lot of things, which isn't ideal to me and is leaving me wondering if everything is even going to work ok, or if it's just going to create other issues.So, yeah, that's basically my question... can you change the "Base Object" property of a placed object in game via script, allowing you to replace/update the mesh/looks of an object without having to have separate objects for everything you want?For visual reference, when you're in the CK and exploring a cell, right-clicking an object and choosing Edit gives you the window I'm linking to below. Changing the value of "Base Object" (circled in red, and which I've only been able to figure out how to do with xEdit so far) allows you to change the mesh/looks of the object without creating a whole new object.https://i.imgur.com/MTFlGTW.png Edited January 14, 2021 by FuryoftheStars Link to comment Share on other sites More sharing options...
dylbill Posted January 14, 2021 Share Posted January 14, 2021 You can maybe use the skse functions GetWorldModelPath() and SetWorldModelPath(string path). You would have to make a check though to set back to the original model path when leaving your custom home because that will change all of the furniture models in game. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 14, 2021 Share Posted January 14, 2021 What you want to do, is not possible. At least not to my knowledge. Even if you could change the base object assignment of a reference object prior to it being loaded, it would load in looking like the new base object. Which means your variety of beds would all look like the original. Link to comment Share on other sites More sharing options...
FuryoftheStars Posted January 15, 2021 Author Share Posted January 15, 2021 You can maybe use the skse functions GetWorldModelPath() and SetWorldModelPath(string path). You would have to make a check though to set back to the original model path when leaving your custom home because that will change all of the furniture models in game.Hmm, no, I don't want to do that. I didn't explain it well enough, but I wanted to leave it open for the player to upgrade some beds but not others.  What you want to do, is not possible. At least not to my knowledge. Even if you could change the base object assignment of a reference object prior to it being loaded, it would load in looking like the new base object. Which means your variety of beds would all look like the original.Apologies, not sure I understand. I'm not looking to change the mesh the base object is using, just change which base object the reference object points to. I hope I'm making sense. :P Link to comment Share on other sites More sharing options...
IsharaMeradin Posted January 15, 2021 Share Posted January 15, 2021 You have a variety of bed references that you have pre-placed to take the place of the original bed reference and other things are replicated in order for quests and such to function.And then you change the base object on the various bed references to point to the original base object so that they can carry over any script data that might be on the original, they will all become references of that original and thus all look the same. If you can guarantee that there is absolutely nothing from the base record required for all the quests and other things that utilize the reference, then you can manually change the base object in the CK or SSEEdit. The single bed reference should take on the new appearance (and possibly need to be re-positioned). But as for a way to do it via script at runtime, not possible to my knowledge. That said, if you can guarantee that there is absolutely nothing from the base record required for all the quests and other things that utilize the reference AND that there are no other references beyond those in the Hearthfires homes. Then and only then you could edit the NIF file to remove the bed mesh and leave behind only the furniture marker. The reference then would be invisible with a furniture marker for interaction. You could then place any bed that did not have the furniture marker in that spot. The invisible marker reference would be the one tied to all the quests and such while the visible beds can be swapped in and out as desired. Of course all the various beds would have to be pre-placed and disabled ahead of time. Link to comment Share on other sites More sharing options...
FuryoftheStars Posted January 15, 2021 Author Share Posted January 15, 2021 (edited) You have a variety of bed references that you have pre-placed to take the place of the original bed reference and other things are replicated in order for quests and such to function.And then you change the base object on the various bed references to point to the original base object so that they can carry over any script data that might be on the original, they will all become references of that original and thus all look the same. If you can guarantee that there is absolutely nothing from the base record required for all the quests and other things that utilize the reference, then you can manually change the base object in the CK or SSEEdit. The single bed reference should take on the new appearance (and possibly need to be re-positioned). But as for a way to do it via script at runtime, not possible to my knowledge. That said, if you can guarantee that there is absolutely nothing from the base record required for all the quests and other things that utilize the reference AND that there are no other references beyond those in the Hearthfires homes. Then and only then you could edit the NIF file to remove the bed mesh and leave behind only the furniture marker. The reference then would be invisible with a furniture marker for interaction. You could then place any bed that did not have the furniture marker in that spot. The invisible marker reference would be the one tied to all the quests and such while the visible beds can be swapped in and out as desired. Of course all the various beds would have to be pre-placed and disabled ahead of time.Still not following your first bit, but that's ok. :smile: I do get your saying that, afayk, it's not possible to switch them out during runtime via script. That said, I think I did get what you were talking about with the last statement and I think that might work better (if I can figure out NIFs well enough). I did spot check a few of the bed furniture objects in the CK (I'll obviously do a more thorough search through before proceeding), and it does look like these base objects are not actually directly used by quests, AI packages, or anything else. Just the placed object references. I'll give that route a try (I won't edit the original objects themselves, just make new ones that the BYOH stuff references instead, that way the rest of the world remains untouched). Thanks! Edit: Just wanted to give an update on this. That last idea you threw at me appears to be working wonderfully. I've been able to successfully create an invisible bed that still has its marker and collision data (the collision appears to be needed for you to be able to activate the markers) and create a visible bed without the collision and marker data (though I may leave collision later? Some beds are definitely shaped differently), and both will load successfully in game. This is only preliminary testing, though, but it's looking good so far. Thanks for the suggestion! Edited January 15, 2021 by FuryoftheStars Link to comment Share on other sites More sharing options...
FuryoftheStars Posted January 22, 2021 Author Share Posted January 22, 2021 This is proving a bit more difficult than I had hoped. I had everything working the way I wanted, but then I noticed it was indeed breaking other stuff. The part that was breaking was I was using my own recipes on the workbenches instead of the HF ones, but then there appears to be some behind the scenes stuff in the scripts that run that dictate usage of the beds. Specifically, spouse will not use the double bed, and adoption system will not kick in with both of the single beds and the dresser built (main hall 2nd floor, not the bedrooms wing). So, I have to leave the HF recipes on the workbench and make the player use that first before showing mine, but this leaves the odd bit that after doing the HF recipe, there's now an invisible bed until they build one of my recipes. Ideal solution from here is some way to fire off a script when the HF object is enabled that will then enable one of my beds, but from what I'm finding online, there is no OnEnable event I can use. I can't just add a second script to the HF misc object, at least not in the case of the double bed, because they're used universally in multiple places. I can't set one of my bed meshes to have an enable parent of the HF bed, cause then I can't disable it. Anybody have any other thoughts? (This would've been so much easier if I could've just been swapping out the base object as needed....) Link to comment Share on other sites More sharing options...
dylbill Posted January 22, 2021 Share Posted January 22, 2021 You can maybe use a reference alias filled with the vanilla bed, and use the OnLoad event: https://www.creationkit.com/index.php?title=OnLoad_-_ObjectReference Link to comment Share on other sites More sharing options...
FuryoftheStars Posted January 22, 2021 Author Share Posted January 22, 2021 You can maybe use a reference alias filled with the vanilla bed, and use the OnLoad event: https://www.creationkit.com/index.php?title=OnLoad_-_ObjectReferenceI'm not sure that'll work? I don't want the script firing off more than once after the bed is constructed, to include when they leave and return. Link to comment Share on other sites More sharing options...
dylbill Posted January 22, 2021 Share Posted January 22, 2021 To make it only run once, make your reference alias optional and use the Self.Clear() at the end of your script. Link to comment Share on other sites More sharing options...
Recommended Posts