forked from rpherbig/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-arcana.lic
642 lines (549 loc) · 23.7 KB
/
common-arcana.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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
# quiet
=begin
Documentation: https://elanthipedia.play.net/Lich_script_development#common-arcana
=end
custom_require.call(%w[common events spellmonitor drinfomon])
$MANA_MAP = {
'weak' => %w[dim glowing bright],
'developing' => %w[faint muted glowing luminous bright],
'improving' => %w[faint hazy flickering shimmering glowing lambent shining fulgent glaring],
'good' => %w[faint dim hazy dull muted dusky pale flickering shimmering pulsating glowing lambent shining luminous radiant fulgent brilliant flaring glaring blazing blinding]
}
module DRCA
module_function
def infuse_om(harness, amount)
return unless DRSpells.active_spells['Osrel Meraud'] && DRSpells.active_spells['Osrel Meraud'] < 90
return unless amount
success = ['having reached its full capacity', 'a sense of fullness', 'Something in the area is interfering with your attempt to harness']
failure = ['as if it hungers for more', 'Your infusion fails completely', 'You don\'t have enough harnessed mana to infuse that much', 'You have no harnessed']
loop do
pause 5 while mana <= amount
harness_mana([amount]) if harness
break if success.include?(DRC.bput("infuse om #{amount}", success, failure))
pause 0.5
waitrt?
end
end
def harness_mana(amount)
amount.each do |mana|
result = DRC.bput("harness #{mana}", 'You tap into', 'Strain though you may')
pause 0.5
waitrt?
break if result =~ /Strain though you may/
end
end
def start_khris(khris, settings)
khris
.map { |name| "Khri #{name}" }
.each do |name|
activate_khri?(settings.kneel_khri, name)
end
end
def activate_khri?(settings_kneel, ability)
return false if DRSpells.active_spells[ability]
kneel = kneel_for_khri?(settings_kneel, ability)
DRC.retreat if kneel
DRC.bput('kneel', 'You kneel', 'You are already', 'You rise') if kneel && !kneeling?
result = DRC.bput(ability, get_data('spells').khri_preps)
waitrt?
DRC.fix_standing
['Your body is willing', 'You have not recovered'].include?(result)
end
def kneel_for_khri?(kneel, ability)
if kneel.is_a? Array
kneel.map(&:downcase).include? ability.downcase.sub('khri ', '')
else
kneel
end
end
def start_barb_abilities(skills, settings)
skills
.reject { |name| DRSpells.active_spells[name] }
.each do |name|
activate_barb_buff(name)
waitrt?
pause settings.meditation_pause_timer.to_i if get_data('spells').barb_abilities[name]['type'].eql? 'meditation'
fix_standing
end
end
def activate_barb_buff(name)
ability_data = get_data('spells').barb_abilities[name]
case DRC.bput(ability_data['start_command'], ability_data['activated_message'], 'But you are already', 'Your inner fire lacks', 'find yourself lacking the inner fire', 'You should stand', 'You must be sitting')
when 'You must be sitting'
DRC.retreat
DRC.bput('sit', 'You sit', 'You are already', 'You rise')
activate_barb_buff(name)
when 'You should stand'
fix_standing
activate_barb_buff(name)
end
end
def prepare?(abbrev, mana, symbiosis = false, command = 'prepare')
return false unless abbrev
DRC.bput('prep symb', 'You recall the exact details of the', 'But you\'ve already prepared') if symbiosis
match = DRC.bput("#{command} #{abbrev} #{mana}", get_data('spells').prep_messages)
case match
when 'Your desire to prepare this offensive spell suddenly slips away'
pause 1
return prepare?(abbrev, mana, symbiosis, command)
when 'Something in the area interferes with your spell preparations'
DRC.bput('rel symb', 'You release the', 'But you haven\'t') if symbiosis
return false
end
match
end
def ritual(spell, settings)
DRC.retreat(settings.ignored_npcs) unless spell['skip_retreat']
DRC.release_invisibility
DRC.set_stance('shield')
command = 'prepare'
command = spell['prep'] if spell['prep']
command = spell['prep_type'] if spell['prep_type']
return unless prepare?(spell['abbrev'], spell['mana'], spell['symbiosis'], command)
find_focus(spell['focus'], spell['worn_focus'], spell['tied_focus'])
invoke(spell['focus'], nil, nil)
stow_focus(spell['focus'], spell['worn_focus'], spell['tied_focus'])
DRC.retreat(settings.ignored_npcs) unless spell['skip_retreat']
waitcastrt?
return unless cast?(spell['cast'], spell['symbiosis'], spell['before'], spell['after'])
DRC.retreat(settings.ignored_npcs) unless spell['skip_retreat']
end
def cast?(cast_command = 'cast', symbiosis = false, before = [], after = [])
before.each { |action| DRC.bput(action['message'], action['matches']) }
Flags.add('spell-fail', 'Currently lacking the skill to complete the pattern', 'backfires', 'Something is interfering with the spell')
Flags.add('cyclic-too-recent', 'The mental strain of initiating a cyclic spell so recently prevents you from formulating the spell pattern')
Flags.add('spell-full-prep', /^This pattern may only be cast with full preparation/)
case DRC.bput(cast_command || 'cast', get_data('spells').cast_messages)
when /^Your target pattern dissipates/, /^You can't cast that at yourself/, /^You need to specify a body part to consume/
DRC.bput('release spell', 'You let your concentration lapse', "You aren't preparing a spell")
DRC.bput('release mana', 'You release all', "You aren't harnessing any mana")
when /You gesture/
pause 0.25
end
waitrt?
if Flags['cyclic-too-recent'] || Flags['spell-full-prep']
pause 1
Flags.delete('spell-full-prep')
return cast?(cast_command, symbiosis, [], after)
end
after.each { |action| DRC.bput(action['message'], action['matches']) }
if symbiosis && Flags['spell-fail']
DRC.bput('release symbiosis', 'You release', 'But you haven\'t prepared')
end
!Flags['spell-fail']
end
def find_charge_invoke_stow(cambrinth, stored_cambrinth, cambrinth_cap, dedicated_camb_use, charges, invoke_exact_amount = nil)
# TODO: Remove default nil argument once all users are up to date with common-arcana
return unless charges
find_cambrinth(cambrinth, stored_cambrinth, cambrinth_cap)
charge_and_invoke(cambrinth, dedicated_camb_use, charges, invoke_exact_amount)
stow_cambrinth(cambrinth, stored_cambrinth, cambrinth_cap)
end
def find_focus(focus, worn, tied)
return unless focus
if worn
DRC.bput("remove my #{focus}", 'You remove', 'You slide', 'You sling', 'You take')
elsif tied
DRC.bput("untie my #{focus} from my #{tied}", 'You remove', '[Y|y]ou untie')
else
DRC.bput("get my #{focus}", 'You get')
end
end
def stow_focus(focus, worn, tied)
return unless focus
if worn
DRC.bput("wear my #{focus}", 'You attach', 'You slide', 'You are already wearing', 'You hang', 'You sling', 'You put', 'You place')
elsif tied
case DRC.bput("tie my #{focus} to my #{tied}", 'You attach', '[Y|y]ou tie', 'You are a little too busy to be worrying')
when 'You are a little too busy to be worrying'
DRC.retreat
stow_focus(focus, worn, tied)
end
else
DRC.bput("stow my #{focus}", 'You put', 'You easily strap your')
end
end
def find_cambrinth(cambrinth, stored_cambrinth, cambrinth_cap)
if stored_cambrinth
DRC.bput("get my #{cambrinth}", 'You get')
elsif DRSkill.getrank('Arcana').to_i < cambrinth_cap * 2 + 100
DRC.bput("remove my #{cambrinth}", 'You remove', 'You slide', 'You sling', 'You take', 'You detach')
end
end
def stow_cambrinth(cambrinth, stored_cambrinth, cambrinth_cap)
if stored_cambrinth
DRC.bput("stow my #{cambrinth}", 'You put')
elsif DRSkill.getrank('Arcana').to_i < cambrinth_cap * 2 + 100
DRC.bput("wear my #{cambrinth}", 'You attach', 'You slide', 'You are already wearing', 'You hang', 'You sling', 'You put', 'You place')
end
end
def charge_and_invoke(cambrinth, dedicated_camb_use, charges, invoke_exact_amount = nil)
# TODO: Remove default nil argument once all users are up to date with common-arcana
charges.each do |mana|
break unless charge?(cambrinth, mana)
end
invoke_amount = invoke_exact_amount ? charges.inject(:+) : nil
invoke(cambrinth, dedicated_camb_use, invoke_amount)
end
def invoke(cambrinth, dedicated_camb_use, invoke_amount)
return unless cambrinth
DRC.bput("invoke my #{cambrinth} #{invoke_amount} #{dedicated_camb_use}".strip, get_data('spells').invoke_messages)
pause
waitrt?
end
def charge?(cambrinth, mana)
result = DRC.bput("charge my #{cambrinth} #{mana}", get_data('spells').charge_messages)
pause
waitrt?
result =~ /absorbs? all of the energy/
end
def release_cyclics
get_data('spells')
.spell_data
.select { |_name, properties| properties['cyclic'] }
.select { |name, _properties| DRSpells.active_spells.keys.include?(name) }
.map { |_name, properties| properties['abbrev'] }
.each { |abbrev| fput("release #{abbrev}") }
end
def parse_regalia # generates an array of currently-worn regalia armor nouns
return unless DRStats.trader?
DRC.bput('inv armor', 'Type INVENTORY HELP for more options')
snapshot = reget(40)
if snapshot.grep(/All of your armor|You aren't wearing anything like that/).any? && snapshot.grep(/Type INVENTORY HELP/).any?
snapshot
.map(&:strip)
.reverse
.take_while { |item| !['All of your armor:', "You aren't wearing anything like that."].include?(item) }
.drop_while { |item| item != '[Type INVENTORY HELP for more options]' }
.drop(1)
.select { |item| item.include?('rough-cut crystal') || item.include?('faceted crystal') || item.include?('resplendent crystal') }
.map { |item| DRC.get_noun(item) }
else
parse_regalia
end
end
def shatter_regalia?(worn_regalia = nil) # takes an array of armor nouns to remove or gets its own from parse_regalia
return false unless DRStats.trader?
worn_regalia ||= parse_regalia
return false if worn_regalia.empty?
worn_regalia.each do |item|
DRC.bput("remove my #{item}", 'into motes of silvery', 'Remove what?', "You .*#{item}")
end
true
end
def parse_mana_message(mana_msg)
manalevels = if mana_msg.include? 'weak'
$MANA_MAP['weak']
elsif mana_msg.include? 'developing'
$MANA_MAP['developing']
elsif mana_msg.include? 'improving'
$MANA_MAP['improving']
else
$MANA_MAP['good']
end
adj = mana_msg.split(' ')[-1]
manalevels.index(adj).to_i + 1
end
def perc_mana
return nil if DRStats.barbarian? || DRStats.thief? || DRStats.trader? || DRStats.commoner?
if DRStats.moon_mage?
DRC.bput('perc mana', 'the Psychic Projection book.')
mana_msgs = reget(5)[0..3]
mana_msgs.collect! do |mana_msg|
mana_msg.split(' streams')[0]
end
mana_levels = {}
mana_levels['enlightened_geometry'] = parse_mana_message(mana_msgs[0])
mana_levels['moonlight_manipulation'] = parse_mana_message(mana_msgs[1])
mana_levels['perception'] = parse_mana_message(mana_msgs[2])
mana_levels['psychic_projection'] = parse_mana_message(mana_msgs[3])
return mana_levels
else
mana_msg = DRC.bput('perc', '^You reach out with your .* and (see|hear) \w+')
return parse_mana_message(mana_msg)
end
end
def perc_aura
return unless DRStats.trader?
starlight_messages = [
'The smallest hint of starlight flickers within your aura',
'A bare flicker of starlight plays within your aura',
'A faint amount of starlight illuminates your aura',
'Your aura pulses slowly with starlight',
'A steady pulse of starlight runs through your aura',
'Starlight dances vividly across the confines of your aura',
'Strong pulses of starlight flare within your aura',
'Your aura seethes with brilliant starlight'
]
Flags.add('aura-level', Regexp.union(starlight_messages))
Flags.add('aura-capped?', 'Your aura contains as much starlight as you can safely handle')
Flags.add('aura-growing?', 'Local conditions permit optimal growth of your aura', 'Local conditions are hindering the growth of your aura')
aura = {}
DRC.bput('perceive aura', 'Roundtime')
aura['level'] = Flags['aura-level'] ? starlight_messages.index(Flags['aura-level'].first) : 0
aura['capped'] = Flags['aura-capped?'] ? true : false
aura['growing'] = Flags['aura-growing?'] ? true : false
Flags.delete('aura-level')
Flags.delete('aura-capped?')
Flags.delete('aura-growing?')
aura
end
def cast_spells(spells, settings, force_cambrinth = false)
infuse_om(!settings.osrel_no_harness, settings.osrel_amount)
spells.each do |name, data|
next if DRSpells.active_spells[name] && (data['recast'].nil? || DRSpells.active_spells[name].to_i > data['recast'])
while mana < 40
echo('Waiting on mana...')
pause 15
end
cast_spell(data, settings, force_cambrinth)
end
end
def update_astral_data(data)
if data['moon']
data = set_moon_data(data)
elsif data['stats']
data = set_planet_data(data)
end
data
end
def find_visible_planets(planets)
return if DRC.bput('get my telescope', 'You get', 'What were you', 'You are already') == 'What were you'
Flags.add('planet-not-visible', 'turns up fruitless')
observed_planets = []
planets.each do |planet|
case DRC.bput("center telescope on #{planet}", 'You put your eye', 'The pain is too much', "That's a bit tough to do when you can't see the sky")
when 'The pain is too much', "That's a bit tough to do when you can't see the sky"
break
end
observed_planets << planet unless Flags['planet-not-visible']
Flags.reset('planet-not-visible')
end
Flags.delete('planet-not-visible')
DRC.bput('stow telescope', 'You put')
observed_planets
end
def set_planet_data(data)
return data unless data['stats']
planets = get_data('constellations')[:constellations].select { |planet| planet['stats'] }
planet_names = planets.map { |planet| planet['name'] }
visible_planets = find_visible_planets(planet_names)
data['stats'].each do |stat|
cast_on = planets.map { |planet| planet['name'] if planet['stats'].include?(stat) && visible_planets.include?(planet['name']) }.compact.first
next unless cast_on
data['cast'] = "cast #{cast_on}"
return data
end
echo 'Could not find any planets to cast on'
nil
end
def set_moon_data(data)
return data unless data['moon']
check_moonwatch
# Look for a moon that will be up for the next few minutes
moon = UserVars.moons.find { |moon_name, moon_data| UserVars.moons['visible'].include?(moon_name) && moon_data['timer'] >= 4 }.first
unless moon
echo "No moon available to cast #{data['abbrev']}"
return nil # Return nil to indicate that setting moon casting data failed
end
data['cast'] = "cast #{moon}"
data
end
def check_moonwatch
return if Script.running? 'moonwatch'
echo 'moonwatch is not running. Starting it now'
UserVars.moons = {}
custom_require.call('moonwatch')
echo "Run `#{$clean_lich_char}e autostart('moonwatch')` to avoid this in the future"
pause 0.5 while UserVars.moons.empty?
end
def cast_spell(data, settings, force_cambrinth = false)
return unless data
return unless settings
data = update_astral_data(data)
return unless data # update_astral_data returns nil on failure
if (data['abbrev'] =~ /locat/i) && !DRSpells.active_spells['Clear Vision']
cast_spell({ 'abbrev' => 'cv', 'mana' => 1, 'prep_time' => 5 }, settings)
end
release_cyclics if data['cyclic']
DRC.bput('release spell', 'You let your concentration lapse', "You aren't preparing a spell") unless checkprep == 'None'
DRC.bput('release mana', 'You release all', "You aren't harnessing any mana")
if data['ritual']
ritual(data, settings)
return
end
command = 'prep'
command = data['prep'] if data['prep']
command = data['prep_type'] if data['prep_type']
return unless prepare?(data['abbrev'], data['mana'], data['symbiosis'], command)
prepare_time = Time.now
unless settings.cambrinth_items[0]['name']
settings.cambrinth_items = [{
'name' => settings.cambrinth,
'cap' => settings.cambrinth_cap,
'stored' => settings.stored_cambrinth
}]
end
if check_to_harness(settings.use_harness_when_arcana_locked) && !force_cambrinth
harness_mana(data['cambrinth'].flatten)
else
settings.cambrinth_items.each_with_index do |item, index|
case data['cambrinth'].first
when Array
find_charge_invoke_stow(item['name'], item['stored'], item['cap'], settings.dedicated_camb_use, data['cambrinth'][index], settings.cambrinth_invoke_exact_amount)
when Fixnum, Integer
find_charge_invoke_stow(item['name'], item['stored'], item['cap'], settings.dedicated_camb_use, data['cambrinth'], settings.cambrinth_invoke_exact_amount)
end
end
end
if data['prep_time']
pause 0.1 until checkcastrt.zero? || Time.now - prepare_time >= data['prep_time']
else
waitcastrt?
end
cast?(data['cast'], data['symbiosis'], data['before'], data['after'])
end
def check_discern(data, settings)
UserVars.discerns = {} unless UserVars.discerns
discern_data = UserVars.discerns[data['abbrev']] || {}
if data['symbiosis']
if discern_data.empty? || discern_data['min'].nil?
DRC.retreat
/requires at minimum (\d+) mana streams/ =~ DRC.bput("discern #{data['abbrev']}", 'requires at minimum \d+ mana streams')
discern_data['mana'] = Regexp.last_match(1).to_i
discern_data['cambrinth'] = nil
discern_data['min'] = Regexp.last_match(1).to_i
discern_data['more'] = 0
end
calculate_mana(discern_data['min'], discern_data['more'], discern_data, false, settings)
elsif discern_data.empty? || discern_data['time_stamp'].nil? || Time.now - discern_data['time_stamp'] > settings.check_discern_timer_in_hours * 60 * 60 || !discern_data['more'].nil?
discern_data['time_stamp'] = Time.now
DRC.retreat
case discern = DRC.bput("discern #{data['abbrev']}", 'The spell requires at minimum \d+ mana streams and you think you can reinforce it with \d+ more', 'You don\'t think you are able to cast this spell', 'You have no idea how to cast that spell')
when /you don't think you are able/i, 'You have no idea how to cast that spell'
discern_data['mana'] = 1
discern_data['cambrinth'] = nil
else
discern =~ /minimum (\d+) mana streams and you think you can reinforce it with (\d+) more/i
calculate_mana(Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, discern_data, data['cyclic'], settings)
end
end
pause 1
waitrt?
UserVars.discerns[data['abbrev']] = discern_data
data['mana'] = discern_data['mana']
data['cambrinth'] = discern_data['cambrinth']
data
end
def calculate_mana(min, more, discern_data, cyclic, settings)
total = min + more
total = (total * settings.prep_scaling_factor).floor
discern_data['mana'] = [(total / 5.0).ceil, min].max
remaining = total - discern_data['mana']
unless settings.cambrinth_items[0]['name']
settings.cambrinth_items = [{
'name' => settings.cambrinth,
'cap' => settings.cambrinth_cap,
'stored' => settings.stored_cambrinth
}]
end
total_cambrinth_cap = settings.cambrinth_items.map { |x| x['cap'] }.inject(&:+)
charges_count_floor = remaining >= settings.cambrinth_num_charges ? settings.cambrinth_num_charges : 1
settings.cambrinth_items.each do |item|
item['charges'] = ((item['cap'].to_f / total_cambrinth_cap) * charges_count_floor).ceil
end
total_cambrinth_charges = settings.cambrinth_items.map { |x| x['charges'] }.inject(&:+)
if remaining > total_cambrinth_cap
discern_data['mana'] = discern_data['mana'] + (remaining - total_cambrinth_cap)
remaining = total - discern_data['mana']
end
if cyclic
discern_data['cambrinth'] = nil
discern_data['mana'] = discern_data['mana'] + remaining
elsif remaining > 0
total_cambrinth_mana = [remaining, total_cambrinth_cap].min
settings.cambrinth_items.each_with_index do |item, index|
discern_data['cambrinth'] ||= []
charge_amount = (total_cambrinth_mana / total_cambrinth_charges) * item['charges']
discern_data['cambrinth'][index] = []
charge_amount.times do |i|
discern_data['cambrinth'][index][i % item['charges']] += 1
end
end
else
discern_data['cambrinth'] = nil
end
end
def check_to_harness(should_harness)
return false unless should_harness
return false if DRSkill.getxp('Attunement') > DRSkill.getxp('Arcana')
true
end
def crafting_cast_spell(data, settings)
return unless data
return unless settings
unless settings.cambrinth_items[0]['name']
settings.cambrinth_items = [{
'name' => settings.cambrinth,
'cap' => settings.cambrinth_cap,
'stored' => settings.stored_cambrinth
}]
end
if check_to_harness(settings.use_harness_when_arcana_locked)
harness_mana(data['cambrinth'].flatten)
else
settings.cambrinth_items.each_with_index do |item, index|
case data['cambrinth'].first
when Array
find_charge_invoke_stow(item['name'], item['stored'], item['cap'], settings.dedicated_camb_use, data['cambrinth'][index], settings.cambrinth_invoke_exact_amount)
when Fixnum, Integer
find_charge_invoke_stow(item['name'], item['stored'], item['cap'], settings.dedicated_camb_use, data['cambrinth'], settings.cambrinth_invoke_exact_amount)
end
end
end
cast?(data['cast'], data['symbiosis'], data['before'], data['after'])
end
def crafting_prepare_spell(data, settings)
return unless data
return unless settings
release_cyclics if data['cyclic']
DRC.bput('release spell', 'You let your concentration lapse', "You aren't preparing a spell") unless checkprep == 'None'
DRC.bput('release mana', 'You release all', "You aren't harnessing any mana")
if data['moon']
check_moonwatch
moon = UserVars.moons['visible'].first
unless moon
weather ||= bput('weather', 'inside', 'You glance up at the sky.')
if weather =~ /inside/
echo "*** You're inside and there are no available moons. You're going to have a hard time casting #{data['abbrev']}"
end
unless moon = UserVars.moons['visible'].first
return
end
data['cast'] = "cast #{moon}"
end
end
command = 'prep'
command = data['prep'] if data['prep']
command = data['prep_type'] if data['prep_type']
prepare?(data['abbrev'], data['mana'], data['symbiosis'], command)
end
def crafting_magic_routine(settings)
training_spells = settings.crafting_training_spells
return if training_spells.empty?
return if mana <= 40
if !XMLData.prepared_spell.eql?('None') && checkcastrt == 0
spell = XMLData.prepared_spell
skill = get_data('spells').spell_data[spell]['skill']
data = training_spells[skill]
crafting_cast_spell(data, settings)
end
return if checkcastrt > 0
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
crafting_prepare_spell(training_spells[needs_training], settings)
end
end