Pick and loot treasure chest by t.lore
Description from the author:
# This script unlocks and completely loots a treasure chest.
# =============
# Author: Khas
# =============
# How it works:
# The script first asks you to set a specific loot bag.
# The script then searches the ground for a metal or wooden chest.
# Once found, it initiates lockpicking and waits for it to complete.
# Once complete, it immediately loots all items, prioritizing
# rare and special loot first down to magic items last.
# Constants
@setvar! lootDelayMs 200
# Set loot bag
if varexist lootBag and find lootBag backpack
overhead 'Loot bag set'
else
@setvar! lootBag
replay
endif
# Find chest
if findtype 'wooden chest' ground -1 -1 2 as chest
overhead 'Found'
setvar treasureChest chest
elseif findtype 'metal chest' ground -1 -1 2 as chest
overhead 'Found'
setvar treasureChest chest
else
overhead 'Chest not found!' 35
overhead 'Move closer!' 35
stop
endif
# Pick chest
getlabel treasureChest chestLabel
if 'stones' in chestLabel
else
if counttype 'lockpicks' backpack = 0
overhead 'No lockpicks!' 35
stop
endif
dclick treasureChest
pause 500
gumpresponse 4
while counttype 'lockpicks' backpack > 0
if insysmsg 'You successfully pick the lock.'
break
endif
overhead 'Picking lock...' 20
@clearsysmsg
wait 500
endwhile
overhead 'Picking done' 63
endif
getlabel treasureChest chestLabel
if 'stones' in chestLabel
else
overhead 'Picking failed!' 35
# If you get this message, you probably ran out of picks part way through.
# Alternatively, there could be something else wrong with the loop waiting for picking to finish.
endif
# Loot
# Rares, specials
while findtype 43206|3985|17686|576|8826|5356|29030|17087|22336|39898|23997|23996|24434|4026|22326 treasureChest as item
lift item 10000
drop lootBag
wait lootDelayMs
endwhile
# Dyes, runes
while findtype 'bottle|rune' treasureChest as item
lift item 10000
drop lootBag
wait lootDelayMs
endwhile
# Gold
while findtype 'gold coin' treasureChest as item
lift item 10000
drop backpack
wait lootDelayMs
endwhile
# Scrolls, regs, consumes, gems
while findtype 3827|3981|3976|3963|3974|3972|3973|3980|3962|3617|3903|7163|8022|8022|8023|8024|3856|3861|3873|3862|3877|3865|3859|3878|3885 treasureChest as item
lift item 10000
drop lootBag
wait lootDelayMs
endwhile
# Armor, weapons
while findtype 5056|5059|5060|5061|5063|5070|5074|5075|5076|5078|5085|5089|5090|5101|5103|5105|5106|5129|5131|5132|5135|5138|5139|5142|5143|5144|5146|5201|5203|5204|5205|5207|7169|7170|7173|7175|7177|7179|7181|7610|7947|31003|31004|31005|31006|31007|31008|31009|31010|31011|31012|31015|31191|31017|31019|31021|31023|31025|31027|31029|31031|31033|31035|31037|31038|31041|31043|31045|31047|31049|31051|31053|31055|3834|3740|3742|3762|3763|10245|20006|20008|20010|20012|20014|20016|7026|7027|7029|7031|7033|7034|7035|7107|7109|31002|31130|3920|5042|5117|30990|30993|30994|30995|31184|31186|3719|3922|3938|5121|5123|5125|30989|30992|30996|30997|30998|31176|31188|3568|3713|3721|3932|5040|5044|5112|5127|5177|5179|5181|30991|30999|31000|31001|31014|31178|31180|31182|3909|3911|3913|3915|3917|3934|3937|5046|5049|5115|5119|5182|5185|5187|30988|31128|31190|22187|31141|31142|31169|31172 treasureChest as item
lift item 10000
drop lootBag
wait lootDelayMs
endwhile
# Final check
getlabel treasureChest chestLabel
if "0 items" in chestLabel
overhead 'Looted!' 70
else
overhead 'Chest not empty!' 35
# If you get this message, there is an item not accounted for.
# Send the Id to Khas if you would be so kind.
endifpicks treasure chest then loots everything