forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestock-shop.lic
More file actions
273 lines (235 loc) · 8.37 KB
/
restock-shop.lic
File metadata and controls
273 lines (235 loc) · 8.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#restock-shop
=end
custom_require.call(%w[common common-crafting common-items common-money common-travel])
class ShopRestock
include DRC
include DRCC
include DRCI
include DRCM
include DRCT
def initialize
ensure_copper_on_hand(40_000, get_settings.hometown)
@shop_id = 7943
@inner_id = 9099
@item_list = [
['mask', 60_000, 2, 'in cabinet', 4, 'quilted cloth mask', 1, 1, 'heavy burlap'],
['hood', 100_000, 9, 'in cabinet', 4, 'quilted cloth hood', 1, 1, 'heavy burlap'],
['gloves', 60_000, 4, 'in cabinet', 4, 'quilted cloth gloves', 1, 1, 'heavy burlap'],
['shirt', 220_000, 34, 'in cabinet', 4, 'quilted cloth shirt', 0, 2, 'heavy burlap'],
['pants', 120_000, 10, 'in cabinet', 4, 'quilted cloth pants', 1, 1, 'heavy burlap'],
['backpack', 100_000, 5, 'on table', 3, 'backpack', 'heavy linen'],
['bag', 100_000, 6, 'on table', 3, 'duffel bag', 'heavy linen'],
['sealed', 220_000, 8, 'in cabinet', 'gryphon'],
['sword', 140_000, 9, 'on rack', 'bastard sword', 'steel'],
['spear', 120_000, 7, 'on rack', 'light metal spear', 'steel'],
['mace', 140_000, 12, 'on rack', 'bar mace', 'steel'],
['cutlass', 120_000, 7, 'on rack', 'cutlass', 'steel'],
['bola', 120_000, 5, 'on rack', 'bola', 'steel'],
['hammer', 120_000, 10, 'on rack', 'throwing hammer', 'steel'],
['akabo', 120_000, 13, 'on rack', 'akabo', 'steel'],
['spike', 100_000, 4, 'on rack', 'throwing spike', 'steel'],
['nightstick', 120_000, 7, 'on rack', 'nightstick', 'steel'],
['greataxe', 120_000, 12, 'on rack', 'greataxe', 'steel'],
['carryall', 200_000, 5, 'on table', 3, 'carryall', 'heavy silk'],
['haversack', 200_000, 6, 'on table', 3, 'haversack', 'heavy silk']
]
walk_to(@shop_id)
fput('open entrance')
pause 0.5
fput('go entrance')
check_surfaces
return if Room.current.id == @inner_id
walk_to(@shop_id)
fput('open entrance')
pause 0.5
fput('go entrance')
end
def check_surfaces
missing_items = []
@item_list.map { |x| x[3] }.uniq.each do |surface|
raw_list = bput("look #{surface}", "There's nothing", 'you see [^\.]*')
raw_list = if raw_list == "There's nothing"
[]
else
list_to_nouns(raw_list)
end
missing_items += @item_list.select { |data| surface == data[3] }.reject { |data| raw_list.include?(data.first) }
end
restock_surfaces(missing_items)
end
def restock_surfaces(missing_items)
echo missing_items
restock_steel(missing_items.select { |x| x.last == 'steel' })
restock_burlap(missing_items.select { |x| x.last == 'heavy burlap' })
restock_silk(missing_items.select { |x| x.last == 'heavy silk' })
restock_linen(missing_items.select { |x| x.last == 'heavy linen' })
restock_gryphon(missing_items.select { |x| x.last == 'gryphon' })
end
def restock_steel(missing_items)
return if missing_items.empty?
echo missing_items
volume = ((missing_items.map { |x| x[2] }.inject(&:+) * 1.25) / 10.0).ceil
wait_for_script_to_complete('makesteel', [volume, 'refine'])
missing_items.each do |item|
wait_for_script_to_complete('smith', ['steel', item[4], 'stamp', 'temper'])
walk_to(@shop_id)
fput('open entrance')
pause 0.5
fput('go entrance')
fput("sell my #{item.first} #{item[3]} for #{item[1]}")
end
wait_for_script_to_complete('workorders', %w[blacksmithing repair])
walk_to(8774)
fput('get my steel ingot')
fput('put ingot in bucket')
end
def restock_burlap(missing_items)
return if missing_items.empty?
echo missing_items
volume = missing_items.map { |x| x[2] }.inject(&:+)
have = 0
if bput('get burlap cloth', 'You get', 'What were') == 'You get'
res = bput('count my cloth', 'You count out .*')
have = res.scan(/\d+/).first.to_i
stow_hands
end
if have < volume
multiples = ((volume - have) / 16.0).ceil
multiples.times do
wait_for_script_to_complete('spin', ['burlap'])
wait_for_script_to_complete('spin', ['burlap'])
wait_for_script_to_complete('weave-cloth')
end
end
while bput('get burlap cloth from back', 'You get', 'What were') == 'You get'
fput('combine cloth')
end
stow_hands
missing_items.each do |item|
move('out') if Room.current.id == @inner_id
item[6].times do
order_item(16_667, 11)
fput('stow padding')
end
item[7].times do
order_item(16_667, 12)
fput('stow padding')
end
wait_for_script_to_complete('sew', ['stow', 'sewing', item[4], item[5], item[0]])
fput("get #{item[0]} from back")
fput('get my stamp')
fput("mark my #{item[0]} with my stamp")
waitrt?
pause
fput('stow stamp')
wait_for_script_to_complete('sew', ['reinforce'])
fput("stow #{item[0]}")
walk_to(@shop_id)
fput('open entrance')
pause 0.5
fput('go entrance')
fput("get #{item[0]} from back")
fput("sell my #{item.first} #{item[3]} for #{item[1]}")
end
wait_for_script_to_complete('workorders', %w[tailoring repair])
end
def restock_linen(missing_items)
return if missing_items.empty?
echo missing_items
volume = missing_items.map { |x| x[2] }.inject(&:+)
have = 0
if bput('get linen cloth', 'You get', 'What were') == 'You get'
res = bput('count my cloth', 'You count out .*')
have = res.scan(/\d+/).first.to_i
stow_hands
end
if have < volume
multiples = ((volume - have) / 16.0).ceil
multiples.times do
wait_for_script_to_complete('spin', ['linen'])
wait_for_script_to_complete('spin', ['linen'])
wait_for_script_to_complete('weave-cloth')
end
end
while bput('get linen cloth from back', 'You get', 'What were') == 'You get'
fput('combine cloth')
end
stow_hands
missing_items.each do |item|
move('out') if Room.current.id == @inner_id
wait_for_script_to_complete('sew', ['stow', 'sewing', item[4], item[5], item[0]])
walk_to(@shop_id)
fput('open entrance')
pause 0.5
fput('go entrance')
fput("get #{item[0]} from back")
fput('get my stamp')
fput("mark my #{item[0]} with my stamp")
waitrt?
pause
fput('stow stamp')
fput("sell my #{item.first} #{item[3]} for #{item[1]}")
end
end
def restock_silk(missing_items)
return if missing_items.empty?
echo missing_items
volume = missing_items.map { |x| x[2] }.inject(&:+)
have = 0
if bput('get silk cloth from my back', 'You get', 'What were') == 'You get'
res = bput('count my cloth', 'You count out .*')
have = res.scan(/\d+/).first.to_i
stow_hands
end
if have < volume
multiples = ((volume - have) / 16.0).ceil
multiples.times do
wait_for_script_to_complete('spin', ['silk'])
wait_for_script_to_complete('spin', ['silk'])
wait_for_script_to_complete('weave-cloth')
end
end
while bput('get silk cloth from my back', 'You get', 'What were') == 'You get'
fput('combine cloth')
end
stow_hands
missing_items.each do |item|
move('out') if Room.current.id == @inner_id
wait_for_script_to_complete('sew', ['stow', 'sewing', item[4], item[5], item[0]])
walk_to(@shop_id)
fput('open entrance')
pause 0.5
fput('go entrance')
fput("get #{item[0]} from back")
fput('get my stamp')
fput("mark my #{item[0]} with my stamp")
waitrt?
pause
fput('stow stamp')
fput("sell my #{item.first} #{item[3]} for #{item[1]}")
end
end
def restock_gryphon(missing_items)
return if missing_items.empty?
echo missing_items
order_item(16_667, 16)
order_item(16_667, 17)
stow_hands
wait_for_script_to_complete('sew', ['stow', 'leather', 10, 'small leather shield', 'shield', 'gryphon'])
fput('stow leather')
fput('get shield from my back')
wait_for_script_to_complete('sew', ['seal'])
walk_to(@shop_id)
fput('open entrance')
pause 0.5
fput('go entrance')
fput('get my stamp')
fput('mark my shield with my stamp')
waitrt?
pause
fput('stow stamp')
fput('sell my shield in cabinet for 220000')
end
end
ShopRestock.new