xanderdunn / skaar

Mods for Skyrim: Hardcore Mode, Soul Displays, Skaar House Mod
53 stars 8 forks source link

Crafting Tables Pull from Nearby Chests #1

Closed xanderdunn closed 6 years ago

xanderdunn commented 10 years ago

Pulling items from the user's inventory is a pain in the ass. Instead, pull everything from a nearby designated chest.

xanderdunn commented 10 years ago

It looks like the location where workbenches get their items is hardcoded to the player.

Idea: Move all items in a container to the player's inventory and then back to the container when done.

  1. Set a custom script on the container that adds every added Form to a FormList:
ScriptName aaCustomContainerScript extends ObjectReference

FormList Property aaItemList auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

    While aiItemCount > 0
        aaItemList.AddForm(akBaseItem) ; tracking list of items in container
        aiItemCount -= 1
    EndWhile

EndEvent
  1. Move from container to RemoveAllItems(akTransferTo = Player, abKeepOwnership = true).
    • Will this add the items to the player silently?
    • Will I need to increase the player's max carry weight for this to work?
    • You could use an AddInventoryEventFilter to ignore any items the player might put in that aren't ingredients
  2. Two possibilities for getting the items back into the container:
    • Iterate through all the forms in the FormList to move it to the container if it still exists. (This will work only if the used items have a checkable state change from the unused ones)
    • Every time the player uses an item, if it is in the FormList, remove it. Then simply move all items in the FormList to the container on workbench completion.
xanderdunn commented 10 years ago

The above isn't going to work because Papyrus is too slow, it doesn't tell me how much of each item is being removed from a container or allow me to get a list of what is in a container, and it doesn't allow arrays larger than 128 items.

property Container item list (cil)

To Do

Situations to worry about:

Tests I need to do

xanderdunn commented 10 years ago

Improvements

xanderdunn commented 6 years ago

This is complete save for #34