forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon-arcana.lic
More file actions
339 lines (273 loc) · 11.1 KB
/
common-arcana.lic
File metadata and controls
339 lines (273 loc) · 11.1 KB
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
# quiet
=begin
Documentation: https://elanthipedia.play.net/Lich_script_development#common-arcana
=end
custom_require.call(%w[common common-travel 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)
DRC.bput("harness #{amount}", 'You tap into', 'Strain though you may')
pause 0.5
waitrt?
end
def activate_khri?(kneel, ability)
return false if DRSpells.active_spells[ability]
DRCT.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 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
case DRC.bput("#{command} #{abbrev} #{mana}", get_data('spells').prep_messages)
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
true
end
def ritual(spell)
DRCT.retreat
DRC.release_invisibility
DRC.bput('stance set 100 0 80', 'Setting your')
return unless prepare?(spell['abbrev'], spell['mana'], spell['symbiosis'])
find_focus(spell['focus'], spell['worn_focus'], spell['tied_focus'])
invoke(spell['focus'], nil)
stow_focus(spell['focus'], spell['worn_focus'], spell['tied_focus'])
DRCT.retreat
waitcastrt?
return unless cast?(spell['cast'], spell['symbiosis'], spell['before'], spell['after'])
DRCT.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')
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/
fput('release spell')
when /^At the ritual's peak, your prophetic connection blooms a thousand-fold/
Flags.add('rtr-expire', get_data('spells').spell_data['Read the Ripples']['expire'])
end
waitrt?
if Flags['cyclic-too-recent']
pause 1
return cast?(cast_command, symbiosis, [], after)
end
after.each { |action| DRC.bput(action['message'], action['matches']) }
if symbiosis && Flags['spell-fail']
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)
return unless charges
find_cambrinth(cambrinth, stored_cambrinth, cambrinth_cap)
charge_and_invoke(cambrinth, dedicated_camb_use, charges)
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
DRC.bput("tie my #{focus} to my #{tied}", 'You attach', '[Y|y]ou tie')
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')
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)
charges.each do |mana|
break unless charge?(cambrinth, mana)
end
invoke(cambrinth, dedicated_camb_use)
end
def invoke(cambrinth, dedicated_camb_use)
return unless cambrinth
DRC.bput("invoke my #{cambrinth} #{dedicated_camb_use}", 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_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 cast_spells(spells, settings)
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)
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|
DRC.bput("center telescope on #{planet}", 'You put your eye')
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'
custom_require.call('moonwatch')
echo "Run `#{$clean_lich_char}e autostart('moonwatch')` to avoid this in the future"
end
def buff(spell, settings)
cast_spell(spell, settings)
end
def cast_spell(data, settings)
return unless data
return unless settings
data = update_astral_data(data)
return unless data # update_astral_data returns nil on failure
release_cyclics if data['cyclic']
if data['ritual']
ritual(data)
return
end
return unless prepare?(data['abbrev'], data['mana'], data['symbiosis'])
prepare_time = Time.now
find_charge_invoke_stow(settings.cambrinth, settings.stored_cambrinth, settings.cambrinth_cap, settings.dedicated_camb_use, data['cambrinth'])
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
end