forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enchant.lic
267 lines (239 loc) · 9.42 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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#enchant
=end
custom_require.call(%w[common common-arcana events common-crafting equipmanager])
class Enchant
include DRC
include DRCC
include DRCA
def initialize
@settings = get_settings
@book_type = 'artificing'
@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.' }
]
]
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
@primary_sigils = []
@secondary_sigils = []
@equipment_manager = EquipmentManager.new
@equipment_manager.empty_hands
wait_for_script_to_complete('buff', ['enchant'])
study_recipe
@item = 'fount' if @item == 'small sphere'
if @item != 'fount'
case bput("tap my #{@fount}", /You tap an unfinished .* atop your brazier./, /You tap .*your .*/, /What were/)
# when /You tap an unfinished (.*) atop your brazier./
# fput("get my #{@fount} from my #{@bag}")
when /You tap (.*) your (.*)/
get_item(@fount)
when /What were/
cleanup
exit
end
case 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'
stow_item(@fount)
end
end
imbue
get_item(@burin)
scribe
end
def study_recipe
get_item("#{@book_type} book")
turn_to("page #{find_recipe(@chapter, @recipe)}")
bput("study my #{@book_type} book", 'You scan', 'You review', 'You peruse')
stow_item("#{@book_type} book")
get_item(@brazier) if @use_own_brazier
case 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
bput("get my #{@baseitem} from my #{@bag}", 'You get a')
end
2.times do
case 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
bput("get my #{@baseitem} from my #{@bag}", 'You get a')
2.times do
case 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}"
crafting_prepare_spell(imbue_data, @settings)
castrt = checkcastrt - (imbue_data['cambrinth'].size * 3)
pause castrt
waitcastrt?
crafting_cast_spell(imbue_data, @settings)
else
get_item(@imbue_wand) unless left_hand.include?(@imbue_wand)
case bput("wave #{@imbue_wand} at #{@item} on #{@brazier}", 'Roundtime', /You need another .* sigil/, '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
stow_item(@imbue_wand) if left_hand.include?(@imbue_wand)
end
end
Flags.reset('enchant-imbue')
end
def clean_brazier
case 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'
bput("clean #{@brazier}", 'a massive ball of flame jets forward and singes everything nearby')
when 'The brazier is not currently lit'
stow_item(left_hand) if left_hand
end
end
def empty_brazier
stow_item(left_hand) if left_hand
case 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
bput("get #{item} from brazier",'You get')
stow_crafting_item(item, @bag, @belt)
end
end
end
def trace_sigil(sigil)
bput("get #{sigil} sigil", 'You get')
bput("study my #{sigil} sigil", 'You study')
waitrt?
bput("trace #{@item} on #{@brazier}", 'you trace')
end
def scribe
if Flags['enchant-sigil']
sigil_type = Flags['enchant-sigil'][:type].delete(' ')
Flags.reset('enchant-sigil')
sigil_type = 'congruence' if sigil_type == ''
stow_item(@burin)
trace_sigil(sigil_type)
get_item(@burin)
scribe
elsif Flags['enchant-focus']
Flags.reset('enchant-focus')
bput("focus #{@item} on #{@brazier}", 'Once finished you sense an imbue spell will be required to continue enchanting.', 'Roundtime')
waitrt?
scribe
elsif Flags['enchant-meditate']
Flags.reset('enchant-meditate')
bput("meditate fount on #{@brazier}", 'Roundtime')
waitrt?
scribe
elsif Flags['enchant-push']
Flags.reset('enchant-push')
stow_item(@burin) if left_hand.include?('burin')
get_item(@loop)
bput("push #{@item} on #{@brazier} with my #{@loop}", 'Roundtime')
waitrt?
stow_item(@loop)
get_item(@burin)
scribe
elsif Flags['enchant-imbue']
Flags.reset('enchant-imbue')
stow_item(@burin) if left_hand.include?(@burin)
imbue
get_item(@burin)
scribe
elsif Flags['imbue-backlash']
stow_item(right_hand) if right_hand
stow_item(left_hand) if left_hand
cleanup
wait_for_script_to_complete('safe-room', ['force'])
exit
elsif Flags['enchant-complete']
stow_item(right_hand) if right_hand
stow_item(left_hand) if left_hand
cleanup
stamp_item
exit
else
bput("scribe #{@item} on #{@brazier} with my #{@burin}", 'Roundtime')
scribe
end
end
def stamp_item
if @stamp
get_item('stamp')
fput("mark my #{@item} with my stamp")
pause
waitrt?
stow_item('stamp')
end
end
def cleanup
stow_item(right_hand) if right_hand
stow_item(left_hand) if left_hand
get_item(@fount) unless @item == 'fount'
stow_item(@fount) unless @item == 'fount'
result = bput("get my #{@item}", 'You get', 'What', 'You pick up')
if result =~ /You get/
stow_item(@item)
bput("get #{@item}",'You get', 'What', 'You pick up')
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
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