-
Notifications
You must be signed in to change notification settings - Fork 177
/
enchant.lic
277 lines (250 loc) · 12.1 KB
/
enchant.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#enchant
=end
custom_require.call(%w[common common-arcana events common-crafting equipmanager])
class Enchant
def initialize
@settings = get_settings
@book_type = 'artificing'
@cube = @settings.cube_armor_piece
@bag = @settings.crafting_container
@bag_items = @settings.crafting_items_in_container
@belt = @settings.enchanting_belt
@bag = @settings.crafting_container
@stamp = @settings.mark_crafted_goods
arg_definitions = [
[
{ name: 'chapter', regex: /\d+/i, variable: true, description: 'Required: Chapter containing the item.' },
{ name: 'recipe', display: 'recipe name', regex: /^[A-z\s\-']+$/i, variable: true, description: 'Required: Name of the recipe, wrap in double quotes if this is multiple words.' },
{ name: 'noun', regex: /\w+/i, variable: true, description: 'Required: Noun of finished product, can wrap in double quotes if this is multiple words. Example: "small brazier"' },
{ name: 'base_noun', regex: /\w+/i, variable: true, optional: true, description: 'Optional: Noun of base item that will change once started. Example: short pole turns into a loop once placed on brazier.' }
],
[
{ name: 'resume', regex: /resume/i },
{ name: 'noun', regex: /\w+/i, variable: true, description: 'Noun of item to resume.' },
]
]
Flags.add('enchant-focus', 'material struggles to accept the sigil scribing')
Flags.add('enchant-meditate', 'The traced sigil pattern blurs before your eyes')
Flags.add('enchant-imbue', 'Once finished you sense an imbue spell will be required to continue enchanting')
Flags.add('enchant-push', 'You notice many of the scribed sigils are slowly merging back')
Flags.add('enchant-sigil', /You need another (?<type>[\w ]*)(?<order>primary|secondary) sigil to continue the enchanting process/)
Flags.add('enchant-complete', 'With the enchanting process completed, you believe it is safe to collect your things once more.', 'With the enchantment complete', 'With enchanting complete', /^You collect the \w+ and place it at your feet/)
Flags.add('imbue-failed', 'The streams collide, rending the space before you and disrupting the enchantment')
Flags.add('imbue-backlash', 'Suddenly the streams slip through your grasp and cascade violently against each other')
@brazier = @settings.enchanting_tools.find { |item| /brazier/ =~ item } || 'brazier'
@fount = @settings.enchanting_tools.find { |item| /fount/ =~ item } || 'fount'
@loop = @settings.enchanting_tools.find { |item| /loop/ =~ item } || 'aug loop'
@imbue_wand = @settings.enchanting_tools.find { |item| /wand|rod/ =~ item } || 'rod'
@burin = @settings.enchanting_tools.find { |item| /burin/ =~ item } || 'burin'
@use_own_brazier = true
DRRoom.room_objs.each do |obj|
if obj.include?("enchanter's brazier")
@brazier = "enchanter's brazier"
@use_own_brazier = false
end
end
args = parse_args(arg_definitions)
@baseitem = args.base_noun || args.noun
@item = args.noun
@chapter = args.chapter
@recipe = args.recipe
@resume = args.resume
@primary_sigils = []
@secondary_sigils = []
@equipment_manager = EquipmentManager.new
@equipment_manager.empty_hands
DRC.wait_for_script_to_complete('buff', ['enchant'])
if @resume
DRCC.get_crafting_item(@brazier, @bag, @bag_items, @belt)
case DRC.bput("analyze #{@item} on my brazier", /scribing additional sigils onto the fount./, /ready for additional scribing./, /application of an imbue spell to advance the enchanting process./, /free of problems that would impede further sigil scribing./, /You do not see anything that would prevent scribing additional sigils/)
when /scribing additional sigils onto the fount./, /ready for additional scribing./, /free of problems that would impede further sigil scribing./, /You do not see anything that would prevent scribing additional sigils/
DRCC.get_crafting_item(@burin, @bag, @bag_items, @belt)
scribe
when /application of an imbue spell to advance the enchanting process./
case DRC.bput("look on my #{@brazier}", /On the.*brazier you see.*and a.*/)
when /On the.*brazier you see.*and a.*/
imbue
else
DRCC.get_crafting_item(@fount, @bag, @bag_items, @belt)
case DRC.bput("wave my #{@fount} at #{@item} on #{@brazier}", /^You slowly wave/, 'The fragile mana fount is not required')
when 'The fragile mana fount is not required'
DRCC.stow_crafting_item(@fount, @bag, @belt)
end
imbue
end
end
else
study_recipe
@item = 'fount' if @item == 'small sphere'
unless @item == "fount"
unless DRCI.exists?(@fount)
cleanup
exit
end
DRCC.get_crafting_item(@fount, @bag, @bag_items, @belt)
case DRC.bput("wave my #{@fount} at #{@item} on #{@brazier}", /^You slowly wave/, 'The fragile mana fount is not required')
when 'The fragile mana fount is not required'
DRCC.stow_crafting_item(@fount, @bag, @belt)
end
end
DRC.bput("touch my #{@cube}", /^Warm vapor swirls around your head in a misty halo/, /^A thin cloud of vapor manifests with no particular effect./, /^Touch what/) if @cube
imbue
DRCC.get_crafting_item(@burin, @bag, @bag_items, @belt)
scribe
end
end
def study_recipe
if @settings.master_crafting_book
DRCC.find_recipe2(@chapter, @recipe, @settings.master_crafting_book, @book_type)
else
DRCC.get_crafting_item("#{@book_type} book", @bag, @bag_items, @forging_belt)
DRCC.find_recipe2(@chapter, @recipe)
DRCC.stow_crafting_item("book", @bag, @forging_belt)
end
DRCC.get_crafting_item(@brazier, @bag, @bag_items, @belt) if @use_own_brazier
case DRC.bput("get my #{@baseitem} from my #{@bag}", 'You get a', 'That is far too dangerous')
when 'That is far too dangerous'
clean_brazier
empty_brazier
DRC.bput("get my #{@baseitem} from my #{@bag}", 'You get a')
end
2.times do
case DRC.bput("put my #{@baseitem} on #{@brazier}", 'You glance down', 'With a flick', 'You must first clean', 'You put')
when 'With a flick', 'You put'
waitrt?
break
when 'You must first clean'
clean_brazier
empty_brazier
DRC.bput("get my #{@baseitem} from my #{@bag}", 'You get a')
2.times do
case DRC.bput("put my #{@baseitem} on #{@brazier}", 'You glance down', 'With a flick', 'You put')
when 'With a flick', 'You put'
waitrt?
break
end
end
end
end
end
def imbue
imbue_data = @settings['waggle_sets']['imbue']['Imbue']
if imbue_data
imbue_data['cast'] = "cast #{@item} on #{@brazier}"
until DRCA.cast_spell?(imbue_data, @settings)
DRC.message("Casting Imbue failed. Retrying")
end
else
DRCC.get_crafting_item(@imbue_wand, @bag, @bag_items, @belt) unless DRC.left_hand.include?(@imbue_wand)
case DRC.bput("wave #{@imbue_wand} at #{@item} on #{@brazier}", /^Roundtime/, /^You need another .* sigil to continue the enchanting process/, 'The streams collide, rending the space before you and disrupting the enchantment')
when 'The streams collide, rending the space before you and disrupting the enchantment'
# Imbue wand failed. Let's try again
imbue
else
DRCC.stow_crafting_item(@imbue_wand, @bag, @belt) if DRC.left_hand.include?(@imbue_wand)
end
end
Flags.reset('enchant-imbue')
end
def clean_brazier
case DRC.bput("clean #{@brazier}", 'You prepare to clean off the brazier', 'There is nothing', 'The brazier is not currently lit')
when 'You prepare to clean off the brazier'
DRC.bput("clean #{@brazier}", 'a massive ball of flame jets forward and singes everything nearby')
when 'The brazier is not currently lit'
DRCC.stow_crafting_item(DRC.left_hand, @bag, @belt) if DRC.left_hand
end
end
def empty_brazier
DRCC.stow_crafting_item(DRC.left_hand, @bag, @belt) if DRC.left_hand
case DRC.bput("look on #{@brazier}", /On the (.*)brazier you see (.*)./, 'There is nothing')
when /On the (.*)brazier you see (.*)./
items = Regexp.last_match(2)
items = items.split(' and ')
items.each do |item|
item = item.split.last
DRC.bput("get #{item} from brazier", 'You get')
DRCC.stow_crafting_item(item, @bag, @belt)
end
end
end
def trace_sigil(sigil)
DRCI.get_item?("#{sigil} sigil")
DRC.bput("study my #{sigil} sigil", /^You study the sigil-scroll and commit the design to memory/)
waitrt?
DRC.bput("trace #{@item} on #{@brazier}", /^Recalling the intricacies of the sigil, you trace its form/)
end
def scribe
if Flags['enchant-sigil']
sigil_type = Flags['enchant-sigil'][:type].delete(' ')
Flags.reset('enchant-sigil')
sigil_type = 'congruence' if sigil_type == ''
DRCC.stow_crafting_item(@burin, @bag, @belt)
trace_sigil(sigil_type)
DRCC.get_crafting_item(@burin, @bag, @bag_items, @belt)
scribe
elsif Flags['enchant-focus']
Flags.reset('enchant-focus')
DRC.bput("focus #{@item} on #{@brazier}", /Once finished you sense an imbue spell will be required to continue enchanting/, /^Roundtime/, /^You need another .* sigil to continue the enchanting process/)
waitrt?
scribe
elsif Flags['enchant-meditate']
Flags.reset('enchant-meditate')
DRC.bput("meditate fount on #{@brazier}", /^Roundtime/, /^You need another .* sigil to continue the enchanting process/)
waitrt?
scribe
elsif Flags['enchant-push']
Flags.reset('enchant-push')
DRCC.stow_crafting_item(@burin, @bag, @belt) if DRC.left_hand.include?('burin')
DRCC.get_crafting_item(@loop, @bag, @bag_items, @belt)
DRC.bput("push #{@item} on #{@brazier} with my #{@loop}", /^Roundtime/, /^You need another .* sigil to continue the enchanting process/)
waitrt?
DRCC.stow_crafting_item(@loop, @bag, @belt)
DRCC.get_crafting_item(@burin, @bag, @bag_items, @belt)
scribe
elsif Flags['enchant-imbue']
Flags.reset('enchant-imbue')
DRCC.stow_crafting_item(@burin, @bag, @belt) if DRC.left_hand.include?('burin')
imbue
DRCC.get_crafting_item(@burin, @bag, @bag_items, @belt)
scribe
elsif Flags['imbue-backlash']
DRCC.stow_crafting_item(DRC.right_hand, @bag, @belt) if DRC.right_hand
DRCC.stow_crafting_item(DRC.left_hand, @bag, @belt) if DRC.left_hand
cleanup
DRC.wait_for_script_to_complete('safe-room', ['force'])
exit
elsif Flags['enchant-complete']
DRCC.stow_crafting_item(DRC.right_hand, @bag, @belt) if DRC.right_hand
DRCC.stow_crafting_item(DRC.left_hand, @bag, @belt) if DRC.left_hand
cleanup
stamp_item(@item) if @stamp
exit
else
DRC.bput("scribe #{@item} on #{@brazier} with my #{@burin}", /^Roundtime/, /^You need another .* sigil to continue the enchanting process/)
scribe
end
end
def stamp_item(noun)
DRCC.get_crafting_item('stamp', @bag, @bag_items, @belt)
DRC.bput("mark my #{noun} with my stamp", 'carefully hammer the stamp', 'You cannot figure out how to do that', 'too badly damaged', /You lazily wave the stamp over the freshly enchanted/)
DRCC.stow_crafting_item('stamp', @bag, @belt)
end
def cleanup
DRCC.stow_crafting_item(DRC.right_hand, @bag, @belt) if DRC.right_hand
DRCC.stow_crafting_item(DRC.left_hand, @bag, @belt) if DRC.left_hand
DRCC.get_crafting_item(@fount, @bag, @bag_items, @belt) unless @item == 'fount'
DRCC.stow_crafting_item(@fount, @bag, @belt) unless @item == 'fount'
if DRCI.get_item?(@item)
DRCC.stow_crafting_item(@item, @bag, @belt)
DRCI.get_item?(@item)
end
end
def turn_to(section)
DRC.bput("turn my book to #{section}", 'You turn your', 'The book is already')
end
end
Enchant.new
before_dying do
['enchant-focus', 'enchant-imbue', 'enchant-meditate', 'enchant-push', 'enchant-sigil', 'enchant-complete', 'imbue-failed', 'imbue-backlash'].each { |flag| Flags.delete(flag) }
end