forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastrology.lic
More file actions
332 lines (293 loc) · 11.4 KB
/
astrology.lic
File metadata and controls
332 lines (293 loc) · 11.4 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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#astrology
=end
custom_require.call(%w[common common-arcana common-travel drinfomon spellmonitor])
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?
@constellations = get_data('constellations').constellations
@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 : 1
@rtr_data = nil
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
# Pop out rtr data from buffs and save it for later
if settings.waggle_sets['astrology']
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') }
cast_spells(buffs, settings)
elsif settings.astrology_buffs
echo '******************'
echo "astrology_buffs has been deprecated in favor of 'astrology' waggle set and will be removed in a future version"
echo '******************'
buffs = settings.astrology_buffs['spells']
@rtr_data = buffs.select { |spell| spell['abbrev'].casecmp('rtr').zero? }.first
buffs.reject { |spell| spell['abbrev'].casecmp('rtr').zero? }
.each { |buff| cast_spell(buff, settings) }
end
end
def visible_bodies
result = []
all_bodies = @constellations
bput('observe sky', 'The following heavenly bodies are visible:')
until (line = get?) =~ /^Roundtime/i
result << all_bodies.find { |body| /\b#{body['name']}\b/i =~ line && line !~ /below the horizon/ }
end
result.compact.select { |data| data['circle'] <= DRStats.circle }
end
def check_moons
%w[xibar yavash katamba].each do |moon|
bput("pow #{moon}", '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 check_ripples(settings)
return unless @rtr_data
return unless settings
return if !Flags['rtr-expire'].nil? && !Flags['rtr-expire']
cast_spell(@rtr_data, settings)
while DRSpells.active_spells.include?('Read the Ripples')
line = get?
res = @constellations.find { |body| /As your consciousness drifts amongst the currents of Fate, .* #{body['name']}/i =~ line }
observe(res['name']) unless res.nil?
pause 1
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' => 'offense',
'defensive combat' => 'defense',
'magic' => 'magic',
'survival' => 'survival',
'lore' => 'lore',
'future events' => 'future events'
}
pools.reject { |_skill, size| (size < @prediction_pool_target) }
.each { |skill, _size| align(skillset_to_pool[skill]) }
end
def check_heavens
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?
observed = 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)
if Flags['bad-search'] == 'is foiled by the daylight'
check_heavens
return
elsif Flags['bad-search'] == 'turns up fruitless'
next
end
result = observe(data['name'])
end
result == 'Roundtime'
end
else
until observe(best_eye_data['name'])
if Flags['bad-search']
check_heavens
return
end
end
best_eye_data
end
pause 2
waitrt?
observed['pools']
.reject { |_skill, value| value.nil? }
.reject { |_skill, value| value < @prediction_pool_target }
.each { |skill, _value| align(skill) }
waitrt?
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")
if bput("center telescope on #{body}", 'You put your eye', 'open it to make any use of it') =~ /open it/
bput('open my telescope', 'extend your telescope')
return observe(body)
end
result = bput('peer telescope', 'You peer aimlessly through your telescope', 'You see nothing regarding the future', 'The pain is too much', 'Roundtime')
if result =~ /The pain is too much/
bput('stow telescope', 'you put', "That can't be picked up")
snapshot = Room.current.id
wait_for_script_to_complete('safe-room')
walk_to(snapshot)
settings = get_settings
do_buffs(settings)
return observe(body)
end
bput('stow telescope', 'you put', "That can't be picked up")
result
else
['Roundtime', 'Clouds obscure'].include? bput("observe #{body} in sky", '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 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
else
bput('predict future', 'roundtime')
end
waitrt?
pause
pause 0.5 while stunned?
fix_standing
end
def train_astrology(settings)
return unless settings
if settings.astrology_training.nil? # TODO: Temporary until everyone is updated
echo ' Astrology training settings have been updated, please restart dependency!'
exit
end
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'
check_moons
end
end
predict_all(check_pools)
bput('predict analyze', 'Roundtime')
waitrt?
end
end
# Call this last to avoid the need for forward declarations
Astrology.new