-
Notifications
You must be signed in to change notification settings - Fork 177
/
autocontingency.lic
56 lines (52 loc) · 1.43 KB
/
autocontingency.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#autocontingency
=end
custom_require.call(%w(common-arcana spellmonitor common-travel))
class Contingency
def initialize
arg_definitions = [
[
{ name: 'anchor', regex: /\w+/, description: 'Contingency to create' },
{ name: 'room', regex: /\d+/, description: 'Room to move to' }
],
[
{ name: 'invoke', regex: /invoke/i }
]
]
args = parse_args(arg_definitions)
@settings = get_settings
@anchor = args.anchor.capitalize
@room = args.room
if args.invoke
check_contingency
else
contingency_saferoom
end
end
def contingency_saferoom
moon = UserVars.moons.select { |each_moon, _data| UserVars.moons['visible'].include?(each_moon) }
.reject { |_moon, data| data['timer'] < 32 }
.max_by { |_moon, data| data['timer'] }
.first
echo "moon=#{moon}"
return unless moon
DRCT.walk_to(@room)
cast_contingency_spells
pause 1
end
def cast_contingency_spells
@settings.waggle_sets['contingency'].values.each do |data|
data['cast'] = "cast #{@anchor}"
DRCA.cast_spell(data, @settings)
end
end
def check_contingency
if DRSpells.active_spells['Contingency'].to_i <= 0
pause 1
echo("No contingency")
else
fput("invoke contingency")
end
end
end
Contingency.new