forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforge.lic
433 lines (395 loc) · 13.4 KB
/
forge.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
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#forge
=end
custom_require.call(%w(common common-crafting common-travel events))
class Forge
include DRC
include DRCC
include DRCT
def initialize
arg_definitions = [
[
{ name: 'book_type', display: 'book type', options: %w(black armor weapon), description: 'What smithing type is this item.' },
{ name: 'chapter', regex: /\d+/i, variable: true, description: 'Chapter containing the item.' },
{ name: 'recipe_name', display: 'recipe name', regex: /^[A-z\s\-]+$/i, variable: true, description: 'Name of the recipe, wrap in double quotes if this is multiple words.' },
{ name: 'metal', regex: /\w+/i, variable: true, description: 'Type of metal ingot to use.' },
{ name: 'noun', regex: /\w+/i, variable: true }
],
[
{ name: 'temper', regex: /temper/i },
{ name: 'noun', regex: /\w+/i, variable: true, description: 'Noun of item to temper.' }
],
[
{ name: 'balance', regex: /balance/i },
{ name: 'noun', regex: /\w+/i, variable: true, description: 'Noun of item to balance.' }
],
[
{ name: 'hone', regex: /hone/i },
{ name: 'noun', regex: /\w+/i, variable: true, description: 'Noun of item to hone.' }
],
[
{ name: 'lighten', regex: /lighten/i },
{ name: 'noun', regex: /\w+/i, variable: true, description: 'Noun of item to lighten.' }
],
[
{ name: 'resume', regex: /resume/i },
{ name: 'book_type', display: 'book type', options: %w(black armor weapon), description: 'What smithing type is this item.' },
{ name: 'noun', regex: /\w+/i, variable: true, description: 'Noun of item to hone.' }
]
]
args = parse_args(arg_definitions)
settings = get_settings
@hometown = settings.hometown
@stamp = settings.mark_crafted_goods
@bag = settings.crafting_container
@bag_items = settings.crafting_items_in_container
@belt = settings.forging_belt
@hammer = settings.forging_tools.find { |item| /hammer/ =~ item }
@item = args.noun
Flags.add('forge-assembly', 'another finished \S+ shield (handle)', 'another finished wooden (hilt|haft)', 'another finished (long|short|small|large) leather (cord|backing)', 'another finished (small|large) cloth (padding)', 'another finished (long|short) wooden (pole)', 'ready to be woven into and around the material')
Flags.add('hone-done', 'the metal now needs protection by pouring oil on it')
if args.temper
temper
elsif args.hone
hone
elsif args.balance
balance
elsif args.lighten
lighten
elsif args.resume
@book_type = args.book_type
analyze_item
else
@book_type = args.book_type
@chapter = args.chapter
@recipe_name = args.recipe_name
@metal = args.metal
smith
end
end
def get_item(name)
get_crafting_item(name, @bag, @bag_items, @belt)
end
def stow_item(name)
stow_crafting_item(name, @bag, @belt)
end
def turn_to(section)
bput("turn my book to #{section}", 'You turn your', 'The book is already')
end
def temper
unless left_hand =~ /#{@item}/i || right_hand =~ /#{@item}/i
echo('***Please hold the item to temper.***')
exit
end
bput("put my #{@item} on the forge", 'Put your item onto the forge')
temper_turn(true)
end
def hone
find_grindstone(@hometown)
get_item('weaponsmithing book')
turn_to("page #{find_recipe(10, 'metal weapon honing')}")
bput('study my book', 'Roundtime')
stow_item('book')
Flags.reset('hone-done')
do_hone
end
def balance
find_grindstone(@hometown)
get_item('weaponsmithing book')
turn_to("page #{find_recipe(10, 'metal weapon balancing')}")
bput('study my book', 'Roundtime')
stow_item('book')
Flags.reset('hone-done')
do_hone
end
def lighten
find_grindstone(@hometown)
get_item('armorsmithing book')
turn_to("page #{find_recipe(5, 'lightening')}")
bput('study my book', 'Roundtime')
stow_item('book')
get_item('plier')
bput("pull my #{@item} with my pliers", 'must be pounded free')
stow_item('plier')
bput("put #{@item} on anvil", 'You put')
get_item(@hammer)
get_item('tongs')
bput("pound #{@item} with my hammer", 'roundtime')
stow_item(@hammer)
stow_item('tongs')
bput("get #{@item}", 'You get')
do_lighten
end
def spin_grindstone
until 'keeping it spinning fast' == bput('turn grind', 'keeping it spinning fast', 'Roundtime')
pause
waitrt?
end
end
def do_hone
spin_grindstone
case bput("push grind with #{@item}", 'The grinding has left many nicks and burs in the metal that should be cleaned away', 'roundtime')
when /nicks and burs/
get_item('wire brush')
bput("rub #{@item} with my brush", 'roundtime')
stow_item('brush')
end
pause
waitrt?
if Flags['hone-done']
pour_oil
else
do_hone
end
end
def do_lighten
spin_grindstone
case bput("push grind with #{@item}", 'With the grinding complete', 'roundtime')
when 'With the grinding complete'
bput("put #{@item} on anvil", 'You put')
get_item(@hammer)
get_item('tongs')
bput("pound #{@item} with my hammer", 'roundtime')
stow_item(@hammer)
stow_item('tongs')
bput("get #{@item}", 'You get')
get_item('plier')
bput("pull my #{@item} with my pliers", 'roundtime')
stow_item('plier')
pour_oil
else
do_lighten
end
end
def temper_turn(first = false)
waitrt?
command = first ? "put my #{@item} on the forge" : "turn #{@item} on forge with my tong"
case bput(command,
'needs more fuel', 'need some more fuel',
'As you finish working the fire dims and produces less heat', 'As you finish the fire flickers and is unable to consume its fuel',
'Roundtime',
'metal looks to be in need of some oil to preserve', 'to be cleaned')
when 'needs more fuel', 'need some more fuel'
get_item('shovel')
bput('push fuel with my shovel', 'Roundtime')
waitrt?
stow_item('shovel')
when 'As you finish working the fire dims and produces less heat', 'As you finish the fire flickers and is unable to consume its fuel'
get_item('bellows')
bput('push my bellows', 'Roundtime')
waitrt?
stow_item('bellows')
when 'metal looks to be in need of some oil to preserve', 'to be cleaned'
temper_finish
return
end
get_item('tongs') unless right_hand
temper_turn
end
def temper_finish
stow_item('tong')
fput("get #{@item} from forge")
pour_oil
end
def smith
get_item("#{@book_type} book")
turn_to("page #{find_recipe(@chapter, @recipe_name)}")
bput('study my book', 'Roundtime')
stow_item('book')
get_item("#{@metal} ingot")
bput('put my ingot on anvil', 'You put your')
get_item(@hammer)
get_item('tongs')
pound('ingot')
end
def pound(item = @item)
waitrt?
case bput("pound #{item} on anvil with my hammer",
'You must be holding',
'needs more fuel', 'need some more fuel',
'As you finish working the fire dims and produces less heat', 'As you finish the fire flickers and is unable to consume its fuel',
'Roundtime',
'ready for cooling in the slack tub', 'ready for a quench hardening in the slack tub',
'straightening along the horn of the anvil', 'would benefit from some soft reworking.',
'sets using tongs', 'into wire using a mandrel or mold set', 'set using tongs',
'That tool does not seem',
'push them deep into the fire to set',
'You believe you can assemble',
'You need a larger volume of metal',
'I could not find what you were referring to')
when 'You must be holding'
get_item(@hammer)
pound(item)
when 'needs more fuel', 'need some more fuel'
add_fuel
when 'As you finish working the fire dims and produces less heat', 'As you finish the fire flickers and is unable to consume its fuel'
bellows
when 'ready for cooling in the slack tub', 'ready for a quench hardening in the slack tub'
slack_tub
when 'straightening along the horn of the anvil', 'would benefit from some soft reworking.', 'sets using tongs', 'set using tongs', 'into wire using a mandrel or mold set'
turn_item
when 'That tool does not seem'
analyze_item
when 'You believe you can assemble'
stow_item(@hammer)
stow_item('tongs')
bput("get #{@item} from anvil", 'You get')
assemble_part
Flags.reset('forge-assembly')
bput("put #{@item} on anvil", 'You put')
analyze_item
when 'You need a larger volume of metal'
echo '***You need a larger ingot to forge this item.***'
exit
when 'I could not find what you were referring to'
echo '*** ERROR TRYING TO CRAFT, EXITING ***'
stow_item(right_hand)
exit
else
pound
end
end
def add_fuel
stow_item('tongs')
get_item('shovel')
case bput('push fuel with my shovel', 'Roundtime', 'That tool does not seem')
when 'That tool does not seem'
analyze_item
else
waitrt?
stow_item('shovel')
get_item('tongs')
pound
end
end
def bellows
stow_item(@hammer)
get_item('bellows')
case bput('push my bellows', 'Roundtime', 'That tool does not seem')
when 'That tool does not seem'
analyze_item
else
waitrt?
stow_item('bellows')
get_item(@hammer)
pound
end
end
def turn_item
waitrt?
case bput("turn #{@item} on anvil with my tongs",
'ready for cooling in the slack tub', 'ready for a quench hardening in the slack tub',
'Roundtime',
'That tool does not seem')
when 'ready for cooling in the slack tub', 'ready for a quench hardening in the slack tub'
slack_tub
when 'That tool does not seem'
analyze_item
else
pound
end
end
def slack_tub
stow_item(@hammer)
stow_item('tongs')
Flags.reset('forge-assembly')
bput('push tub', 'Roundtime')
waitrt?
bput("get #{@item} from anvil", 'You get')
assemble_part
if 'armorsmithing'.include? @book_type
get_item('pliers')
loop do
case bput("pull my #{@item} with my pliers", 'roundtime', 'need of some oil', 'That tool does not seem suitable for that task')
when 'That tool does not seem suitable for that task'
stow_item('pliers')
bput("put #{@item} on anvil", 'You put')
Flags.reset('forge-assembly')
analyze_item
return
when 'need of some oil'
break
end
pause
waitrt?
stow_item('pliers')
assemble_part
get_item('pliers')
end
stow_item('pliers')
elsif 'weaponsmithing'.include? @book_type
grind_item
end
add_oil
end
def assemble_part
while Flags['forge-assembly']
part = nil
part = if Flags['forge-assembly'].first == 'ready to be woven into and around the material'
'padding'
else
Flags['forge-assembly'][1..-1].join('.')
end
Flags.reset('forge-assembly')
fput("get my #{part}")
bput("assemble my #{@item} with my #{part}", 'affix it securely in place', 'and tighten the pommel to secure it', 'carefully mark where it will attach when you continue crafting')
waitrt?
end
end
def grind_item
find_grindstone(@hometown)
spin_grindstone
bput("push grind with my #{@item}", 'Roundtime', 'needs protection')
waitrt?
end
def pour_oil
ords = %w(second third fourth fifth sixth)
get_item('oil')
while "You can't pour" == bput("pour my oil on my #{@item}", 'Roundtime', 'Applying the final touches', "You can't pour")
stow_item('oil')
get_item("#{ords.shift} oil")
end
waitrt?
stow_item('oil')
end
def add_oil
pour_oil
return unless @stamp
get_item('stamp')
fput("mark my #{@item} with my stamp")
pause
waitrt?
stow_item('stamp')
end
def analyze_item
waitrt?
stow_item(left_hand) # store contents of both hands, reacquire hammer and tongs
stow_item(right_hand)
get_item(@hammer)
get_item('tongs')
case bput("analyze #{@item}", 'The metal is ready to be cooled', 'Almost all of the coal has been consumed', 'ready for more pounding', 'metal will quickly rust', 'The forge fire has died down', 'metal is in need of some gentle bending', 'to be pulled', 'ready to be pounded', 'ready for pounding', 'with the pliers to stitch them together')
when 'The metal is ready to be cooled'
slack_tub
when 'Almost all of the coal has been consumed'
add_fuel
when 'ready for more pounding', 'ready to be pounded', 'ready for pounding'
pound
when 'metal will quickly rust'
stow_item(left_hand)
stow_item(right_hand)
bput("get #{@item} from anvil", 'You get')
add_oil
when 'The forge fire has died down'
bellows
when 'metal is in need of some gentle bending', 'to be pulled', 'a mandrel or mold set'
turn_item
when 'with the pliers to stitch them together'
stow_item('tongs')
get_item('plier')
bput("pull my #{@item} with my pliers", 'roundtime')
stow_item('plier')
analyze_item
end
end
end
Forge.new