forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-crafting.lic
244 lines (222 loc) · 9.87 KB
/
common-crafting.lic
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
# quiet
=begin
Documentation: https://elanthipedia.play.net/Lich_script_development#common-crafting
=end
custom_require.call(%w[common common-travel drinfomon])
module DRCC
module_function
def empty_crucible?
['nothing in there'].include?(DRC.bput('look in cruc', 'nothing in there', 'you see'))
end
def find_empty_crucible(hometown)
return unless DRC.bput('tap crucible', 'I could not', 'You tap.*crucible') == 'I could not'
crucibles = get_data('crafting')['blacksmithing'][hometown]['crucibles']
idle_room = get_data('crafting')['blacksmithing'][hometown]['idle-room']
DRCT.find_sorted_empty_room(crucibles, idle_room, proc { (DRRoom.pcs - DRRoom.group_members).empty? && empty_crucible? })
end
def clean_anvil?
case result = DRC.bput('look on anvil', 'surface looks clean and ready', "anvil you see an? (.*)\.", 'anvil you see')
when /surface looks clean and ready/i
true
when /anvil you see an?/
/anvil you see an? (.*)\./ =~ result
clutter = Regexp.last_match(1).split.last
case DRC.bput('clean anvil', 'You drag the', 'remove them yourself')
when /drag/
fput('clean anvil')
pause
waitrt?
else
case DRC.bput("get #{clutter} from anvil", 'You get', 'is not yours')
when 'is not yours'
fput('clean anvil')
fput('clean anvil')
when 'You get'
bput("put #{clutter} in bucket", 'You drop')
else
return false
end
end
true
else
false
end
end
def find_wheel(hometown)
wheels = get_data('crafting')['tailoring'][hometown]['spinning-rooms']
idle_room = get_data('crafting')['tailoring'][hometown]['idle-room']
DRCT.find_sorted_empty_room(wheels, idle_room)
end
def find_anvil(hometown)
return unless DRC.bput('tap anvil', 'I could not', 'You tap.*anvil') == 'I could not'
anvils = get_data('crafting')['blacksmithing'][hometown]['anvils']
idle_room = get_data('crafting')['blacksmithing'][hometown]['idle-room']
DRCT.find_sorted_empty_room(anvils, idle_room, proc { (DRRoom.pcs - DRRoom.group_members).empty? && clean_anvil? })
end
def find_grindstone(hometown)
return unless DRC.bput('tap grindstone', 'I could not', 'You tap.*grindstone') == 'I could not'
grindstones = get_data('crafting')['blacksmithing'][hometown]['grindstones']
idle_room = get_data('crafting')['blacksmithing'][hometown]['idle-room']
DRCT.find_sorted_empty_room(grindstones, idle_room)
end
def find_sewing_room(hometown, override = nil)
if override
DRCT.walk_to(override)
else
sewingrooms = get_data('crafting')['tailoring'][hometown]['sewing-rooms']
idle_room = get_data('crafting')['tailoring'][hometown]['idle-room']
DRCT.find_sorted_empty_room(sewingrooms, idle_room)
end
end
def find_loom_room(hometown, override = nil)
if override
DRCT.walk_to(override)
else
loom_rooms = get_data('crafting')['tailoring'][hometown]['loom-rooms']
idle_room = get_data('crafting')['tailoring'][hometown]['idle-room']
DRCT.find_sorted_empty_room(loom_rooms, idle_room)
end
end
def find_shaping_room(hometown, override = nil)
if override
DRCT.walk_to(override)
else
shapingrooms = get_data('crafting')['shaping'][hometown]['shaping-rooms']
idle_room = get_data('crafting')['shaping'][hometown]['idle-room']
DRCT.find_sorted_empty_room(shapingrooms, idle_room)
end
end
def find_press_grinder_room(hometown)
return unless DRC.bput('tap grinder', 'I could not', 'You tap.*grinder') == 'I could not'
pressgrinderrooms = get_data('crafting')['remedies'][hometown]['press-grinder-rooms']
idle_room = get_data('crafting')['remedies'][hometown]['idle-room']
DRCT.find_sorted_empty_room(pressgrinderrooms, idle_room)
end
def find_enchanting_room(hometown, override = nil)
if override
DRCT.walk_to(override)
else
enchanting_rooms = get_data('crafting')['artificing'][hometown]['brazier-rooms']
idle_room = get_data('crafting')['artificing'][hometown]['idle-room']
DRCT.find_sorted_empty_room(enchanting_rooms, idle_room)
end
end
def recipe_lookup(recipes, item_name)
match_names = recipes.map { |x| x['name'] }.select { |x| x =~ /#{item_name}/i }
case match_names.length
when 0
echo("No recipe in base-recipes.yaml matches #{item_name}")
nil
when 1
recipes.find { |x| x['name'] =~ /#{item_name}/i }
else
echo('Please select desired recipe ;send #')
match_names.each_with_index { |x, i| respond " #{i + 1}: #{x}" }
line = get until line.strip =~ /^([0-9]+)$/
item_name = match_names[Regexp.last_match(1).to_i - 1]
recipes.find { |x| x['name'] =~ /#{item_name}/i }
end
end
def find_recipe(chapter, match_string)
case bput("turn my book to chapter #{chapter}", 'You turn', 'You are too distracted to be doing that right now', 'The book is already turned')
when 'You are too distracted to be doing that right now'
echo '***CANNOT TURN BOOK, ASSUMING I AM ENGAGED IN COMBAT***'
fput('look')
fput('exit')
end
recipe = DRC.bput('read my book', "Page \\d+:\\s(?:some|a|an)?\\s*#{match_string}").split('Page').find { |x| x =~ /#{match_string}/i }
recipe =~ /(\d+):/
Regexp.last_match(1)
end
def get_crafting_item(name, bag, bag_items, belt, skip_exit = false)
waitrt?
if belt && belt['items'].find { |item| /\b#{name}/i =~ item || /\b#{item}/i =~ name }
if DRC.bput("untie my #{name} from my #{belt['name']}", 'You (remove|untie)', 'Untie what', 'Your wounds hinder your ability to do that.') =~ /You (remove|untie)/
return
elsif DRC.bput("untie my #{name} from my #{belt['name']}", 'You (remove|untie)', 'Untie what', 'Your wounds hinder your ability to do that.') =~ /Your wounds hinder your ability to do that./
craft_room = Room.current.id
wait_for_script_to_complete('safe-room', ['force'])
DRCT.walk_to(craft_room)
return get_crafting_item(name, bag, bag_items, belt)
end
end
command = "get my #{name}"
command += " from my #{bag}" if bag_items && bag_items.include?(name)
case DRC.bput(command, '^You get', '^You are already', '^What do you', '^What were you', 'You pick up', "can't quite lift it")
when 'What do you', 'What were you'
pause 2
return if DRCI.in_hands?(name)
beep
echo("You seem to be missing: #{name}")
exit unless skip_exit
when "can't quite lift it"
get_crafting_item(name, bag, bag_items, belt)
end
end
def stow_crafting_item(name, bag, belt)
return unless name
waitrt?
if belt && belt['items'].find { |item| /\b#{name}/i =~ item || /\b#{item}/i =~ name }
case DRC.bput("tie my #{name} to my #{belt['name']}", 'you attach', 'Your wounds hinder')
when 'Your wounds hinder'
craft_room = Room.current.id
wait_for_script_to_complete('safe-room', ['force'])
DRCT.walk_to(craft_room)
return stow_crafting_item(name, bag, belt)
end
else
case DRC.bput("put my #{name} in my #{bag}", 'You put your', 'What were you referring to', 'is too \w+ to fit', 'Weirdly, you can\'t manage', 'There\'s no room', 'You can\'t put that there', 'You combine')
when /is too \w+ to fit/, 'Weirdly, you can\'t manage', 'There\'s no room'
fput("stow my #{name}")
when 'Weirdly, you can\'t manage'
fput("stow my #{name}")
when 'You can\'t put that there'
fput("put my #{name} in my other #{bag}")
return false
end
end
true
end
def logbook_item(logbook, noun, container)
DRC.bput("get my #{logbook} logbook", 'You get')
case DRC.bput("bundle my #{noun} with my logbook", 'You notate the', 'This work order has expired', 'The work order requires items of a higher quality', 'That isn\'t the correct type of item for this work order.')
when 'This work order has expired', 'The work order requires items of a higher quality', 'That isn\'t the correct type of item for this work order.'
dispose_trash(noun)
end
case DRC.bput("put my #{logbook} logbook in my #{container}", 'You put', 'What were you referring to')
when 'What were you referring to'
DRC.bput("stow my #{logbook} logbook", 'You put', 'What were you referring to')
end
end
def order_enchant(stock_room, stock_needed, stock_number, bag, belt)
stock_needed.times do
DRCT.order_item(stock_room, stock_number)
stow_crafting_item(left_hand, bag, belt)
stow_crafting_item(right_hand, bag, belt)
next unless left_hand && right_hand
end
end
def fount(stock_room, stock_needed, stock_number, quantity, bag, bag_items, belt)
case bput('tap my fount', /You tap .* inside your .*/, /You tap .*your .*/, /I could not find what you were referring to./)
when /You tap (.*) inside your (.*)/, /You tap (.*) your (.*)/
/(\d+)/ =~ bput('analyze my fount', 'This appears to be a crafting tool and it has approximately \d+ uses remaining')
if Regexp.last_match(1).to_i < (quantity + 1)
get_crafting_item('fount', bag, bag_items, belt)
DRCT.dispose('fount')
stow_hands
order_enchant(stock_room, stock_needed, stock_number, bag, belt)
end
when /I could not find what you were referring to./
case bput('tap my fount on my brazier', /You tap .* atop a .*brazier./, /I could not find what you were referring to./)
when /You tap (.*) atop a (.*)brazier./
/(\d+)/ =~ bput('analyze my fount on my brazier', 'This appears to be a crafting tool and it has approximately \d+ uses remaining')
if Regexp.last_match(1).to_i < quantity
stow_hands
order_enchant(stock_room, stock_needed, stock_number, bag, belt)
end
when /I could not find what you were referring to./
order_enchant(stock_room, stock_needed, stock_number, bag, belt)
end
end
end
end