forked from rpherbig/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
astrology.lic
404 lines (356 loc) · 13.4 KB
/
astrology.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#astrology
=end
custom_require.call(%w[common common-arcana common-travel drinfomon equipmanager spellmonitor events])
class Astrology
include DRC
include DRCA
include DRCT
def initialize
exit unless DRStats.moon_mage?
settings = get_settings
arg_definitions = [
[],
[{ name: 'rtr', regex: /rtr/i, description: 'Runs Read the Ripples' }]
]
args = parse_args(arg_definitions)
# Make sure that our Cirlce is up-to-date - avoid using stale data for new characters who joined the guild
bput('info', 'Circle:') if DRStats.circle.zero?
@equipment_manager = EquipmentManager.new
@constellations = get_data('constellations').constellations
@divination_tool = settings.divination_tool['name']
@divination_tool_container = settings.divination_tool['container']
@divination_tool_tied = settings.divination_tool['tied']
@divination_tool_worn = settings.divination_tool['worn']
@have_divination_bones = settings.have_divination_bones
@divination_bones_container = settings.divination_bones_storage['container']
@divination_bones_tied = settings.divination_bones_storage['tied']
@have_telescope = settings.have_telescope
@ap_source = settings.astral_plane_training['train_source']
@ap_destination = settings.astral_plane_training['train_destination']
@prediction_pool_target = settings.astrology_use_full_pools ? 10 : settings.astrology_pool_target
@rtr_data = nil
@astrology_prediction_skills_magic = settings.astrology_prediction_skills['magic']
@astrology_prediction_skills_lore = settings.astrology_prediction_skills['lore']
@astrology_prediction_skills_offense = settings.astrology_prediction_skills['offense']
@astrology_prediction_skills_defense = settings.astrology_prediction_skills['defense']
@astrology_prediction_skills_survival = settings.astrology_prediction_skills['survival']
echo " Flags['rtr-expire'].nil? #{Flags['rtr-expire'].nil?}" if UserVars.astrology_debug
echo " Flags['rtr-expire'] = #{Flags['rtr-expire']}" if UserVars.astrology_debug
do_buffs(settings)
if args.rtr
check_ripples(settings)
else
train_astrology(settings)
end
end
def do_buffs(settings)
return unless settings
return unless settings.waggle_sets['astrology']
@equipment_manager.empty_hands
# Pop out rtr data from buffs and save it for later
buffs = settings.waggle_sets['astrology']
@rtr_data = buffs.select { |spell| spell.eql?('Read the Ripples') }
.values
.first
buffs.reject! { |spell| spell.eql?('Read the Ripples') }
buffs.each_value do |value|
next unless value['use_auto_mana']
check_discern(value, settings)
end
cast_spells(buffs, settings)
end
def visible_bodies
result = []
all_bodies = @constellations
case bput('observe heavens', 'The following heavenly bodies are visible:', "That's a bit hard to do while inside")
when "That's a bit hard to do while inside"
echo('Must be outdoors to observe sky')
exit
end
until (line = get?) =~ /^Roundtime/i
result << all_bodies.find { |body| /\b#{body['name'].split.last}\b/i =~ line && line !~ /below the horizon/ }
end
result.compact.select { |data| data['circle'] <= DRStats.circle }
end
def check_attunement
return if DRSkill.getxp('Attunement') > 30
['', 'mana', 'moons', 'planets'].each do |target|
bput("perceive #{target}", 'roundtime')
waitrt?
end
end
def check_pools
pools = {
'lore' => 0,
'magic' => 0,
'survival' => 0,
'offensive combat' => 0,
'defensive combat' => 0,
'future events' => 0
}
pools_to_size = {
/You have no understanding of the celestial influences over/ => 0,
/You have a feeble understanding of the celestial influences over/ => 1,
/You have a weak understanding of the celestial influences over/ => 2,
/You have a fledgling understanding of the celestial influences over/ => 3,
/You have a modest understanding of the celestial influences over/ => 4,
/You have a decent understanding of the celestial influences over/ => 5,
/You have a significant understanding of the celestial influences over/ => 6,
/You have a potent understanding of the celestial influences over/ => 7,
/You have an insightful understanding of the celestial influences over/ => 8,
/You have a powerful understanding of the celestial influences over/ => 9,
/You have a complete understanding of the celestial influences over/ => 10
}
bput('predict state all', 'roundtime')
lines = reget(50).reverse
lines.select! { |line| line =~ /celestial influences/ }
pools.select! { |name, _level| pools[name] = lines.find { |line| line =~ /#{name}/ } }
pools.each { |name, text| pools_to_size.each { |match_text, value| pools[name] = value if match_text =~ text } }
echo " pools: #{pools}" if UserVars.astrology_debug
waitrt?
pools
end
def check_events(pools)
waitrt?
prev_size = pools['future events']
result = nil
until ['You are unable to sense additional information'].include? result
result = bput('study sky', 'You feel a lingering sense', 'You feel it is too soon', 'Roundtime', 'You are unable to sense additional information', 'detect any portents')
waitrt?
return if ['detect any portents'].include? result
pools = check_pools
break if pools['future events'] == prev_size
break if pools['future events'] == 10
prev_size = pools['future events']
end
bput('predict event', 'You focus inwardly')
end
def check_weather
echo 'Checking the weather' if UserVars.astrology_debug
bput('predict weather', 'roundtime', 'You gaze')
waitrt?
end
def rtr_active?
# DRSpells.active_spells sometimes shows RtR as inactive even though it is active
100.times do
pause 0.01
return true if DRSpells.active_spells.include?('Read the Ripples')
end
false
end
def check_ripples(settings)
return unless @rtr_data
return unless settings
return if !Flags['rtr-expire'].nil? && !Flags['rtr-expire']
@equipment_manager.empty_hands
cast_spell(@rtr_data, settings)
perc_time = Time.now - 61
Flags.add('rtr-expire', get_data('spells').spell_data['Read the Ripples']['expire']) if rtr_active?
while rtr_active?
line = get?
if perc_time + 60 < Time.now
perc_mana
perc_time = Time.now
end
res = @constellations.find { |body| /As your consciousness drifts amongst the currents of Fate, .* #{body['name']}/i =~ line }
observe(res['name']) unless res.nil?
end
nil
end
def check_astral
return unless DRStats.circle > 99
return unless @ap_source
return unless @ap_destination
return if !UserVars.astral_plane_exp_timer.nil? && Time.now - UserVars.astral_plane_exp_timer < 3600
wait_for_script_to_complete('bescort', ['ways', @ap_destination])
UserVars.astral_plane_exp_timer = Time.now
wait_for_script_to_complete('bescort', ['ways', @ap_source])
exit
end
def predict_all(pools)
skillset_to_pool = {
'offensive combat' => @astrology_prediction_skills_offense,
'defensive combat' => @astrology_prediction_skills_defense,
'magic' => @astrology_prediction_skills_magic,
'survival' => @astrology_prediction_skills_survival,
'lore' => @astrology_prediction_skills_lore,
'future events' => 'future events'
}
pools.reject { |_skill, size| (size < @prediction_pool_target) }
.each_key do |skill|
break if DRSkill.getxp('Astrology') > 30
align(skillset_to_pool[skill])
end
end
def check_heavens
@equipment_manager.empty_hands
vis_bodies = visible_bodies
night = vis_bodies.find { |body| body['constellation'] }
best_eye_data = vis_bodies
.select { |data| @have_telescope || !data['telescope'] }
.max_by { |data| [data['pools'].values.compact.size, data['circle']] }
echo(" best_eye_data = #{best_eye_data}") if UserVars.astrology_debug
waitrt?
if @have_telescope
things_to_try = @constellations.select do |data|
data['telescope'] &&
data['circle'] <= DRStats.circle &&
data['circle'] > best_eye_data['circle'] &&
(night || !data['constellation']) &&
data['pools'].values.compact.size > best_eye_data['pools'].values.compact.size
end
things_to_try << best_eye_data
things_to_try.sort! { |data| data['circle'] }.reverse!
echo(" things_to_try = #{things_to_try}") if UserVars.astrology_debug
things_to_try.find do |data|
result = nil
until ['Roundtime', 'You peer aimlessly through your telescope'].include?(result)
return check_heavens if Flags['bad-search'] == 'is foiled by the daylight'
next if Flags['bad-search'] == 'turns up fruitless'
result = observe(data['name'])
end
result == 'Roundtime'
end
else
until observe(best_eye_data['name'])
if Flags['bad-search']
check_heavens
return
end
end
end
pause 2
waitrt?
end
def get_healed
@equipment_manager.empty_hands
snapshot = Room.current.id
wait_for_script_to_complete('safe-room', ['force'])
walk_to(snapshot)
settings = get_settings
do_buffs(settings)
end
def observe(body)
Flags.add('bad-search', 'is foiled by the (daylight|darkness)', 'turns up fruitless')
if @have_telescope
bput('get telescope', 'you get', 'You are already', "That can't be picked up")
case bput("center telescope on #{body}", 'You put your eye', 'open it to make any use of it', 'The pain is too much')
when /open it/
bput('open my telescope', 'extend your telescope')
return observe(body)
when /The pain is too much/
get_healed
return observe(body)
end
result = bput('peer telescope', 'You peer aimlessly through your telescope', 'open it to make any use of it', 'You see nothing regarding the future', 'The pain is too much', 'Roundtime')
case result
when /The pain is too much/
get_healed
return observe(body)
when /open it/
bput('open my telescope', 'extend your telescope')
return observe(body)
end
@equipment_manager.empty_hands
result
else
['Roundtime', 'Clouds obscure'].include? bput("observe #{body} in heavens", 'Your search for', 'You see nothing regarding the future', 'Clouds obscure', 'Roundtime')
end
end
def roll_bones
if @divination_bones_tied
bput("untie bones from my #{@divination_bones_container}", 'divination bones')
else
bput("get bones from my #{@divination_bones_container}", 'divination bones', 'you get')
end
bput('roll my bones', 'roundtime')
waitrt?
if @divination_bones_tied
bput("tie bones to my #{@divination_bones_container}", 'divination bones')
else
bput("put bones in my #{@divination_bones_container}", 'divination bones', 'you put')
end
end
def execute_tool
verbs = {
'charts' => 'review',
'bones' => 'roll',
'mirror' => 'gaze',
'bowl' => 'gaze',
'prism' => 'raise'
}
if @divination_tool_tied
bput("untie #{@divination_tool} from my #{@divination_tool_container}", @divination_tool)
elsif @divination_tool_worn
bput("remove my #{@divination_tool}", @divination_tool)
else
bput("get my #{@divination_tool} from my #{@divination_tool_container}", @divination_tool, 'you get')
end
verbs.each do |tool, verb|
next unless @divination_tool.include? tool
bput("#{verb} my #{@divination_tool}", 'roundtime')
waitrt?
break
end
if @divination_tool_tied
bput("tie #{@divination_tool} to my #{@divination_tool_container}", @divination_tool)
elsif @divination_tool_worn
bput("wear my #{@divination_tool}", @divination_tool)
else
bput("put #{@divination_tool} in my #{@divination_tool_container}", @divination_tool, 'you put')
end
end
def align(skill)
if skill == 'future events'
bput('predict event', 'You focus inwardly')
return
end
bput("align #{skill}", 'You focus internally')
waitrt?
if @have_divination_bones
roll_bones
elsif @divination_tool
execute_tool
else
bput('predict future', 'roundtime')
end
waitrt?
pause
pause 0.5 while stunned?
fix_standing
end
def train_astrology(settings)
return unless settings
return unless settings.astrology_training.is_a?(Array)
return if settings.astrology_training.none?
settings.astrology_training.each do |task|
break if DRSkill.getxp('Astrology') > 30
case task
when 'ways'
check_astral
when 'observe'
check_heavens
when 'rtr'
check_ripples(settings)
when 'weather'
check_weather
when 'events'
check_events(check_pools)
when 'moons' # deprecated - left for backwards compat. only
echo '- Moons is deprecated and will be removed soon. Please use - attunement instead'
check_attunement
when 'attunement'
check_attunement
end
end
predict_all(check_pools)
bput('predict analyze', 'Roundtime')
waitrt?
end
end
before_dying do
Flags.delete('bad-search')
end
# Call this last to avoid the need for forward declarations
Astrology.new