-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaze.cmd
More file actions
450 lines (375 loc) · 13.3 KB
/
maze.cmd
File metadata and controls
450 lines (375 loc) · 13.3 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# useful variables: $roomid, $roomexits, $roomobjs
#
# Korya's Duskruin Maze Do-er Version 1.2
#
# Updated by Saragos
# Added a command line option for incidentals only - .maze inc
# Added a look at the beginning to make sure the first exits are set.
# Script will also now start searching rooms again if it thinks it's exhausted all of the rooms.
# Fixed broken timer logic. If the script is restarted, it should also now recognize that it's continuing a run and keep the existing timer.
# Fixed pet noun (sack to crate).
# Added missing text for having already searched a room.
# Search counting will now only decrement if you actually find something.
# Script will now report anything it finds to the log window, not just a pet.
# At the 5 minutes remaining warning, script will now just search for incidentals.
# Added up/down movement options for testing purposes and just in case it's ever needed.
#
# Usage: Open the Automapper window before entering the maze.
# Click New Map, Record, and Allow Duplicate Labels
# Have dueling slip/rat token in your hand.
# Run the script, follow instructions if outside the maze
#
######################## USER VARIABLES ##############################
var PACK duffel bag
## ** IMPORTANT! Set PACK properly! **
var MAZE_LIMIT 100
var PET 1
var INCIDENTAL 0
## Set PET to 0 to test mapping without waiting for pigs/rats/etc ##
## Set INCIDENTAL to 1 to just go ham grabbing stuff instead ##
#debug 10
var DEBUG 0
# Level 1 = List the room ID that the script's "Automapper to the last unexplored branch" routine tried to go to
# Level 2 = List all the found rooms and exits that are left
# Level 3 = SLOW mode, prompts for input before moving
############################# SETUP ##################################
#action put #echo >Log yellow Map reset!; math RESET add 1; goto START when (no longer certain of your directions\!$|^Shaking off the momentary surprise|scurries off before you can catch it\!$)
#action math RESET add 1 when ^Shaking off the momentary surprise
#action math RESET add 1 when longer certain of your directions\!$
#action math RESET add 1 when scurries off before you can catch it\!$
action put #echo >Log yellow Map reset!; math RESET add 1; goto START when (no longer certain of your directions\!$|^Shaking off the momentary surprise)
action put #echo >Log yellow WARNING! 5 minutes left!; var INCIDENTAL 1; VAR PET 0; goto START when ^You only have about 5 minutes left in the labyrinth\!
action var WARNING 1 when ^You only have about 5 minutes
action put #echo >Log Found $1! when ^You search around and find (.*)!
action var FOUND 1 when claiming your new pet\.$
action var NEWEXITS $1 when ^(Obvious exits.*)
action var NEWEXITS $1 when ^(Obvious paths.*)
var waitstring ^\.\.\.wait|^Sorry\, you may only type ahead|^You are still stunned|^You can\'t do that while|^You don\'t seem to be able|Between the ringing in your head|Strangely, you don't feel like fighting right now\.|Your desire to prepare this offensive spell suddenly slips away\.
var DIR northwest|north|northeast|east|southeast|south|southwest|west|up|down
var PREV_DIR southeast|south|southwest|west|northwest|north|northeast|east|down|up
var PATTER run|go|canter|cartwheel|dance|drift|duck|glide|hobble|hop|jog|limp|lope|lurch|lumber|march|meander|mosey|pad|parade|patter|plod|prance|ramble|rove|run|rush|sashay|saunter|scamper|scramble|shamble|shuffle|skip|slink|slog|slouch|sprint|stagger|stomp|stride|stroll|strut|stumble|swagger|traipse|tramp|tread|trek|troop|trot|trudge|walk|wander
if_1 then
{
if (matchre("%1", "inc")) then var INCIDENTAL 1
}
var SEARCHCOUNT 10
var TOTAL 0
var RESET 0
var WARNING 0
var FOUND 0
if ("$roomname" = "Duskruin, Darkened Antechamber") then
{
put #echo
put #echo aqua Go portcullis to start!
put #echo aqua IMPORTANT! Make sure automapper is open, RECORD (red circle) and ALLOW DUPLICATE NODES (green and black box) are pressed!
put #echo
waitforre ^The guard finally stops and says
}
if ("$roomname" = "Duskruin, Underground Labyrinth") then
{
var timetest $gametime
math timetest subtract $mazestart
echo timetest: %timetest
if (%timetest < 3600) then
{
put #echo >Log aqua Restarting the maze!
}
else
{
put #var mazestart $gametime
put #echo >Log aqua Starting the maze!
}
}
else
{
put #var mazestart $gametime
put #echo >Log aqua Starting the maze!
}
START:
gosub NEW_MAP
var MOVE 0
var FULLPATH 0
var CHECKED 0
var COMPLETED 0
var LAST_DIR 0
if matchre ("$righthand","slip|token") then gosub ACTION stow r
if matchre ("$lefthand","slip|token") then gosub ACTION stow l
gosub ACTION look
pause 1
# does this block only have to happen if roomid = 0?
if ($roomid = 0) then
{
eval EXITS replacere("%NEWEXITS","\, ","|")
eval EXITS replacere("%EXITS","(^Obvious (exits|paths)\: |\.)","")
echo exits: %EXITS
var ROOM_$roomid %EXITS
gosub CHOOSE_PATH
if %DEBUG > 2 then gosub SLOW
gosub ACTION %NEXT_DIR
var LAST_DIR 0
}
########################### MAIN LOOP ################################
NEW_ROOM:
gosub clear
if matchre ("$roomname","Duskruin, Darkened Antechamber") then goto END_SEARCH
#if %WARNING != 0 then gosub CHECK_TIMER
eval EXITS replacere("%NEWEXITS","\, ","|")
eval EXITS replacere("%EXITS","(^Obvious (exits|paths)\: |\.)","")
## see if this is a new room! ##
if $roomid > %MOVE then
{
var ROOM_$roomid %EXITS|none
var CHECKED %CHECKED|$roomid
math TOTAL add 1
math MOVE add 1
gosub SEARCHLOGIC
}
if %MOVE = %MAZE_LIMIT then goto END
if !matchre ("%ROOM_$roomid","COMPLETED") then
{
eval ROOM_$roomid replacere("%ROOM_$roomid","(\|\b%LAST_DIR\b|\b%LAST_DIR\b\||\b%LAST_DIR\b|)","")
}
gosub CHECK_COMPLETE_ROOM
if matchre ("%ROOM_$roomid","COMPLETED") then goto PREV_BRANCH
goto CONTINUE_ROOM
CONTINUE_ROOM:
gosub CHOOSE_PATH
if %LAST_DIR = 1 then goto PREV_BRANCH
gosub ACTION %NEXT_DIR
## pause for the mapper to add the new node if necessary ##
pause 0.05
var FULLPATH %FULLPATH|%LAST_DIR
if %DEBUG > 0 then put #echo To return: %FULLPATH
## With the script updates, this shouldn't proc at all! ##
if $roomid <= %MOVE then put #echo yellow Been here before!
if %DEBUG > 1 then gosub LIST_ROOMS
if %DEBUG > 2 then gosub SLOW
goto NEW_ROOM
########################## PATHFINDING ###############################
PREV_BRANCH:
if %MOVE = 1 then goto CONTINUE_ROOM
var LAST_DIR 0
gosub FIND_LAST_ROOM
if %LIST = 0 then goto START
var GOING %LIST
gosub MAPPER
if %DEBUG > 0 then put #echo yellow Automapper to %GOING
if %DEBUG > 1 then gosub LIST_ROOMS
if %DEBUG > 2 then gosub SLOW
goto NEW_ROOM
FIND_LAST_ROOM:
var LIST %MOVE
FIND_LAST_ROOM_LOOP:
if !matchre ("%ROOM_%LIST","COMPLETED") then return
math LIST subtract 1
if %LIST = 0 then
{
goto ERROR_NOWHERE_LEFT
}
goto FIND_LAST_ROOM_LOOP
CHOOSE_PATH:
var PATH 0
goto FIND_PATH
NEXT_PATH:
math PATH add 1
if %PATH = 10 then
{
if %LAST_DIR = 0 then
{
var LAST_DIR 1
return
}
var LAST_DIR 0
var PATH 0
}
FIND_PATH:
eval NEXT_DIR element("%DIR","%PATH")
if !matchre ("%ROOM_$roomid","\b%NEXT_DIR\b") then goto NEXT_PATH
if %LAST_DIR = %NEXT_DIR then goto NEXT_PATH
eval LAST_DIR element("%PREV_DIR","%PATH")
eval ROOM_$roomid replacere("%ROOM_$roomid","(\|\b%NEXT_DIR\b|\b%NEXT_DIR\b\||\b%NEXT_DIR\b|)","")
gosub CHECK_COMPLETE_ROOM
return
CHECK_COMPLETE_ROOM:
if %ROOM_$roomid = none then
{
var ROOM_$roomid %EXITS|COMPLETED
var COMPLETED %COMPLETED|$roomid
}
return
NEW_MAP:
put #mapper clear
put #var roomid 0
put #mapper record true
#put #mapper allowdupes true
var LIST %MAZE_LIMIT
ROOM_RESET:
var ROOM_%LIST
if %LIST = 0 then return
math LIST subtract 1
goto ROOM_RESET
########################### DEBUGGING ################################
SLOW:
put #link Continue? #parse BOOP
waitforre ^BOOP
return
LIST_ROOMS:
var LIST 1
LIST_ROOMS_LOOP:
put #echo Room %LIST exits left: %ROOM_%LIST
math LIST add 1
if %LIST > %MOVE then return
goto LIST_ROOMS_LOOP
############################ ACTIONS #################################
SEARCHLOGIC:
action instant goto END_SEARCH when ^\[Duskruin\, Darkened Antechamber\]
if %INCIDENTAL = 1 then goto DO_SEARCH
if %PET = 0 then return
put #echo Waiting for a critter to show...
put #echo
matchre DO_SEARCH scurrying around the area\.$
matchre RETURN ^A small .* scurries (%DIR)\!$
matchwait
DO_SEARCH:
gosub SEARCH
if (%PET = 1) then
{
if matchre ("$righthand|$lefthand","crate") then
{
var PET 0
var INCIDENTAL 1
}
}
if !matchre ("$righthand","Empty") then gosub ACTION put my $righthandnoun in my %PACK
if !matchre ("$lefthand","Empty") then gosub ACTION put my $lefthandnoun in my %PACK
if %SEARCHCOUNT = 0 then goto END
return
SEARCHP:
put #echo >Log SearchP
pause
SEARCH:
put #echo >Log Searching...
matchre SEARCHP ^\.\.\.wait|^Sorry\,|^You are still stunned|^You are so overburdened|^You are already
match SEARCHNOPUPPY You search around the area and find a small puppy, but it scurries off before you can catch it!
matchre SEARCHRETURN You search around and find (.*)!
matchre PET_FOUND ^You search around the area and find (.*)! The (?:.*) scampers toward you and nuzzles your foot, quickly deciding you're its new owner. As you reach for the puppy, it scrambles into a wooden crate with (.*), which is its home. You pick them both up, claiming your new pet\.$
match RETURN You've recently searched this area, try again in a bit or try somewhere else.
put search
matchwait
SEARCHNOPUPPY:
#put #echo >Log SearchNoPuppy
math SEARCHCOUNT subtract 1
put #echo >Log No puppy found. %SEARCHCOUNT searches left!
return
SEARCHRETURN:
#put #echo >Log SearchReturn
math SEARCHCOUNT subtract 1
put #echo >Log %SEARCHCOUNT searches left!
return
PET_FOUND:
#put #echo >Log PetFound
math SEARCHCOUNT subtract 1
put #flash
put #echo
put #echo
put #echo lime Found a pet!
put #echo
put #echo
put #echo >Log yellow Pet found ($1) in room $roomid! -- Total moves: %TOTAL -- Maze resets: %RESET
put #echo >Log %SEARCHCOUNT searches left!
gosub TIME
var PET 0
var INCIDENTAL 1
gosub ACTION stow crate
return
ACTION:
var ACTION $0
DO_ACTION:
pause 0.1
put %ACTION
matchre DO_ACTION ^\.\.\.wait|^Sorry\,|^You are still stunned|^You are so overburdened|^You are already
matchre RETURN ^You (%PATTER|stand|put|search around and find)|^\[Duskruin|Obvious|You've recently searched this area, try again in a bit or try somewhere else\.
matchre ADJUST_EXITS ^You can't go there
matchre PET_FOUND claiming your new pet\.$
matchre STAND ^You can't do that while lying
matchwait
ADJUST_EXITS:
gosub ACTION look
eval EXITS replacere("%NEWEXITS","\, ","|")
eval EXITS replacere("%EXITS","(^Obvious (exits|paths)\: |\.)","")
goto CONTINUE_ROOM
STAND:
var BACKUP %ACTION
gosub ACTION stand
var ACTION %BACKUP
goto DO_ACTION
MAPPER:
pause 0.1
put #goto %GOING
matchre MAPPER ^\.\.\.wait|^Sorry\,|^You are still stunned
matchre RETURN ^YOU HAVE ARRIVED
matchwait
RETURN:
return
########################### END RESULTS ###############################
CHECK_TIMER:
if (%WARNING = 1) then
{
var INCIDENTAL 1
var PET 0
goto START
}
return
TIME:
var timetest $gametime
math timetest subtract $mazestart
var TIME %timetest
math TIME divide 60
if matchre ("%TIME","^\d\.") then var TIME 0%TIME
eval TIME replacere ("%TIME","((?<=\d\d\.\d\d).*)","")
pause 0.05
put #echo >Log Minutes spent in maze: %TIME
return
END_SEARCH:
eval COMPLETED replacere ("%COMPLETED","^0\|","")
put #flash
put #echo
put #echo lime Grabbed some junk!
put #echo
put #echo aqua Rooms fully exhausted: %COMPLETED
if %FOUND = 1 then put #echo >Log lime Found a pet! Total moves: %TOTAL -- Maze resets: %RESET
else put #echo >Log yellow Did not find pet! Total moves: %TOTAL -- Maze resets: %RESET
gosub TIME
exit
END:
eval COMPLETED replacere ("%COMPLETED","^0\|","")
put #flash
put #echo
put #echo lime Whoops! There's nowhere else to go!
put #echo
put #echo aqua Rooms fully exhausted: %COMPLETED
if %FOUND = 1 then put #echo >Log lime Found a pet! Total moves: %TOTAL -- Maze resets: %RESET
else put #echo >Log yellow Did not find pet! Total moves: %TOTAL -- Maze resets: %RESET
gosub TIME
exit
ERROR:
eval COMPLETED replacere ("%COMPLETED","^0\|","")
put #flash
put #echo
put #echo red No exits left?
put #echo
put #echo aqua Rooms fully exhausted: %COMPLETED
put #echo yellow Total moves: %TOTAL -- Maze resets: %RESET
gosub TIME
math RESET add 1
goto START
ERROR_NOWHERE_LEFT:
eval COMPLETED replacere ("%COMPLETED","^0\|","")
put #flash
put #echo
put #echo red Everything has been explored?
put #echo
#put #echo aqua Rooms fully exhausted: %COMPLETED
#put #echo yellow Total moves: %TOTAL -- Maze resets: %RESET
put #echo >Log Explored all rooms with nothing found. Searching again until map resets.
goto START