Jump to content

[Script] Deep clone an item including modifications


othunderx

Recommended Posts

As I know this can be done by create a base item and attach all other object mods.

 

ObjectReference newItem = PlayerREF.PlaceAtMe(givenWeapon)

int j = 0
while j < givenMods.getSize()
newItem.attachMod( givenMods.GetAt( j ) as ObjectMod )
j += 1
EndWhile

PlayerREF.addItem( newItem, 1, true )

 

But how can I get all base forms of attached object mods on an exists item? If there are workarounds though, any information would be appreciated.

Link to comment
Share on other sites

I could be wrong but I believe this isn't in the base game - but fallout 4 script extender has a function GetAllMods at the bottom of their version of ObjectReference.psc, so that might do the trick. If you're lucky it will be as simple as putting givenMods = givenWeapon.GetAllMods() just before your loop. I've never actually used the script extender, but that might be a good starting point.

Link to comment
Share on other sites

Thank you for your reply Comiconomist , thats really a good point.

I think there is a way I do not even need to use F4SE in developing time, it should exists in its runtime after I installed F4SE and run f4se_loader.exe.

And for script I intend to using reflection:

givenMods = givenWeaponRef.CallFunction( "GetAllMods", new Var[0])

But sadly it runs failed with error "Failed to call member function GetAllMods on [ObjectReference <Item 6 in container (190055D0)>] - function name likely invalid, or object incorrect type".

Still need to figure out how to using F4SE to developing.

Edited by othunderx
Link to comment
Share on other sites

Things in containers aren't treated like object references anymore, and you can't run scripts on them. Try testing on something in the world.

I've test item in the world, but still face the same error "Failed to call member function GetAllMods on [ObjectReference < (190055D3)>] - function name likely invalid, or object incorrect type".

Link to comment
Share on other sites

This is really a nightmare, after givenMods = givenWeaponRef.CallFunction( "GetAllMods", new Var[0])

I just found out I can't do anything on givenMods because its Var type and function GetAllMods it returned ObjectMod[].

Compile will failed on cast givenMods to any object array type, Dose anyone face same issue before?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...