forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exp-monitor.lic
31 lines (27 loc) · 994 Bytes
/
exp-monitor.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
no_pause_all
no_kill_all
custom_require.call(['drinfomon'])
UserVars.echo_exp = true
UserVars.echo_exp_time ||= 1
DRSkill.gained_skills.clear
before_dying do
# Turn off setting when script stops otherwise drinfomon script will
# continue to append data to DRSkill.gained_skills array as a memory leak.
UserVars.echo_exp = false
DRSkill.gained_skills.clear
end
loop do
new_skills = DRSkill.gained_skills.shift(DRSkill.gained_skills.size)
# Some actions may pulse the same skill multiple times.
# When this happens then we aggregate the individual pulses
# so that we can report on "Skill(+3)" instead of "Skill(+1), Skill(+1), ..."
new_skills = new_skills.reduce(Hash.new) do |result, gain|
skill = gain[:skill]
value = gain[:change]
result[skill] += value
result
end
new_skills = new_skills.keys.map { |skill| "#{skill}(+#{new_skills[skill]})" }
respond("Gained: #{new_skills.join(', ')}") unless new_skills.empty?
pause UserVars.echo_exp_time
end