forked from brycole/gemstone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisarm_only.lic
More file actions
162 lines (147 loc) · 5.08 KB
/
disarm_only.lic
File metadata and controls
162 lines (147 loc) · 5.08 KB
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
## Disarm only
## Kalros
## 1/11/2016
## v. 01
def bput(message, *matches)
waitrt?
timer = Time.now
log = []
matches.flatten!
matches.map! { |item| item.is_a?(Regexp) ? item : /#{item}/i }
clear
put message
while Time.now - timer < 15
response = get?
if response.nil?
pause 0.1
next
end
log += [response]
case response
when /(?:\.\.\.wait |Wait |\.\.\. wait )([0-9]+)/
pause Regexp.last_match(1).to_i
put message
timer = Time.now
next
when /Sorry, you may only type ahead/
pause 1
put message
timer = Time.now
next
when /^You are still stunned/
pause 0.5
put message
timer = Time.now
next
end
matches.each do |match|
if (result = response.match(match))
check_status
return result.to_a.first
end
end
end
echo '*** No match was found after 15 seconds, dumping info'
echo "messages seen length: #{log.length}"
log.each { |message| echo "message: #{message}" }
echo "checked against #{matches}"
$FAILED_COMMAND
end
def check_status
waitrt?
return
end
def hands_empty?
return false if !GameObj.right_hand.id.nil? or !GameObj.left_hand.id.nil?
return true
end
def stow_trapped_box(box_id)
bput "_drag ##{box_id} ##{GameObj[/case/].id}", "#{$put_msg}" if $case_full == false
$case_full = true unless hands_empty?
bput "_drag ##{box_id} ##{GameObj[/satchel/].id}", "#{$put_msg}" if $case_full == true
unless hands_empty?
echo "Out of room for disarmed boxes."
return
end
end
$put_msg = /^You tuck|^You put|^Your .+ won't/
disarm_messages =[]
disarm_messages << acid_msg = "^The lock appears to be free"
disarm_messages << crystal_msg = "^Looking closely into the keyhole of the lock, you spy.*crystal"
disarm_messages << cloud_msg = "^Looking closely into the keyhole of the lock, you spy a small vial of liquid"
disarm_messages << fire_msg = "^Looking closely into the keyhole of the lock, you spy a small vial of fire-red liquid"
disarm_messages << jaws_msg = "^You notice a discolored oval ring around the outside of the"
disarm_messages << needle_msg = "^Hmmm, you can see what appears to be a tiny hole"
disarm_messages << scarab_msg = "^Peering closely into the lock, you spy a"
disarm_messages << sphere_msg = "^Examining the .*(box|strongbox|chest|trunk|coffer), you locate.*sphere held"
disarm_messages << spore_msg = "^Peering into the box's lock, you see a small tube"
disarm_messages << springs_msg = "^After carefully examining the lock, you move on to the hinges of the"
disarm_messages << plate_msg = "^You see a metal"
disarm_messages = "#{disarm_messages.join('|')}"
$disarm_msg = /^Roundtime|^You discover no|^Contortionist|^The lock appears to be free|#{disarm_messages}/
if $disarm_list.nil? or $disarm_list.empty? or $disarm_index.nil?
$disarm_list = GameObj.loot
$disarm_index = 0
end
$disarm_list.each_with_index {|box, index|
fput "disarm ##{box.id}"
sleep 1;waitrt?
result = matchtimeout(1, "#{$disarm_msg}")
if result !~ /#{$disarm_msg}/
## Moving boxes, first to cloak, then to pack, then exiting script.
## Need to move containers to variables in the future.
bput "_drag ##{box.id} ##{GameObj[/cloak/].id}", "#{$put_msg}" if $cloak_full == false
$cloak_full = true unless hands_empty?
bput "_drag ##{box.id} ##{GameObj[/pack/].id}", "#{$put_msg}" if $cloak_full == true
unless hands_empty?
echo "Out of room for boxes."
break
end
next
elsif
## Messages for traps that have been disarmed, no traps, or otherwise no disarm needed.
result =~ /^Contortionist|^The lock appears to be free|with some sort of dark paste|bent back slightly|which appears to be empty/
next
elsif result =~ /#{acid_msg}/
echo "Acid trap. Stowing."
stow_trapped_box(box.id); next
elsif result =~ /#{crystal_msg}/
echo "Crystal trap. Stowing."
stow_trapped_box(box.id); next
elsif result =~ /#{cloud_msg}/
echo "Cloud trap. Stowing."
stow_trapped_box(box.id); next
elsif result =~ /#{fire_msg}/
echo "Fire-cloud trap. Stowing."
stow_trapped_box(box.id); next
elsif result =~ /#{jaws_msg}/
echo "Jaws trap. Stowing."
stow_trapped_box(box.id); next
elsif result =~ /#{needle_msg}/
echo "Needle trap. Stowing."
stow_trapped_box(box.id); next
elsif result =~ /#{scarab_msg}/
echo "Scarab trap. Skipping!"; next
elsif result =~ /#{sphere_msg}/
echo "Sphere trap. Stowing."
stow_trapped_box(box.id); next
elsif result =~ /#{spore_msg}/
echo "Spore trap. Skipping."; next
elsif result =~ /#{springs_msg}/
echo "Springs trap. Stowing for acid."
stow_trapped_box(box.id); next
elsif result =~ /#{plate_msg}/
echo "Plate trap found! Skipping"
## Place holder for plate boxes
next
else
echo "Trap found!"
echo "Skipping!"
#$disarm_index -= 1
next
end
}
echo $disarm_index
$disarm_list = $disarm_list.drop($disarm_index + 1)
$cloak_full = false
$case_full = false