Code:
;~ Description: Opens storage window, only in outpost its possible to change content of chest.
Func OpenStorageWindow()
Local $ID = StorageSessionID()
DllStructSetData($mOpenStorage, 2, $ID)
DllStructSetData($mOpenStorage, 3, 0)
DllStructSetData($mOpenStorage, 4, 1)
Enqueue($mOpenStoragePtr, 16)
EndFunc ;==>OpenStorageWindow
;~ Description: Gets current storage session ID.
Func StorageSessionID()
Local $lOffset[3] = [0x118, 0x10, 0]
$lReturn = MemoryReadPtr($mStorageSessionBase, $lOffset)
Return MemoryRead($lReturn[1] + 0x14)
EndFunc ;==>StorageSessionID
;~ Description: Store full stacks, unident golds and mods.
Func StoreItems()
$mStoreMaterials = true
UpdateEmptyStorageSlot($mEmptyBag, $mEmptySlot)
Update("Empty Spot: " & $mEmptyBag & ", " & $mEmptySlot)
If $mEmptySlot = 0 Then Return ; no more empty slots found
OpenStorageWindow()
For $bag = 1 To 4 ; inventory only
$lBagPtr = GetBagPtr($bag)
If $lBagPtr = 0 Then ContinueLoop ; empty bag slot
$lItemArrayPtr = MemoryRead($lBagPtr + 24, 'ptr')
For $slot = 0 To MemoryRead($lBagPtr + 32, 'long') - 1
$lItemPtr = MemoryRead($lItemArrayPtr + 4 * ($slot), 'ptr')
If $lItemPtr = 0 Then ContinueLoop ; empty slot
$lItemID = MemoryRead($lItemPtr, 'long')
$lItemType = MemoryRead($lItemPtr + 32, 'byte')
$lItemQuantity = MemoryRead($lItemPtr + 75, 'byte')
$lItemMID = MemoryRead($lItemPtr + 44, 'long')
If $lItemType = 11 And $lItemQuantity = 250 And $mStoreMaterials Then ; materials
If $lItemMID = 948 or $lItemMID = 929 or $lItemMID = 933 or $lItemMID = 934 or $lItemMID = 921 Then
Update("Store Materials: " & $bag & ", " & $slot & " -> " & $mEmptyBag & ", " & $mEmptySlot)
MoveItem($lItemID, $mEmptyBag, $mEmptySlot)
Do
Sleep(250)
Until MemoryRead($lItemArrayPtr + 4 * ($slot), 'ptr') = 0
UpdateEmptyStorageSlot($mEmptyBag, $mEmptySlot)
If $mEmptySlot = 0 Then Return
ContinueLoop
EndIf
EndIf
If StackableItems($lItemMID) And $lItemQuantity = 250 Then ; only full stacks
Update("Store Stack: " & $bag & ", " & $slot & " -> " & $mEmptyBag & ", " & $mEmptySlot)
MoveItem($lItemID, $mEmptyBag, $mEmptySlot)
Do
Sleep(250)
Until MemoryRead($lItemArrayPtr + 4 * ($slot), 'ptr') = 0
UpdateEmptyStorageSlot($mEmptyBag, $mEmptySlot)
If $mEmptySlot = 0 Then Return
ContinueLoop
EndIf
If Keepers($lItemMID) Then
Update("Store Keepers: " & $bag & ", " & $slot & " -> " & $mEmptyBag & ", " & $mEmptySlot)
MoveItem($lItemID, $mEmptyBag, $mEmptySlot)
Do
Sleep(250)
Until MemoryRead($lItemArrayPtr + 4 * ($slot), 'ptr') = 0
UpdateEmptyStorageSlot($mEmptyBag, $mEmptySlot)
If $mEmptySlot = 0 Then Return ; no more empty slots
ContinueLoop
EndIf
If $mStoreGold And GetRarity($lItemPtr) = 2624 Then ; store unident golds if possible
Update("Store Golds: " & $bag & ", " & $slot & " -> " & $mEmptyBag & ", " & $mEmptySlot)
MoveItem($lItemID, $mEmptyBag, $mEmptySlot)
Do
Sleep(250)
Until MemoryRead($lItemArrayPtr + 4 * ($slot), 'ptr') = 0
UpdateEmptyStorageSlot($mEmptyBag, $mEmptySlot)
If $mEmptySlot = 0 Then Return ; no more empty slots
ContinueLoop
EndIf
Next
Next
EndFunc ;==>StoreItems