Lemecc Posted July 6 Share Posted July 6 I promise I was doing my very best to figure this out without having to make a forum thread, probably spent a solid six hours today studying and rewriting script, but I once again hit the limit of my understanding on scripts. I'd like to, via a quest, use a script to send/update new property values to scripts already running in the game. From all the threads I've been scouring, I gather this is possible, but I haven't seen any explanation or examples, just statements of "it's possible, but really hard.". To give an exact example, I'm trying to make a quest where, after the player fulfills some conditions (has to have made some choices in other quests, has to move far away enough for things to progress, etc), I want to tell a specific workshop to change the CustomWorkshopNPC property it has from the default inherited value into a custom NPC template I've made. All the conditions to get there are easy-peasy, but I'm just not sure how to access and change the CustomWorkshopNPC property itself. I understand I need to access one specific instance of the script, I don't want to affect all workshops, just a single one. I kind of know how to get to the point where I'm pointing towards the right Workshop as WorkshopScript, but what comes after is what I'm not grasping. I've been trying to follow this page and this page on the wiki, and I'm definitely not comprehending it, or understanding how to apply it to my situation. Unfortunately, I also can't really think of a time in the base game where a WorkshopScript property on a single Workshop might get changed on the fly, so as far as I know, there's no vanilla examples I can study and follow. Would anybody be able to shed some light or point me to a tutorial or example-in-CK of one script passing new property values to a second script on a different external object/reference/etc? Thank you! Link to comment Share on other sites More sharing options...
DieFeM Posted July 6 Share Posted July 6 Let say you have the workshop reference as a property, like this: ObjectReference Property WorkshopRef Auto You can either replace ObjectReference with WorkshopScript, like this: WorkshopScript Property WorkshopRef Auto Or you can cast the ObjecetReference as WorkshopScript WorkshopScript CastedWorkshopRef = WorkshopRef As WorkshopScript Or you can just use (WorkshopRef As WorkshopScript) When you have a WorkshopScript object, you only need to assign the new ActorBase like this: WorkshopRef.CustomWorkshopNPC = YourBaseNPC or CastedWorkshopRef.CustomWorkshopNPC = YourBaseNPC or (WorkshopRef As WorkshopScript).CustomWorkshopNPC = YourBaseNPC There might be other methods, but I never needed anything fancier than that. 1 Link to comment Share on other sites More sharing options...
Lemecc Posted July 6 Author Share Posted July 6 41 minutes ago, DieFeM said: Let say you have the workshop reference as a property, like this: ObjectReference Property WorkshopRef Auto You can either replace ObjectReference with WorkshopScript, like this: WorkshopScript Property WorkshopRef Auto Or you can cast the ObjecetReference as WorkshopScript WorkshopScript CastedWorkshopRef = WorkshopRef As WorkshopScript Or you can just use (WorkshopRef As WorkshopScript) When you have a WorkshopScript object, you only need to assign the new ActorBase like this: WorkshopRef.CustomWorkshopNPC = YourBaseNPC or CastedWorkshopRef.CustomWorkshopNPC = YourBaseNPC or (WorkshopRef As WorkshopScript).CustomWorkshopNPC = YourBaseNPC There might be other methods, but I never needed anything fancier than that. Thanks so much for the help! Actually, I was trying a bunch of configurations like this already, but definitely getting it in slightly the wrong order. I also managed to over-complicate it in my mind, oops. That said, I'm trying this as (WorkshopRef As WorkshopScript).CustomWorkshopNPC = YourBaseNPC, and I get the compile error "property CustomWorkshopNPC on script workshopscript is read-only, you cannot give it a value". Is this because the workshop I'm casting to doesn't have a value set for CustomWorkshopNPC, and instead during runtime pulls the value from the overall parent workshopscript? Link to comment Share on other sites More sharing options...
DieFeM Posted July 7 Share Posted July 7 (edited) If you look at WorkshopScript.psc you'll notice this property is marked as a constant ActorBase Property CustomWorkshopNPC Auto const Unfortunately this property cannot be changed during runtime. Edit: As the comment of this property points out, this property is meant to override the one in the workshop parent script, so it is probably not set in the workshop reference. You can only set that manually, in the CK, editing the script properties, in the object reference from the worldspace/interior, in the render window. Quote { Patch 1.4: the actor that gets created when a settlement makes a successful recruitment roll - overrides properties on WorkshopParentScript } Edited July 7 by DieFeM Link to comment Share on other sites More sharing options...
Lemecc Posted July 7 Author Share Posted July 7 (edited) 4 hours ago, DieFeM said: If you look at WorkshopScript.psc you'll notice this property is marked as a constant ActorBase Property CustomWorkshopNPC Auto const Unfortunately this property cannot be changed during runtime. Edit: As the comment of this property points out, this property is meant to override the one in the workshop parent script, so it is probably not set in the workshop reference. You can only set that manually, in the CK, editing the script properties, in the object reference from the worldspace/interior, in the render window. Not being able to change during runtime; damn, that's a real shame. It would have made for a really cool mod (imo, at least). I'm aware of changing the property in CK, in fact what I was actually intending on making was an "alternate ending" patch for one of my settlement mods here on the Nexus. An alternate ending in which player choices means the settlement will then start recruiting a different set of NPCs rather than normal ones. I may try and look into how Nuka World handles switching workshops over into raider workshops - I should have thought of that earlier - I'm guessing that Bethesda had to jump through some hoops if the original property cannot be so easily changed, but I'm beginning to suspect that's going to be a lot of hassle and roundabout workings for what I had intended to be a small fun patch. Many thanks for the help though! And many thanks for pointing out const in the original script. I feel like a total dummy missing that (woulda saved myself hours of headbutting a wall), but I did. Edited July 7 by Lemecc Link to comment Share on other sites More sharing options...
adb3nj Posted July 8 Share Posted July 8 You can modify WorkshopScript in the Creation Kit, but bear in mind that will make your mod incompatible with any other mod that does the same thing. Link to comment Share on other sites More sharing options...
Lemecc Posted July 8 Author Share Posted July 8 (edited) 6 hours ago, adb3nj said: You can modify WorkshopScript in the Creation Kit, but bear in mind that will make your mod incompatible with any other mod that does the same thing. I care about mod quality and game safety so there's no way I will ever ever do that. Every mod I make is all new forms and/or script injection in every case that I can. I'll just have to check out the Nuka World conversion system, and decide from there whether I want to borrow from that or whether I think the "cost" outweighs the benefits. Edited July 8 by Lemecc Link to comment Share on other sites More sharing options...
adb3nj Posted July 8 Share Posted July 8 2 hours ago, Lemecc said: I care about mod quality and game safety so there's no way I will ever ever do that. If it needs to be done, it needs to be done… High-profile mods like Workshop Framework do it. Sometimes there's no alternative. Just keep track of what you're editing, make sure you only share archived versions of the scripts (so they're easy to disable), and warn people about potential conflicts. It's not ideal, but you can do it responsibly. Link to comment Share on other sites More sharing options...
Lemecc Posted July 8 Author Share Posted July 8 3 hours ago, adb3nj said: If it needs to be done, it needs to be done… High-profile mods like Workshop Framework do it. Sometimes there's no alternative. Just keep track of what you're editing, make sure you only share archived versions of the scripts (so they're easy to disable), and warn people about potential conflicts. It's not ideal, but you can do it responsibly. I don't even want to imagine how inundated I'd be with furious comments and bug reports if I dared step on the toes of mods like Workshop Framework. I appreciate the thoughts, but this is definitely something I'll never do. Not to mention that in this particular case, I very specifically don't want to ever affect more than one singular workshop. Anyway, in case anybody is interested in the thread; I read the DLC04 scripts relevant to having workshops recruit raiders. Unsurprisingly, they do sidestep the base game a lot - which makes perfect sense. A great way to make sure no permanent or troublesome changes happen to the workshop that has been converted. It's a longer process to get to the desired result, but probably a far safer and reversible method with maximum compatibility, so I think I'll copy Bethesda's homework on this one - not in as far as making an entirely new workshopparentscript like Nuka World does, but in hijacking the recruitment beacon object a bit to kind of fake-recruit the actor I want so long as the workshop it's attached to has a certain keyword, etc etc. I'd been hoping for a really direct way to pass the new actorbase to the specific workshop, but I think Nuka World gives me an idea of how to script in circles around it for a result that looks identical to the end user. Good ol' smoke and mirrors. Link to comment Share on other sites More sharing options...
Recommended Posts