Indarello Posted September 3, 2021 Share Posted September 3, 2021 Hi, I am using this for container script: Event OnItemAdded(form itemForm, int count, objectReference itemRef, objectReference sourceContainerRef) PlayerRef.AddItem(itemForm, count, true)EndEvent It works, but It loses legendary and other modifications for armoritemRef is always none, I dont know whyI tried this near container but it finds only armor on floor not in containerObjectReference[] containerItems = PlayerRef.FindAllReferencesOfType(itemForm, 1000.0) Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 3, 2021 Share Posted September 3, 2021 ItemRef will only be valid if the object added to the container is persistent. You can pass the specific item back to the player when added to the container using RemoveItem, but then it won't be in the container any longer. Not sure what you are wanting to specifically accomplish. Link to comment Share on other sites More sharing options...
Indarello Posted September 3, 2021 Author Share Posted September 3, 2021 ItemRef will only be valid if the object added to the container is persistent. You can pass the specific item back to the player when added to the container using RemoveItem, but then it won't be in the container any longer. Not sure what you are wanting to specifically accomplish. I need item to be in container and in player inventory Link to comment Share on other sites More sharing options...
Zorkaz Posted September 3, 2021 Share Posted September 3, 2021 Scriptname IDItemDuplChestScr extends ObjectReference Event OnLoad() Self.AddInventoryEventFilter(None) EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Int Number = aiItemCount Game.Getplayer().Additem (AkBaseItem, Number) EndEvent Bear in mind that modified weapons and armor can come out very differently when you copy them Link to comment Share on other sites More sharing options...
LarannKiar Posted September 3, 2021 Share Posted September 3, 2021 (edited) There's an F4SE ObjectMod[] function called GetAllMods(). You can use it to add the objects mods of your (container) item into a Papyrus array. Then, use the AttachModToInventoryItem() function to add the objects mods from the array to the (player inventory) item. Note that this function can only add the object mods to a base form and not an object reference (akItem has to be a base form), which means if you have more of this item in your inventory, it will simply add the object mods to one of them. Forgot to mention that before you call AttachModToInventoryItem(), you can remove the object mods from the (player inventory) item with the RemoveModFromInventoryItem() or RemoveAllModsFromInventoryItem() functions. Edited September 3, 2021 by LarannKiar Link to comment Share on other sites More sharing options...
Indarello Posted September 3, 2021 Author Share Posted September 3, 2021 (edited) There's an F4SE ObjectMod[] function called GetAllMods(). You can use it to add the objects mods of your (container) item into a Papyrus array. Then, use the AttachModToInventoryItem() function to add the objects mods from the array to the (player inventory) item. Note that this function can only add the object mods to a base form and not an object reference (akItem has to be a base form), which means if you have more of this item in your inventory, it will simply add the object mods to one of them. Forgot to mention that before you call AttachModToInventoryItem(), you can remove the object mods from the (player inventory) item with the RemoveModFromInventoryItem() or RemoveAllModsFromInventoryItem() functions.Thanks, But first I dont know how to get ObjRefAlso, forgot to mention, I dont need container to have armor with mods, I need only that player wont lose his armor modsso it will be also good for me if item in container will be base form item and player have his moded, legendary armorhope it makes this task simpler Edited September 3, 2021 by Indarello Link to comment Share on other sites More sharing options...
Indarello Posted September 3, 2021 Author Share Posted September 3, 2021 (edited) ItemRef will only be valid if the object added to the container is persistent. You can pass the specific item back to the player when added to the container using RemoveItem, but then it won't be in the container any longer. Not sure what you are wanting to specifically accomplish. So if I try to use use RemoveItem() on Event OnItemAddedand then additem() to container -> player will have his modded legendary armor and container will have base form of item?thanks Edited September 3, 2021 by Indarello Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 3, 2021 Share Posted September 3, 2021 If the player puts the item into the container, you can send it back. If there are no other instances of that object in said container, then the one sent back will be the one put in. If there are other instances of the object in the container, unsure which will be returned, it may be the last added to the stack or the first (testing will be needed) After than you can add a new instance of the object to the container, but this new instance will not have any of the modifications that the player may have made to the initial instance. It is an idea worth exploring, but FO4 may have more available tricks than Skyrim. Feel free to explore some of the other things mentioned. Link to comment Share on other sites More sharing options...
Indarello Posted September 4, 2021 Author Share Posted September 4, 2021 (edited) If the player puts the item into the container, you can send it back. If there are no other instances of that object in said container, then the one sent back will be the one put in. If there are other instances of the object in the container, unsure which will be returned, it may be the last added to the stack or the first (testing will be needed) After than you can add a new instance of the object to the container, but this new instance will not have any of the modifications that the player may have made to the initial instance. It is an idea worth exploring, but FO4 may have more available tricks than Skyrim. Feel free to explore some of the other things mentioned.I dont know but with this code, item just deleted and there will not be this item on player or container anymore Event OnItemAdded(form itemForm, int count, objectReference itemRef, objectReference sourceContainerRef) RemoveItem(itemForm, count, true)EndEvent Edited September 4, 2021 by Indarello Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 5, 2021 Share Posted September 5, 2021 Try the following and see if it meets your needs. Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) (Self as ObjectReference).RemoveItem(akBaseItem,aiItemCount,false,akSourceContainer) ;remove original instance back to source - should be player (Self as ObjectReference).AddItem(akBaseItem,aiItemCount) ;add new instance of the base form to container EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts