forked from rpherbig/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jail-buddy.lic
95 lines (80 loc) · 3.24 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
87
88
89
90
91
92
93
94
95
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#jail-buddy
=end
custom_require.call(%w[common common-money])
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(old_loc)
pause 1 until DRC.pause_all
stop_script('go2') if Script.running?('go2')
echo('** DON\'T PANIC JAIL BUDDY HAS YOUR BACK! **')
waitfor('PLEAD INNOCENT or PLEAD GUILTY')
stop_script('outdoorsmanship') if Script.running?('outdoorsmanship')
fput('PLEAD INNOCENT')
loop do
case waitfor('this court finds you innocent of the charges brought upon you', 'is guilty of no crime in my district', 'I pronounce a fine upon you of', 'I hereby fine you a total of', 'send you to the stocks')
when /this court finds you innocent of the charges brought upon you/i, /is guilty of no crime in my district/i
pause 5
check_sack
break
when /I pronounce a fine upon you of/i, /I hereby fine you a total of/i
pause 5
recover_gear
break
when /send you to the stocks/i
pause 5
wait_stocks
break
end
end
DRCM.ensure_copper_on_hand(300, get_settings)
DRC.wait_for_script_to_complete('go2', [old_loc.to_s], force: true) if old_loc
DRC.unpause_all
end
loop do
current_loc ||= Room.current.id
line = script.gets
next if line =~ /DRPrime/
if [/^Before you really realize .* you are marched off./, /wrestle you to the ground, bind you in chains, and drag you off to jail/, /ushered to a cell, the door opened just long enough for you to be shoved inside/, /\[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/, /The sentinel brings you to the jail/, /^You slowly wake up again to find that all your belongings have been stripped/].find { |x| x =~ line }
pause 0.5
get_out_of_jail(current_loc)
end
end