Pick and loot treasure chest by t.lore
Description: picks treasure chest then loots everything
1# This script unlocks and completely loots a treasure chest.
2# =============
3# Author: Khas
4# =============
5# How it works:
6# The script first asks you to set a specific loot bag.
7# The script then searches the ground for a metal or wooden chest.
8# Once found, it initiates lockpicking and waits for it to complete.
9# Once complete, it immediately loots all items, prioritizing
10# rare and special loot first down to magic items last.
11
12# Constants
13@setvar! lootDelayMs 200
14
15# Set loot bag
16if varexist lootBag and find lootBag backpack
17 overhead 'Loot bag set'
18else
19 @setvar! lootBag
20 replay
21endif
22
23
24# Find chest
25if findtype 'wooden chest' ground -1 -1 2 as chest
26 overhead 'Found'
27 setvar treasureChest chest
28elseif findtype 'metal chest' ground -1 -1 2 as chest
29 overhead 'Found'
30 setvar treasureChest chest
31else
32 overhead 'Chest not found!' 35
33 overhead 'Move closer!' 35
34 stop
35endif
36
37# Pick chest
38getlabel treasureChest chestLabel
39if 'stones' in chestLabel
40else
41 if counttype 'lockpicks' backpack = 0
42 overhead 'No lockpicks!' 35
43 stop
44 endif
45 dclick treasureChest
46 pause 500
47 gumpresponse 4
48 while counttype 'lockpicks' backpack > 0
49 if insysmsg 'You successfully pick the lock.'
50 break
51 endif
52 overhead 'Picking lock...' 20
53 @clearsysmsg
54 wait 500
55 endwhile
56 overhead 'Picking done' 63
57endif
58getlabel treasureChest chestLabel
59if 'stones' in chestLabel
60else
61 overhead 'Picking failed!' 35
62 # If you get this message, you probably ran out of picks part way through.
63 # Alternatively, there could be something else wrong with the loop waiting for picking to finish.
64endif
65
66# Loot
67# Rares, specials
68while findtype 43206|3985|17686|576|8826|5356|29030|17087|22336|39898|23997|23996|24434|4026|22326 treasureChest as item
69 lift item 10000
70 drop lootBag
71 wait lootDelayMs
72endwhile
73# Dyes, runes
74while findtype 'bottle|rune' treasureChest as item
75 lift item 10000
76 drop lootBag
77 wait lootDelayMs
78endwhile
79# Gold
80while findtype 'gold coin' treasureChest as item
81 lift item 10000
82 drop backpack
83 wait lootDelayMs
84endwhile
85# Scrolls, regs, consumes, gems
86while 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
87 lift item 10000
88 drop lootBag
89 wait lootDelayMs
90endwhile
91# Armor, weapons
92while 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
93 lift item 10000
94 drop lootBag
95 wait lootDelayMs
96endwhile
97
98# Final check
99getlabel treasureChest chestLabel
100if "0 items" in chestLabel
101 overhead 'Looted!' 70
102else
103 overhead 'Chest not empty!' 35
104 # If you get this message, there is an item not accounted for.
105 # Send the Id to Khas if you would be so kind.
106endif