forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jail-buddy.lic
86 lines (75 loc) · 2.71 KB
/
jail-buddy.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#jail-buddy
=end
custom_require.call(%w(common))
no_pause_all
no_kill_all
def check_sack
return unless DRC.right_hand =~ /sack/ || DRC.left_hand =~ /sack/
fput('open my sack')
raw_contents = DRC.bput('look in my sack', /^In the .* you see .*\./, 'There is nothing in there')
if raw_contents == 'There is nothing in there'
fput('drop my sack')
return
end
items = raw_contents.match(/^In the .* you see (.*)\./).to_a[1].split(/,|\sand\s/)
items.each do |item|
stow_noun = item.split.reverse.find { |noun| /you/i =~ DRC.bput("get #{noun} from my sack", 'You pick up', 'You get', 'What were', 'Please rephrase that command') }
fput("stow my #{stow_noun}")
end
raw_contents = DRC.bput('look in my sack', /^In the .* you see .*\./, 'There is nothing in there')
if raw_contents == 'There is nothing in there'
fput('drop my sack')
return
end
fput('stow my sack')
end
def wait_stocks
waitfor('You accept a sack and retrieve the equipment stored inside')
pause 5
fput('stand')
check_sack
end
def recover_gear
case waitfor('You are free to go', 'your possessions will be in a sack marked with your name')
when /your possessions will be in/i
DRC.wait_for_script_to_complete('pay-debt', ['sack'])
unless [DRC.right_hand, DRC.left_hand].grep(/sack/).any?
echo '***STATUS*** Failed to pay debt and retrieve items'
DRC.beep
exit
end
end
check_sack
end
def get_out_of_jail
Script.running.find_all { |s| !s.paused? && !s.no_pause_all }.each(&:pause)
echo('** DON\'T PANIC JAIL BUDDY HAS YOUR BACK! **')
waitfor('PLEAD INNOCENT or PLEAD GUILTY')
fput('PLEAD INNOCENT')
loop do
case waitfor('this court finds you innocent of the charges brought upon you', 'I pronounce a fine upon you of', 'send you to the stocks')
when /this court finds you innocent of the charges brought upon you/i
pause 5
check_sack
break
when /I pronounce a fine upon you of/i
pause 5
recover_gear
break
when /send you to the stocks/i
pause 5
wait_stocks
break
end
end
DRC.wait_for_script_to_complete('sell-loot')
Script.running.find_all { |s| s.paused? && !s.no_pause_all }.each(&:unpause)
end
loop do
line = script.gets
if [/^Before you really realize .* you are marched off./, /wrestle you to the ground, bind you in chains, and drag you off to jail/, /\[Guard House, Jail Cell\]/, /^The guard looks you over.* and leads you firmly off to jail/, /A sparkling cloud of silver motes envelops your body like a mist of stars/, /Although your head is still ringing from the assault/].find { |x| x =~ line }
pause 0.5
get_out_of_jail
end
end