forked from rpherbig/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
carve.lic
241 lines (216 loc) · 7.64 KB
/
carve.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#carve
=end
custom_require.call(%w[common common-arcana events common-crafting drinfomon])
class Carve
include DRC
include DRCC
include DRCA
def initialize
@settings = get_settings
@bag = @settings.crafting_container
@bag_items = @settings.crafting_items_in_container
@belt = @settings.engineering_belt
@stamp = @settings.mark_crafted_goods
arg_definitions = [
[
{ 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: 'material', regex: /\w+/i, variable: true, description: 'Type of stone/bone to use.' },
{ name: 'type', options: %w[stack rock stone pebble boulder deed], description: 'What material noun you are using.' },
{ name: 'noun', regex: /\w+/i, variable: true }
],
[
{ name: 'resume', regex: /resume/i },
{ name: 'type', options: %w[bone stone], description: 'Which material type the item is.' },
{ name: 'noun', regex: /\w+/i, variable: true, description: 'Noun of item to resume.' }
]
]
args = parse_args(arg_definitions)
@chapter = args.chapter
@recipe_name = args.recipe_name
@material = args.material
@type = args.type
@noun = args.noun
@training_spells = @settings.crafting_training_spells
@main_tool = if @type == 'stack' || @type == 'bone'
'saw'
else
'chisel'
end
wait_for_script_to_complete('buff', ['carve'])
Flags.add('carve-assembly', 'another finished wooden (hilt|haft)', 'another finished (long|short) wooden (pole)', 'another finished (long|short) leather (cord)')
if args.resume
resume
else
carve_item
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)
unless section
echo('Failed to find recipe in book, buy a better book?')
stow_item('book')
magic_cleanup
exit
end
bput("turn my book to #{section}", 'You turn your', 'The book is already')
end
def carve_item
crafting_magic_routine(@settings)
get_item('carving book')
echo('*** You will need to upgrade to a journeyman or master book before 176 ranks! ***') if DRSkill.getrank('Engineering') == 175
turn_to("chapter #{@chapter}")
turn_to("page #{find_recipe(@chapter, @recipe_name)}")
bput('study my book', 'Roundtime')
stow_item('book')
get_item(@main_tool)
if @type != 'boulder'
case DRC.bput("get #{@material} #{@type}", '^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'
beep
echo("You seem to be missing: #{name}")
exit
when /can\'t quite lift it/
@my = ''
when /^You get|You pick up|^You are already/
@my = 'my '
end
if @type == 'deed'
/(\w+) onto/ =~ bput('tap deed', '\w+ onto a sled')
@type = checkleft || Regexp.last_match(1)
@my = '' unless checkleft
end
else
@my = ''
end
carve("cut #{@my}#{@type} with my #{@main_tool}")
end
def assemble_part
return unless Flags['carve-assembly']
tool = right_hand
stow_item(tool)
part = Flags['carve-assembly'][1..-1].join('.')
Flags.reset('carve-assembly')
get_item(part)
bput("assemble #{@my}#{@noun} with my #{part}", 'affix it securely in place', 'carefully mark where it will attach when you continue crafting', 'add several marks indicating optimal locations')
get_item(tool)
end
def carve(command)
waitrt?
crafting_magic_routine(@settings)
assemble_part
case bput(command,
'rough, jagged',
'determine',
'developed an uneven texture along its surface',
'You cannot figure out how to do that.',
'you see some discolored areas',
'Roundtime')
when 'rough, jagged'
waitrt?
stow_item(right_hand)
get_item('rifflers')
command = "rub #{@my}#{@noun} with my rifflers"
when 'determine', 'developed an uneven texture along its surface'
waitrt?
stow_item(right_hand)
get_item('rasp')
command = "rub #{@my}#{@noun} with my rasp"
when 'you see some discolored areas'
waitrt?
stow_item(right_hand)
get_item('polish')
command = "apply my polish to #{@my}#{@noun}"
when 'You cannot figure out how to do that.'
finish
else
waitrt?
unless right_hand =~ /#{@main_tool}/i
stow_item(right_hand)
get_item(@main_tool)
end
command = "cut #{@my}#{@noun} with my #{@main_tool}"
end
waitrt?
crafting_magic_routine(@settings)
carve(command)
end
def resume
waitrt?
case bput("get #{@noun}", /You get/, /You are already holding/, /You pick up/, /You are not strong enough/, /What were you referring to/)
when /You get/, /You are already holding/, /You pick up/
@my = 'my '
DRC.bput('swap', /to your left hand/) unless left_hand.include?(@noun)
when /You are not strong enough/
@my = ''
else
echo '*** ITEM NOT FOUND ***'
exit
end
stow_item(right_hand) if right_hand
case bput("analyze my #{@noun}",
/You do not see anything that would (prevent|obstruct) carving/,
/free of defects that would impede further carving/,
/ready for further carving/,
/corrected by rubbing the .* with a riffler set/,
/corrected by scraping the .* with a rasp/,
'angle of cut will improve if scraped with a rasp',
'by applying some polish to',
'This appears to be a type of finished',
'Roundtime')
when /You do not see anything that would (prevent|obstruct) carving|free of defects that would impede further carving|ready for further carving/
waitrt?
get_item(@main_tool)
command = "cut #{@my}#{@noun} with my #{@main_tool}"
when /corrected by rubbing the .* with a riffler set/
waitrt?
get_item('rifflers')
command = "rub #{@my}#{@noun} with my rifflers"
when /corrected by scraping the .* with a rasp/, 'angle of cut will improve if scraped with a rasp'
waitrt?
get_item('rasp')
command = "rub #{@my}#{@noun} with my rasp"
when 'by applying some polish to'
waitrt?
get_item('polish')
command = "apply my polish to #{@my}#{@noun}"
when 'This appears to be a type of finished'
echo '*** THIS ITEM IS ALREADY FINISHED ***'
exit
else
echo '*** UNKNOWN NEXT COMMAND WHEN TRYING TO RESUME ***'
exit
end
carve(command)
end
def magic_cleanup
return if @training_spells.empty?
bput('release spell', 'You let your concentration lapse', "You aren't preparing a spell")
bput('release mana', 'You release all', "You aren't harnessing any mana")
bput('release symb', "But you haven't", 'You release', 'Repeat this command')
end
def finish
stow_item(right_hand)
if @stamp
get_item('stamp')
fput("mark #{@my}#{@noun} with my stamp")
pause
waitrt?
stow_item('stamp')
end
waitrt?
magic_cleanup
fput "get #{@noun}" unless left_hand =~ /#{@noun}/i || right_hand =~ /#{@noun}/i
exit
end
end
before_dying do
Flags.delete('carve-assembly')
end
Carve.new