forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
afk.lic
83 lines (67 loc) · 2.1 KB
/
afk.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#afk
=end
custom_require.call(%w(drinfomon common))
no_pause_all
no_kill_all
def exit_game
echo "Current room: #{Room.current.id}"
echo "Exiting at #{Time.now}"
fput('exit')
end
echo 'Afk script started - pausing for 10 seconds or until health passes threshold'
pause 10
settings = get_settings
health_threshold = settings.health_threshold
depart_on_death = settings.depart_on_death
justice_threshold = settings.afk_justice_threshold
warning_threshold = (100 + health_threshold) / 2
warned = false
pause 1 while health < [health_threshold + 20, 100].min || spirit < [health_threshold + 20, 100].min
justice_message_count = 0
loop do
line = script.gets?
pause 0.05 unless line
fput(%w(tdp time age).sample) if line =~ /you have been idle too long/i
justice_message_count += 1 if line =~ /You hear the cries echo around you as everyone in the vicinity immediately gives/
justice_message_count += 1 if line =~ /authorities will try to bring you in for endangering the public/
if justice_message_count > justice_threshold
echo "Looks like you've run into trouble with the law. Exiting"
exit_game
end
if Room.current.id == 9610
DRC.fix_standing
move('out')
end
if dead?
echo '*' * 30
echo 'Afk - detected death departing in 3 minutes'
echo '*' * 30
pause 60
echo '*' * 30
echo 'Afk - detected death departing in 2 minutes'
echo '*' * 30
pause 60
echo '*' * 30
echo 'Afk - detected death departing in 1 minute'
echo '*' * 30
pause 60
fput('depart item') if depart_on_death
exit_game
end
if !warned && (health < warning_threshold || spirit < warning_threshold)
echo 'Afk - approaching low vitality/spirit threshold'
warned = true
end
if warned && health > warning_threshold && spirit > warning_threshold
warned = false
end
next unless health < health_threshold || spirit < health_threshold
echo 'Afk - detected low vitality/spirit health'
fput('health')
pause 1
echo 'Turning off avoids'
fput('avoid all')
pause 1
exit_game
end