-
Notifications
You must be signed in to change notification settings - Fork 3
/
findraffle.lic
182 lines (165 loc) · 5.63 KB
/
findraffle.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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
=begin
Moves around searching for a warcamp, derived from Tillmen's wander script and inspired by Casis' warcampfind script.
Unlike warcampfind, findwarcamp will try to stay local to a disturbance and only ventures to 'cold' rooms if it can't
find any warm ones. Thus, for maximal effectiveness, it is best to manually use Sigil of Location every 20-30 rooms
in your search area until you find interference and only then activate findwarcamp.
author: LostRanger ([email protected])
game: Gemstone
tags: movement
version: 0.1
changelog:
0.1 (2017-05-21) derived from Wander 0.6 (2015-04-11):
initial release
=end
CharSettings['boundary'] ||= Set.new
def check_room_for_warcamp
return :HOT if GameObj.loot.find{|item| item.name == 'shimmering path' or item.name == 'shimmering patch of air' }
waitrt?
fput 'sigil of location'
line = waitfor 'Roundtime', 'interference with your sigil coming from', 'shimmering pat'
return :HOT if line =~ /shimmering/
return :COLD if line =~ /Roundtime/
:WARM
end
if script.vars[1] =~ /help/i
output = "\n"
output.concat ";findwarcamp add adds the current room to the boundary list\n"
output.concat ";findwarcamp add <room id> adds the given room id to the boundary list\n"
output.concat ";findwarcamp rem deletes the current room to the boundary list\n"
output.concat ";findwarcamp rem <room id> deletes the given room id to the boundary list\n"
output.concat ";findwarcamp clear clears the boundary list\n"
output.concat ";findwarcamp list shows saved boundaries\n"
output.concat ";findwarcamp start searching for a warcamps\n"
output.concat "\n"
respond output
elsif script.vars[1] =~ /^add$|^set$/i
if script.vars[2]
for var in script.vars[2..-1]
if var =~ /^[0-9]+$/
CharSettings['boundary'].add(var)
echo "room #{var} has been added to the boundary list"
else
echo "ignoring #{var}: not a room id"
end
end
elsif room = Room.current
CharSettings['boundary'].add(room.id.to_s)
echo "this room (#{room.id}) has been added to the boundary list"
else
echo 'error: current room is unknown'
end
elsif script.vars[1] =~ /^del(?:ete)?$|^rem(?:ove)?$/i
if script.vars[2]
for var in script.vars[2..-1]
if var =~ /^[0-9]+$/
if CharSettings['boundary'].delete(var)
echo "room #{var} has been removed from the boundary list"
else
echo "room #{var} was not found in the boundary list"
end
else
echo "ignoring #{var}: not a room id"
end
end
elsif room = Room.current
if CharSettings['boundary'].delete(room.id.to_s)
echo "this room (#{room.id}) has been removed from the boundary list"
else
echo "this room (#{room.id}) was not found in the boundary list"
end
else
echo 'current room is unknown'
end
elsif script.vars[1] =~ /^list$/i
output = "\n"
if CharSettings['boundary'].empty?
output.concat " boundaries: none\n"
else
output.concat " boundaries:\n"
for boundary in CharSettings['boundary']
output.concat " #{boundary.to_s.rjust(5)} #{Room[boundary].title.first}\n"
end
end
respond output
elsif script.vars[1] =~ /^clear$/i
CharSettings['boundary'] = Set.new
respond 'done'
elsif script.vars.empty?
temp = nil
searched = Set.new
warm_frontier = Set.new
cold_frontier = Set.new
room = nil
while temp != :HOT
last_temp = temp
previous = room
room = Room.current
# Add to searched, remove from frontiers
searched.add(room.id)
warm_frontier.delete(room.id)
cold_frontier.delete(room.id)
# Check temperature
temp = check_room_for_warcamp
if temp == :HOT
echo "Warcamp found! Room #{Room.current.id}"
exit
end
echo "Current room is #{temp.to_s} -- Searched: #{searched.length} -- Warm: #{warm_frontier.length} -- Cold: #{cold_frontier.length}"
waitrt?
# Iterate over exits and add them to frontiers as appropriate. Also mark as candidates for next movement
candidates = {}
room.wayto.each{|dest, dir|
idest = dest.to_i
next if CharSettings['boundary'].include?(idest) # Skip boundary rooms
next if searched.include?(idest) # Skip already-searched rooms
next if warm_frontier.include?(idest) # Skip already-warm-frontier room.
candidates[dest] = dir
if temp == :COLD
cold_frontier.add(idest)
else
cold_frontier.delete(idest)
warm_frontier.add(idest)
end
}
# Movement logic:
# If we're warm, favor candidates. If we're cold, do this only if the warm frontier is empty.
command = nil
unless candidates.empty?
if temp == :WARM or warm_frontier.empty?
here = room.id.to_s
candidates.each{|dest, dir|
# Prefer direcitons that do not involve procs first.
if dir.is_a?(String)
command = dir
# Break if it's fully backtrackable, too, since there's no better option.
break if Room[dest].wayto[here].is_a?(String)
elsif command == nil # No command set, so begrudgingly take a stringproc
command = dir
end
}
end
end
# If both frontiers are empty, give up.
if cold_frontier.empty? and warm_frontier.empty?
echo 'Exhausted search area, giving up.'
return
end
if command
# If we have a moment command, execute it and go to the next iteration of the loop
if command.is_a?(String)
move command
else
command.call
end
wait_until { Room.current.id != room.id }
next
end
# If we're still here, there was no reasonable direct movement.
# Find the nearest frontier room and go2 it.
target = room.find_nearest(((warm_frontier.empty? and cold_frontier) or warm_frontier))
i_stand_alone
start_script 'go2', [target.to_s]
wait_until { Room.current.id == target }
i_stand_alone
end
end