Artemis Auto Splitter by abianche
Description from the author:
# ------------------------------------------------------------
# Auto Splitter v2.1
# Made by @abianche on Discord (Artemis)
#
# Description
# Automatically splits stackable items into multiple smaller stacks
# and distributes them into chosen containers (anti-theft).
#
# Splits: Reagents, Recall Scrolls, Potions, Bandages, Vet Supplies,
# Rope, Traps, Crystals, Arrows, Bolts
#
# Features
# - Each item group (reagents, potions, misc, ammo) can be switched on/off
# - Bags are auto-selected or manually picked, separately for
# reagents, potions, misc and quiver
# - Auto-select priority: satchel > pouch > backpack bag > rounded bag
# > main backpack, and each bag type can be allowed/skipped
# - The character's main backpack is excluded when searching for
# "backpack bag" containers
# - All items are data-driven: to add one, add a block to the
# ITEM DATA section (id, hue, drop Y, amount profile, target bag)
#
# Changelog
# v2.1 Bag-type toggles for auto-select, main backpack excluded
# from the bag search
# v2.0 Single data-driven loop for all items, split toggles,
# overhead messages built from the item label
# v1.2 Added crystals
# v1.1 Added traps
# v1.0 Initial implementation
#
# ------------------------------------------------------------
# =========================
# USER SETTINGS
# =========================
# Reagents bag. 1 = auto select, 0 = manual select.
@setvar! autoSelectRegBag 1
# Potions bag. 1 = auto select, 0 = manual select.
@setvar! autoSelectPotionBag 1
# Misc bag. 1 = auto select, 0 = manual select.
@setvar! autoSelectMiscBag 1
# Quiver bag. 1 = auto select (quiver if found), 0 = manual select.
@setvar! autoSelectQuiverBag 1
# Split items. 1 = split, 0 = do not split.
@setvar! splitReagents 1
@setvar! splitPotions 1
@setvar! splitMisc 1
@setvar! splitAmmo 1
# Bag types auto-select may use. 1 = allowed, 0 = skip.
# Priority stays: satchel > pouch > backpack bag > rounded bag > main backpack
@setvar! useSatchel 1
@setvar! usePouch 1
@setvar! useBackpackBag 1
@setvar! useRoundedBag 1
# =========================
# DO NOT EDIT BELOW UNLESS YOU KNOW THE SCRIPT
# =========================
clearignore
@setvar! maxwaittimeinms 650
#********** Bags **********#
# slot 0 = reagents, 1 = potions, 2 = misc, 3 = quiver
for 4
# per-slot settings
if index = 0
@setvar! autoOn autoSelectRegBag
@setvar! prefType 30765
elseif index = 1
@setvar! autoOn autoSelectPotionBag
@setvar! prefType 31262
elseif index = 2
@setvar! autoOn autoSelectMiscBag
@setvar! prefType 0
else
@setvar! autoOn autoSelectQuiverBag
@setvar! prefType 12215
endif
@setvar! thisBag 0
if autoOn = 1
if index = 3
# Quiver: real quiver if found, otherwise the misc bag
@setvar! thisBag myMiscBag
if findtype prefType self as q
@setvar! thisBag q
endif
else
@ignore backpack
if useSatchel = 1
if prefType > 0
if findtype prefType self as b
@setvar! thisBag b
endif
endif
endif
if thisBag = 0 and usePouch = 1
if findtype 3705 self as b
@setvar! thisBag b
endif
endif
if thisBag = 0 and useBackpackBag = 1
if findtype 3701 self as b
@setvar! thisBag b
endif
endif
if thisBag = 0 and useRoundedBag = 1
if findtype 3702 self as b
@setvar! thisBag b
endif
endif
@unignore backpack
if thisBag = 0
@setvar! thisBag backpack
endif
endif
else
clearsysmsg
if index = 0
overhead "Select Reagent bag:" 68
elseif index = 1
overhead "Select Potion bag:" 68
elseif index = 2
overhead "Select Misc bag:" 68
else
overhead "Select Quiver bag:" 68
endif
@setvar! thisBag
wait 200
while not targetexists and not insysmsg "Select"
@setvar! thisBag
endwhile
if find thisBag self
getlabel thisBag bagLabel
if "satchel" in bagLabel or "pouch" in bagLabel or "bag" in bagLabel or "backpack" in bagLabel or "quiver" in bagLabel
sysmsg "new bag set" 55
else
overhead "That is not a bag" 34
sysmsg "That is not a bag" 34
stop
endif
else
overhead "No bag found!" 34
stop
endif
endif
if index = 0
@setvar! myRegBag thisBag
elseif index = 1
@setvar! myPotionBag thisBag
elseif index = 2
@setvar! myMiscBag thisBag
else
@setvar! myQuiverBag thisBag
endif
endfor
overhead "Auto Splitter started..." 55
#********** Drop X positions **********#
# Column used for the 1st, 2nd, 3rd... stack. Stacks past the
# end of the list reuse the last column (142 / 125 / 55).
if not listexists 'x_pack'
createlist 'x_pack'
endif
if not listexists 'x_misc'
createlist 'x_misc'
endif
if not listexists 'x_ammo'
createlist 'x_ammo'
endif
clearlist 'x_pack'
clearlist 'x_misc'
clearlist 'x_ammo'
# Reagent + potion bags
pushlist 'x_pack' 44 back
pushlist 'x_pack' 68 back
pushlist 'x_pack' 96 back
pushlist 'x_pack' 121 back
pushlist 'x_pack' 142 back
# Misc bag
pushlist 'x_misc' 45 back
pushlist 'x_misc' 65 back
pushlist 'x_misc' 85 back
pushlist 'x_misc' 105 back
pushlist 'x_misc' 125 back
# Quiver
pushlist 'x_ammo' 35 back
pushlist 'x_ammo' 40 back
pushlist 'x_ammo' 45 back
pushlist 'x_ammo' 50 back
pushlist 'x_ammo' 55 back
#********** ITEM DATA **********#
# item_ids : item graphic id
# item_hue : overhead hue
# item_y : drop Y position inside the bag
# item_amt : amount profile 1 = standard, 2 = recall scroll,
# 3 = greater agility, 4 = greater magic resist
# item_bag : target bag 1 = reagents, 2 = potions, 3 = misc, 4 = quiver
if not listexists 'item_ids'
createlist 'item_ids'
endif
if not listexists 'item_hue'
createlist 'item_hue'
endif
if not listexists 'item_y'
createlist 'item_y'
endif
if not listexists 'item_amt'
createlist 'item_amt'
endif
if not listexists 'item_bag'
createlist 'item_bag'
endif
clearlist 'item_ids'
clearlist 'item_hue'
clearlist 'item_y'
clearlist 'item_amt'
clearlist 'item_bag'
# ----- Reagents + Recall -----
if splitReagents = 1
# Spider Silk
pushlist 'item_ids' 3981 back
pushlist 'item_hue' 0 back
pushlist 'item_y' 65 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 1 back
# Black Pearl
pushlist 'item_ids' 3962 back
pushlist 'item_hue' 11 back
pushlist 'item_y' 75 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 1 back
# Nightshade
pushlist 'item_ids' 3976 back
pushlist 'item_hue' 66 back
pushlist 'item_y' 85 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 1 back
# Mandrake Root
pushlist 'item_ids' 3974 back
pushlist 'item_hue' 439 back
pushlist 'item_y' 95 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 1 back
# Sulfurous Ash
pushlist 'item_ids' 3980 back
pushlist 'item_hue' 56 back
pushlist 'item_y' 105 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 1 back
# Ginseng
pushlist 'item_ids' 3973 back
pushlist 'item_hue' 149 back
pushlist 'item_y' 115 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 1 back
# Blood Moss
pushlist 'item_ids' 3963 back
pushlist 'item_hue' 35 back
pushlist 'item_y' 125 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 1 back
# Garlic
pushlist 'item_ids' 3972 back
pushlist 'item_hue' 910 back
pushlist 'item_y' 135 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 1 back
# Recall Scroll
pushlist 'item_ids' 8012 back
pushlist 'item_hue' 0 back
pushlist 'item_y' 145 back
pushlist 'item_amt' 2 back
pushlist 'item_bag' 1 back
endif
# ----- Potions -----
if splitPotions = 1
# Greater Heal
pushlist 'item_ids' 3852 back
pushlist 'item_hue' 48 back
pushlist 'item_y' 65 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 2 back
# Greater Cure
pushlist 'item_ids' 3847 back
pushlist 'item_hue' 44 back
pushlist 'item_y' 75 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 2 back
# Greater Agility
pushlist 'item_ids' 3848 back
pushlist 'item_hue' 93 back
pushlist 'item_y' 85 back
pushlist 'item_amt' 3 back
pushlist 'item_bag' 2 back
# Total Refresh
pushlist 'item_ids' 3851 back
pushlist 'item_hue' 38 back
pushlist 'item_y' 95 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 2 back
# Greater Magic Resist
pushlist 'item_ids' 3846 back
pushlist 'item_hue' 897 back
pushlist 'item_y' 105 back
pushlist 'item_amt' 4 back
pushlist 'item_bag' 2 back
# Greater Strength
pushlist 'item_ids' 3849 back
pushlist 'item_hue' 2041 back
pushlist 'item_y' 115 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 2 back
# Greater Explode
pushlist 'item_ids' 3853 back
pushlist 'item_hue' 1275 back
pushlist 'item_y' 125 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 2 back
# Lethal Poison
pushlist 'item_ids' 3850 back
pushlist 'item_hue' 1267 back
pushlist 'item_y' 135 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 2 back
endif
# ----- Misc (Bandages + Vet Supplies + Rope + Traps + Crystals) -----
if splitMisc = 1
# Bandages
pushlist 'item_ids' 3617 back
pushlist 'item_hue' 0 back
pushlist 'item_y' 45 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 3 back
# Vet Supplies
pushlist 'item_ids' 25750 back
pushlist 'item_hue' 15 back
pushlist 'item_y' 70 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 3 back
# Rope
pushlist 'item_ids' 5370 back
pushlist 'item_hue' 360 back
pushlist 'item_y' 105 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 3 back
# Traps
pushlist 'item_ids' 19821 back
pushlist 'item_hue' 897 back
pushlist 'item_y' 125 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 3 back
# Crystals
pushlist 'item_ids' 20309 back
pushlist 'item_hue' 999 back
pushlist 'item_y' 125 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 3 back
endif
# ----- Ammo -----
if splitAmmo = 1
# Arrows
pushlist 'item_ids' 3903 back
pushlist 'item_hue' 38 back
pushlist 'item_y' 45 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 4 back
# Bolts
pushlist 'item_ids' 7163 back
pushlist 'item_hue' 93 back
pushlist 'item_y' 65 back
pushlist 'item_amt' 1 back
pushlist 'item_bag' 4 back
endif
#********** MAIN LOOP **********#
while list 'item_ids' > 0
if poplist 'item_ids' front as tmpVal
@setvar! itemID tmpVal
else
overhead "Item list error" 34
stop
endif
if poplist 'item_hue' front as tmpVal
@setvar! itemHue tmpVal
endif
if poplist 'item_y' front as tmpVal
@setvar! dropY tmpVal
endif
if poplist 'item_amt' front as tmpVal
@setvar! amtProfile tmpVal
endif
if poplist 'item_bag' front as tmpVal
@setvar! bagKind tmpVal
endif
# ---- target bag ----
if bagKind = 1
@setvar! targetBag myRegBag
elseif bagKind = 2
@setvar! targetBag myPotionBag
elseif bagKind = 3
@setvar! targetBag myMiscBag
else
@setvar! targetBag myQuiverBag
endif
# ---- count stacks ----
@setvar! myCounter 0
while findtype itemID self as r
@setvar! myCounter index
@ignore r
endwhile
@clearignore
# ---- amount per split ----
if amtProfile = 2
# Recall scroll profile
if counttype itemID self <= 5
@setvar! amount 1
elseif counttype itemID self <= 10
@setvar! amount 2
elseif counttype itemID self <= 20
@setvar! amount 4
elseif counttype itemID self <= 40
@setvar! amount 8
else
@setvar! amount 15
endif
elseif amtProfile = 3
# Greater Agility profile
if counttype itemID self <= 10
@setvar! amount 1
elseif counttype itemID self <= 20
@setvar! amount 2
elseif counttype itemID self <= 50
@setvar! amount 4
elseif counttype itemID self <= 100
@setvar! amount 10
elseif counttype itemID self <= 150
@setvar! amount 20
elseif counttype itemID self <= 200
@setvar! amount 30
else
@setvar! amount 40
endif
elseif amtProfile = 4
# Greater Magic Resist profile
if counttype itemID self <= 10
@setvar! amount 1
elseif counttype itemID self <= 20
@setvar! amount 2
elseif counttype itemID self <= 50
@setvar! amount 5
elseif counttype itemID self <= 100
@setvar! amount 10
elseif counttype itemID self <= 150
@setvar! amount 20
elseif counttype itemID self <= 200
@setvar! amount 30
else
@setvar! amount 40
endif
else
# Standard profile
if counttype itemID self <= 10
@setvar! amount 2
elseif counttype itemID self <= 20
@setvar! amount 4
elseif counttype itemID self <= 50
@setvar! amount 10
elseif counttype itemID self <= 100
@setvar! amount 20
elseif counttype itemID self <= 150
@setvar! amount 30
elseif counttype itemID self <= 200
@setvar! amount 40
else
@setvar! amount 50
endif
endif
# ---- split and move ----
while findtype itemID self as thisStack
# drop column for this stack
if bagKind = 3
@setvar! dropX 125
if atlist 'x_misc' index as tmpVal
@setvar! dropX tmpVal
endif
elseif bagKind = 4
@setvar! dropX 55
if atlist 'x_ammo' index as tmpVal
@setvar! dropX tmpVal
endif
else
@setvar! dropX 142
if atlist 'x_pack' index as tmpVal
@setvar! dropX tmpVal
endif
endif
@setvar! moveIt 0
if myCounter = 0
@setvar! moveIt 1
elseif not find thisStack targetBag
@setvar! moveIt 1
endif
if moveIt = 1
# sysmsg "id {{itemID}} stack {{thisStack}} idx {{index}}" 90
getlabel thisStack stackLabel
overhead "{{stackLabel}}..." itemHue
lift thisStack amount
drop targetBag dropX dropY 0
endif
@ignore thisStack
if moveIt = 1
wait maxwaittimeinms
endif
endwhile
endwhile
overhead "Splitter completed!" 55Automatically splits stackable items into multiple smaller stacks nd distributes them into chosen containers (anti-theft).








