SandMouseAnarchy Posted March 1, 2019 Share Posted March 1, 2019 How do you copy/clone a weapon so that there are two exact copies of it? For example - a script where a weapon is dropped but it drops two copies of itself with all its mods. I've been looking all over Google for any information I can find, but I've found exactly nothing. Link to comment Share on other sites More sharing options...
DieFeM Posted March 1, 2019 Share Posted March 1, 2019 Scriptname DropDupesScript extends Quest Event OnQuestInit() AddInventoryEventFilter(akFilter = None) RegisterForRemoteEvent(Game.GetPlayer(), "OnItemRemoved") EndEvent Event ObjectReference.OnItemRemoved(ObjectReference akSenderRef, Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) If !akDestContainer && akBaseItem As Weapon ObjectReference Duplicate = akSenderRef.PlaceAtMe(akBaseItem) ;----- Needs F4se (GetAllMods) ---------------------------- If Duplicate ObjectMod[] WeaponMods = akItemReference.GetAllMods() If WeaponMods.Length > 0 Int i = 0 While i < WeaponMods.Length Duplicate.AttachMod(WeaponMods[i]) i += 1 EndWhile EndIf EndIf ;----- Needs F4se End ------------------------------------- EndIf EndEvent Link to comment Share on other sites More sharing options...
SandMouseAnarchy Posted March 2, 2019 Author Share Posted March 2, 2019 Ah, that's brilliant! I think that will work nicely ^.^ (I'll have to test tomorrow unfortunately) **bows to DieFeM's infinite knowledge** Thankyou yet again DieFeM! Link to comment Share on other sites More sharing options...
shavkacagarikia Posted March 2, 2019 Share Posted March 2, 2019 Nope I dont think it will work, objects in containers dont have objectreference if they arent persistent. So when dropping that weapon from inventory akItemReference parameter of the onitemremoved event will be none Link to comment Share on other sites More sharing options...
SandMouseAnarchy Posted March 2, 2019 Author Share Posted March 2, 2019 Hmm, maybe we need to pick up a different event then, because dropping and placeatnode both cause a ref to be persistent, so maybe instead of "on weapon removed" we find the closest weapon in the world after the drop and clone at that point ^.^ Link to comment Share on other sites More sharing options...
DieFeM Posted March 2, 2019 Share Posted March 2, 2019 Well, I've tested it and it works fine, at least for the weapons I've tested, there could be two reasons, the weapons I've tested are persistent references or, since you are dropping them to the world, they are no more in the inventory, so I think they actually have a reference. Test the code before discarding it. Link to comment Share on other sites More sharing options...
SandMouseAnarchy Posted March 2, 2019 Author Share Posted March 2, 2019 Ah that's excellent DieFeM! ^.^ I'm just finishing off another script myself and then I'll tie this one into the test script ^.^ Link to comment Share on other sites More sharing options...
Evangela Posted March 8, 2019 Share Posted March 8, 2019 (edited) Nope I dont think it will work, objects in containers dont have objectreference if they arent persistent. So when dropping that weapon from inventory akItemReference parameter of the onitemremoved event will be noneI think this issue only arises when using removeItem. The code also isn't checking for equipped items, which would only make the intended outcome complicating, if not impossible. Edited March 8, 2019 by Rasikko Link to comment Share on other sites More sharing options...
SandMouseAnarchy Posted March 8, 2019 Author Share Posted March 8, 2019 (edited) Yeh, I can confirm that any item dropped or placed-at-player will be given a reference that is persistent :) persistence can also be forced with place-at-node even though it's attach-to function is bugged to hell :) Edited March 8, 2019 by SandMouseAnarchy Link to comment Share on other sites More sharing options...
Recommended Posts