forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastrology.lic
157 lines (131 loc) · 5.24 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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#astrology
=end
custom_require.call(%w(common common-arcana drinfomon spellmonitor))
class Astrology
include DRC
include DRCA
def initialize
settings = get_settings
@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_training = settings.astral_plane_training['train_in_ap']
@ap_source = settings.astral_plane_training['train_source']
@ap_destination = settings.astral_plane_training['train_destination']
do_buffs(settings)
check_astral
train_astrology
end
def do_buffs(settings)
settings.astrology_buffs['spells'].each do |spell|
echo "Buffing: #{spell}" if UserVars.astrology_debug
buff(spell, 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_astral
return unless DRStats.circle > 99
return unless @ap_training
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 train_astrology
fput('predict weather')
waitrt?
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) if UserVars.astrology_debug
waitrt?
Flags.add('bad-search', 'is foiled by the (daylight|darkness)', 'turns up fruitless')
observed = if @have_telescope
bput('get telescope', 'you get', 'You are already', "That can't be picked up")
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) if UserVars.astrology_debug
things_to_try.find do |data|
bput("center telescope on #{data['name']}", 'You put your eye')
result = nil
until ['Roundtime', 'You peer aimlessly through your telescope'].include?(result)
if Flags['bad-search'] == 'is foiled by the daylight'
train_astrology
return
elsif Flags['bad-search'] == 'turns up fruitless'
next
end
result = bput('peer telescope', 'You peer aimlessly through your telescope', 'You see nothing regarding the future', 'Roundtime')
end
result == 'Roundtime'
end
else
until ['Roundtime', 'Clouds obscure'].include? bput("observe #{best_eye_data['name']} in sky", 'Your search for', 'You see nothing regarding the future', 'Clouds obscure', 'Roundtime')
if Flags['bad-search']
train_astrology
return
end
end
best_eye_data
end
pause 2
waitrt?
bput('stow telescope', 'you put') if @have_telescope
observed['pools']
.reject { |_skill, value| value.nil? }
.each { |skill, _value| align(skill) }
bput('predict anal', 'roundtime')
waitrt?
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')
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')
end
end
def align(skill)
bput("align #{skill}", 'You focus internally')
waitrt?
if @have_divination_bones
roll_bones
else
bput('predict future', 'roundtime')
end
waitrt?
pause 0.5 while stunned?
fix_standing
end
end
# Call this last to avoid the need for forward declarations
Astrology.new