-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobals.zil
514 lines (439 loc) · 12.4 KB
/
globals.zil
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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
"GLOBALS for
Mini-Zork II: The Wizard of Frobozz
(c) Copyright 1988 Infocom, Inc. All Rights Reserved."
<DIRECTIONS NORTH EAST WEST SOUTH NE NW SE SW UP DOWN IN OUT LAND>
<OBJECT GLOBAL-OBJECTS
(FLAGS INVISIBLE TOUCHBIT SURFACEBIT TRYTAKEBIT
OPENBIT SEARCHBIT TRANSBIT ONBIT RLANDBIT
RMUNGBIT)>
<OBJECT LOCAL-GLOBALS
(IN GLOBAL-OBJECTS)
(SYNONYM ZZMGCK) ;"Yes, this synonym needs to exist... sigh">
<OBJECT ROOMS
(IN TO ROOMS)>
<OBJECT INTNUM
(IN GLOBAL-OBJECTS)
(DESC "number")
(SYNONYM INTNUM)
(FLAGS TOOLBIT)>
<OBJECT PSEUDO-OBJECT
(IN LOCAL-GLOBALS)
(DESC "pseudo")
(ACTION ME-F)>
<OBJECT IT
(IN GLOBAL-OBJECTS)
(SYNONYM IT THEM HER HIM)
(DESC "thing")
(FLAGS NDESCBIT TOUCHBIT)>
<OBJECT NOT-HERE-OBJECT
(DESC "thing")
(ACTION NOT-HERE-OBJECT-F)>
<ROUTINE NOT-HERE-OBJECT-F ("AUX" TBL (PRSO? T))
;"This COND is game independent (except the TELL)"
<COND (<AND <EQUAL? ,PRSO ,NOT-HERE-OBJECT>
<EQUAL? ,PRSI ,NOT-HERE-OBJECT>>
<TELL "Those things aren't here!" CR>
<RTRUE>)
(<EQUAL? ,PRSO ,NOT-HERE-OBJECT>
<SET TBL ,P-PRSO>)
(T
<SET TBL ,P-PRSI>
<SET PRSO? <>>)>
;"Here is the default 'cant see any' printer"
<SETG P-CONT <>>
<SETG QUOTE-FLAG <>>
<COND (<EQUAL? ,WINNER ,ADVENTURER>
<TELL "You can't see any ">
<NOT-HERE-PRINT .PRSO?>
<TELL " here!" CR>)
(T
<TELL "The " D ,WINNER " seems confused. \"I don't see any ">
<NOT-HERE-PRINT .PRSO?>
<TELL " here!\"" CR>)>
<RTRUE>>
;<ROUTINE FIND-NOT-HERE (TBL PRSO? "AUX" M-F OBJ)
;"Here is where special-case code goes. <MOBY-FIND .TBL> returns
number of matches. If 1, then P-MOBY-FOUND is it. One may treat
the 0 and >1 cases alike or different. It doesn't matter. Always
return RFALSE (not handled) if you have resolved the problem."
<SET M-F <MOBY-FIND .TBL>>
;<COND (,DEBUG
<TELL "[Moby-found " N .M-F " objects" "]" CR>)>
<COND (<AND <G? .M-F 1>
<SET OBJ <GETP <GET .TBL 1> ,P?GLOBAL>>>
<SET M-F 1>
<SETG P-MOBY-FOUND .OBJ>)>
<COND (<==? 1 .M-F>
;<COND (,DEBUG <TELL "[Namely: " D ,P-MOBY-FOUND "]" CR>)>
<COND (.PRSO? <SETG PRSO ,P-MOBY-FOUND>)
(T <SETG PRSI ,P-MOBY-FOUND>)>
<RFALSE>)
(<NOT .PRSO?>
<TELL "You wouldn't find any ">
<NOT-HERE-PRINT .PRSO?>
<TELL " there." CR>
<RTRUE>)
(T ,NOT-HERE-OBJECT)>>
;<ROUTINE GLOBAL-NOT-HERE-PRINT (OBJ)
;<COND (,P-MULT <SETG P-NOT-HERE <+ ,P-NOT-HERE 1>>)>
<SETG P-CONT <>>
<SETG QUOTE-FLAG <>>
<TELL "You can't see any">
<COND (<EQUAL? .OBJ ,PRSO> <PRSO-PRINT>)
(T <PRSI-PRINT>)>
<TELL " here." CR>>
<ROUTINE NOT-HERE-PRINT (PRSO?)
<COND (,P-OFLAG
<COND (,P-XADJ <PRINTB ,P-XADJN>)>
<COND (,P-XNAM <PRINTB ,P-XNAM>)>)
(T
<THING-PRINT .PRSO?>)>>
<OBJECT GROUND
(IN GLOBAL-OBJECTS)
(DESC "ground")
(SYNONYM GROUND DIRT FLOOR)
(ACTION GROUND-F)>
<ROUTINE GROUND-F ()
<COND (<AND <VERB? PUT PUT-ON>
<EQUAL? ,PRSI ,GROUND>>
<PERFORM ,V?DROP ,PRSO>
<RTRUE>)>>
<OBJECT WATER
(DESC "quantity of water")
(LDESC "There is some water here.")
(SYNONYM WATER LIQUID)
(SIZE 4)
(FLAGS TAKEBIT TRYTAKEBIT DRINKBIT)
(ACTION WATER-F)>
<OBJECT GLOBAL-WATER
(IN LOCAL-GLOBALS)
(DESC "water")
(SYNONYM WATER)
(FLAGS DRINKBIT)
(ACTION WATER-F)>
<ROUTINE WATER-F ("AUX" AV W PI?)
<COND (<VERB? SGIVE EAT DRINK>
<RFALSE>)
(<VERB? ENTER>
<PERFORM ,V?SWIM ,PRSO>
<RTRUE>)
(<VERB? FILL> ;"fill bottle with water =>"
<SET W ,PRSI> ;"put water in bottle"
<SETG PRSA ,V?PUT>
<SETG PRSI ,PRSO>
<SETG PRSO .W>
<SET PI? <>>)
(<EQUAL? ,PRSO ,GLOBAL-WATER ,WATER>
<SET W ,PRSO>
<SET PI? <>>)
(,PRSI
<SET W ,PRSI>
<SET PI? T>)>
<COND (<EQUAL? .W ,GLOBAL-WATER>
<SET W ,WATER>
<COND (<VERB? TAKE PUT> <REMOVE .W>)>)>
<COND (.PI? <SETG PRSI .W>)
(T <SETG PRSO .W>)>
<SET AV <LOC ,WINNER>>
<COND (<NOT <FSET? .AV ,VEHBIT>> <SET AV <>>)>
<COND (<AND <VERB? TAKE PUT> <NOT .PI?>>
<COND (<AND .AV <EQUAL? .AV ,PRSI>>
<PUDDLE .AV>)
(<AND .AV <NOT ,PRSI> <NOT <IN? .W .AV>>>
<PUDDLE .AV>)
(<AND ,PRSI <NOT <EQUAL? ,PRSI ,TEAPOT>>>
<TELL "The water leaks out of the " D ,PRSI
" and evaporates immediately." CR>
<REMOVE .W>)
(<IN? ,TEAPOT ,WINNER>
<COND (<NOT <FIRST? ,TEAPOT>>
<MOVE ,WATER ,TEAPOT>
<TELL "The teapot is now full of water." CR>)
(T
<TELL "The teapot isn't currently empty." CR>
<RTRUE>)>)
(<AND <IN? ,PRSO ,TEAPOT>
<VERB? TAKE>
<NOT ,PRSI>>
<SETG PRSO ,TEAPOT>
<ITAKE>
<SETG PRSO .W>)
(T
<TELL "The water slips through your fingers." CR>)>)
(.PI?
<TELL "Nice try." CR>)
(<VERB? DROP GIVE>
<COND (<AND <EQUAL? ,PRSO ,WATER>
<NOT <HELD? ,WATER>>>
<TELL ,YOU-DONT-HAVE "any water." CR>
<RTRUE>)>
<REMOVE ,WATER>
<COND (.AV
<PUDDLE .AV>)
(T
<TELL
"The water spills to the floor and evaporates." CR>
<REMOVE ,WATER>)>)
(<VERB? THROW>
<TELL
"The water splashes on the walls and evaporates." CR>
<REMOVE ,WATER>)>>
<ROUTINE PUDDLE (AV)
<TELL "There is now a puddle in the bottom of the " D .AV ,PERIOD-CR>
<MOVE ,PRSO .AV>>
<OBJECT GRUE
(IN GLOBAL-OBJECTS)
(DESC "lurking grue")
(SYNONYM GRUE)
(ADJECTIVE LURKING)
(TEXT
"The grue is a sinister, lurking presence in the dark places of the earth.
Its favorite diet is adventurers, but its insatiable appetite is tempered
by its fear of light.")
(ACTION GRUE-F)>
<ROUTINE GRUE-F ()
<COND (<VERB? FIND>
<TELL
"There's probably one lurking in the darkness nearby. Don't let your light
go out!" CR>)>>
<OBJECT ME
(IN GLOBAL-OBJECTS)
(DESC "brave adventurer")
(SYNONYM ME MYSELF SELF)
(FLAGS ACTORBIT)
(TEXT "Difficult, unless your eyes are prehensile.")
(ACTION ME-F)>
<ROUTINE ME-F ()
<COND (<VERB? TELL>
<SETG P-CONT <>>
<SETG QUOTE-FLAG <>>
<TELL ,TALKING-TO-YOURSELF>)
(<VERB? EAT>
<TELL "Auto-cannibalism is not the answer." CR>)
(<AND <VERB? ATTACK MUNG>
<EQUAL? ,PRSO ,ME>>
<JIGS-UP "Poof, you're dead!">)
(<VERB? TAKE>
<TELL "How romantic!" CR>)>>
<OBJECT ADVENTURER
(IN INSIDE-THE-BARROW)
(DESC "thing")
(SYNONYM ADVENTURER)
(FLAGS NDESCBIT INVISIBLE ACTORBIT)
(ACTION 0)>
<OBJECT PATH-OBJECT
(IN GLOBAL-OBJECTS)
(DESC "passage")
(SYNONYM PATH PASSAGE TUNNEL)
(ADJECTIVE DARK DAMP SMOKEY SCORCHED NARROW)
(FLAGS NDESCBIT)
(ACTION PATH-OBJECT-F)>
<ROUTINE PATH-OBJECT-F ()
<COND (<VERB? TAKE FOLLOW>
<V-WALK-AROUND>)>>
<OBJECT ZORKMID
(IN GLOBAL-OBJECTS)
(DESC "zorkmid")
(SYNONYM ZORKMID)
(ACTION ZORKMID-F)>
<ROUTINE ZORKMID-F ()
<COND (<VERB? EXAMINE>
<TELL
"The zorkmid is the unit of currency of" ,GUE-NAME ,PERIOD-CR>)>>
<OBJECT HANDS
(IN GLOBAL-OBJECTS)
(DESC "pair of hands")
(SYNONYM PAIR HANDS HAND)
(ADJECTIVE BARE)
(FLAGS NDESCBIT TOOLBIT)>
<OBJECT STREAM
(IN LOCAL-GLOBALS)
(DESC "stream")
(SYNONYM STREAM)
(ADJECTIVE COLD)
(FLAGS NDESCBIT)
(ACTION STREAM-F)>
<ROUTINE STREAM-F ()
<COND (<VERB? DRINK-FROM>
<HIT-SPOT>)
(<VERB? ENTER>
<V-SWIM>)>>
<OBJECT CHASM
(IN LOCAL-GLOBALS)
(DESC "chasm")
(SYNONYM CHASM RAVINE)
(ADJECTIVE DEEP)
(FLAGS NDESCBIT)
(ACTION CHASM-F)>
<ROUTINE CHASM-F ()
<COND (<AND <VERB? PUT>
<EQUAL? ,PRSI ,CHASM>>
<TELL "The " D ,PRSO " disappears into the chasm." CR>
<REMOVE-CAREFULLY ,PRSO>
<RTRUE>)>
<BRIDGE-F>>
<OBJECT BRIDGE
(IN LOCAL-GLOBALS)
(DESC "bridge")
(SYNONYM BRIDGE)
(ADJECTIVE STONE)
(FLAGS NDESCBIT)
(ACTION BRIDGE-F)>
<ROUTINE BRIDGE-F ()
<COND (<VERB? LEAP>
<JIGS-UP "You should have looked before you leaped.">)>>
<OBJECT WALL
(IN GLOBAL-OBJECTS)
(DESC "wall")
(SYNONYM WALL)
(ADJECTIVE EAST EASTERN WEST WESTERN SOUTH SOUTHE NORTH NORTHE)>
<ROUTINE OPEN-CLOSE (FLAG)
<COND (<NOT .FLAG>
<TELL "The door is locked." CR>)
(<VERB? OPEN>
<COND (<FSET? ,PRSO ,OPENBIT>
<TELL ,LOOK-AROUND>)
(T
<FSET ,PRSO ,OPENBIT>
<TELL "The " D ,PRSO " is now open." CR>)>)
(<FSET? ,PRSO ,OPENBIT>
<FCLEAR ,PRSO ,OPENBIT>
<TELL "The " D ,PRSO " is now closed." CR>)
(T
<TELL ,LOOK-AROUND>)>>
<ROUTINE UNLOCK-LOCK (UNLOCKED? KEY)
<COND (<VERB? UNLOCK>
<COND (.UNLOCKED?
<TELL ,ALREADY>
<RTRUE>)
(<EQUAL? ,PRSI .KEY>
<TELL "The door is now unlocked." CR>
<RTRUE>)
(<FSET? ,PRSI ,TOOLBIT>
<TELL ,DOESNT-FIT-LOCK>
<RFALSE>)
(T
<TELL <PICK-ONE ,YUKS> CR>
<RFALSE>)>)
(T
<COND (<NOT .UNLOCKED?>
<TELL ,ALREADY>
<RFALSE>)
(<EQUAL? ,PRSI .KEY>
<TELL "The door is now locked." CR>
<RFALSE>)
(<FSET? ,PRSI ,TOOLBIT>
<TELL ,DOESNT-FIT-LOCK>
<RTRUE>)
(T
<TELL <PICK-ONE ,YUKS> CR>
<RTRUE>)>)>>
<ROUTINE HELLO? (WHO)
<COND (<OR <EQUAL? ,WINNER .WHO>
<VERB? TELL SAY HELLO INCANT>>
<COND (<VERB? TELL SAY INCANT>
<SETG P-CONT <>>
<SETG QUOTE-FLAG <>>)>
<RTRUE>)>>
<ROUTINE FIND-TARGET (TARGET "AUX" P TX L ROOM)
<COND (<IN? .TARGET ,HERE> ,HERE)
(T
<SET P 0>
<REPEAT ()
<COND (<0? <SET P <NEXTP ,HERE .P>>>
<RETURN <>>)
(<NOT <L? .P ,LOW-DIRECTION>>
<SET TX <GETPT ,HERE .P>>
<SET L <PTSIZE .TX>>
<COND (<EQUAL? .L ,UEXIT ,CEXIT ,DEXIT>
<SET ROOM <GETB .TX 0>>
<COND (<IN? .TARGET .ROOM>
<RETURN .ROOM>)>)>)>>)>>
<ROUTINE NOW-DARK? ()
<SETG LIT <LIT? ,HERE>>
<COND (<NOT ,LIT>
<TELL "It is now pitch black." CR>)>
<RTRUE>>
<ROUTINE DO-WALK (DIR)
<SETG P-WALK-DIR .DIR>
<PERFORM ,V?WALK .DIR>>
<ROUTINE GLOBAL-IN? (OBJ1 OBJ2 "AUX" TX)
<COND (<SET TX <GETPT .OBJ2 ,P?GLOBAL>>
<ZMEMQB .OBJ1 .TX <- <PTSIZE .TX> 1>>)>>
<ROUTINE FIND-IN (WHERE WHAT "AUX" W)
<SET W <FIRST? .WHERE>>
<COND (<NOT .W>
<RFALSE>)>
<REPEAT ()
<COND (<AND <FSET? .W .WHAT>
<NOT <EQUAL? .W ,ADVENTURER>>>
<RETURN .W>)
(<NOT <SET W <NEXT? .W>>>
<RETURN <>>)>>>
<ROUTINE HELD? (CAN)
<REPEAT ()
<SET CAN <LOC .CAN>>
<COND (<NOT .CAN>
<RFALSE>)
(<EQUAL? .CAN ,WINNER>
<RTRUE>)>>>
<ROUTINE OTHER-SIDE (DOBJ "AUX" (P 0) TX) ;"finds room beyond given door"
<REPEAT ()
<COND (<L? <SET P <NEXTP ,HERE .P>> ,LOW-DIRECTION>
<RETURN <>>)
(T
<SET TX <GETPT ,HERE .P>>
<COND (<AND <EQUAL? <PTSIZE .TX> ,DEXIT>
<EQUAL? <GETB .TX ,DEXITOBJ> .DOBJ>>
<RETURN .P>)>)>>>
<ROUTINE HACK-HACK (STR)
<TELL .STR D ,PRSO <PICK-ONE ,HO-HUM> ,PERIOD-CR>>
<GLOBAL HO-HUM
<LTABLE
0
" doesn't seem to work"
" isn't notably helpful"
" has no effect">>
<GLOBAL YUKS
<LTABLE
0
"A valiant attempt."
"You can't be serious."
"Not bloody likely."
"An interesting idea..."
"What a concept!">>
<GLOBAL RIDDLE-TEXT
"What's tall as a house,|
round as a cup,|
and all the king's horses|
can't draw it up?\"|">
<GLOBAL PERIOD-CR ".|">
<GLOBAL DEMON-GONE "The demon is gone for a moment. ">
<GLOBAL STRANGE-VISION
"As you peer into the sphere, a strange vision takes shape">
<GLOBAL LOOK-AROUND "Look around you.|">
<GLOBAL TOO-DARK "It's too dark to see.">
<GLOBAL ONLY-DARKNESS "You see only darkness.|">
<GLOBAL ALREADY "It already is!|">
<GLOBAL WAND-STOPS-GLOWING
"The wand stops glowing, but there is no other apparent effect.|">
<GLOBAL CANT-GO "You can't go that way.|">
<GLOBAL PLACE-MAT-VISIBLE "The edge of a place mat is visible under the door.">
<GLOBAL DOESNT-FIT-LOCK "It doesn't fit the lock.|">
<GLOBAL GUE-NAME " the Great Underground Empire">
<GLOBAL REFERRING "It's not clear what you're referring to.|">
<GLOBAL STOPS " comes to a stop.||">
<GLOBAL B-W-C "\"Buzz, whirr, click!">
<GLOBAL WAVES-WAND "The Wizard waves his wand ">
<GLOBAL INVISIBLE-HAND
", almost as though an invisible hand had tipped it over.|">
<GLOBAL GREEDILY-DEVOURS "The guardian greedily devours ">
<GLOBAL NOTHING-HAPPENS "Nothing happens.|">
<GLOBAL TALKING-TO-YOURSELF
"Talking to yourself is a sign of impending mental collapse.|">
<GLOBAL NOUN-MISSING "There seems to be a noun missing in that sentence!|">
<GLOBAL THERE-IS-NOTHING "There is nothing ">
<GLOBAL STEEL-CAGE-FALLS " the sphere, a solid steel cage falls ">
<GLOBAL YOU-DONT-HAVE "You don't have ">
<GLOBAL PROVIDING-LIGHT " (providing light)">
<GLOBAL IS-CLOSED " is closed.|">