-
Notifications
You must be signed in to change notification settings - Fork 177
/
athletics.lic
416 lines (365 loc) · 13.9 KB
/
athletics.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#athletics
=end
custom_require.call(%w[common common-items common-travel events])
class Athletics
def initialize
@settings = get_settings
@athletics_options = get_data('athletics').athletics_options
@performance_pause = @settings.performance_pause
athletics_location = @settings.athletics_town || @settings.fang_cove_override_town || @settings.hometown
@climbing_target = get_data('athletics').practice_options[@settings.climbing_target]
@swimming_target = get_data('athletics').swimming_options[@settings.swimming_target]
have_climbing_rope = get_settings.have_climbing_rope
@outdoorsmanship_rooms = get_settings.athletics_outdoorsmanship_rooms
get_athletics_items
start_exp = DRSkill.getxp('Athletics')
@end_exp = [start_exp + 15, 29].min
arg_definitions = [
[
{ name: 'wyvern', regex: /^wy.*/i, optional: true, description: 'Climb both undergondola and wyvern cliffs' },
{ name: 'undergondola', regex: /^un.*/i, optional: true, description: 'Climb branch etc undergondola' },
{ name: 'xalas', regex: /^xala.*/i, optional: true, description: 'Climb xalas in zoluren in instead of undergondola' },
{ name: 'stationary', regex: /^stat.*/i, optional: true, description: 'Stand still and use a climbing rope' },
{ name: 'cliffs', regex: /^cliff.*/i, optional: true, description: 'Climb undergondola without attempting branch' },
{ name: 'max', regex: /^max/i, optional: true, description: 'Keep training until 32/34+' }
]
]
args = parse_args(arg_definitions)
@end_exp = 32 if args.max
start_script('skill-recorder') unless Script.running?('skill-recorder')
if args.wyvern || (@settings.climbing_target == 'wyvern')
climb_wyvern
elsif args.undergondola || (@settings.climbing_target == 'undergondola')
climb_branch
elsif args.xalas || (@settings.climbing_target == 'xalas')
climb_xalas
elsif args.cliffs || (@settings.climbing_target == 'cliffs')
climb_cliffs
elsif have_climbing_rope
train_with_rope(args.stationary)
elsif @swimming_target
swim_loop(@swimming_target['rooms'])
elsif @climbing_target
climb_practice(@climbing_target['id'], @climbing_target['target'], @climbing_target['hide'])
elsif athletics_location == 'Crossing'
crossing_athletics
elsif athletics_location == 'Riverhaven'
crossing_athletics if DRSkill.getrank('Athletics') > 140
elsif athletics_location == 'Shard'
shard_athletics
elsif athletics_location == 'Hibarnhvidar'
hib_athletics
elsif athletics_location == 'Ratha'
ratha_athletics
end
stow_athletics_items
end
def outdoorsmanship_waiting(number)
start = Time.now
DRCT.walk_to(@outdoorsmanship_rooms.sample) unless @outdoorsmanship_rooms.empty?
stow_athletics_items
DRC.wait_for_script_to_complete('outdoorsmanship', [number, "room=#{Room.current.id}", 'rock'])
remaining_pause = ((number * 15) - (Time.now - start))
pause remaining_pause if remaining_pause > 0
get_athletics_items
end
def get_athletics_items
return if @settings.held_athletics_items.empty?
@settings.held_athletics_items.each { |item| DRC.bput("get my #{item}", 'You', 'What were') }
end
def stow_athletics_items
return if @settings.held_athletics_items.empty?
@settings.held_athletics_items.each { |item| DRC.bput("stow my #{item}", 'You', 'Stow what?') }
end
def override_location_and_practice(place)
@climbing_target = get_data('athletics').practice_options[place]
climb_practice(@climbing_target['id'], @climbing_target['target'], @climbing_target['hide'])
end
def swim_loop(rooms)
return unless rooms
rooms.each { |x| DRCT.walk_to(x) } until done_training?
end
def done_training?
DRSkill.getxp('Athletics') >= @end_exp
end
def offset_climbing_song(direction)
return unless UserVars.climbing_song_offset
return unless @song_list
if direction.eql?(1)
UserVars.climbing_song = @song_list[UserVars.climbing_song]
elsif direction.eql?(-1)
UserVars.climbing_song = @song_list.key(UserVars.climbing_song)
else
echo 'Invalid offset direction'
end
end
def train_with_rope(stationary)
return unless DRCI.exists?("#{@settings.climbing_rope_adjective} rope")
return unless DRCI.exists?(@settings.worn_instrument)
UserVars.climbing_song ||= pick_climbing_song
echo "UserVars.climbing_song: #{UserVars.climbing_song}" if UserVars.athletics_debug
@song_list = get_data('perform').perform_options
echo "@song_list: #{@song_list}" if UserVars.athletics_debug
Flags.add('climbing-finished', 'You finish practicing your climbing', 'The rope\'s will quickly fades away', 'Your focus diverts away from the rope')
Flags.add('climbing-too-hard', 'This climb is too difficult')
Flags.add('climbing-too-easy', 'This climb is no challenge at all, so you stop practicing')
Flags.add('climbing-dead-rope', '^You believe you can use it for \d+ minutes per day\.', '^You finish practicing your climbing skill just as your rope begins to slacken')
Flags.add('climbing-live-rope', '^You believe you haven\'t yet used it today')
DRCI.stow_hands
DRCT.walk_to @settings.safe_room unless stationary
case DRC.bput("get #{@settings.climbing_rope_adjective} rope", 'You are already holding that', 'You get', 'What were you', 'But that is already')
when 'But that is already'
DRC.bput("remove my #{@settings.climbing_rope_adjective} rope", 'You remove')
end
Flags['climbing-dead-rope'] = !check_rope?
until done_training? || Flags['climbing-dead-rope']
DRC.fix_standing
Flags.reset('climbing-finished')
break unless DRC.play_song?(@settings, @song_list, true, true, true)
case DRC.bput("climb practice #{@settings.climbing_rope_adjective} rope", 'You begin to practice ', 'you mime a convincing climb while pulling the rope hand over hand', 'Directing your attention toward your rope', 'Allows you to climb various things like a tree', 'But you aren\'t holding', 'You should stop practicing')
when /you mime/
break unless check_rope?
break unless DRC.play_song?(@settings, @song_list, true, true, true)
when /Directing your/, /You should stop practicing/
loop do
pause 1
break if Flags['climbing-finished']
if Flags['climbing-too-hard']
Flags.reset('climbing-too-hard')
UserVars.climbing_song_offset = true
DRC.stop_playing
offset_climbing_song(-1)
break
elsif Flags['climbing-too-easy']
Flags.reset('climbing-too-easy')
UserVars.climbing_song_offset = true
DRC.stop_playing
offset_climbing_song(1)
break
elsif Flags['dead-rope']
break unless check_rope?
break unless DRC.play_song?(@settings, @song_list, true, true, true)
end
end
when /Allows you to climb various things like a tree/
echo 'Waiting for rope to become climbable again'
pause 20
when /But you aren't holding/
DRC.bput("get #{@settings.climbing_rope_adjective} rope", 'You are already holding that', 'You get', 'What were you')
end
end
DRC.bput('stop climb', 'You stop practicing your climbing skills.', "You weren't practicing your climbing skills anyway.")
DRC.stop_playing
DRC.fix_standing
DRCI.stow_hands
end
def check_rope?
DRC.bput("study #{@settings.climbing_rope_adjective} rope", 'You\'re certain you can')
pause 1
if Flags['climbing-dead-rope'] && !Flags['climbing-live-rope']
DRC.message('Your rope is dead tired! Get a better one, you poor slob!')
false
else
true
end
end
def pick_climbing_song
# start at a high difficulty guess and work downwards
case DRSkill.getrank('Athletics')
when 0..100
'lament'
when 100..250
'psalm'
when 250..350
'tarantella'
when 350..450
'rondo'
when 450..1750
'concerto masterful'
end
end
def crossing_athletics
if UserVars.athletics.to_i <= 50
swim_loop(get_data('athletics').swimming_options['arthe_dale']['rooms'])
elsif UserVars.athletics.to_i < 290
waitrt?
pause @performance_pause # to give performance time to complete before_dying if stopped from the previous script
start_script('performance') unless Script.running?('performance')
until done_training?
@athletics_options['crossing']
.reject { |data| @settings.avoid_athletics_in_justice && data['justice'] }
.each do |data|
break unless climb?(data['room'], data['targets'])
end
end
elsif UserVars.athletics.to_i < 450
override_location_and_practice('segoltha_bank')
else
DRC.message("The xalas argument will train faster at 650+ athletics. Be aware that it's potentially dangerous.") if UserVars.athletics.to_i > 650
override_location_and_practice('arthelun_rocks')
DRC.message("The xalas argument will train faster at 650+ athletics. Be aware that it's potentially dangerous.") if UserVars.athletics.to_i > 650
end
end
def shard_athletics
until done_training?
if UserVars.athletics.to_i < 240
until done_training?
@athletics_options['shard']
.reject { |data| @settings.avoid_athletics_in_justice && data['justice'] }
.each do |data|
break unless climb?(data['room'], data['targets'])
end
end
elsif UserVars.athletics.to_i < 540
climb_cliffs
elsif UserVars.athletics.to_i < 850
climb_branch
elsif UserVars.athletics
climb_wyvern
end
end
end
def hib_athletics
swim_liirewsag
end
def ratha_athletics
until done_training?
if DRSkill.getrank('Athletics') <= 185
override_location_and_practice('ratha_rock_gorge')
elsif DRSkill.getrank('Stealth') >= 130
override_location_and_practice('ratha_deep_crack')
else
# stops in infinte loop when > 185 ranks in athletics and < 130 ranks in stealth
DRC.message("You don't meet current requirements for Ratha climbing. You need at least 130 stealth.")
break
end
end
end
def swim_zaldeni
until done_training?
DRCT.walk_to(11_481)
DRCT.walk_to(11_482)
DRCT.walk_to(11_483)
end
end
def swim_liirewsag
# Intermittent errors in the map will cause go2 to get stuck. The manual moves are a workaround for that
DRCT.walk_to(4155)
move('nw')
until done_training?
move('climb bank')
3.times do
move('south')
waitrt?
end
DRCT.walk_to(4155)
move('nw')
end
move('climb bank')
waitrt?
end
def climb_practice(room, target, to_hide = false)
return unless target
DRCT.walk_to(room)
until done_training?
DRC.retreat
if to_hide
remaining_attempts = 5
while remaining_attempts > 0
break if DRC.hide?
remaining_attempts -= 1
end
return if remaining_attempts.zero?
else
start_script('performance', ['noclean']) unless Script.running?('performance')
pause @performance_pause # make sure you are playing before starting climb practice
end
Flags.add('ct-climbing-finished', 'You finish practicing your climbing')
Flags.add('ct-climbing-combat', 'You are engaged in combat')
DRC.bput("climb practice #{target}", 'You begin to practice ')
loop do
pause
break if Flags['ct-climbing-finished']
return if Flags['ct-climbing-combat']
break if done_training?
end
DRC.bput('stop climb', 'You stop practicing your climbing skills.', "You weren't practicing your climbing skills anyway.")
end
DRC.bput('unhide', 'You come out of hiding', 'You slip out of hiding', 'But you are not') if to_hide
end
def climb?(room, targets)
targets.each do |target|
DRCT.walk_to(room)
return true if DRRoom.npcs.length >= 3
DRC.bput("climb #{target}", '.*')
pause
waitrt?
return false if done_training?
end
true
end
def climb_branch
if UserVars.athletics.to_i < 540
override_location_and_practice('undergondola_branch')
else
DRC.message("Warning: Using the undergondola arg with more than 850 athletics is not best use and you may consider the wyvern option instead.") if UserVars.athletics.to_i > 850
DRCT.walk_to(9607)
DRCT.walk_to(9515)
until done_training?
DRCT.walk_to(2245)
DRCT.walk_to(9607)
DRCT.walk_to(11_126)
DRCT.walk_to(9515)
break if done_training?
outdoorsmanship_waiting(4)
end
end
end
def climb_cliffs
until done_training?
DRCT.walk_to(9525)
DRCT.walk_to(9609)
DRCT.walk_to(9607)
DRCT.walk_to(2900)
break if done_training?
outdoorsmanship_waiting(4)
end
end
def climb_wyvern
DRCT.walk_to(19_464)
until done_training?
DRCT.walk_to(2245) if UserVars.athletics.to_i > 540
DRCT.walk_to(9607)
DRCT.walk_to(11_126)
DRCT.walk_to(19_464)
DRCT.walk_to(13_558)
DRCT.walk_to(14_010)
DRCT.walk_to(13_117)
DRCT.walk_to(6443)
break if done_training?
outdoorsmanship_waiting(3)
end
end
def climb_xalas
DRCT.walk_to(6154)
until done_training?
DRCT.walk_to(12_838)
DRCT.walk_to(6154)
break if done_training?
outdoorsmanship_waiting(4)
end
end
end
before_dying do
stop_script('performance') if Script.running?('performance')
put('stop climb')
Flags.delete('climbing-finished')
Flags.delete('climbing-too-easy')
Flags.delete('climbing-too-hard')
Flags.delete('climbing-dead-rope')
Flags.delete('climbing-live-rope')
Flags.delete('ct-climbing-finished')
Flags.delete('ct-climbing-combat')
end
Athletics.new