Objective: Moving a subsection of an inventory from one container to another (Requires OBSE 9a/b/c)
Credit should also go to Wolfhound for this one.
This will move a portion of items from one non-player container to another. The items will stay exactly as they are - statuses, health, charge, script variables, etc.
1. Make 3 persistent reference containers and place them in a far-off cell the player can never enter (preferably one of your own). In this example they will be TempInvCont, TempListEquip, and TempListQuest for temporary inventory container, temporary list of equipped items, and temporary list of quest items.
2. Have a script that grabs the reference to the old container and the new container. Here the old container's reference is pOldCont and the new container's reference is pNewCont.
3. Add this to the appropriate script. You will probably want to place it in both a MenuMode block and a GameMode block. If you do, make sure you use different labels for each block.
short InvPositionref pInvObj ;Initialize TempInvCont.RemoveAllItems TempListEquip.RemoveAllItems TempListQuest.RemoveAllItems ;Figure out player's equipment and quest items, remove everything from their inventory to TempInvCont set InvPosition to (player.GetNumItems - 1) Label 1 if (InvPosition >= 0) set pInvObj to (player.GetInventoryObject InvPosition) if (IsQuestItem pInvObj == 0) if (player.GetEquipped pInvObj) TempListEquip.AddItem pInvObj 1 endif else TempListQuest.AddItem pInvObj 1 SetQuestItem 0 pInvObj endif set InvPosition to (InvPosition - 1) Goto 1 endif player.RemoveAllItems TempInvCont, 1 ;Figure out which items in the old container (pOldCont) are what you want and which are quest items, move to player set InvPosition to (pOldCont.GetNumItems - 1) Label 2 if (InvPosition >= 0) set pInvObj to (pOldCont.GetInventoryObject InvPosition) if (IsQuestItem pInvObj == 0) if (IsIngredient pInvObj == 0);or whatever test(s) you want SetQuestItem 1 pInvObj endif else TempListQuest.AddItem pInvObj 1 endif set InvPosition to (InvPosition - 1) Goto 2 endif pIngCont.RemoveAllItems player, 1 ;Move all of the desired items to the new container (pNewCont) player.RemoveAllItems pNewCont, 1 ;Move all of the items back to the old container (pOldCont) set InvPosition to (player.GetNumItems - 1) Label 3 if (InvPosition >= 0) set pInvObj to (player.GetInventoryObject InvPosition) SetQuestItem 0 pInvObj set InvPosition to (InvPosition - 1) Goto 3 endif player.RemoveAllItems pOldCont, 1 ;Move all of the player's items back to the player TempInvCont.RemoveAllItems player, 1 ;Turn everything back into quest items set InvPosition to (TempListQuest.GetNumItems - 1) Label 4 if (InvPosition >= 0) set pInvObj to (TempListQuest.GetInventoryObject InvPosition) SetQuestItem 1 pInvObj set InvPosition to (InvPosition - 1) Goto 4 endif ;Re-equip the player message " " message " " set InvPosition to (TempListEquip.GetNumItems - 1) Label 5 if (InvPosition >= 0) set pInvObj to (TempListEquip.GetInventoryObject InvPosition) player.EquipItem pInvObj set InvPosition to (InvPosition - 1) Goto 5 endif