-
Notifications
You must be signed in to change notification settings - Fork 177
/
attunement.lic
165 lines (148 loc) · 5.25 KB
/
attunement.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#attunement
=end
custom_require.call(%w[common common-arcana common-travel])
class Attunement
LUNAR_PERCEIVE_COMMANDS = ['mana', 'moons in sky', 'planets']
PRIMARY_SIGILS_PATTERN = /\b(?:abolition|congruence|induction|permutation|rarefaction) sigil\b/
SECONDARY_SIGILS_PATTERN = /\b(?:antipode|ascension|clarification|decay|evolution|integration|metamorphosis|nurture|paradox|unity) sigil\b/
def initialize
arg_definitions = [
[
{
name: 'health',
regex: /health/,
optional: true,
description: 'As an Empath, will do PERCEIVE HEALTH instead of PERCEIVE to train empathy.'
},
{
name: 'sigil',
regex: /sigil/,
optional: true,
description: 'Do sigil walking (scholarship training) instead of regular attunement walking'
}
]
]
args = parse_args(arg_definitions, true)
settings = get_settings
@stationary_skills_only = settings.crossing_training_stationary_skills_only
@hometown = settings.fang_cove_override_town || settings.hometown
@attunement_rooms = settings.attunement_rooms
@perceive_health_rooms = settings.perceive_health_rooms
@sigil_walk_rooms = settings.sigil_walk_rooms
@skill_to_train = if (DRStats.empath? && args.health)
'Empathy'
elsif args.sigil
'Scholarship'
else
'Attunement'
end
@exp_max_threshold = settings.crossing_training_max_threshold
@exp_target_increment = settings.attunement_target_increment
@exp_start_mindstate = DRSkill.getxp(@skill_to_train)
@exp_stop_mindstate = [@exp_start_mindstate + @exp_target_increment, @exp_max_threshold, 34].min
@lunar_perceive_index = -1
train_skill(settings)
end
def is_lunar_mage?
DRStats.moon_mage? || DRStats.trader?
end
def is_health_walk?
@skill_to_train == 'Empathy'
end
def is_sigil_walk?
@skill_to_train == 'Scholarship'
end
def get_next_lunar_perceive_index
@lunar_perceive_index = (@lunar_perceive_index + 1) % LUNAR_PERCEIVE_COMMANDS.length
end
def get_perceive_command
if is_health_walk?
"perceive health"
elsif is_sigil_walk?
"perceive sigil"
elsif is_lunar_mage?
"perceive #{LUNAR_PERCEIVE_COMMANDS[get_next_lunar_perceive_index]}"
else
"perceive"
end
end
def get_rooms
rooms = []
if is_health_walk?
rooms = @perceive_health_rooms
if rooms.nil? || rooms.empty?
rooms = get_data('town')[@hometown]['perceive_health_rooms']
end
if rooms.nil? || rooms.empty?
DRC.message("No room ids defined for 'perceive_health_rooms' in your yaml nor in base-town.yaml for #{@hometown}.")
exit
end
elsif is_sigil_walk?
rooms = @sigil_walk_rooms
if rooms.nil? || rooms.empty?
rooms = get_data('town')[@hometown]['sigil_walk_rooms']
end
elsif @stationary_skills_only || is_lunar_mage?
rooms = [Room.current.id]
end
# fall back to attunement rooms if still nothing set
if rooms.nil? || rooms.empty?
rooms = @attunement_rooms
if rooms.nil? || rooms.empty?
rooms = get_data('town')[@hometown]['attunement_rooms']
end
if rooms.nil? || rooms.empty?
DRC.message("No room ids defined for 'attunement_rooms' in your yaml nor in base-town.yaml for #{@hometown}.")
exit
end
end
rooms
end
def done_training?
DRSkill.getxp(@skill_to_train) >= @exp_stop_mindstate
end
def train_skill(settings)
room_list = get_rooms
until done_training?
# If we keep looping, ensure buffs stay active
DRCA.do_buffs(settings, 'attunement')
room_list.each do |room_id|
train_skill_in_room(room_id)
break if done_training?
end
end
end
def train_skill_in_room(room_id)
DRCT.walk_to(room_id)
# When health walking, you may fail to perceive your first time.
# Either from lack of skill or waiting on the timer between perceive health attempts.
# When health walking, will retry a few times before moving on.
# When power walking, will be successful first try and move on like normal.
5.times do
break if perceived?
# There is a 60 second timer between successful 'perceive health' commands.
# So if doing a health walk then pause a little bit between retries to avoid
# spamming the room (and yourself) with failed attempts. For normal attunement
# training then the wait is only as long as the perceive command takes.
pause(is_health_walk? ? 10 : 0)
waitrt?
end
waitrt?
end
def perceived?
if is_sigil_walk?
while /Roundtime/ =~ DRC.bput(get_perceive_command, SECONDARY_SIGILS_PATTERN, 'Having recently been searched, this area contains no traces of sigils', "Roundtime",)
waitrt?
end
return true
end
case DRC.bput(get_perceive_command, "You fail to sense", "You're not ready to do that again, yet", "You reach out", "You sense:", "Roundtime", "Something in the area is interfering")
when "You reach out", "You sense:"
true
else
false
end
end
end
Attunement.new