YouDoNotKnowMyName Posted June 23, 2020 Share Posted June 23, 2020 Good evening everybody! I just saw this thread https://forums.nexusmods.com/index.php?/topic/8844053-how-to-get-equipped-object/ and it reminded me of something that I wanted to do for a while now ... In that topic it is stated that "normal" weapons in the players inventory do not have a unique ID. So would it still somehow be possible to attatch an OMOD to a currently equipped item? What I want to do is to make a equipped weapon "switchable" between full auto and semi auto fire with a key on the keyboard. I also want this to be as "compatible" with "custom weapon mods" as possible (so maybe doing this with keywords? So that you could easily "limit" this functionality to certain weapons only ...)So the script that I will use needs to check for those keywords (I am confident that I can do that :laugh:) I know that it is possible to have a script that does someting when a key on the keyboard is pressed (I already have a script for that somewhere ...).But on the CK wiki, there is somehow no real documented function for attatching a OMOD to a weapon.Maybe this (https://www.creationkit.com/fallout4/index.php?title=SetEmbeddedMod_-_Weapon), but I don't know ... Sorry for this inconsistent mess of text here, but my brain works (?) in weird ways ....And most of the time while I am thinking about some "great idea", I will go from "yes, I want to do this" to "this will just be another 'impossible thing' because of FO4s weird limitations and I want to stop this right now before I get too 'invested in it' and I don't want to 'get my hopes up' " and I end up just going to bed at that point and after waking up a few hours later, it starts all over again ... Link to comment Share on other sites More sharing options...
YouDoNotKnowMyName Posted July 23, 2020 Author Share Posted July 23, 2020 So nobody knows anything about how to do this? Link to comment Share on other sites More sharing options...
IDontEvenKnow Posted July 28, 2020 Share Posted July 28, 2020 Oh, I made a mod that does exactly that a few weeks ago. Mostly as a basic demo, but it does work.https://drive.google.com/file/d/1Ol9pAUNKYhEWkWig_bsyIxKY8yhZ9jIm/view?usp=sharingSource is in the .ba2.In that version, compatibility for new weapons is achieved by adding additional entries to the WeaponOverrides array, which should be fairly self-explanatory. It has "pseudo-compatibility" for the vanilla Assault Rifle, and 10mm pistols as examples, but the intention is to replace those entries entirely with the "semi-auto"/"full auto" OMODs that lots of weapon mods tend to provide. If you uncomment lines 81-87 in idek:mst:FireModeController and recompile, it will also swap between two "generic" auto/semi-auto mods for any weapon type that's not in the WeaponOverrides array, and that does work on absolutely any weapon. It isn't guaranteed to work properly, though, since it doesn't affect base fire rates and so on. (edit: oh, you'll have to tweak the MST_FireModeSemi/MST_FireModeAuto OMODs too, at one point I removed the property that sets bIsAutomatic from them) There's also some commented-out code that mostly works that's based off of ObjectReference.AttachMod(), instead of ObjectReference.AttachModToInventoryItem() that the "active" code is based off of. Some of it might be of interest to you if you want to experiment. If you wanted to add "soft" compatibility to nearly any number of mods, you'd unflag WeaponOverrides as Const, and write some additional code to do a bunch of Game.IsPluginloaded() checks, followed by grabbing the appropriate forms via Game.GetFormFromFile(), inserting them into new WeaponOverride struct instances, and adding the new structs to WeaponOverrides, all at runtime. Feel free to do whatever you want with it by the way, I never intended to release it anyway. It's a good base to start from if you want to polish it up into a fully-featured mod. Link to comment Share on other sites More sharing options...
YouDoNotKnowMyName Posted July 28, 2020 Author Share Posted July 28, 2020 Oh, I made a mod that does exactly that a few weeks ago. Mostly as a basic demo, but it does work.https://drive.google.com/file/d/1Ol9pAUNKYhEWkWig_bsyIxKY8yhZ9jIm/view?usp=sharingSource is in the .ba2.In that version, compatibility for new weapons is achieved by adding additional entries to the WeaponOverrides array, which should be fairly self-explanatory. It has "pseudo-compatibility" for the vanilla Assault Rifle, and 10mm pistols as examples, but the intention is to replace those entries entirely with the "semi-auto"/"full auto" OMODs that lots of weapon mods tend to provide. If you uncomment lines 81-87 in idek:mst:FireModeController and recompile, it will also swap between two "generic" auto/semi-auto mods for any weapon type that's not in the WeaponOverrides array, and that does work on absolutely any weapon. It isn't guaranteed to work properly, though, since it doesn't affect base fire rates and so on. (edit: oh, you'll have to tweak the MST_FireModeSemi/MST_FireModeAuto OMODs too, at one point I removed the property that sets bIsAutomatic from them) There's also some commented-out code that mostly works that's based off of ObjectReference.AttachMod(), instead of ObjectReference.AttachModToInventoryItem() that the "active" code is based off of. Some of it might be of interest to you if you want to experiment. If you wanted to add "soft" compatibility to nearly any number of mods, you'd unflag WeaponOverrides as Const, and write some additional code to do a bunch of Game.IsPluginloaded() checks, followed by grabbing the appropriate forms via Game.GetFormFromFile(), inserting them into new WeaponOverride struct instances, and adding the new structs to WeaponOverrides, all at runtime. Feel free to do whatever you want with it by the way, I never intended to release it anyway. It's a good base to start from if you want to polish it up into a fully-featured mod.YES! This is exactly what I wanted to to! I will take a look at this for sure ... Thank you very very much!!!1 Link to comment Share on other sites More sharing options...
Recommended Posts