forked from rpherbig/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
carve.lic
196 lines (170 loc) · 5.71 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
=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 }
]
]
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'
'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)')
Flags.add('carve-magic-ready', 'You feel fully prepared to cast your spell.')
carve_item
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
magic_routine
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'
get_item("#{@material} #{@type}")
@my = 'my'
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?
magic_routine
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?
magic_routine
carve(command)
end
def magic_routine
return if @training_spells.empty?
needs_training = %w[Warding Utility Augmentation]
.select { |skill| @training_spells[skill] }
.select { |skill| DRSkill.getxp(skill) < 31 }
.sort_by { |skill| DRSkill.getxp(skill) }.first
return unless needs_training
data = @training_spells[needs_training]
if Flags['carve-magic-ready'] && mana > 40
crafting_cast_spell(data, @settings)
Flags.reset('carve-magic-ready')
@preparing = false
end
return if @preparing
crafting_prepare_spell(data, @settings)
@preparing = true
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')
Flags.delete('carve-magic-ready')
end
Carve.new