idlesheep Posted April 6, 2016 Share Posted April 6, 2016 Hello, guys.I was stuck in develping a weapon mod, any suggestion will be appreciated. I'd like to know is there anyway I can change the OMOD for the weapon that currently holding? I know there is a refid.amod console works similarly, but that is not able to change something in the inventory, and I want this only affect the specific item I am holding. Million thanks. Link to comment Share on other sites More sharing options...
TrickyVein Posted April 6, 2016 Share Posted April 6, 2016 Check out Loads. Link to comment Share on other sites More sharing options...
registrator2000 Posted April 8, 2016 Share Posted April 8, 2016 ObjectReference.AttachModToInventoryItem(Form akItem, objectmod akMod) and ObjectReference.AttachMod(objectmod akMod, int aiAttachIndex) are probably what you want. You could do something like Game.GetPlayer().GetEquippedWeapon(0).AttachMod(objectmod akMod, int aiAttachIndex). If I recall correctly, I experimented with this when making my Car Launcher mod. But the results weren't satisfactory in that it wasn't immersive. The weapon would disappear and then reappear in the player's hands if called on an equipped weapon! Link to comment Share on other sites More sharing options...
idlesheep Posted April 8, 2016 Author Share Posted April 8, 2016 Thank you so much registrator2000! I am more than happy to have your advise, since I have been wondering how could I made this switching function available with your newest hotkey mod! However I have no experience in scripts, is there a way to edit the command for specific OMOD in your hotkey mod, while the loading number is dynamically assigned? And about the disappear and reappear issue, I don't know if it is relevant, but I have read some records in FO4Edit referring internal modification (I don't recall where this record exactly is), yet I don't know for sure if it is anything to do with this issue. Thanks again for your advise, now there is hope again. :D Link to comment Share on other sites More sharing options...
registrator2000 Posted April 8, 2016 Share Posted April 8, 2016 To dynamically retrieve the load-order corrected object from a mod-added plugin, you'll need a script! But the great news is that you can call into loose Papyrus scripts without ever needing to reference them in an ESP. You can compile and drop this utility script into Data\Scripts and Hotkeys or any other script will be able to call into it. ScriptName OMODScript extends ScriptObject Function SwitchOMOD(int whichOMOD) global objectmod myOMOD1 = Game.GetFormFromFile(0x800, "MyMod.esp") as objectmod objectmod myOMOD2 = Game.GetFormFromFile(0x801, "MyMod.esp") as objectmod If (whichOMOD == 1) Game.GetPlayer().GetEquippedWeapon(0).AttachMod(myOMOD1, <aiAttachIndex>) ElseIf (whichOMOD == 2) Game.GetPlayer().GetEquippedWeapon(0).AttachMod(myOMOD2, <aiAttachIndex>) EndIf EndFunction I haven't tested it, but you'd want to replace 0x800 and 0x801 with the form ID of your OMODs (without the load order - the function will get the right object for you) as well as MyMod.esp with your own ESP filename. I can't recall right now which values aiAttachIndex expects, so you might want to try some numbers to see which work. (Possibly 0 for weapons) Regarding hotkeys then, in Hotkeys.ini, these two lines will swap your OMOD when you press the assigned hotkey. NumPad1=cgf "OMODScript.SwitchOMOD" 1 NumPad2=cgf "OMODScript.SwitchOMOD" 2 Link to comment Share on other sites More sharing options...
idlesheep Posted April 8, 2016 Author Share Posted April 8, 2016 Thank you! registrator2000! You are a savior! I can tell that you have already written me every details, I am really really appreciated!I will try how to make it work, thank you very much. :laugh: :laugh: :laugh: Sincerely. Link to comment Share on other sites More sharing options...
Recommended Posts