]> code.delx.au - gnu-emacs/blob - lisp/play/dunnet.el
8aba50b8dc513bfe6d24b4dc967605fd33b43cb9
[gnu-emacs] / lisp / play / dunnet.el
1 ;;; dunnet.el --- text adventure for Emacs
2
3 ;; Copyright (C) 1992-1993, 2001-2015 Free Software Foundation, Inc.
4
5 ;; Author: Ron Schnell <ronnie@driver-aces.com>
6 ;; Created: 25 Jul 1992
7 ;; Version: 2.02
8 ;; Keywords: games
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25 ;;; Commentary:
26
27 ;; This game can be run in batch mode. To do this, use:
28 ;; emacs -batch -l dunnet
29
30 ;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31 ;;; The log file should be set for your system, and it must
32 ;;; be writable by all.
33
34 ;;; Code:
35
36 (defgroup dunnet nil
37 "Text adventure for Emacs."
38 :prefix "dun-"
39 :group 'games)
40
41 (defcustom dun-log-file "/usr/local/dunnet.score"
42 "Name of file to store score information for dunnet."
43 :type 'file
44 :group 'dunnet)
45
46 ;;;; Mode definitions for interactive mode
47
48 (define-derived-mode dun-mode text-mode "Dungeon"
49 "Major mode for running dunnet."
50 (make-local-variable 'scroll-step)
51 (setq scroll-step 2))
52
53 (defun dun-parse (arg)
54 "Function called when return is pressed in interactive mode to parse line."
55 (interactive "*p")
56 (beginning-of-line)
57 (let ((beg (1+ (point)))
58 line)
59 (end-of-line)
60 (if (and (not (= beg (point))) (not (< (point) beg))
61 (string= ">" (buffer-substring (- beg 1) beg)))
62 (progn
63 (setq line (downcase (buffer-substring beg (point))))
64 (princ line)
65 (if (eq (dun-vparse dun-ignore dun-verblist line) -1)
66 (dun-mprinc "I don't understand that.\n")))
67 (goto-char (point-max))
68 (dun-mprinc "\n")))
69 (dun-messages))
70
71 (defun dun-messages ()
72 (if dun-dead
73 (text-mode)
74 (if (eq dungeon-mode 'dungeon)
75 (progn
76 (if (not (= room dun-current-room))
77 (progn
78 (dun-describe-room dun-current-room)
79 (setq room dun-current-room)))
80 (dun-fix-screen)
81 (dun-mprinc ">")))))
82
83 \f
84 ;;;###autoload
85 (defun dunnet ()
86 "Switch to *dungeon* buffer and start game."
87 (interactive)
88 (switch-to-buffer "*dungeon*")
89 (dun-mode)
90 (setq dun-dead nil)
91 (setq room 0)
92 (dun-messages))
93
94 ;;;;
95 ;;;; This section contains all of the verbs and commands.
96 ;;;;
97
98 ;;; Give long description of room if haven't been there yet. Otherwise
99 ;;; short. Also give long if we were called with negative room number.
100
101 (defun dun-describe-room (room)
102 (if (and (not (member (abs room) dun-light-rooms))
103 (not (member obj-lamp dun-inventory))
104 (not (member obj-lamp (nth dun-current-room dun-room-objects))))
105 (dun-mprincl "It is pitch dark. You are likely to be eaten by a grue.")
106 (dun-mprincl (cadr (nth (abs room) dun-rooms)))
107 (if (and (and (or (member room dun-visited)
108 (string= dun-mode "dun-superb")) (> room 0))
109 (not (string= dun-mode "long")))
110 nil
111 (dun-mprinc (car (nth (abs room) dun-rooms)))
112 (dun-mprinc "\n"))
113 (if (not (string= dun-mode "long"))
114 (if (not (member (abs room) dun-visited))
115 (setq dun-visited (append (list (abs room)) dun-visited))))
116 (dolist (xobjs (nth dun-current-room dun-room-objects))
117 (if (= xobjs obj-special)
118 (dun-special-object)
119 (if (>= xobjs 0)
120 (dun-mprincl (car (nth xobjs dun-objects)))
121 (if (not (and (= xobjs obj-bus) dun-inbus))
122 (progn
123 (dun-mprincl (car (nth (abs xobjs) dun-perm-objects)))))))
124 (if (and (= xobjs obj-jar) dun-jar)
125 (progn
126 (dun-mprincl "The jar contains:")
127 (dolist (x dun-jar)
128 (dun-mprinc " ")
129 (dun-mprincl (car (nth x dun-objects)))))))
130 (if (and (member obj-bus (nth dun-current-room dun-room-objects)) dun-inbus)
131 (dun-mprincl "You are on the bus."))))
132
133 ;;; There is a special object in the room. This object's description,
134 ;;; or lack thereof, depends on certain conditions.
135
136 (defun dun-special-object ()
137 (if (= dun-current-room computer-room)
138 (if dun-computer
139 (dun-mprincl
140 "The panel lights are flashing in a seemingly organized pattern.")
141 (dun-mprincl "The panel lights are steady and motionless.")))
142
143 (if (and (= dun-current-room red-room)
144 (not (member obj-towel (nth red-room dun-room-objects))))
145 (dun-mprincl "There is a hole in the floor here."))
146
147 (if (and (= dun-current-room marine-life-area) dun-black)
148 (dun-mprincl
149 "The room is lit by a black light, causing the fish, and some of
150 your objects, to give off an eerie glow."))
151 (if (and (= dun-current-room fourth-vermont-intersection) dun-hole)
152 (progn
153 (if (not dun-inbus)
154 (progn
155 (dun-mprincl"You fall into a hole in the ground.")
156 (setq dun-current-room vermont-station)
157 (dun-describe-room vermont-station))
158 (progn
159 (dun-mprincl
160 "The bus falls down a hole in the ground and explodes.")
161 (dun-die "burning")))))
162
163 (if (> dun-current-room endgame-computer-room)
164 (progn
165 (if (not dun-correct-answer)
166 (dun-endgame-question)
167 (dun-mprincl "Your question is:")
168 (dun-mprincl dun-endgame-question))))
169
170 (if (= dun-current-room sauna)
171 (progn
172 (dun-mprincl (nth dun-sauna-level '(
173 "It is normal room temperature in here."
174 "It is luke warm in here."
175 "It is comfortably hot in here."
176 "It is refreshingly hot in here."
177 "You are dead now.")))
178 (if (= dun-sauna-level 3)
179 (progn
180 (if (or (member obj-rms dun-inventory)
181 (member obj-rms (nth dun-current-room dun-room-objects)))
182 (progn
183 (dun-mprincl
184 "You notice the wax on your statuette beginning to melt, until it completely
185 melts off. You are left with a beautiful diamond!")
186 (if (member obj-rms dun-inventory)
187 (progn
188 (dun-remove-obj-from-inven obj-rms)
189 (setq dun-inventory (append dun-inventory
190 (list obj-diamond))))
191 (dun-remove-obj-from-room dun-current-room obj-rms)
192 (dun-replace dun-room-objects dun-current-room
193 (append (nth dun-current-room dun-room-objects)
194 (list obj-diamond))))))
195 (if (or (member obj-floppy dun-inventory)
196 (member obj-floppy (nth dun-current-room dun-room-objects)))
197 (progn
198 (dun-mprincl
199 "You notice your floppy disk beginning to melt. As you grab for it, the
200 disk bursts into flames, and disintegrates.")
201 (dun-remove-obj-from-inven obj-floppy)
202 (dun-remove-obj-from-room dun-current-room obj-floppy))))))))
203
204
205 (defun dun-die (murderer)
206 (dun-mprinc "\n")
207 (if murderer
208 (dun-mprincl "You are dead."))
209 (dun-do-logfile 'dun-die murderer)
210 (dun-score nil)
211 (setq dun-dead t))
212
213 (defun dun-quit (args)
214 (dun-die nil))
215
216 ;;; Print every object in player's inventory. Special case for the jar,
217 ;;; as we must also print what is in it.
218
219 (defun dun-inven (args)
220 (dun-mprinc "You currently have:")
221 (dun-mprinc "\n")
222 (dolist (curobj dun-inventory)
223 (if curobj
224 (progn
225 (dun-mprincl (cadr (nth curobj dun-objects)))
226 (if (and (= curobj obj-jar) dun-jar)
227 (progn
228 (dun-mprincl "The jar contains:")
229 (dolist (x dun-jar)
230 (dun-mprinc " ")
231 (dun-mprincl (cadr (nth x dun-objects))))))))))
232
233 (defun dun-shake (obj)
234 (let (objnum)
235 (when (setq objnum (dun-objnum-from-args-std obj))
236 (if (member objnum dun-inventory)
237 (progn
238 ;;; If shaking anything will do anything, put here.
239 (dun-mprinc "Shaking ")
240 (dun-mprinc (downcase (cadr (nth objnum dun-objects))))
241 (dun-mprinc " seems to have no effect.")
242 (dun-mprinc "\n")
243 )
244 (if (and (not (member objnum (nth dun-current-room dun-room-silents)))
245 (not (member objnum (nth dun-current-room dun-room-objects))))
246 (dun-mprincl "I don't see that here.")
247 ;;; Shaking trees can be deadly
248 (if (= objnum obj-tree)
249 (progn
250 (dun-mprinc
251 "You begin to shake a tree, and notice a coconut begin to fall from the air.
252 As you try to get your hand up to block it, you feel the impact as it lands
253 on your head.")
254 (dun-die "a coconut"))
255 (if (= objnum obj-bear)
256 (progn
257 (dun-mprinc
258 "As you go up to the bear, it removes your head and places it on the ground.")
259 (dun-die "a bear"))
260 (if (< objnum 0)
261 (dun-mprincl "You cannot shake that.")
262 (dun-mprincl "You don't have that.")))))))))
263
264
265 (defun dun-drop (obj)
266 (if dun-inbus
267 (dun-mprincl "You can't drop anything while on the bus.")
268 (let (objnum ptr)
269 (when (setq objnum (dun-objnum-from-args-std obj))
270 (if (not (setq ptr (member objnum dun-inventory)))
271 (dun-mprincl "You don't have that.")
272 (progn
273 (dun-remove-obj-from-inven objnum)
274 (dun-replace dun-room-objects dun-current-room
275 (append (nth dun-current-room dun-room-objects)
276 (list objnum)))
277 (dun-mprincl "Done.")
278 (if (member objnum (list obj-food obj-weight obj-jar))
279 (dun-drop-check objnum))))))))
280
281 ;;; Dropping certain things causes things to happen.
282
283 (defun dun-drop-check (objnum)
284 (if (and (= objnum obj-food) (= room bear-hangout)
285 (member obj-bear (nth bear-hangout dun-room-objects)))
286 (progn
287 (dun-mprincl
288 "The bear takes the food and runs away with it. He left something behind.")
289 (dun-remove-obj-from-room dun-current-room obj-bear)
290 (dun-remove-obj-from-room dun-current-room obj-food)
291 (dun-replace dun-room-objects dun-current-room
292 (append (nth dun-current-room dun-room-objects)
293 (list obj-key)))))
294
295 (if (and (= objnum obj-jar) (member obj-nitric dun-jar)
296 (member obj-glycerine dun-jar))
297 (progn
298 (dun-mprincl
299 "As the jar impacts the ground it explodes into many pieces.")
300 (setq dun-jar nil)
301 (dun-remove-obj-from-room dun-current-room obj-jar)
302 (if (= dun-current-room fourth-vermont-intersection)
303 (progn
304 (setq dun-hole t)
305 (setq dun-current-room vermont-station)
306 (dun-mprincl
307 "The explosion causes a hole to open up in the ground, which you fall
308 through.")))))
309
310 (if (and (= objnum obj-weight) (= dun-current-room maze-button-room))
311 (dun-mprincl "A passageway opens.")))
312
313 ;;; Give long description of current room, or an object.
314
315 (defun dun-examine (obj)
316 (let (objnum)
317 (setq objnum (dun-objnum-from-args obj))
318 (if (eq objnum obj-special)
319 (dun-describe-room (* dun-current-room -1))
320 (if (and (eq objnum obj-computer)
321 (member obj-pc (nth dun-current-room dun-room-silents)))
322 (dun-examine '("pc"))
323 (if (eq objnum nil)
324 (dun-mprincl "I don't know what that is.")
325 (if (and (not (member objnum
326 (nth dun-current-room dun-room-objects)))
327 (not (and (member obj-jar dun-inventory)
328 (member objnum dun-jar)))
329 (not (member objnum
330 (nth dun-current-room dun-room-silents)))
331 (not (member objnum dun-inventory)))
332 (dun-mprincl "I don't see that here.")
333 (if (>= objnum 0)
334 (if (and (= objnum obj-bone)
335 (= dun-current-room marine-life-area) dun-black)
336 (dun-mprincl
337 "In this light you can see some writing on the bone. It says:
338 For an explosive time, go to Fourth St. and Vermont.")
339 (if (nth objnum dun-physobj-desc)
340 (dun-mprincl (nth objnum dun-physobj-desc))
341 (dun-mprincl "I see nothing special about that.")))
342 (if (nth (abs objnum) dun-permobj-desc)
343 (progn
344 (dun-mprincl (nth (abs objnum) dun-permobj-desc)))
345 (dun-mprincl "I see nothing special about that.")))))))))
346
347 (defun dun-take (obj)
348 (setq obj (dun-firstword obj))
349 (if (not obj)
350 (dun-mprincl "You must supply an object.")
351 (if (string= obj "all")
352 (let (gotsome)
353 (if dun-inbus
354 (dun-mprincl "You can't take anything while on the bus.")
355 (setq gotsome nil)
356 (dolist (x (nth dun-current-room dun-room-objects))
357 (if (and (>= x 0) (not (= x obj-special)))
358 (progn
359 (setq gotsome t)
360 (dun-mprinc (cadr (nth x dun-objects)))
361 (dun-mprinc ": ")
362 (dun-take-object x))))
363 (if (not gotsome)
364 (dun-mprincl "Nothing to take."))))
365 (let (objnum)
366 (setq objnum (cdr (assq (intern obj) dun-objnames)))
367 (if (eq objnum nil)
368 (progn
369 (dun-mprinc "I don't know what that is.")
370 (dun-mprinc "\n"))
371 (if (and dun-inbus (not (and (member objnum dun-jar)
372 (member obj-jar dun-inventory))))
373 (dun-mprincl "You can't take anything while on the bus.")
374 (dun-take-object objnum)))))))
375
376 (defun dun-take-object (objnum)
377 (if (and (member objnum dun-jar) (member obj-jar dun-inventory))
378 (let (newjar)
379 (dun-mprincl "You remove it from the jar.")
380 (setq newjar nil)
381 (dolist (x dun-jar)
382 (if (not (= x objnum))
383 (setq newjar (append newjar (list x)))))
384 (setq dun-jar newjar)
385 (setq dun-inventory (append dun-inventory (list objnum))))
386 (if (not (member objnum (nth dun-current-room dun-room-objects)))
387 (if (not (member objnum (nth dun-current-room dun-room-silents)))
388 (dun-mprinc "I do not see that here.")
389 (dun-try-take objnum))
390 (if (>= objnum 0)
391 (progn
392 (if (and (car dun-inventory)
393 (> (+ (dun-inven-weight) (nth objnum dun-object-lbs)) 11))
394 (dun-mprinc "Your load would be too heavy.")
395 (setq dun-inventory (append dun-inventory (list objnum)))
396 (dun-remove-obj-from-room dun-current-room objnum)
397 (dun-mprinc "Taken. ")
398 (if (and (= objnum obj-towel) (= dun-current-room red-room))
399 (dun-mprinc
400 "Taking the towel reveals a hole in the floor."))))
401 (dun-try-take objnum)))
402 (dun-mprinc "\n")))
403
404 (defun dun-inven-weight ()
405 (let (total)
406 (setq total 0)
407 (dolist (x dun-jar)
408 (setq total (+ total (nth x dun-object-lbs))))
409 (dolist (x dun-inventory)
410 (setq total (+ total (nth x dun-object-lbs)))) total))
411
412 ;;; We try to take an object that is untakable. Print a message
413 ;;; depending on what it is.
414
415 (defun dun-try-take (obj)
416 (dun-mprinc "You cannot take that."))
417
418 (defun dun-dig (args)
419 (if dun-inbus
420 (dun-mprincl "Digging here reveals nothing.")
421 (if (not (member 0 dun-inventory))
422 (dun-mprincl "You have nothing with which to dig.")
423 (if (not (nth dun-current-room dun-diggables))
424 (dun-mprincl "Digging here reveals nothing.")
425 (dun-mprincl "I think you found something.")
426 (dun-replace dun-room-objects dun-current-room
427 (append (nth dun-current-room dun-room-objects)
428 (nth dun-current-room dun-diggables)))
429 (dun-replace dun-diggables dun-current-room nil)))))
430
431 (defun dun-climb (obj)
432 (let (objnum)
433 (setq objnum (dun-objnum-from-args obj))
434 (cond ((not objnum)
435 (dun-mprincl "I don't know what that object is."))
436 ((and (not (eq objnum obj-special))
437 (not (member objnum (nth dun-current-room dun-room-objects)))
438 (not (member objnum (nth dun-current-room dun-room-silents)))
439 (not (and (member objnum dun-jar) (member obj-jar dun-inventory)))
440 (not (member objnum dun-inventory)))
441 (dun-mprincl "I don't see that here."))
442 ((and (eq objnum obj-special)
443 (not (member obj-tree (nth dun-current-room dun-room-silents))))
444 (dun-mprincl "There is nothing here to climb."))
445 ((and (not (eq objnum obj-tree)) (not (eq objnum obj-special)))
446 (dun-mprincl "You can't climb that."))
447 (t
448 (dun-mprincl
449 "You manage to get about two feet up the tree and fall back down. You
450 notice that the tree is very unsteady.")))))
451
452 (defun dun-eat (obj)
453 (let (objnum)
454 (when (setq objnum (dun-objnum-from-args-std obj))
455 (if (not (member objnum dun-inventory))
456 (dun-mprincl "You don't have that.")
457 (if (not (= objnum obj-food))
458 (progn
459 (dun-mprinc "You forcefully shove ")
460 (dun-mprinc (downcase (cadr (nth objnum dun-objects))))
461 (dun-mprincl " down your throat, and start choking.")
462 (dun-die "choking"))
463 (dun-mprincl "That tasted horrible.")
464 (dun-remove-obj-from-inven obj-food))))))
465
466 (defun dun-put (args)
467 (let (newargs objnum objnum2 obj)
468 (setq newargs (dun-firstwordl args))
469 (if (not newargs)
470 (dun-mprincl "You must supply an object")
471 (setq obj (intern (car newargs)))
472 (setq objnum (cdr (assq obj dun-objnames)))
473 (if (not objnum)
474 (dun-mprincl "I don't know what that object is.")
475 (if (not (member objnum dun-inventory))
476 (dun-mprincl "You don't have that.")
477 (setq newargs (dun-firstwordl (cdr newargs)))
478 (setq newargs (dun-firstwordl (cdr newargs)))
479 (if (not newargs)
480 (dun-mprincl "You must supply an indirect object.")
481 (setq objnum2 (cdr (assq (intern (car newargs)) dun-objnames)))
482 (if (and (eq objnum2 obj-computer) (= dun-current-room pc-area))
483 (setq objnum2 obj-pc))
484 (if (not objnum2)
485 (dun-mprincl "I don't know what that indirect object is.")
486 (if (and (not (member objnum2
487 (nth dun-current-room dun-room-objects)))
488 (not (member objnum2
489 (nth dun-current-room dun-room-silents)))
490 (not (member objnum2 dun-inventory)))
491 (dun-mprincl "That indirect object is not here.")
492 (dun-put-objs objnum objnum2)))))))))
493
494 (defun dun-put-objs (obj1 obj2)
495 (if (and (= obj2 obj-drop) (not dun-nomail))
496 (setq obj2 obj-chute))
497
498 (if (= obj2 obj-disposal) (setq obj2 obj-chute))
499
500 (if (and (= obj1 obj-cpu) (= obj2 obj-computer))
501 (progn
502 (dun-remove-obj-from-inven obj-cpu)
503 (setq dun-computer t)
504 (dun-mprincl
505 "As you put the CPU board in the computer, it immediately springs to life.
506 The lights start flashing, and the fans seem to startup."))
507 (if (and (= obj1 obj-weight) (= obj2 obj-button))
508 (dun-drop '("weight"))
509 (if (= obj2 obj-jar) ;; Put something in jar
510 (if (not (member obj1 (list obj-paper obj-diamond obj-emerald
511 obj-license obj-coins obj-egg
512 obj-nitric obj-glycerine)))
513 (dun-mprincl "That will not fit in the jar.")
514 (dun-remove-obj-from-inven obj1)
515 (setq dun-jar (append dun-jar (list obj1)))
516 (dun-mprincl "Done."))
517 (if (= obj2 obj-chute) ;; Put something in chute
518 (progn
519 (dun-remove-obj-from-inven obj1)
520 (dun-mprincl
521 "You hear it slide down the chute and off into the distance.")
522 (dun-put-objs-in-treas (list obj1)))
523 (if (= obj2 obj-box) ;; Put key in key box
524 (if (= obj1 obj-key)
525 (progn
526 (dun-mprincl
527 "As you drop the key, the box begins to shake. Finally it explodes
528 with a bang. The key seems to have vanished!")
529 (dun-remove-obj-from-inven obj1)
530 (dun-replace dun-room-objects computer-room (append
531 (nth computer-room
532 dun-room-objects)
533 (list obj1)))
534 (dun-remove-obj-from-room dun-current-room obj-box)
535 (setq dun-key-level (1+ dun-key-level)))
536 (dun-mprincl "You can't put that in the key box!"))
537
538 (if (and (= obj1 obj-floppy) (= obj2 obj-pc))
539 (progn
540 (setq dun-floppy t)
541 (dun-remove-obj-from-inven obj1)
542 (dun-mprincl "Done."))
543
544 (if (= obj2 obj-urinal) ;; Put object in urinal
545 (progn
546 (dun-remove-obj-from-inven obj1)
547 (dun-replace dun-room-objects urinal (append
548 (nth urinal dun-room-objects)
549 (list obj1)))
550 (dun-mprincl
551 "You hear it plop down in some water below."))
552 (if (= obj2 obj-mail)
553 (dun-mprincl "The mail chute is locked.")
554 (if (member obj1 dun-inventory)
555 (dun-mprincl
556 "I don't know how to combine those objects. Perhaps you should
557 just try dropping it.")
558 (dun-mprincl"You can't put that there.")))))))))))
559
560 (defun dun-type (args)
561 (if (not (= dun-current-room computer-room))
562 (dun-mprincl "There is nothing here on which you could type.")
563 (if (not dun-computer)
564 (dun-mprincl
565 "You type on the keyboard, but your characters do not even echo.")
566 (dun-unix-interface))))
567
568 ;;; Various movement directions
569
570 (defun dun-n (args)
571 (dun-move north))
572
573 (defun dun-s (args)
574 (dun-move south))
575
576 (defun dun-e (args)
577 (dun-move east))
578
579 (defun dun-w (args)
580 (dun-move west))
581
582 (defun dun-ne (args)
583 (dun-move northeast))
584
585 (defun dun-se (args)
586 (dun-move southeast))
587
588 (defun dun-nw (args)
589 (dun-move northwest))
590
591 (defun dun-sw (args)
592 (dun-move southwest))
593
594 (defun dun-up (args)
595 (dun-move up))
596
597 (defun dun-down (args)
598 (dun-move down))
599
600 (defun dun-in (args)
601 (dun-move in))
602
603 (defun dun-out (args)
604 (dun-move out))
605
606 (defun dun-go (args)
607 (if (or (not (car args))
608 (eq (dun-doverb dun-ignore dun-verblist (car args)
609 (cdr (cdr args))) -1))
610 (dun-mprinc "I don't understand where you want me to go.\n")))
611
612 ;;; Uses the dungeon-map to figure out where we are going. If the
613 ;;; requested direction yields 255, we know something special is
614 ;;; supposed to happen, or perhaps you can't go that way unless
615 ;;; certain conditions are met.
616
617 (defun dun-move (dir)
618 (if (and (not (member dun-current-room dun-light-rooms))
619 (not (member obj-lamp dun-inventory))
620 (not (member obj-lamp (nth dun-current-room dun-room-objects))))
621 (progn
622 (dun-mprinc
623 "You trip over a grue and fall into a pit and break every bone in your
624 body.")
625 (dun-die "a grue"))
626 (let (newroom)
627 (setq newroom (nth dir (nth dun-current-room dungeon-map)))
628 (if (eq newroom -1)
629 (dun-mprinc "You can't go that way.\n")
630 (if (eq newroom 255)
631 (dun-special-move dir)
632 (setq room -1)
633 (setq dun-lastdir dir)
634 (if dun-inbus
635 (progn
636 (if (or (< newroom 58) (> newroom 83))
637 (dun-mprincl "The bus cannot go this way.")
638 (dun-mprincl
639 "The bus lurches ahead and comes to a screeching halt.")
640 (dun-remove-obj-from-room dun-current-room obj-bus)
641 (setq dun-current-room newroom)
642 (dun-replace dun-room-objects newroom
643 (append (nth newroom dun-room-objects)
644 (list obj-bus)))))
645 (setq dun-current-room newroom)))))))
646
647 ;;; Movement in this direction causes something special to happen if the
648 ;;; right conditions exist. It may be that you can't go this way unless
649 ;;; you have a key, or a passage has been opened.
650
651 ;;; coding note: Each check of the current room is on the same 'if' level,
652 ;;; i.e. there aren't else's. If two rooms next to each other have
653 ;;; specials, and they are connected by specials, this could cause
654 ;;; a problem. Be careful when adding them to consider this, and
655 ;;; perhaps use else's.
656
657 (defun dun-special-move (dir)
658 (if (= dun-current-room building-front)
659 (if (not (member obj-key dun-inventory))
660 (dun-mprincl "You don't have a key that can open this door.")
661 (setq dun-current-room old-building-hallway))
662 (if (= dun-current-room north-end-of-cave-passage)
663 (let (combo)
664 (dun-mprincl
665 "You must type a 3 digit combination code to enter this room.")
666 (dun-mprinc "Enter it here: ")
667 (setq combo (dun-read-line))
668 (if (not dun-batch-mode)
669 (dun-mprinc "\n"))
670 (if (string= combo dun-combination)
671 (setq dun-current-room gamma-computing-center)
672 (dun-mprincl "Sorry, that combination is incorrect."))))
673
674 (if (= dun-current-room bear-hangout)
675 (if (member obj-bear (nth bear-hangout dun-room-objects))
676 (progn
677 (dun-mprinc
678 "The bear is very annoyed that you would be so presumptuous as to try
679 and walk right by it. He tells you so by tearing your head off.
680 ")
681 (dun-die "a bear"))
682 (dun-mprincl "You can't go that way.")))
683
684 (if (= dun-current-room vermont-station)
685 (progn
686 (dun-mprincl
687 "As you board the train it immediately leaves the station. It is a very
688 bumpy ride. It is shaking from side to side, and up and down. You
689 sit down in one of the chairs in order to be more comfortable.")
690 (dun-mprincl
691 "\nFinally the train comes to a sudden stop, and the doors open, and some
692 force throws you out. The train speeds away.\n")
693 (setq dun-current-room museum-station)))
694
695 (if (= dun-current-room old-building-hallway)
696 (if (and (member obj-key dun-inventory)
697 (> dun-key-level 0))
698 (setq dun-current-room meadow)
699 (dun-mprincl "You don't have a key that can open this door.")))
700
701 (if (and (= dun-current-room maze-button-room) (= dir northwest))
702 (if (member obj-weight (nth maze-button-room dun-room-objects))
703 (setq dun-current-room 18)
704 (dun-mprincl "You can't go that way.")))
705
706 (if (and (= dun-current-room maze-button-room) (= dir up))
707 (if (member obj-weight (nth maze-button-room dun-room-objects))
708 (dun-mprincl "You can't go that way.")
709 (setq dun-current-room weight-room)))
710
711 (if (= dun-current-room classroom)
712 (dun-mprincl "The door is locked."))
713
714 (if (or (= dun-current-room lakefront-north)
715 (= dun-current-room lakefront-south))
716 (dun-swim nil))
717
718 (if (= dun-current-room reception-area)
719 (if (not (= dun-sauna-level 3))
720 (setq dun-current-room health-club-front)
721 (dun-mprincl
722 "As you exit the building, you notice some flames coming out of one of the
723 windows. Suddenly, the building explodes in a huge ball of fire. The flames
724 engulf you, and you burn to death.")
725 (dun-die "burning")))
726
727 (if (= dun-current-room red-room)
728 (if (not (member obj-towel (nth red-room dun-room-objects)))
729 (setq dun-current-room long-n-s-hallway)
730 (dun-mprincl "You can't go that way.")))
731
732 (if (and (> dir down) (> dun-current-room gamma-computing-center)
733 (< dun-current-room museum-lobby))
734 (if (not (member obj-bus (nth dun-current-room dun-room-objects)))
735 (dun-mprincl "You can't go that way.")
736 (if (= dir in)
737 (if dun-inbus
738 (dun-mprincl
739 "You are already in the bus!")
740 (if (member obj-license dun-inventory)
741 (progn
742 (dun-mprincl
743 "You board the bus and get in the driver's seat.")
744 (setq dun-nomail t)
745 (setq dun-inbus t))
746 (dun-mprincl "You are not licensed for this type of vehicle.")))
747 (if (not dun-inbus)
748 (dun-mprincl "You are already off the bus!")
749 (dun-mprincl "You hop off the bus.")
750 (setq dun-inbus nil))))
751 (if (= dun-current-room fifth-oaktree-intersection)
752 (if (not dun-inbus)
753 (progn
754 (dun-mprincl "You fall down the cliff and land on your head.")
755 (dun-die "a cliff"))
756 (dun-mprincl
757 "The bus flies off the cliff, and plunges to the bottom, where it explodes.")
758 (dun-die "a bus accident")))
759 (if (= dun-current-room main-maple-intersection)
760 (progn
761 (if (not dun-inbus)
762 (dun-mprincl "The gate will not open.")
763 (dun-mprincl
764 "As the bus approaches, the gate opens and you drive through.")
765 (dun-remove-obj-from-room main-maple-intersection obj-bus)
766 (dun-replace dun-room-objects museum-entrance
767 (append (nth museum-entrance dun-room-objects)
768 (list obj-bus)))
769 (setq dun-current-room museum-entrance)))))
770 (if (= dun-current-room cave-entrance)
771 (progn
772 (dun-mprincl
773 "As you enter the room you hear a rumbling noise. You look back to see
774 huge rocks sliding down from the ceiling, and blocking your way out.\n")
775 (setq dun-current-room misty-room)))))
776
777 (defun dun-long (args)
778 (setq dun-mode "long"))
779
780 (defun dun-turn (obj)
781 (let (objnum direction)
782 (when (setq objnum (dun-objnum-from-args-std obj))
783 (if (not (or (member objnum (nth dun-current-room dun-room-objects))
784 (member objnum (nth dun-current-room dun-room-silents))))
785 (dun-mprincl "I don't see that here.")
786 (if (not (= objnum obj-dial))
787 (dun-mprincl "You can't turn that.")
788 (setq direction (dun-firstword (cdr obj)))
789 (if (or (not direction)
790 (not (or (string= direction "clockwise")
791 (string= direction "counterclockwise"))))
792 (dun-mprincl "You must indicate clockwise or counterclockwise.")
793 (if (string= direction "clockwise")
794 (setq dun-sauna-level (+ dun-sauna-level 1))
795 (setq dun-sauna-level (- dun-sauna-level 1)))
796
797 (if (< dun-sauna-level 0)
798 (progn
799 (dun-mprincl
800 "The dial will not turn further in that direction.")
801 (setq dun-sauna-level 0))
802 (dun-sauna-heat))))))))
803
804 (defun dun-sauna-heat ()
805 (if (= dun-sauna-level 0)
806 (dun-mprincl
807 "The temperature has returned to normal room temperature."))
808 (if (= dun-sauna-level 1)
809 (dun-mprincl "It is now luke warm in here. You are perspiring."))
810 (if (= dun-sauna-level 2)
811 (dun-mprincl "It is pretty hot in here. It is still very comfortable."))
812 (if (= dun-sauna-level 3)
813 (progn
814 (dun-mprincl
815 "It is now very hot. There is something very refreshing about this.")
816 (if (or (member obj-rms dun-inventory)
817 (member obj-rms (nth dun-current-room dun-room-objects)))
818 (progn
819 (dun-mprincl
820 "You notice the wax on your statuette beginning to melt, until it completely
821 melts off. You are left with a beautiful diamond!")
822 (if (member obj-rms dun-inventory)
823 (progn
824 (dun-remove-obj-from-inven obj-rms)
825 (setq dun-inventory (append dun-inventory
826 (list obj-diamond))))
827 (dun-remove-obj-from-room dun-current-room obj-rms)
828 (dun-replace dun-room-objects dun-current-room
829 (append (nth dun-current-room dun-room-objects)
830 (list obj-diamond))))))
831 (if (or (member obj-floppy dun-inventory)
832 (member obj-floppy (nth dun-current-room dun-room-objects)))
833 (progn
834 (dun-mprincl
835 "You notice your floppy disk beginning to melt. As you grab for it, the
836 disk bursts into flames, and disintegrates.")
837 (if (member obj-floppy dun-inventory)
838 (dun-remove-obj-from-inven obj-floppy)
839 (dun-remove-obj-from-room dun-current-room obj-floppy))))))
840
841 (if (= dun-sauna-level 4)
842 (progn
843 (dun-mprincl
844 "As the dial clicks into place, you immediately burst into flames.")
845 (dun-die "burning"))))
846
847 (defun dun-press (obj)
848 (let (objnum)
849 (when (setq objnum (dun-objnum-from-args-std obj))
850 (if (not (or (member objnum (nth dun-current-room dun-room-objects))
851 (member objnum (nth dun-current-room dun-room-silents))))
852 (dun-mprincl "I don't see that here.")
853 (if (not (member objnum (list obj-button obj-switch)))
854 (progn
855 (dun-mprinc "You can't ")
856 (dun-mprinc (car line-list))
857 (dun-mprincl " that."))
858 (if (= objnum obj-button)
859 (dun-mprincl
860 "As you press the button, you notice a passageway open up, but
861 as you release it, the passageway closes."))
862 (if (= objnum obj-switch)
863 (if dun-black
864 (progn
865 (dun-mprincl "The button is now in the off position.")
866 (setq dun-black nil))
867 (dun-mprincl "The button is now in the on position.")
868 (setq dun-black t))))))))
869
870 (defun dun-swim (args)
871 (if (not (member dun-current-room (list lakefront-north lakefront-south)))
872 (dun-mprincl "I see no water!")
873 (if (not (member obj-life dun-inventory))
874 (progn
875 (dun-mprincl
876 "You dive in the water, and at first notice it is quite cold. You then
877 start to get used to it as you realize that you never really learned how
878 to swim.")
879 (dun-die "drowning"))
880 (if (= dun-current-room lakefront-north)
881 (setq dun-current-room lakefront-south)
882 (setq dun-current-room lakefront-north)))))
883
884
885 (defun dun-score (args)
886 (if (not dun-endgame)
887 (let (total)
888 (setq total (dun-reg-score))
889 (dun-mprinc "You have scored ")
890 (dun-mprinc total)
891 (dun-mprincl " out of a possible 90 points.") total)
892 (dun-mprinc "You have scored ")
893 (dun-mprinc (dun-endgame-score))
894 (dun-mprincl " endgame points out of a possible 110.")
895 (if (= (dun-endgame-score) 110)
896 (dun-mprincl
897 "\n\nCongratulations. You have won. The wizard password is ‘moby’"))))
898
899 (defun dun-help (args)
900 (dun-mprincl
901 "Welcome to dunnet (2.02), by Ron Schnell (ronnie@driver-aces.com - @RonnieSchnell).
902 Here is some useful information (read carefully because there are one
903 or more clues in here):
904 - If you have a key that can open a door, you do not need to explicitly
905 open it. You may just use ‘in’ or walk in the direction of the door.
906
907 - If you have a lamp, it is always lit.
908
909 - You will not get any points until you manage to get treasures to a certain
910 place. Simply finding the treasures is not good enough. There is more
911 than one way to get a treasure to the special place. It is also
912 important that the objects get to the special place *unharmed* and
913 *untarnished*. You can tell if you have successfully transported the
914 object by looking at your score, as it changes immediately. Note that
915 an object can become harmed even after you have received points for it.
916 If this happens, your score will decrease, and in many cases you can never
917 get credit for it again.
918
919 - You can save your game with the ‘save’ command, and use restore it
920 with the ‘restore’ command.
921
922 - There are no limits on lengths of object names.
923
924 - Directions are: north,south,east,west,northeast,southeast,northwest,
925 southwest,up,down,in,out.
926
927 - These can be abbreviated: n,s,e,w,ne,se,nw,sw,u,d,in,out.
928
929 - If you go down a hole in the floor without an aid such as a ladder,
930 you probably won't be able to get back up the way you came, if at all.
931
932 - To run this game in batch mode (no Emacs window), use:
933 emacs -batch -l dunnet
934 NOTE: This game *should* be run in batch mode!
935
936 If you have questions or comments, please contact ronnie@driver-aces.com
937 My home page is http://www.driver-aces.com/ronnie.html
938 "))
939
940 (defun dun-flush (args)
941 (if (not (= dun-current-room bathroom))
942 (dun-mprincl "I see nothing to flush.")
943 (dun-mprincl "Whoooosh!!")
944 (dun-put-objs-in-treas (nth urinal dun-room-objects))
945 (dun-replace dun-room-objects urinal nil)))
946
947 (defun dun-piss (args)
948 (if (not (= dun-current-room bathroom))
949 (dun-mprincl "You can't do that here, don't even bother trying.")
950 (if (not dun-gottago)
951 (dun-mprincl "I'm afraid you don't have to go now.")
952 (dun-mprincl "That was refreshing.")
953 (setq dun-gottago nil)
954 (dun-replace dun-room-objects urinal (append
955 (nth urinal dun-room-objects)
956 (list obj-URINE))))))
957
958
959 (defun dun-sleep (args)
960 (if (not (= dun-current-room bedroom))
961 (dun-mprincl
962 "You try to go to sleep while standing up here, but can't seem to do it.")
963 (setq dun-gottago t)
964 (dun-mprincl
965 "As soon as you start to doze off you begin dreaming. You see images of
966 workers digging caves, slaving in the humid heat. Then you see yourself
967 as one of these workers. While no one is looking, you leave the group
968 and walk into a room. The room is bare except for a horseshoe
969 shaped piece of stone in the center. You see yourself digging a hole in
970 the ground, then putting some kind of treasure in it, and filling the hole
971 with dirt again. After this, you immediately wake up.")))
972
973 (defun dun-break (obj)
974 (let (objnum)
975 (if (not (member obj-axe dun-inventory))
976 (dun-mprincl "You have nothing you can use to break things.")
977 (when (setq objnum (dun-objnum-from-args-std obj))
978 (if (member objnum dun-inventory)
979 (progn
980 (dun-mprincl
981 "You take the object in your hands and swing the axe. Unfortunately, you miss
982 the object and slice off your hand. You bleed to death.")
983 (dun-die "an axe"))
984 (if (not (or (member objnum (nth dun-current-room dun-room-objects))
985 (member objnum
986 (nth dun-current-room dun-room-silents))))
987 (dun-mprincl "I don't see that here.")
988 (if (= objnum obj-cable)
989 (progn
990 (dun-mprincl
991 "As you break the ethernet cable, everything starts to blur. You collapse
992 for a moment, then straighten yourself up.
993 ")
994 (dun-replace dun-room-objects gamma-computing-center
995 (append
996 (nth gamma-computing-center dun-room-objects)
997 dun-inventory))
998 (if (member obj-key dun-inventory)
999 (progn
1000 (setq dun-inventory (list obj-key))
1001 (dun-remove-obj-from-room
1002 gamma-computing-center obj-key))
1003 (setq dun-inventory nil))
1004 (setq dun-current-room computer-room)
1005 (setq dun-ethernet nil)
1006 (dun-mprincl "Connection closed.")
1007 (dun-unix-interface))
1008 (if (< objnum 0)
1009 (progn
1010 (dun-mprincl "Your axe shatters into a million pieces.")
1011 (dun-remove-obj-from-inven obj-axe))
1012 (dun-mprincl "Your axe breaks it into a million pieces.")
1013 (dun-remove-obj-from-room dun-current-room objnum)))))))))
1014
1015 (defun dun-drive (args)
1016 (if (not dun-inbus)
1017 (dun-mprincl "You cannot drive when you aren't in a vehicle.")
1018 (dun-mprincl "To drive while you are in the bus, just give a direction.")))
1019
1020 (defun dun-superb (args)
1021 (setq dun-mode 'dun-superb))
1022
1023 (defun dun-reg-score ()
1024 (let (total)
1025 (setq total 0)
1026 (dolist (x (nth treasure-room dun-room-objects))
1027 (setq total (+ total (nth x dun-object-pts))))
1028 (if (member obj-URINE (nth treasure-room dun-room-objects))
1029 (setq total 0)) total))
1030
1031 (defun dun-endgame-score ()
1032 (let (total)
1033 (setq total 0)
1034 (dolist (x (nth endgame-treasure-room dun-room-objects))
1035 (setq total (+ total (nth x dun-object-pts)))) total))
1036
1037 (defun dun-answer (args)
1038 (if (not dun-correct-answer)
1039 (dun-mprincl "I don't believe anyone asked you anything.")
1040 (setq args (car args))
1041 (if (not args)
1042 (dun-mprincl "You must give the answer on the same line.")
1043 (if (dun-members args dun-correct-answer)
1044 (progn
1045 (dun-mprincl "Correct.")
1046 (if (= dun-lastdir 0)
1047 (setq dun-current-room (1+ dun-current-room))
1048 (setq dun-current-room (- dun-current-room 1)))
1049 (setq dun-correct-answer nil))
1050 (dun-mprincl "That answer is incorrect.")))))
1051
1052 (defun dun-endgame-question ()
1053 (if (not dun-endgame-questions)
1054 (progn
1055 (dun-mprincl "Your question is:")
1056 (dun-mprincl "No more questions, just do ‘answer foo’.")
1057 (setq dun-correct-answer '("foo")))
1058 (let (which i newques)
1059 (setq i 0)
1060 (setq newques nil)
1061 (setq which (random (length dun-endgame-questions)))
1062 (dun-mprincl "Your question is:")
1063 (dun-mprincl (setq dun-endgame-question (car
1064 (nth which
1065 dun-endgame-questions))))
1066 (setq dun-correct-answer (cdr (nth which dun-endgame-questions)))
1067 (while (< i which)
1068 (setq newques (append newques (list (nth i dun-endgame-questions))))
1069 (setq i (1+ i)))
1070 (setq i (1+ which))
1071 (while (< i (length dun-endgame-questions))
1072 (setq newques (append newques (list (nth i dun-endgame-questions))))
1073 (setq i (1+ i)))
1074 (setq dun-endgame-questions newques))))
1075
1076 (defun dun-power (args)
1077 (if (not (= dun-current-room pc-area))
1078 (dun-mprincl "That operation is not applicable here.")
1079 (if (not dun-floppy)
1080 (dun-dos-no-disk)
1081 (dun-dos-interface))))
1082
1083 (defun dun-feed (args)
1084 (let (objnum)
1085 (when (setq objnum (dun-objnum-from-args-std args))
1086 (if (and (= objnum obj-bear)
1087 (member obj-bear (nth dun-current-room dun-room-objects)))
1088 (progn
1089 (if (not (member obj-food dun-inventory))
1090 (dun-mprincl "You have nothing with which to feed it.")
1091 (dun-drop '("food"))))
1092 (if (not (or (member objnum (nth dun-current-room dun-room-objects))
1093 (member objnum dun-inventory)
1094 (member objnum (nth dun-current-room dun-room-silents))))
1095 (dun-mprincl "I don't see that here.")
1096 (dun-mprincl "You cannot feed that."))))))
1097
1098
1099 ;;;;
1100 ;;;; This section defines various utility functions used
1101 ;;;; by dunnet.
1102 ;;;;
1103
1104
1105 ;;; Function which takes a verb and a list of other words. Calls proper
1106 ;;; function associated with the verb, and passes along the other words.
1107
1108 (defun dun-doverb (dun-ignore dun-verblist verb rest)
1109 (if (not verb)
1110 nil
1111 (if (member (intern verb) dun-ignore)
1112 (if (not (car rest)) -1
1113 (dun-doverb dun-ignore dun-verblist (car rest) (cdr rest)))
1114 (if (not (cdr (assq (intern verb) dun-verblist))) -1
1115 (setq dun-numcmds (1+ dun-numcmds))
1116 (eval (list (cdr (assq (intern verb) dun-verblist)) (quote rest)))))))
1117
1118
1119 ;;; Function to take a string and change it into a list of lowercase words.
1120
1121 (defun dun-listify-string (strin)
1122 (let (pos ret-list end-pos)
1123 (setq pos 0)
1124 (setq ret-list nil)
1125 (while (setq end-pos (string-match "[ ,:;]" (substring strin pos)))
1126 (setq end-pos (+ end-pos pos))
1127 (if (not (= end-pos pos))
1128 (setq ret-list (append ret-list (list
1129 (downcase
1130 (substring strin pos end-pos))))))
1131 (setq pos (+ end-pos 1))) ret-list))
1132
1133 (defun dun-listify-string2 (strin)
1134 (let (pos ret-list end-pos)
1135 (setq pos 0)
1136 (setq ret-list nil)
1137 (while (setq end-pos (string-match " " (substring strin pos)))
1138 (setq end-pos (+ end-pos pos))
1139 (if (not (= end-pos pos))
1140 (setq ret-list (append ret-list (list
1141 (downcase
1142 (substring strin pos end-pos))))))
1143 (setq pos (+ end-pos 1))) ret-list))
1144
1145 (defun dun-replace (list n number)
1146 (rplaca (nthcdr n list) number))
1147
1148
1149 ;;; Get the first non-ignored word from a list.
1150
1151 (defun dun-firstword (list)
1152 (if (not (car list))
1153 nil
1154 (while (and list (member (intern (car list)) dun-ignore))
1155 (setq list (cdr list)))
1156 (car list)))
1157
1158 (defun dun-firstwordl (list)
1159 (if (not (car list))
1160 nil
1161 (while (and list (member (intern (car list)) dun-ignore))
1162 (setq list (cdr list)))
1163 list))
1164
1165 ;;; parse a line passed in as a string Call the proper verb with the
1166 ;;; rest of the line passed in as a list.
1167
1168 (defun dun-vparse (dun-ignore dun-verblist line)
1169 (dun-mprinc "\n")
1170 (setq line-list (dun-listify-string (concat line " ")))
1171 (dun-doverb dun-ignore dun-verblist (car line-list) (cdr line-list)))
1172
1173 (defun dun-parse2 (dun-ignore dun-verblist line)
1174 (dun-mprinc "\n")
1175 (setq line-list (dun-listify-string2 (concat line " ")))
1176 (dun-doverb dun-ignore dun-verblist (car line-list) (cdr line-list)))
1177
1178 ;;; Read a line, in window mode
1179
1180 (defun dun-read-line ()
1181 (let (line)
1182 (setq line (read-string ""))
1183 (dun-mprinc line) line))
1184
1185 ;;; Insert something into the window buffer
1186
1187 (defun dun-minsert (string)
1188 (if (stringp string)
1189 (insert string)
1190 (insert (prin1-to-string string))))
1191
1192 ;;; Print something out, in window mode
1193
1194 (defun dun-mprinc (string)
1195 (if (stringp string)
1196 (insert string)
1197 (insert (prin1-to-string string))))
1198
1199 ;;; In window mode, keep screen from jumping by keeping last line at
1200 ;;; the bottom of the screen.
1201
1202 (defun dun-fix-screen ()
1203 (interactive)
1204 (forward-line (- 0 (- (window-height) 2 )))
1205 (set-window-start (selected-window) (point))
1206 (end-of-buffer))
1207
1208 ;;; Insert something into the buffer, followed by newline.
1209
1210 (defun dun-minsertl (string)
1211 (dun-minsert string)
1212 (dun-minsert "\n"))
1213
1214 ;;; Print something, followed by a newline.
1215
1216 (defun dun-mprincl (string)
1217 (dun-mprinc string)
1218 (dun-mprinc "\n"))
1219
1220 ;;; Function which will get an object number given the list of
1221 ;;; words in the command, except for the verb.
1222
1223 (defun dun-objnum-from-args (obj)
1224 (let (objnum)
1225 (setq obj (dun-firstword obj))
1226 (if (not obj)
1227 obj-special
1228 (setq objnum (cdr (assq (intern obj) dun-objnames))))))
1229
1230 (defun dun-objnum-from-args-std (obj)
1231 (let (result)
1232 (if (eq (setq result (dun-objnum-from-args obj)) obj-special)
1233 (dun-mprincl "You must supply an object."))
1234 (if (eq result nil)
1235 (dun-mprincl "I don't know what that is."))
1236 (if (eq result obj-special)
1237 nil
1238 result)))
1239
1240 ;;; Take a short room description, and change spaces and slashes to dashes.
1241
1242 (defun dun-space-to-hyphen (string)
1243 (let (space)
1244 (if (setq space (string-match "[ /]" string))
1245 (progn
1246 (setq string (concat (substring string 0 space) "-"
1247 (substring string (1+ space))))
1248 (dun-space-to-hyphen string))
1249 string)))
1250
1251 ;;; Given a unix style pathname, build a list of path components (recursive)
1252
1253 (defun dun-get-path (dirstring startlist)
1254 (let (slash pos)
1255 (if (= (length dirstring) 0)
1256 startlist
1257 (if (string= (substring dirstring 0 1) "/")
1258 (dun-get-path (substring dirstring 1) (append startlist (list "/")))
1259 (if (not (setq slash (string-match "/" dirstring)))
1260 (append startlist (list dirstring))
1261 (dun-get-path (substring dirstring (1+ slash))
1262 (append startlist
1263 (list (substring dirstring 0 slash)))))))))
1264
1265
1266 ;;; Is a string a member of a string list?
1267
1268 (defun dun-members (string string-list)
1269 (let (found)
1270 (setq found nil)
1271 (dolist (x string-list)
1272 (if (string= x string)
1273 (setq found t))) found))
1274
1275 ;;; Function to put objects in the treasure room. Also prints current
1276 ;;; score to let user know he has scored.
1277
1278 (defun dun-put-objs-in-treas (objlist)
1279 (let (oscore newscore)
1280 (setq oscore (dun-reg-score))
1281 (dun-replace dun-room-objects 0 (append (nth 0 dun-room-objects) objlist))
1282 (setq newscore (dun-reg-score))
1283 (if (not (= oscore newscore))
1284 (dun-score nil))))
1285
1286 ;;; Load an encrypted file, and eval it.
1287
1288 (defun dun-load-d (filename)
1289 (let (old-buffer result)
1290 (setq result t)
1291 (setq old-buffer (current-buffer))
1292 (switch-to-buffer (get-buffer-create "*loadc*"))
1293 (erase-buffer)
1294 (condition-case nil
1295 (insert-file-contents filename)
1296 (error (setq result nil)))
1297 (unless (not result)
1298 (condition-case nil
1299 (dun-rot13)
1300 (error (yank)))
1301 (eval-buffer)
1302 (kill-buffer (current-buffer)))
1303 (switch-to-buffer old-buffer)
1304 result))
1305
1306 ;;; Functions to remove an object either from a room, or from inventory.
1307
1308 (defun dun-remove-obj-from-room (room objnum)
1309 (let (newroom)
1310 (setq newroom nil)
1311 (dolist (x (nth room dun-room-objects))
1312 (if (not (= x objnum))
1313 (setq newroom (append newroom (list x)))))
1314 (rplaca (nthcdr room dun-room-objects) newroom)))
1315
1316 (defun dun-remove-obj-from-inven (objnum)
1317 (let (new-inven)
1318 (setq new-inven nil)
1319 (dolist (x dun-inventory)
1320 (if (not (= x objnum))
1321 (setq new-inven (append new-inven (list x)))))
1322 (setq dun-inventory new-inven)))
1323
1324 (defun dun-rot13 ()
1325 (rot13-region (point-min) (point-max)))
1326
1327 ;;;;
1328 ;;;; This section defines the globals that are used in dunnet.
1329 ;;;;
1330 ;;;; IMPORTANT
1331 ;;;; All globals which can change must be saved from 'save-game. Add
1332 ;;;; all new globals to bottom of file.
1333
1334 (setq dun-visited '(27))
1335 (setq dun-current-room 1)
1336 (setq dun-exitf nil)
1337 (setq dun-badcd nil)
1338 (define-obsolete-variable-alias 'dungeon-mode-map 'dun-mode-map "22.1")
1339 (define-key dun-mode-map "\r" 'dun-parse)
1340 (defvar dungeon-batch-map (make-keymap))
1341 (if (string= (substring emacs-version 0 2) "18")
1342 (let (n)
1343 (setq n 32)
1344 (while (< 0 (setq n (- n 1)))
1345 (aset dungeon-batch-map n 'dungeon-nil)))
1346 (let (n)
1347 (setq n 32)
1348 (while (< 0 (setq n (- n 1)))
1349 (aset (car (cdr dungeon-batch-map)) n 'dungeon-nil))))
1350 (define-key dungeon-batch-map "\r" 'exit-minibuffer)
1351 (define-key dungeon-batch-map "\n" 'exit-minibuffer)
1352 (setq dun-computer nil)
1353 (setq dun-floppy nil)
1354 (setq dun-key-level 0)
1355 (setq dun-hole nil)
1356 (setq dun-correct-answer nil)
1357 (setq dun-lastdir 0)
1358 (setq dun-numsaves 0)
1359 (setq dun-jar nil)
1360 (setq dun-dead nil)
1361 (setq room 0)
1362 (setq dun-numcmds 0)
1363 (setq dun-wizard nil)
1364 (setq dun-endgame-question nil)
1365 (setq dun-logged-in nil)
1366 (setq dungeon-mode 'dungeon)
1367 (setq dun-unix-verbs '((ls . dun-ls) (ftp . dun-ftp) (echo . dun-echo)
1368 (exit . dun-uexit) (cd . dun-cd) (pwd . dun-pwd)
1369 (rlogin . dun-rlogin) (ssh . dun-rlogin)
1370 (uncompress . dun-uncompress) (cat . dun-cat)))
1371
1372 (setq dun-dos-verbs '((dir . dun-dos-dir) (type . dun-dos-type)
1373 (exit . dun-dos-exit) (command . dun-dos-spawn)
1374 (b: . dun-dos-invd) (c: . dun-dos-invd)
1375 (a: . dun-dos-nil)))
1376
1377
1378 (setq dun-batch-mode nil)
1379
1380 (setq dun-cdpath "/usr/toukmond")
1381 (setq dun-cdroom -10)
1382 (setq dun-uncompressed nil)
1383 (setq dun-ethernet t)
1384 (setq dun-restricted
1385 '(dun-room-objects dungeon-map dun-rooms
1386 dun-room-silents dun-combination))
1387 (setq dun-ftptype 'ascii)
1388 (setq dun-endgame nil)
1389 (setq dun-gottago t)
1390 (setq dun-black nil)
1391
1392 (setq dun-rooms '(
1393 (
1394 "You are in the treasure room. A door leads out to the north."
1395 "Treasure room"
1396 )
1397 (
1398 "You are at a dead end of a dirt road. The road goes to the east.
1399 In the distance you can see that it will eventually fork off. The
1400 trees here are very tall royal palms, and they are spaced equidistant
1401 from each other."
1402 "Dead end"
1403 )
1404 (
1405 "You are on the continuation of a dirt road. There are more trees on
1406 both sides of you. The road continues to the east and west."
1407 "E/W Dirt road"
1408 )
1409 (
1410 "You are at a fork of two passages, one to the northeast, and one to the
1411 southeast. The ground here seems very soft. You can also go back west."
1412 "Fork"
1413 )
1414 (
1415 "You are on a northeast/southwest road."
1416 "NE/SW road"
1417 )
1418 (
1419 "You are at the end of the road. There is a building in front of you
1420 to the northeast, and the road leads back to the southwest."
1421 "Building front"
1422 )
1423 (
1424 "You are on a southeast/northwest road."
1425 "SE/NW road"
1426 )
1427 (
1428 "You are standing at the end of a road. A passage leads back to the
1429 northwest."
1430 "Bear hangout"
1431 )
1432 (
1433 "You are in the hallway of an old building. There are rooms to the east
1434 and west, and doors leading out to the north and south."
1435 "Old Building hallway"
1436 )
1437 (
1438 "You are in a mailroom. There are many bins where the mail is usually
1439 kept. The exit is to the west."
1440 "Mailroom"
1441 )
1442 (
1443 "You are in a computer room. It seems like most of the equipment has
1444 been removed. There is a VAX 11/780 in front of you, however, with
1445 one of the cabinets wide open. A sign on the front of the machine
1446 says: This VAX is named ‘pokey’. To type on the console, use the
1447 ‘type’ command. The exit is to the east."
1448 "Computer room"
1449 )
1450 (
1451 "You are in a meadow in the back of an old building. A small path leads
1452 to the west, and a door leads to the south."
1453 "Meadow"
1454 )
1455 (
1456 "You are in a round, stone room with a door to the east. There
1457 is a sign on the wall that reads: ‘receiving room’."
1458 "Receiving room"
1459 )
1460 (
1461 "You are at the south end of a hallway that leads to the north. There
1462 are rooms to the east and west."
1463 "Northbound Hallway"
1464 )
1465 (
1466 "You are in a sauna. There is nothing in the room except for a dial
1467 on the wall. A door leads out to west."
1468 "Sauna"
1469 )
1470 (
1471 "You are at the end of a north/south hallway. You can go back to the south,
1472 or off to a room to the east."
1473 "End of N/S Hallway"
1474 )
1475 (
1476 "You are in an old weight room. All of the equipment is either destroyed
1477 or completely broken. There is a door out to the west, and there is a ladder
1478 leading down a hole in the floor."
1479 "Weight room" ;16
1480 )
1481 (
1482 "You are in a maze of twisty little passages, all alike.
1483 There is a button on the ground here."
1484 "Maze button room"
1485 )
1486 (
1487 "You are in a maze of little twisty passages, all alike."
1488 "Maze"
1489 )
1490 (
1491 "You are in a maze of thirsty little passages, all alike."
1492 "Maze" ;19
1493 )
1494 (
1495 "You are in a maze of twenty little passages, all alike."
1496 "Maze"
1497 )
1498 (
1499 "You are in a daze of twisty little passages, all alike."
1500 "Maze" ;21
1501 )
1502 (
1503 "You are in a maze of twisty little cabbages, all alike."
1504 "Maze" ;22
1505 )
1506 (
1507 "You are in a reception area for a health and fitness center. The place
1508 appears to have been recently ransacked, and nothing is left. There is
1509 a door out to the south, and a crawlspace to the southeast."
1510 "Reception area"
1511 )
1512 (
1513 "You are outside a large building to the north which used to be a health
1514 and fitness center. A road leads to the south."
1515 "Health Club front"
1516 )
1517 (
1518 "You are at the north side of a lake. On the other side you can see
1519 a road which leads to a cave. The water appears very deep."
1520 "Lakefront North"
1521 )
1522 (
1523 "You are at the south side of a lake. A road goes to the south."
1524 "Lakefront South"
1525 )
1526 (
1527 "You are in a well-hidden area off to the side of a road. Back to the
1528 northeast through the brush you can see the bear hangout."
1529 "Hidden area"
1530 )
1531 (
1532 "The entrance to a cave is to the south. To the north, a road leads
1533 towards a deep lake. On the ground nearby there is a chute, with a sign
1534 that says ‘put treasures here for points’."
1535 "Cave Entrance" ;28
1536 )
1537 (
1538 "You are in a misty, humid room carved into a mountain.
1539 To the north is the remains of a rockslide. To the east, a small
1540 passage leads away into the darkness." ;29
1541 "Misty Room"
1542 )
1543 (
1544 "You are in an east/west passageway. The walls here are made of
1545 multicolored rock and are quite beautiful."
1546 "Cave E/W passage" ;30
1547 )
1548 (
1549 "You are at the junction of two passages. One goes north/south, and
1550 the other goes west."
1551 "N/S/W Junction" ;31
1552 )
1553 (
1554 "You are at the north end of a north/south passageway. There are stairs
1555 leading down from here. There is also a door leading west."
1556 "North end of cave passage" ;32
1557 )
1558 (
1559 "You are at the south end of a north/south passageway. There is a hole
1560 in the floor here, into which you could probably fit."
1561 "South end of cave passage" ;33
1562 )
1563 (
1564 "You are in what appears to be a worker's bedroom. There is a queen-
1565 sized bed in the middle of the room, and a painting hanging on the
1566 wall. A door leads to another room to the south, and stairways
1567 lead up and down."
1568 "Bedroom" ;34
1569 )
1570 (
1571 "You are in a bathroom built for workers in the cave. There is a
1572 urinal hanging on the wall, and some exposed pipes on the opposite
1573 wall where a sink used to be. To the north is a bedroom."
1574 "Bathroom" ;35
1575 )
1576 (
1577 "This is a marker for the urinal. User will not see this, but it
1578 is a room that can contain objects."
1579 "Urinal" ;36
1580 )
1581 (
1582 "You are at the northeast end of a northeast/southwest passageway.
1583 Stairs lead up out of sight."
1584 "NE end of NE/SW cave passage" ;37
1585 )
1586 (
1587 "You are at the junction of northeast/southwest and east/west passages."
1588 "NE/SW-E/W junction" ;38
1589 )
1590 (
1591 "You are at the southwest end of a northeast/southwest passageway."
1592 "SW end of NE/SW cave passage" ;39
1593 )
1594 (
1595 "You are at the east end of an E/W passage. There are stairs leading up
1596 to a room above."
1597 "East end of E/W cave passage" ;40
1598 )
1599 (
1600 "You are at the west end of an E/W passage. There is a hole on the ground
1601 which leads down out of sight."
1602 "West end of E/W cave passage" ;41
1603 )
1604 (
1605 "You are in a room which is bare, except for a horseshoe shaped boulder
1606 in the center. Stairs lead down from here." ;42
1607 "Horseshoe boulder room"
1608 )
1609 (
1610 "You are in a room which is completely empty. Doors lead out to the north
1611 and east."
1612 "Empty room" ;43
1613 )
1614 (
1615 "You are in an empty room. Interestingly enough, the stones in this
1616 room are painted blue. Doors lead out to the east and south." ;44
1617 "Blue room"
1618 )
1619 (
1620 "You are in an empty room. Interestingly enough, the stones in this
1621 room are painted yellow. Doors lead out to the south and west." ;45
1622 "Yellow room"
1623 )
1624 (
1625 "You are in an empty room. Interestingly enough, the stones in this room
1626 are painted red. Doors lead out to the west and north."
1627 "Red room" ;46
1628 )
1629 (
1630 "You are in the middle of a long north/south hallway." ;47
1631 "Long n/s hallway"
1632 )
1633 (
1634 "You are 3/4 of the way towards the north end of a long north/south hallway."
1635 "3/4 north" ;48
1636 )
1637 (
1638 "You are at the north end of a long north/south hallway. There are stairs
1639 leading upwards."
1640 "North end of long hallway" ;49
1641 )
1642 (
1643 "You are 3/4 of the way towards the south end of a long north/south hallway."
1644 "3/4 south" ;50
1645 )
1646 (
1647 "You are at the south end of a long north/south hallway. There is a hole
1648 to the south."
1649 "South end of long hallway" ;51
1650 )
1651 (
1652 "You are at a landing in a stairwell which continues up and down."
1653 "Stair landing" ;52
1654 )
1655 (
1656 "You are at the continuation of an up/down staircase."
1657 "Up/down staircase" ;53
1658 )
1659 (
1660 "You are at the top of a staircase leading down. A crawlway leads off
1661 to the northeast."
1662 "Top of staircase." ;54
1663 )
1664 (
1665 "You are in a crawlway that leads northeast or southwest."
1666 "NE crawlway" ;55
1667 )
1668 (
1669 "You are in a small crawlspace. There is a hole in the ground here, and
1670 a small passage back to the southwest."
1671 "Small crawlspace" ;56
1672 )
1673 (
1674 "You are in the Gamma Computing Center. An IBM 3090/600s is whirring
1675 away in here. There is an ethernet cable coming out of one of the units,
1676 and going through the ceiling. There is no console here on which you
1677 could type."
1678 "Gamma computing center" ;57
1679 )
1680 (
1681 "You are near the remains of a post office. There is a mail drop on the
1682 face of the building, but you cannot see where it leads. A path leads
1683 back to the east, and a road leads to the north."
1684 "Post office" ;58
1685 )
1686 (
1687 "You are at the intersection of Main Street and Maple Ave. Main street
1688 runs north and south, and Maple Ave runs east off into the distance.
1689 If you look north and east you can see many intersections, but all of
1690 the buildings that used to stand here are gone. Nothing remains except
1691 street signs.
1692 There is a road to the northwest leading to a gate that guards a building."
1693 "Main-Maple intersection" ;59
1694 )
1695 (
1696 "You are at the intersection of Main Street and the west end of Oaktree Ave."
1697 "Main-Oaktree intersection" ;60
1698 )
1699 (
1700 "You are at the intersection of Main Street and the west end of Vermont Ave."
1701 "Main-Vermont intersection" ;61
1702 )
1703 (
1704 "You are at the north end of Main Street at the west end of Sycamore Ave." ;62
1705 "Main-Sycamore intersection"
1706 )
1707 (
1708 "You are at the south end of First Street at Maple Ave." ;63
1709 "First-Maple intersection"
1710 )
1711 (
1712 "You are at the intersection of First Street and Oaktree Ave." ;64
1713 "First-Oaktree intersection"
1714 )
1715 (
1716 "You are at the intersection of First Street and Vermont Ave." ;65
1717 "First-Vermont intersection"
1718 )
1719 (
1720 "You are at the north end of First Street at Sycamore Ave." ;66
1721 "First-Sycamore intersection"
1722 )
1723 (
1724 "You are at the south end of Second Street at Maple Ave." ;67
1725 "Second-Maple intersection"
1726 )
1727 (
1728 "You are at the intersection of Second Street and Oaktree Ave." ;68
1729 "Second-Oaktree intersection"
1730 )
1731 (
1732 "You are at the intersection of Second Street and Vermont Ave." ;69
1733 "Second-Vermont intersection"
1734 )
1735 (
1736 "You are at the north end of Second Street at Sycamore Ave." ;70
1737 "Second-Sycamore intersection"
1738 )
1739 (
1740 "You are at the south end of Third Street at Maple Ave." ;71
1741 "Third-Maple intersection"
1742 )
1743 (
1744 "You are at the intersection of Third Street and Oaktree Ave." ;72
1745 "Third-Oaktree intersection"
1746 )
1747 (
1748 "You are at the intersection of Third Street and Vermont Ave." ;73
1749 "Third-Vermont intersection"
1750 )
1751 (
1752 "You are at the north end of Third Street at Sycamore Ave." ;74
1753 "Third-Sycamore intersection"
1754 )
1755 (
1756 "You are at the south end of Fourth Street at Maple Ave." ;75
1757 "Fourth-Maple intersection"
1758 )
1759 (
1760 "You are at the intersection of Fourth Street and Oaktree Ave." ;76
1761 "Fourth-Oaktree intersection"
1762 )
1763 (
1764 "You are at the intersection of Fourth Street and Vermont Ave." ;77
1765 "Fourth-Vermont intersection"
1766 )
1767 (
1768 "You are at the north end of Fourth Street at Sycamore Ave." ;78
1769 "Fourth-Sycamore intersection"
1770 )
1771 (
1772 "You are at the south end of Fifth Street at the east end of Maple Ave." ;79
1773 "Fifth-Maple intersection"
1774 )
1775 (
1776 "You are at the intersection of Fifth Street and the east end of Oaktree Ave.
1777 There is a cliff off to the east."
1778 "Fifth-Oaktree intersection" ;80
1779 )
1780 (
1781 "You are at the intersection of Fifth Street and the east end of Vermont Ave."
1782 "Fifth-Vermont intersection" ;81
1783 )
1784 (
1785 "You are at the north end of Fifth Street and the east end of Sycamore Ave."
1786 "Fifth-Sycamore intersection" ;82
1787 )
1788 (
1789 "You are in front of the Museum of Natural History. A door leads into
1790 the building to the north, and a road leads to the southeast."
1791 "Museum entrance" ;83
1792 )
1793 (
1794 "You are in the main lobby for the Museum of Natural History. In the center
1795 of the room is the huge skeleton of a dinosaur. Doors lead out to the
1796 south and east."
1797 "Museum lobby" ;84
1798 )
1799 (
1800 "You are in the geological display. All of the objects that used to
1801 be on display are missing. There are rooms to the east, west, and
1802 north."
1803 "Geological display" ;85
1804 )
1805 (
1806 "You are in the marine life area. The room is filled with fish tanks,
1807 which are filled with dead fish that have apparently died due to
1808 starvation. Doors lead out to the south and east."
1809 "Marine life area" ;86
1810 )
1811 (
1812 "You are in some sort of maintenance room for the museum. There is a
1813 switch on the wall labeled ‘BL’. There are doors to the west and north."
1814 "Maintenance room" ;87
1815 )
1816 (
1817 "You are in a classroom where school children were taught about natural
1818 history. On the blackboard is written, ‘No children allowed downstairs.’
1819 There is a door to the east with an ‘exit’ sign on it. There is another
1820 door to the west."
1821 "Classroom" ;88
1822 )
1823 (
1824 "You are at the Vermont St. subway station. A train is sitting here waiting."
1825 "Vermont station" ;89
1826 )
1827 (
1828 "You are at the Museum subway stop. A passage leads off to the north."
1829 "Museum station" ;90
1830 )
1831 (
1832 "You are in a north/south tunnel."
1833 "N/S tunnel" ;91
1834 )
1835 (
1836 "You are at the north end of a north/south tunnel. Stairs lead up and
1837 down from here. There is a garbage disposal here."
1838 "North end of N/S tunnel" ;92
1839 )
1840 (
1841 "You are at the top of some stairs near the subway station. There is
1842 a door to the west."
1843 "Top of subway stairs" ;93
1844 )
1845 (
1846 "You are at the bottom of some stairs near the subway station. There is
1847 a room to the northeast."
1848 "Bottom of subway stairs" ;94
1849 )
1850 (
1851 "You are in another computer room. There is a computer in here larger
1852 than you have ever seen. It has no manufacturers name on it, but it
1853 does have a sign that says: This machine's name is ‘endgame’. The
1854 exit is to the southwest. There is no console here on which you could
1855 type."
1856 "Endgame computer room" ;95
1857 )
1858 (
1859 "You are in a north/south hallway."
1860 "Endgame N/S hallway" ;96
1861 )
1862 (
1863 "You have reached a question room. You must answer a question correctly in
1864 order to get by. Use the ‘answer’ command to answer the question."
1865 "Question room 1" ;97
1866 )
1867 (
1868 "You are in a north/south hallway."
1869 "Endgame N/S hallway" ;98
1870 )
1871 (
1872 "You are in a second question room."
1873 "Question room 2" ;99
1874 )
1875 (
1876 "You are in a north/south hallway."
1877 "Endgame N/S hallway" ;100
1878 )
1879 (
1880 "You are in a third question room."
1881 "Question room 3" ;101
1882 )
1883 (
1884 "You are in the endgame treasure room. A door leads out to the north, and
1885 a hallway leads to the south."
1886 "Endgame treasure room" ;102
1887 )
1888 (
1889 "You are in the winner's room. A door leads back to the south."
1890 "Winner's room" ;103
1891 )
1892 (
1893 "You have reached a dead end. There is a PC on the floor here. Above
1894 it is a sign that reads:
1895 Type the ‘reset’ command to type on the PC.
1896 A hole leads north."
1897 "PC area" ;104
1898 )
1899 ))
1900
1901 (setq dun-light-rooms '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 24 25 26 27 28 58 59
1902 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
1903 77 78 79 80 81 82 83))
1904
1905 (setq dun-verblist '((die . dun-die) (ne . dun-ne) (north . dun-n)
1906 (south . dun-s) (east . dun-e) (west . dun-w)
1907 (u . dun-up) (d . dun-down) (i . dun-inven)
1908 (inventory . dun-inven) (look . dun-examine) (n . dun-n)
1909 (s . dun-s) (e . dun-e) (w . dun-w) (se . dun-se)
1910 (nw . dun-nw) (sw . dun-sw) (up . dun-up)
1911 (down . dun-down) (in . dun-in) (out . dun-out)
1912 (go . dun-go) (drop . dun-drop) (southeast . dun-se)
1913 (southwest . dun-sw) (northeast . dun-ne)
1914 (northwest . dun-nw) (save . dun-save-game)
1915 (restore . dun-restore) (long . dun-long) (dig . dun-dig)
1916 (shake . dun-shake) (wave . dun-shake)
1917 (examine . dun-examine) (describe . dun-examine)
1918 (climb . dun-climb) (eat . dun-eat) (put . dun-put)
1919 (type . dun-type) (insert . dun-put)
1920 (score . dun-score) (help . dun-help) (quit . dun-quit)
1921 (read . dun-examine) (verbose . dun-long)
1922 (urinate . dun-piss) (piss . dun-piss)
1923 (flush . dun-flush) (sleep . dun-sleep) (lie . dun-sleep)
1924 (x . dun-examine) (break . dun-break) (drive . dun-drive)
1925 (board . dun-in) (enter . dun-in) (turn . dun-turn)
1926 (press . dun-press) (push . dun-press) (swim . dun-swim)
1927 (on . dun-in) (off . dun-out) (chop . dun-break)
1928 (switch . dun-press) (cut . dun-break) (exit . dun-out)
1929 (leave . dun-out) (reset . dun-power) (flick . dun-press)
1930 (superb . dun-superb) (answer . dun-answer)
1931 (throw . dun-drop) (l . dun-examine) (take . dun-take)
1932 (get . dun-take) (feed . dun-feed)))
1933
1934 (setq dun-inbus nil)
1935 (setq dun-nomail nil)
1936 (setq dun-ignore '(the to at))
1937 (setq dun-mode 'moby)
1938 (setq dun-sauna-level 0)
1939
1940 (defconst north 0)
1941 (defconst south 1)
1942 (defconst east 2)
1943 (defconst west 3)
1944 (defconst northeast 4)
1945 (defconst southeast 5)
1946 (defconst northwest 6)
1947 (defconst southwest 7)
1948 (defconst up 8)
1949 (defconst down 9)
1950 (defconst in 10)
1951 (defconst out 11)
1952
1953 (setq dungeon-map '(
1954 ; no so ea we ne se nw sw up do in ot
1955 ( 96 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;0
1956 ( -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;1
1957 ( -1 -1 3 1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;2
1958 ( -1 -1 -1 2 4 6 -1 -1 -1 -1 -1 -1 ) ;3
1959 ( -1 -1 -1 -1 5 -1 -1 3 -1 -1 -1 -1 ) ;4
1960 ( -1 -1 -1 -1 255 -1 -1 4 -1 -1 255 -1 ) ;5
1961 ( -1 -1 -1 -1 -1 7 3 -1 -1 -1 -1 -1 ) ;6
1962 ( -1 -1 -1 -1 -1 255 6 27 -1 -1 -1 -1 ) ;7
1963 ( 255 5 9 10 -1 -1 -1 5 -1 -1 -1 5 ) ;8
1964 ( -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 ) ;9
1965 ( -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;10
1966 ( -1 8 -1 58 -1 -1 -1 -1 -1 -1 -1 -1 ) ;11
1967 ( -1 -1 13 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;12
1968 ( 15 -1 14 12 -1 -1 -1 -1 -1 -1 -1 -1 ) ;13
1969 ( -1 -1 -1 13 -1 -1 -1 -1 -1 -1 -1 -1 ) ;14
1970 ( -1 13 16 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;15
1971 ( -1 -1 -1 15 -1 -1 -1 -1 -1 17 16 -1 ) ;16
1972 ( -1 -1 17 17 17 17 255 17 255 17 -1 -1 ) ;17
1973 ( 18 18 18 18 18 -1 18 18 19 18 -1 -1 ) ;18
1974 ( -1 18 18 19 19 20 19 19 -1 18 -1 -1 ) ;19
1975 ( -1 -1 -1 18 -1 -1 -1 -1 -1 21 -1 -1 ) ;20
1976 ( -1 -1 -1 -1 -1 20 22 -1 -1 -1 -1 -1 ) ;21
1977 ( 18 18 18 18 16 18 23 18 18 18 18 18 ) ;22
1978 ( -1 255 -1 -1 -1 19 -1 -1 -1 -1 -1 -1 ) ;23
1979 ( 23 25 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;24
1980 ( 24 255 -1 -1 -1 -1 -1 -1 -1 -1 255 -1 ) ;25
1981 (255 28 -1 -1 -1 -1 -1 -1 -1 -1 255 -1 ) ;26
1982 ( -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 ) ;27
1983 ( 26 255 -1 -1 -1 -1 -1 -1 -1 -1 255 -1 ) ;28
1984 ( -1 -1 30 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;29
1985 ( -1 -1 31 29 -1 -1 -1 -1 -1 -1 -1 -1 ) ;30
1986 ( 32 33 -1 30 -1 -1 -1 -1 -1 -1 -1 -1 ) ;31
1987 ( -1 31 -1 255 -1 -1 -1 -1 -1 34 -1 -1 ) ;32
1988 ( 31 -1 -1 -1 -1 -1 -1 -1 -1 35 -1 -1 ) ;33
1989 ( -1 35 -1 -1 -1 -1 -1 -1 32 37 -1 -1 ) ;34
1990 ( 34 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;35
1991 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;36
1992 ( -1 -1 -1 -1 -1 -1 -1 38 34 -1 -1 -1 ) ;37
1993 ( -1 -1 40 41 37 -1 -1 39 -1 -1 -1 -1 ) ;38
1994 ( -1 -1 -1 -1 38 -1 -1 -1 -1 -1 -1 -1 ) ;39
1995 ( -1 -1 -1 38 -1 -1 -1 -1 42 -1 -1 -1 ) ;40
1996 ( -1 -1 38 -1 -1 -1 -1 -1 -1 43 -1 -1 ) ;41
1997 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 40 -1 -1 ) ;42
1998 ( 44 -1 46 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;43
1999 ( -1 43 45 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;44
2000 ( -1 46 -1 44 -1 -1 -1 -1 -1 -1 -1 -1 ) ;45
2001 ( 45 -1 -1 43 -1 -1 -1 -1 -1 255 -1 -1 ) ;46
2002 ( 48 50 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;47
2003 ( 49 47 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;48
2004 ( -1 48 -1 -1 -1 -1 -1 -1 52 -1 -1 -1 ) ;49
2005 ( 47 51 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;50
2006 ( 50 104 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;51
2007 ( -1 -1 -1 -1 -1 -1 -1 -1 53 49 -1 -1 ) ;52
2008 ( -1 -1 -1 -1 -1 -1 -1 -1 54 52 -1 -1 ) ;53
2009 ( -1 -1 -1 -1 55 -1 -1 -1 -1 53 -1 -1 ) ;54
2010 ( -1 -1 -1 -1 56 -1 -1 54 -1 -1 -1 54 ) ;55
2011 ( -1 -1 -1 -1 -1 -1 -1 55 -1 31 -1 -1 ) ;56
2012 ( -1 -1 32 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;57
2013 ( 59 -1 11 -1 -1 -1 -1 -1 -1 -1 255 255) ;58
2014 ( 60 58 63 -1 -1 -1 255 -1 -1 -1 255 255) ;59
2015 ( 61 59 64 -1 -1 -1 -1 -1 -1 -1 255 255) ;60
2016 ( 62 60 65 -1 -1 -1 -1 -1 -1 -1 255 255) ;61
2017 ( -1 61 66 -1 -1 -1 -1 -1 -1 -1 255 255) ;62
2018 ( 64 -1 67 59 -1 -1 -1 -1 -1 -1 255 255) ;63
2019 ( 65 63 68 60 -1 -1 -1 -1 -1 -1 255 255) ;64
2020 ( 66 64 69 61 -1 -1 -1 -1 -1 -1 255 255) ;65
2021 ( -1 65 70 62 -1 -1 -1 -1 -1 -1 255 255) ;66
2022 ( 68 -1 71 63 -1 -1 -1 -1 -1 -1 255 255) ;67
2023 ( 69 67 72 64 -1 -1 -1 -1 -1 -1 255 255) ;68
2024 ( 70 68 73 65 -1 -1 -1 -1 -1 -1 255 255) ;69
2025 ( -1 69 74 66 -1 -1 -1 -1 -1 -1 255 255) ;70
2026 ( 72 -1 75 67 -1 -1 -1 -1 -1 -1 255 255) ;71
2027 ( 73 71 76 68 -1 -1 -1 -1 -1 -1 255 255) ;72
2028 ( 74 72 77 69 -1 -1 -1 -1 -1 -1 255 255) ;73
2029 ( -1 73 78 70 -1 -1 -1 -1 -1 -1 255 255) ;74
2030 ( 76 -1 79 71 -1 -1 -1 -1 -1 -1 255 255) ;75
2031 ( 77 75 80 72 -1 -1 -1 -1 -1 -1 255 255) ;76
2032 ( 78 76 81 73 -1 -1 -1 -1 -1 -1 255 255) ;77
2033 ( -1 77 82 74 -1 -1 -1 -1 -1 -1 255 255) ;78
2034 ( 80 -1 -1 75 -1 -1 -1 -1 -1 -1 255 255) ;79
2035 ( 81 79 255 76 -1 -1 -1 -1 -1 -1 255 255) ;80
2036 ( 82 80 -1 77 -1 -1 -1 -1 -1 -1 255 255) ;81
2037 ( -1 81 -1 78 -1 -1 -1 -1 -1 -1 255 255) ;82
2038 ( 84 -1 -1 -1 -1 59 -1 -1 -1 -1 255 255) ;83
2039 ( -1 83 85 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;84
2040 ( 86 -1 87 84 -1 -1 -1 -1 -1 -1 -1 -1 ) ;85
2041 ( -1 85 88 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;86
2042 ( 88 -1 -1 85 -1 -1 -1 -1 -1 -1 -1 -1 ) ;87
2043 ( -1 87 255 86 -1 -1 -1 -1 -1 -1 -1 -1 ) ;88
2044 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 -1 ) ;89
2045 ( 91 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;90
2046 ( 92 90 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;91
2047 ( -1 91 -1 -1 -1 -1 -1 -1 93 94 -1 -1 ) ;92
2048 ( -1 -1 -1 88 -1 -1 -1 -1 -1 92 -1 -1 ) ;93
2049 ( -1 -1 -1 -1 95 -1 -1 -1 92 -1 -1 -1 ) ;94
2050 ( -1 -1 -1 -1 -1 -1 -1 94 -1 -1 -1 -1 ) ;95
2051 ( 97 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;96
2052 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;97
2053 ( 99 97 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;98
2054 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;99
2055 ( 101 99 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;100
2056 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;101
2057 ( 103 101 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;102
2058 ( -1 102 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;103
2059 ( 51 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;104
2060 )
2061 ; no so ea we ne se nw sw up do in ot
2062 )
2063
2064
2065 ;;; How the user references *all* objects, permanent and regular.
2066 (setq dun-objnames '(
2067 (shovel . 0)
2068 (lamp . 1)
2069 (cpu . 2) (board . 2) (card . 2) (chip . 2)
2070 (food . 3)
2071 (key . 4)
2072 (paper . 5) (slip . 5)
2073 (rms . 6) (statue . 6) (statuette . 6) (stallman . 6)
2074 (diamond . 7)
2075 (weight . 8)
2076 (life . 9) (preserver . 9)
2077 (bracelet . 10) (emerald . 10)
2078 (gold . 11)
2079 (platinum . 12)
2080 (towel . 13) (beach . 13)
2081 (axe . 14)
2082 (silver . 15)
2083 (license . 16)
2084 (coins . 17)
2085 (egg . 18)
2086 (jar . 19)
2087 (bone . 20)
2088 (acid . 21) (nitric . 21)
2089 (glycerine . 22)
2090 (ruby . 23)
2091 (amethyst . 24)
2092 (mona . 25)
2093 (bill . 26)
2094 (floppy . 27) (disk . 27)
2095
2096 (boulder . -1)
2097 (tree . -2) (trees . -2) (palm . -2)
2098 (bear . -3)
2099 (bin . -4) (bins . -4)
2100 (cabinet . -5) (computer . -5) (vax . -5) (ibm . -5)
2101 (protoplasm . -6)
2102 (dial . -7)
2103 (button . -8)
2104 (chute . -9)
2105 (painting . -10)
2106 (bed . -11)
2107 (urinal . -12)
2108 (URINE . -13)
2109 (pipes . -14) (pipe . -14)
2110 (box . -15) (slit . -15)
2111 (cable . -16) (ethernet . -16)
2112 (mail . -17) (drop . -17)
2113 (bus . -18)
2114 (gate . -19)
2115 (cliff . -20)
2116 (skeleton . -21) (dinosaur . -21)
2117 (fish . -22)
2118 (tanks . -23) (tank . -23)
2119 (switch . -24)
2120 (blackboard . -25)
2121 (disposal . -26) (garbage . -26)
2122 (ladder . -27)
2123 (subway . -28) (train . -28)
2124 (pc . -29) (drive . -29) (coconut . -30) (coconuts . -30)
2125 (lake . -32) (water . -32)
2126 ))
2127
2128 (dolist (x dun-objnames)
2129 (let (name)
2130 (setq name (concat "obj-" (prin1-to-string (car x))))
2131 (eval (list 'defconst (intern name) (cdr x)))))
2132
2133 (defconst obj-special 255)
2134
2135 ;;; The initial setup of what objects are in each room.
2136 ;;; Regular objects have whole numbers lower than 255.
2137 ;;; Objects that cannot be taken but might move and are
2138 ;;; described during room description are negative.
2139 ;;; Stuff that is described and might change are 255, and are
2140 ;;; handled specially by 'dun-describe-room.
2141
2142 (setq dun-room-objects (list nil
2143
2144 (list obj-shovel) ;; treasure-room
2145 (list obj-boulder) ;; dead-end
2146 nil nil nil
2147 (list obj-food) ;; se-nw-road
2148 (list obj-bear) ;; bear-hangout
2149 nil nil
2150 (list obj-special) ;; computer-room
2151 (list obj-lamp obj-license obj-silver);; meadow
2152 nil nil
2153 (list obj-special) ;; sauna
2154 nil
2155 (list obj-weight obj-life) ;; weight-room
2156 nil nil
2157 (list obj-rms obj-floppy) ;; thirsty-maze
2158 nil nil nil nil nil nil nil
2159 (list obj-emerald) ;; hidden-area
2160 nil
2161 (list obj-gold) ;; misty-room
2162 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2163 (list obj-towel obj-special) ;; red-room
2164 nil nil nil nil nil
2165 (list obj-box) ;; stair-landing
2166 nil nil nil
2167 (list obj-axe) ;; small-crawlspace
2168 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2169 nil nil nil nil nil
2170 (list obj-special) ;; fourth-vermont-intersection
2171 nil nil
2172 (list obj-coins) ;; fifth-oaktree-intersection
2173 nil
2174 (list obj-bus) ;; fifth-sycamore-intersection
2175 nil
2176 (list obj-bone) ;; museum-lobby
2177 nil
2178 (list obj-jar obj-special obj-ruby) ;; marine-life-area
2179 (list obj-nitric) ;; maintenance-room
2180 (list obj-glycerine) ;; classroom
2181 nil nil nil nil nil
2182 (list obj-amethyst) ;; bottom-of-subway-stairs
2183 nil nil
2184 (list obj-special) ;; question-room-1
2185 nil
2186 (list obj-special) ;; question-room-2
2187 nil
2188 (list obj-special) ;; question-room-three
2189 nil
2190 (list obj-mona) ;; winner's-room
2191 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2192 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2193 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2194 nil))
2195
2196 ;;; These are objects in a room that are only described in the
2197 ;;; room description. They are permanent.
2198
2199 (setq dun-room-silents (list nil
2200 (list obj-tree obj-coconut) ;; dead-end
2201 (list obj-tree obj-coconut) ;; e-w-dirt-road
2202 nil nil nil nil nil nil
2203 (list obj-bin) ;; mailroom
2204 (list obj-computer) ;; computer-room
2205 nil nil nil
2206 (list obj-dial) ;; sauna
2207 nil
2208 (list obj-ladder) ;; weight-room
2209 (list obj-button obj-ladder) ;; maze-button-room
2210 nil nil nil
2211 nil nil nil nil
2212 (list obj-lake) ;; lakefront-north
2213 (list obj-lake) ;; lakefront-south
2214 nil
2215 (list obj-chute) ;; cave-entrance
2216 nil nil nil nil nil
2217 (list obj-painting obj-bed) ;; bedroom
2218 (list obj-urinal obj-pipes) ;; bathroom
2219 nil nil nil nil nil nil
2220 (list obj-boulder) ;; horseshoe-boulder-room
2221 nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2222 (list obj-computer obj-cable) ;; gamma-computing-center
2223 (list obj-mail) ;; post-office
2224 (list obj-gate) ;; main-maple-intersection
2225 nil nil nil nil nil nil nil nil nil nil nil nil nil
2226 nil nil nil nil nil nil nil
2227 (list obj-cliff) ;; fifth-oaktree-intersection
2228 nil nil nil
2229 (list obj-dinosaur) ;; museum-lobby
2230 nil
2231 (list obj-fish obj-tanks) ;; marine-life-area
2232 (list obj-switch) ;; maintenance-room
2233 (list obj-blackboard) ;; classroom
2234 (list obj-train) ;; vermont-station
2235 nil nil
2236 (list obj-disposal) ;; north-end-of-n-s-tunnel
2237 nil nil
2238 (list obj-computer) ;; endgame-computer-room
2239 nil nil nil nil nil nil nil nil
2240 (list obj-pc) ;; pc-area
2241 nil nil nil nil nil nil
2242 ))
2243 (setq dun-inventory '(1))
2244
2245 ;;; Descriptions of objects, as they appear in the room description, and
2246 ;;; the inventory.
2247
2248 (setq dun-objects '(
2249 ("There is a shovel here." "A shovel") ;0
2250 ("There is a lamp nearby." "A lamp") ;1
2251 ("There is a CPU card here." "A computer board") ;2
2252 ("There is some food here." "Some food") ;3
2253 ("There is a shiny brass key here." "A brass key") ;4
2254 ("There is a slip of paper here." "A slip of paper") ;5
2255 ("There is a wax statuette of Richard Stallman here." ;6
2256 "An RMS statuette")
2257 ("There is a shimmering diamond here." "A diamond") ;7
2258 ("There is a 10 pound weight here." "A weight") ;8
2259 ("There is a life preserver here." "A life preserver");9
2260 ("There is an emerald bracelet here." "A bracelet") ;10
2261 ("There is a gold bar here." "A gold bar") ;11
2262 ("There is a platinum bar here." "A platinum bar") ;12
2263 ("There is a beach towel on the ground here." "A beach towel")
2264 ("There is an axe here." "An axe") ;14
2265 ("There is a silver bar here." "A silver bar") ;15
2266 ("There is a bus driver's license here." "A license") ;16
2267 ("There are some valuable coins here." "Some valuable coins")
2268 ("There is a jewel-encrusted egg here." "A valuable egg") ;18
2269 ("There is a glass jar here." "A glass jar") ;19
2270 ("There is a dinosaur bone here." "A bone") ;20
2271 ("There is a packet of nitric acid here." "Some nitric acid")
2272 ("There is a packet of glycerine here." "Some glycerine") ;22
2273 ("There is a valuable ruby here." "A ruby") ;23
2274 ("There is a valuable amethyst here." "An amethyst") ;24
2275 ("The Mona Lisa is here." "The Mona Lisa") ;25
2276 ("There is a 100 dollar bill here." "A $100 bill") ;26
2277 ("There is a floppy disk here." "A floppy disk") ;27
2278 )
2279 )
2280
2281 ;;; Weight of objects
2282
2283 (setq dun-object-lbs
2284 '(2 1 1 1 1 0 2 2 10 3 1 1 1 0 1 1 0 1 1 1 1 0 0 2 2 1 0 0))
2285 (setq dun-object-pts
2286 '(0 0 0 0 0 0 0 10 0 0 10 10 10 0 0 10 0 10 10 0 0 0 0 10 10 10 10 0))
2287
2288
2289 ;;; Unix representation of objects.
2290 (setq dun-objfiles '(
2291 "shovel.o" "lamp.o" "cpu.o" "food.o" "key.o" "paper.o"
2292 "rms.o" "diamond.o" "weight.o" "preserver.o" "bracelet.o"
2293 "gold.o" "platinum.o" "towel.o" "axe.o" "silver.o" "license.o"
2294 "coins.o" "egg.o" "jar.o" "bone.o" "nitric.o" "glycerine.o"
2295 "ruby.o" "amethyst.o"
2296 ))
2297
2298 ;;; These are the descriptions for the negative numbered objects from
2299 ;;; dun-room-objects
2300
2301 (setq dun-perm-objects '(
2302 nil
2303 ("There is a large boulder here.")
2304 nil
2305 ("There is a ferocious bear here!")
2306 nil
2307 nil
2308 ("There is a worthless pile of protoplasm here.")
2309 nil
2310 nil
2311 nil
2312 nil
2313 nil
2314 nil
2315 ("There is a strange smell in this room.")
2316 nil
2317 (
2318 "There is a box with a slit in it, bolted to the wall here."
2319 )
2320 nil
2321 nil
2322 ("There is a bus here.")
2323 nil
2324 nil
2325 nil
2326 ))
2327
2328
2329 ;;; These are the descriptions the user gets when regular objects are
2330 ;;; examined.
2331
2332 (setq dun-physobj-desc '(
2333 "It is a normal shovel with a price tag attached that says $19.99."
2334 "The lamp is hand-crafted by Geppetto."
2335 "The CPU board has a VAX chip on it. It seems to have
2336 2 Megabytes of RAM onboard."
2337 "It looks like some kind of meat. Smells pretty bad."
2338 nil
2339 "The paper says: Don't forget to type ‘help’ for help. Also, remember
2340 this word: ‘worms’"
2341 "The statuette is of the likeness of Richard Stallman, the author of the
2342 famous EMACS editor. You notice that he is not wearing any shoes."
2343 nil
2344 "You observe that the weight is heavy."
2345 "It says S. S. Minnow."
2346 nil
2347 nil
2348 nil
2349 "It has a picture of snoopy on it."
2350 nil
2351 nil
2352 "It has your picture on it!"
2353 "They are old coins from the 19th century."
2354 "It is a valuable Fabrege egg."
2355 "It is a plain glass jar."
2356 nil
2357 nil
2358 nil
2359 nil
2360 nil
2361 )
2362 )
2363
2364 ;;; These are the descriptions the user gets when non-regular objects
2365 ;;; are examined.
2366
2367 (setq dun-permobj-desc '(
2368 nil
2369 "It is just a boulder. It cannot be moved."
2370 "They are palm trees with a bountiful supply of coconuts in them."
2371 "It looks like a grizzly to me."
2372 "All of the bins are empty. Looking closely you can see that there
2373 are names written at the bottom of each bin, but most of them are
2374 faded away so that you cannot read them. You can only make out three
2375 names:
2376 Jeffrey Collier
2377 Robert Toukmond
2378 Thomas Stock
2379 "
2380 nil
2381 "It is just a garbled mess."
2382 "The dial points to a temperature scale which has long since faded away."
2383 nil
2384 nil
2385 "It is a velvet painting of Elvis Presley. It seems to be nailed to the
2386 wall, and you cannot move it."
2387 "It is a queen sized bed, with a very firm mattress."
2388 "The urinal is very clean compared with everything else in the cave. There
2389 isn't even any rust. Upon close examination you realize that the drain at the
2390 bottom is missing, and there is just a large hole leading down the
2391 pipes into nowhere. The hole is too small for a person to fit in. The
2392 flush handle is so clean that you can see your reflection in it."
2393 nil
2394 nil
2395 "The box has a slit in the top of it, and on it, in sloppy handwriting, is
2396 written: ‘For key upgrade, put key in here.’"
2397 nil
2398 "It says ‘express mail’ on it."
2399 "It is a 35 passenger bus with the company name ‘mobytours’ on it."
2400 "It is a large metal gate that is too big to climb over."
2401 "It is a HIGH cliff."
2402 "Unfortunately you do not know enough about dinosaurs to tell very much about
2403 it. It is very big, though."
2404 "The fish look like they were once quite beautiful."
2405 nil
2406 nil
2407 nil
2408 nil
2409 "It is a normal ladder that is permanently attached to the hole."
2410 "It is a passenger train that is ready to go."
2411 "It is a personal computer that has only one floppy disk drive."
2412 )
2413 )
2414
2415 (setq dun-diggables
2416 (list nil nil nil (list obj-cpu) nil nil nil nil nil nil nil
2417 nil nil nil nil nil nil nil nil nil nil ;11-20
2418 nil nil nil nil nil nil nil nil nil nil ;21-30
2419 nil nil nil nil nil nil nil nil nil nil ;31-40
2420 nil (list obj-platinum) nil nil nil nil nil nil nil nil))
2421
2422 (setq dun-room-shorts nil)
2423 (dolist (x dun-rooms)
2424 (setq dun-room-shorts
2425 (append dun-room-shorts (list (downcase
2426 (dun-space-to-hyphen
2427 (cadr x)))))))
2428
2429 (setq dun-endgame-questions '(
2430 (
2431 "What is your password on the machine called ‘pokey’?" "robert")
2432 (
2433 "What password did you use during anonymous ftp to gamma?" "foo")
2434 (
2435 "Excluding the endgame, how many places are there where you can put
2436 treasures for points?" "4" "four")
2437 (
2438 "What is your login name on the ‘endgame’ machine?" "toukmond"
2439 )
2440 (
2441 "What is the nearest whole dollar to the price of the shovel?" "20" "twenty")
2442 (
2443 "What is the name of the bus company serving the town?" "mobytours")
2444 (
2445 "Give either of the two last names in the mailroom, other than your own."
2446 "collier" "stock")
2447 (
2448 "What cartoon character is on the towel?" "snoopy")
2449 (
2450 "What is the last name of the author of EMACS?" "stallman")
2451 (
2452 "How many megabytes of memory is on the CPU board for the Vax?" "2")
2453 (
2454 "Which street in town is named after a U.S. state?" "vermont")
2455 (
2456 "How many pounds did the weight weigh?" "ten" "10")
2457 (
2458 "Name the STREET which runs right over the subway stop." "fourth" "4" "4th")
2459 (
2460 "How many corners are there in town (excluding the one with the Post Office)?"
2461 "24" "twentyfour" "twenty-four")
2462 (
2463 "What type of bear was hiding your key?" "grizzly")
2464 (
2465 "Name either of the two objects you found by digging." "cpu" "card" "vax"
2466 "board" "platinum")
2467 (
2468 "What network protocol is used between pokey and gamma?" "tcp/ip" "ip" "tcp")
2469 ))
2470
2471 (let (a)
2472 (setq a 0)
2473 (dolist (x dun-room-shorts)
2474 (eval (list 'defconst (intern x) a))
2475 (setq a (+ a 1))))
2476
2477
2478
2479 ;;;;
2480 ;;;; This section defines the UNIX emulation functions for dunnet.
2481 ;;;;
2482
2483 (defun dun-unix-parse (args)
2484 (interactive "*p")
2485 (beginning-of-line)
2486 (let (beg esign)
2487 (setq beg (+ (point) 2))
2488 (end-of-line)
2489 (if (and (not (= beg (point)))
2490 (string= "$" (buffer-substring (- beg 2) (- beg 1))))
2491 (progn
2492 (setq line (downcase (buffer-substring beg (point))))
2493 (princ line)
2494 (if (eq (dun-parse2 nil dun-unix-verbs line) -1)
2495 (progn
2496 (if (setq esign (string-match "=" line))
2497 (dun-doassign line esign)
2498 (dun-mprinc (car line-list))
2499 (dun-mprincl ": not found.")))))
2500 (goto-char (point-max))
2501 (dun-mprinc "\n"))
2502 (if (eq dungeon-mode 'unix)
2503 (progn
2504 (dun-fix-screen)
2505 (dun-mprinc "$ ")))))
2506
2507 (defun dun-doassign (line esign)
2508 (if (not dun-wizard)
2509 (let (passwd)
2510 (dun-mprinc "Enter wizard password: ")
2511 (setq passwd (dun-read-line))
2512 (if (not dun-batch-mode)
2513 (dun-mprinc "\n"))
2514 (if (string= passwd "moby")
2515 (progn
2516 (setq dun-wizard t)
2517 (dun-doassign line esign))
2518 (dun-mprincl "Incorrect.")))
2519
2520 (let (varname epoint afterq i value)
2521 (setq varname (replace-regexp-in-string " " "" (substring line 0 esign)))
2522
2523 (if (or (= (length varname) 0) (< (- (length line) esign) 2))
2524 (progn
2525 (dun-mprinc line)
2526 (dun-mprincl " : not found."))
2527
2528 (if (not (setq epoint (string-match ")" line)))
2529 (if (string= (substring line (1+ esign) (+ esign 2))
2530 "\"")
2531 (progn
2532 (setq afterq (substring line (+ esign 2)))
2533 (setq epoint (+
2534 (string-match "\"" afterq)
2535 (+ esign 3))))
2536
2537 (if (not (setq epoint (string-match " " line)))
2538 (setq epoint (length line))))
2539 (setq epoint (1+ epoint))
2540 (while (and
2541 (not (= epoint (length line)))
2542 (setq i (string-match ")" (substring line epoint))))
2543 (setq epoint (+ epoint i 1))))
2544 (setq value (substring line (1+ esign) epoint))
2545 (dun-eval varname value)))))
2546
2547 (defun dun-eval (varname value)
2548 (let (eval-error)
2549 (switch-to-buffer (get-buffer-create "*dungeon-eval*"))
2550 (erase-buffer)
2551 (insert "(setq ")
2552 (insert varname)
2553 (insert " ")
2554 (insert value)
2555 (insert ")")
2556 (setq eval-error nil)
2557 (condition-case nil
2558 (eval-buffer)
2559 (error (setq eval-error t)))
2560 (kill-buffer (current-buffer))
2561 (switch-to-buffer "*dungeon*")
2562 (if eval-error
2563 (dun-mprincl "Invalid syntax."))))
2564
2565
2566 (defun dun-unix-interface ()
2567 (dun-login)
2568 (if dun-logged-in
2569 (progn
2570 (setq dungeon-mode 'unix)
2571 (define-key dun-mode-map "\r" 'dun-unix-parse)
2572 (dun-mprinc "$ "))))
2573
2574 (defun dun-login ()
2575 (let (tries username password)
2576 (setq tries 4)
2577 (while (and (not dun-logged-in) (> (setq tries (- tries 1)) 0))
2578 (dun-mprinc "\n\nUNIX System V, Release 2.2 (pokey)\n\nlogin: ")
2579 (setq username (dun-read-line))
2580 (if (not dun-batch-mode)
2581 (dun-mprinc "\n"))
2582 (dun-mprinc "password: ")
2583 (setq password (dun-read-line))
2584 (if (not dun-batch-mode)
2585 (dun-mprinc "\n"))
2586 (if (or (not (string= username "toukmond"))
2587 (not (string= password "robert")))
2588 (dun-mprincl "login incorrect")
2589 (setq dun-logged-in t)
2590 (dun-mprincl "
2591 Welcome to Unix\n
2592 Please clean up your directories. The filesystem is getting full.
2593 Our tcp/ip link to gamma is a little flaky, but seems to work.
2594 The current version of ftp can only send files from your home
2595 directory, and deletes them after they are sent! Be careful.
2596
2597 Note: Restricted bourne shell in use.\n")))
2598 (setq dungeon-mode 'dungeon)))
2599
2600 (defun dun-ls (args)
2601 (if (car args)
2602 (let (ocdpath ocdroom)
2603 (setq ocdpath dun-cdpath)
2604 (setq ocdroom dun-cdroom)
2605 (if (not (eq (dun-cd args) -2))
2606 (dun-ls nil))
2607 (setq dun-cdpath ocdpath)
2608 (setq dun-cdroom ocdroom))
2609 (if (= dun-cdroom -10)
2610 (dun-ls-inven))
2611 (if (= dun-cdroom -2)
2612 (dun-ls-rooms))
2613 (if (= dun-cdroom -3)
2614 (dun-ls-root))
2615 (if (= dun-cdroom -4)
2616 (dun-ls-usr))
2617 (if (> dun-cdroom 0)
2618 (dun-ls-room))))
2619
2620 (defun dun-ls-root ()
2621 (dun-mprincl "total 4
2622 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2623 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..
2624 drwxr-xr-x 3 root staff 2048 Jan 1 1970 usr
2625 drwxr-xr-x 3 root staff 2048 Jan 1 1970 rooms"))
2626
2627 (defun dun-ls-usr ()
2628 (dun-mprincl "total 4
2629 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2630 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..
2631 drwxr-xr-x 3 toukmond restricted 512 Jan 1 1970 toukmond"))
2632
2633 (defun dun-ls-rooms ()
2634 (dun-mprincl "total 16
2635 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2636 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..")
2637 (dolist (x dun-visited)
2638 (dun-mprinc
2639 "drwxr-xr-x 3 root staff 512 Jan 1 1970 ")
2640 (dun-mprincl (nth x dun-room-shorts))))
2641
2642 (defun dun-ls-room ()
2643 (dun-mprincl "total 4
2644 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2645 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..
2646 -rwxr-xr-x 3 root staff 2048 Jan 1 1970 description")
2647 (dolist (x (nth dun-cdroom dun-room-objects))
2648 (if (and (>= x 0) (not (= x 255)))
2649 (progn
2650 (dun-mprinc "-rwxr-xr-x 1 toukmond restricted 0 Jan 1 1970 ")
2651 (dun-mprincl (nth x dun-objfiles))))))
2652
2653 (defun dun-ls-inven ()
2654 (dun-mprinc "total 467
2655 drwxr-xr-x 3 toukmond restricted 512 Jan 1 1970 .
2656 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..")
2657 (dolist (x dun-unix-verbs)
2658 (if (not (eq (car x) 'IMPOSSIBLE))
2659 (progn
2660 (dun-mprinc"
2661 -rwxr-xr-x 1 toukmond restricted 10423 Jan 1 1970 ")
2662 (dun-mprinc (car x)))))
2663 (dun-mprinc "\n")
2664 (if (not dun-uncompressed)
2665 (dun-mprincl
2666 "-rwxr-xr-x 1 toukmond restricted 0 Jan 1 1970 paper.o.Z"))
2667 (dolist (x dun-inventory)
2668 (dun-mprinc
2669 "-rwxr-xr-x 1 toukmond restricted 0 Jan 1 1970 ")
2670 (dun-mprincl (nth x dun-objfiles))))
2671
2672 (defun dun-echo (args)
2673 (let (nomore var)
2674 (setq nomore nil)
2675 (dolist (x args)
2676 (if (not nomore)
2677 (progn
2678 (if (not (string= (substring x 0 1) "$"))
2679 (progn
2680 (dun-mprinc x)
2681 (dun-mprinc " "))
2682 (setq var (intern (substring x 1)))
2683 (if (not (boundp var))
2684 (dun-mprinc " ")
2685 (if (member var dun-restricted)
2686 (progn
2687 (dun-mprinc var)
2688 (dun-mprinc ": Permission denied")
2689 (setq nomore t))
2690 (eval (list 'dun-mprinc var))
2691 (dun-mprinc " ")))))))
2692 (dun-mprinc "\n")))
2693
2694
2695 (defun dun-ftp (args)
2696 (let (host username passwd ident newlist)
2697 (if (not (car args))
2698 (dun-mprincl "ftp: hostname required on command line.")
2699 (setq host (intern (car args)))
2700 (if (not (member host '(gamma dun-endgame)))
2701 (dun-mprincl "ftp: Unknown host.")
2702 (if (eq host 'dun-endgame)
2703 (dun-mprincl "ftp: connection to endgame not allowed")
2704 (if (not dun-ethernet)
2705 (dun-mprincl "ftp: host not responding.")
2706 (dun-mprincl "Connected to gamma. FTP ver 0.9 00:00:00 01/01/70")
2707 (dun-mprinc "Username: ")
2708 (setq username (dun-read-line))
2709 (if (string= username "toukmond")
2710 (if dun-batch-mode
2711 (dun-mprincl "toukmond ftp access not allowed.")
2712 (dun-mprincl "\ntoukmond ftp access not allowed."))
2713 (if (string= username "anonymous")
2714 (if dun-batch-mode
2715 (dun-mprincl
2716 "Guest login okay, send your user ident as password.")
2717 (dun-mprincl
2718 "\nGuest login okay, send your user ident as password."))
2719 (if dun-batch-mode
2720 (dun-mprinc "Password required for ")
2721 (dun-mprinc "\nPassword required for "))
2722 (dun-mprincl username))
2723 (dun-mprinc "Password: ")
2724 (setq ident (dun-read-line))
2725 (if (not (string= username "anonymous"))
2726 (if dun-batch-mode
2727 (dun-mprincl "Login failed.")
2728 (dun-mprincl "\nLogin failed."))
2729 (if (= (length ident) 0)
2730 (if dun-batch-mode
2731 (dun-mprincl "Password is required.")
2732 (dun-mprincl "\nPassword is required."))
2733 (if dun-batch-mode
2734 (dun-mprincl
2735 "Guest login okay, user access restrictions apply.")
2736 (dun-mprincl
2737 "\nGuest login okay, user access restrictions apply."))
2738 (dun-ftp-commands)
2739 (setq newlist
2740 '("What password did you use during anonymous ftp to gamma?"))
2741 (setq newlist (append newlist (list ident)))
2742 (rplaca (nthcdr 1 dun-endgame-questions) newlist))))))))))
2743
2744 (defun dun-ftp-commands ()
2745 (setq dun-exitf nil)
2746 (let (line)
2747 (while (not dun-exitf)
2748 (dun-mprinc "ftp> ")
2749 (setq line (dun-read-line))
2750 (if
2751 (eq
2752 (dun-parse2 nil
2753 '((type . dun-ftptype) (binary . dun-bin) (bin . dun-bin)
2754 (send . dun-send) (put . dun-send) (quit . dun-ftpquit)
2755 (help . dun-ftphelp)(ascii . dun-fascii)
2756 ) line)
2757 -1)
2758 (dun-mprincl "No such command. Try help.")))
2759 (setq dun-ftptype 'ascii)))
2760
2761 (defun dun-ftptype (args)
2762 (if (not (car args))
2763 (dun-mprincl "Usage: type [binary | ascii]")
2764 (setq args (intern (car args)))
2765 (if (eq args 'binary)
2766 (dun-bin nil)
2767 (if (eq args 'ascii)
2768 (dun-fascii 'nil)
2769 (dun-mprincl "Unknown type.")))))
2770
2771 (defun dun-bin (args)
2772 (dun-mprincl "Type set to binary.")
2773 (setq dun-ftptype 'binary))
2774
2775 (defun dun-fascii (args)
2776 (dun-mprincl "Type set to ascii.")
2777 (setq dun-ftptype 'ascii))
2778
2779 (defun dun-ftpquit (args)
2780 (setq dun-exitf t))
2781
2782 (defun dun-send (args)
2783 (if (not (car args))
2784 (dun-mprincl "Usage: send <filename>")
2785 (setq args (car args))
2786 (let (counter foo)
2787 (setq foo nil)
2788 (setq counter 0)
2789
2790 ;;; User can send commands! Stupid user.
2791
2792
2793 (if (assq (intern args) dun-unix-verbs)
2794 (progn
2795 (rplaca (assq (intern args) dun-unix-verbs) 'IMPOSSIBLE)
2796 (dun-mprinc "Sending ")
2797 (dun-mprinc dun-ftptype)
2798 (dun-mprinc " file for ")
2799 (dun-mprincl args)
2800 (dun-mprincl "Transfer complete."))
2801
2802 (dolist (x dun-objfiles)
2803 (if (string= args x)
2804 (progn
2805 (if (not (member counter dun-inventory))
2806 (progn
2807 (dun-mprincl "No such file.")
2808 (setq foo t))
2809 (dun-mprinc "Sending ")
2810 (dun-mprinc dun-ftptype)
2811 (dun-mprinc " file for ")
2812 (dun-mprinc (downcase (cadr (nth counter dun-objects))))
2813 (dun-mprincl ", (0 bytes)")
2814 (if (not (eq dun-ftptype 'binary))
2815 (progn
2816 (if (not (member obj-protoplasm
2817 (nth receiving-room
2818 dun-room-objects)))
2819 (dun-replace dun-room-objects receiving-room
2820 (append (nth receiving-room
2821 dun-room-objects)
2822 (list obj-protoplasm))))
2823 (dun-remove-obj-from-inven counter))
2824 (dun-remove-obj-from-inven counter)
2825 (dun-replace dun-room-objects receiving-room
2826 (append (nth receiving-room dun-room-objects)
2827 (list counter))))
2828 (setq foo t)
2829 (dun-mprincl "Transfer complete."))))
2830 (setq counter (+ 1 counter)))
2831 (if (not foo)
2832 (dun-mprincl "No such file."))))))
2833
2834 (defun dun-ftphelp (args)
2835 (dun-mprincl
2836 "Possible commands are:\nsend quit type ascii binary help"))
2837
2838 (defun dun-uexit (args)
2839 (setq dungeon-mode 'dungeon)
2840 (dun-mprincl "\nYou step back from the console.")
2841 (define-key dun-mode-map "\r" 'dun-parse)
2842 (if (not dun-batch-mode)
2843 (dun-messages)))
2844
2845 (defun dun-pwd (args)
2846 (dun-mprincl dun-cdpath))
2847
2848 (defun dun-uncompress (args)
2849 (if (not (car args))
2850 (dun-mprincl "Usage: uncompress <filename>")
2851 (setq args (car args))
2852 (if (or dun-uncompressed
2853 (and (not (string= args "paper.o"))
2854 (not (string= args "paper.o.z"))))
2855 (dun-mprincl "Uncompress command failed.")
2856 (setq dun-uncompressed t)
2857 (setq dun-inventory (append dun-inventory (list obj-paper))))))
2858
2859 (defun dun-rlogin (args)
2860 (let (passwd)
2861 (if (not (car args))
2862 (dun-mprincl "Usage: rlogin <hostname>")
2863 (setq args (car args))
2864 (if (string= args "endgame")
2865 (dun-rlogin-endgame)
2866 (if (not (string= args "gamma"))
2867 (if (string= args "pokey")
2868 (dun-mprincl "Can't rlogin back to localhost")
2869 (dun-mprincl "No such host."))
2870 (if (not dun-ethernet)
2871 (dun-mprincl "Host not responding.")
2872 (dun-mprinc "Password: ")
2873 (setq passwd (dun-read-line))
2874 (if (not (string= passwd "worms"))
2875 (dun-mprincl "\nlogin incorrect")
2876 (dun-mprinc
2877 "\nYou begin to feel strange for a moment, and you lose your items."
2878 )
2879 (dun-replace dun-room-objects computer-room
2880 (append (nth computer-room dun-room-objects)
2881 dun-inventory))
2882 (setq dun-inventory nil)
2883 (setq dun-current-room receiving-room)
2884 (dun-uexit nil))))))))
2885
2886 (defun dun-cd (args)
2887 (let (tcdpath tcdroom path-elements room-check)
2888 (if (not (car args))
2889 (dun-mprincl "Usage: cd <path>")
2890 (setq tcdpath dun-cdpath)
2891 (setq tcdroom dun-cdroom)
2892 (setq dun-badcd nil)
2893 (condition-case nil
2894 (setq path-elements (dun-get-path (car args) nil))
2895 (error (dun-mprincl "Invalid path")
2896 (setq dun-badcd t)))
2897 (dolist (pe path-elements)
2898 (unless dun-badcd
2899 (if (not (string= pe "."))
2900 (if (string= pe "..")
2901 (progn
2902 (if (> tcdroom 0) ;In a room
2903 (progn
2904 (setq tcdpath "/rooms")
2905 (setq tcdroom -2))
2906 ;In /rooms,/usr,root
2907 (if (or
2908 (= tcdroom -2) (= tcdroom -4)
2909 (= tcdroom -3))
2910 (progn
2911 (setq tcdpath "/")
2912 (setq tcdroom -3))
2913 (if (= tcdroom -10) ;In /usr/toukmond
2914 (progn
2915 (setq tcdpath "/usr")
2916 (setq tcdroom -4))))))
2917 (if (string= pe "/")
2918 (progn
2919 (setq tcdpath "/")
2920 (setq tcdroom -3))
2921 (if (= tcdroom -4)
2922 (if (string= pe "toukmond")
2923 (progn
2924 (setq tcdpath "/usr/toukmond")
2925 (setq tcdroom -10))
2926 (dun-nosuchdir))
2927 (if (= tcdroom -10)
2928 (dun-nosuchdir)
2929 (if (> tcdroom 0)
2930 (dun-nosuchdir)
2931 (if (= tcdroom -3)
2932 (progn
2933 (if (string= pe "rooms")
2934 (progn
2935 (setq tcdpath "/rooms")
2936 (setq tcdroom -2))
2937 (if (string= pe "usr")
2938 (progn
2939 (setq tcdpath "/usr")
2940 (setq tcdroom -4))
2941 (dun-nosuchdir))))
2942 (if (= tcdroom -2)
2943 (progn
2944 (dolist (x dun-visited)
2945 (setq room-check
2946 (nth x
2947 dun-room-shorts))
2948 (if (string= room-check pe)
2949 (progn
2950 (setq tcdpath
2951 (concat "/rooms/" room-check))
2952 (setq tcdroom x))))
2953 (if (= tcdroom -2)
2954 (dun-nosuchdir)))))))))))))
2955 (if (not dun-badcd)
2956 (progn
2957 (setq dun-cdpath tcdpath)
2958 (setq dun-cdroom tcdroom)
2959 0)
2960 -2))))
2961
2962 (defun dun-nosuchdir ()
2963 (dun-mprincl "No such directory.")
2964 (setq dun-badcd t))
2965
2966 (defun dun-cat (args)
2967 (let (doto checklist)
2968 (if (not (setq args (car args)))
2969 (dun-mprincl "Usage: cat <ascii-file-name>")
2970 (if (string-match "/" args)
2971 (dun-mprincl "cat: only files in current directory allowed.")
2972 (if (and (> dun-cdroom 0) (string= args "description"))
2973 (dun-mprincl (car (nth dun-cdroom dun-rooms)))
2974 (if (setq doto (string-match "\\.o" args))
2975 (progn
2976 (if (= dun-cdroom -10)
2977 (setq checklist dun-inventory)
2978 (setq checklist (nth dun-cdroom dun-room-objects)))
2979 (if (not (member (cdr
2980 (assq (intern
2981 (substring args 0 doto))
2982 dun-objnames))
2983 checklist))
2984 (dun-mprincl "File not found.")
2985 (dun-mprincl "Ascii files only.")))
2986 (if (assq (intern args) dun-unix-verbs)
2987 (dun-mprincl "Ascii files only.")
2988 (dun-mprincl "File not found."))))))))
2989
2990 (defun dun-rlogin-endgame ()
2991 (if (not (= (dun-score nil) 90))
2992 (dun-mprincl
2993 "You have not achieved enough points to connect to endgame.")
2994 (dun-mprincl"\nWelcome to the endgame. You are a truly noble adventurer.")
2995 (setq dun-current-room treasure-room)
2996 (setq dun-endgame t)
2997 (dun-replace dun-room-objects endgame-treasure-room (list obj-bill))
2998 (dun-uexit nil)))
2999
3000
3001 (setq tloc (+ 60 (random 18)))
3002 (dun-replace dun-room-objects tloc
3003 (append (nth tloc dun-room-objects) (list 18)))
3004
3005 (setq tcomb (+ 100 (random 899)))
3006 (setq dun-combination (prin1-to-string tcomb))
3007
3008 ;;;;
3009 ;;;; This section defines the DOS emulation functions for dunnet
3010 ;;;;
3011
3012 (defun dun-dos-parse (args)
3013 (interactive "*p")
3014 (beginning-of-line)
3015 (let (beg)
3016 (setq beg (+ (point) 3))
3017 (end-of-line)
3018 (if (not (= beg (point)))
3019 (let (line)
3020 (setq line (downcase (buffer-substring beg (point))))
3021 (princ line)
3022 (if (eq (dun-parse2 nil dun-dos-verbs line) -1)
3023 (progn
3024 (sleep-for 1)
3025 (dun-mprincl "Bad command or file name"))))
3026 (goto-char (point-max))
3027 (dun-mprinc "\n"))
3028 (if (eq dungeon-mode 'dos)
3029 (progn
3030 (dun-fix-screen)
3031 (dun-dos-prompt)))))
3032
3033 (defun dun-dos-interface ()
3034 (dun-dos-boot-msg)
3035 (setq dungeon-mode 'dos)
3036 (define-key dun-mode-map "\r" 'dun-dos-parse)
3037 (dun-dos-prompt))
3038
3039 (defun dun-dos-type (args)
3040 (sleep-for 2)
3041 (if (setq args (car args))
3042 (if (string= args "foo.txt")
3043 (dun-dos-show-combination)
3044 (if (string= args "command.com")
3045 (dun-mprincl "Cannot type binary files")
3046 (dun-mprinc "File not found - ")
3047 (dun-mprincl (upcase args))))
3048 (dun-mprincl "Must supply file name")))
3049
3050 (defun dun-dos-invd (args)
3051 (sleep-for 1)
3052 (dun-mprincl "Invalid drive specification"))
3053
3054 (defun dun-dos-dir (args)
3055 (sleep-for 1)
3056 (if (or (not (setq args (car args))) (string= args "\\"))
3057 (dun-mprincl "
3058 Volume in drive A is FOO
3059 Volume Serial Number is 1A16-08C9
3060 Directory of A:\\
3061
3062 COMMAND COM 47845 04-09-91 2:00a
3063 FOO TXT 40 01-20-93 1:01a
3064 2 file(s) 47845 bytes
3065 1065280 bytes free
3066 ")
3067 (dun-mprincl "
3068 Volume in drive A is FOO
3069 Volume Serial Number is 1A16-08C9
3070 Directory of A:\\
3071
3072 File not found")))
3073
3074
3075 (defun dun-dos-prompt ()
3076 (dun-mprinc "A> "))
3077
3078 (defun dun-dos-boot-msg ()
3079 (sleep-for 3)
3080 (dun-mprinc "Current time is ")
3081 (dun-mprincl (format-time-string "%H:%M:%S"))
3082 (dun-mprinc "Enter new time: ")
3083 (dun-read-line)
3084 (if (not dun-batch-mode)
3085 (dun-mprinc "\n")))
3086
3087 (defun dun-dos-spawn (args)
3088 (sleep-for 1)
3089 (dun-mprincl "Cannot spawn subshell"))
3090
3091 (defun dun-dos-exit (args)
3092 (setq dungeon-mode 'dungeon)
3093 (dun-mprincl "\nYou power down the machine and step back.")
3094 (define-key dun-mode-map "\r" 'dun-parse)
3095 (if (not dun-batch-mode)
3096 (dun-messages)))
3097
3098 (defun dun-dos-no-disk ()
3099 (sleep-for 3)
3100 (dun-mprincl "Boot sector not found"))
3101
3102
3103 (defun dun-dos-show-combination ()
3104 (sleep-for 2)
3105 (dun-mprinc "\nThe combination is ")
3106 (dun-mprinc dun-combination)
3107 (dun-mprinc ".\n"))
3108
3109 (defun dun-dos-nil (args))
3110
3111
3112 ;;;;
3113 ;;;; This section defines the save and restore game functions for dunnet.
3114 ;;;;
3115
3116 (defun dun-save-game (filename)
3117 (if (not (setq filename (car filename)))
3118 (dun-mprincl "You must supply a filename for the save.")
3119 (if (file-exists-p filename)
3120 (delete-file filename))
3121 (setq dun-numsaves (1+ dun-numsaves))
3122 (dun-make-save-buffer)
3123 (dun-save-val "dun-current-room")
3124 (dun-save-val "dun-computer")
3125 (dun-save-val "dun-combination")
3126 (dun-save-val "dun-visited")
3127 (dun-save-val "dun-diggables")
3128 (dun-save-val "dun-key-level")
3129 (dun-save-val "dun-floppy")
3130 (dun-save-val "dun-numsaves")
3131 (dun-save-val "dun-numcmds")
3132 (dun-save-val "dun-logged-in")
3133 (dun-save-val "dungeon-mode")
3134 (dun-save-val "dun-jar")
3135 (dun-save-val "dun-lastdir")
3136 (dun-save-val "dun-black")
3137 (dun-save-val "dun-nomail")
3138 (dun-save-val "dun-unix-verbs")
3139 (dun-save-val "dun-hole")
3140 (dun-save-val "dun-uncompressed")
3141 (dun-save-val "dun-ethernet")
3142 (dun-save-val "dun-sauna-level")
3143 (dun-save-val "dun-room-objects")
3144 (dun-save-val "dun-room-silents")
3145 (dun-save-val "dun-inventory")
3146 (dun-save-val "dun-endgame-questions")
3147 (dun-save-val "dun-endgame")
3148 (dun-save-val "dun-cdroom")
3149 (dun-save-val "dun-cdpath")
3150 (dun-save-val "dun-correct-answer")
3151 (dun-save-val "dun-inbus")
3152 (if (dun-compile-save-out filename)
3153 (dun-mprincl "Error saving to file.")
3154 (dun-do-logfile 'save nil)
3155 (switch-to-buffer "*dungeon*")
3156 (princ "")
3157 (dun-mprincl "Done."))))
3158
3159 (defun dun-make-save-buffer ()
3160 (switch-to-buffer (get-buffer-create "*save-dungeon*"))
3161 (erase-buffer))
3162
3163 (defun dun-compile-save-out (filename)
3164 (let (ferror)
3165 (setq ferror nil)
3166 (condition-case nil
3167 (dun-rot13)
3168 (error (setq ferror t)))
3169 (if (not ferror)
3170 (progn
3171 (goto-char (point-min))))
3172 (condition-case nil
3173 (write-region 1 (point-max) filename nil 1)
3174 (error (setq ferror t)))
3175 (kill-buffer (current-buffer))
3176 ferror))
3177
3178
3179 (defun dun-save-val (varname)
3180 (let (value)
3181 (setq varname (intern varname))
3182 (setq value (eval varname))
3183 (dun-minsert "(setq ")
3184 (dun-minsert varname)
3185 (dun-minsert " ")
3186 (if (or (listp value)
3187 (symbolp value))
3188 (dun-minsert "'"))
3189 (if (stringp value)
3190 (dun-minsert "\""))
3191 (dun-minsert value)
3192 (if (stringp value)
3193 (dun-minsert "\""))
3194 (dun-minsertl ")")))
3195
3196
3197 (defun dun-restore (args)
3198 (let (file)
3199 (if (not (setq file (car args)))
3200 (dun-mprincl "You must supply a filename.")
3201 (if (not (dun-load-d file))
3202 (dun-mprincl "Could not load restore file.")
3203 (dun-mprincl "Done.")
3204 (setq room 0)))))
3205
3206
3207 (defun dun-do-logfile (type how)
3208 (let (ferror newscore)
3209 (setq ferror nil)
3210 (switch-to-buffer (get-buffer-create "*score*"))
3211 (erase-buffer)
3212 (condition-case nil
3213 (insert-file-contents dun-log-file)
3214 (error (setq ferror t)))
3215 (unless ferror
3216 (goto-char (point-max))
3217 (dun-minsert (current-time-string))
3218 (dun-minsert " ")
3219 (dun-minsert (user-login-name))
3220 (dun-minsert " ")
3221 (if (eq type 'save)
3222 (dun-minsert "saved ")
3223 (if (= (dun-endgame-score) 110)
3224 (dun-minsert "won ")
3225 (if (not how)
3226 (dun-minsert "quit ")
3227 (dun-minsert "killed by ")
3228 (dun-minsert how)
3229 (dun-minsert " "))))
3230 (dun-minsert "at ")
3231 (dun-minsert (cadr (nth (abs room) dun-rooms)))
3232 (dun-minsert ". score: ")
3233 (if (> (dun-endgame-score) 0)
3234 (dun-minsert (setq newscore (+ 90 (dun-endgame-score))))
3235 (dun-minsert (setq newscore (dun-reg-score))))
3236 (dun-minsert " saves: ")
3237 (dun-minsert dun-numsaves)
3238 (dun-minsert " commands: ")
3239 (dun-minsert dun-numcmds)
3240 (dun-minsert "\n")
3241 (write-region 1 (point-max) dun-log-file nil 1))
3242 (kill-buffer (current-buffer))))
3243
3244
3245 ;;;;
3246 ;;;; These are functions, and function re-definitions so that dungeon can
3247 ;;;; be run in batch mode.
3248
3249
3250 (defun dun-batch-mprinc (arg)
3251 (if (stringp arg)
3252 (send-string-to-terminal arg)
3253 (send-string-to-terminal (prin1-to-string arg))))
3254
3255
3256 (defun dun-batch-mprincl (arg)
3257 (if (stringp arg)
3258 (progn
3259 (send-string-to-terminal arg)
3260 (send-string-to-terminal "\n"))
3261 (send-string-to-terminal (prin1-to-string arg))
3262 (send-string-to-terminal "\n")))
3263
3264 (defun dun-batch-parse (dun-ignore dun-verblist line)
3265 (setq line-list (dun-listify-string (concat line " ")))
3266 (dun-doverb dun-ignore dun-verblist (car line-list) (cdr line-list)))
3267
3268 (defun dun-batch-parse2 (dun-ignore dun-verblist line)
3269 (setq line-list (dun-listify-string2 (concat line " ")))
3270 (dun-doverb dun-ignore dun-verblist (car line-list) (cdr line-list)))
3271
3272 (defun dun-batch-read-line ()
3273 (read-from-minibuffer "" nil dungeon-batch-map))
3274
3275
3276 (defun dun-batch-loop ()
3277 (setq dun-dead nil)
3278 (setq room 0)
3279 (while (not dun-dead)
3280 (if (eq dungeon-mode 'dungeon)
3281 (progn
3282 (if (not (= room dun-current-room))
3283 (progn
3284 (dun-describe-room dun-current-room)
3285 (setq room dun-current-room)))
3286 (dun-mprinc ">")
3287 (setq line (downcase (dun-read-line)))
3288 (if (eq (dun-vparse dun-ignore dun-verblist line) -1)
3289 (dun-mprinc "I don't understand that.\n"))))))
3290
3291 (defun dun-batch-dos-interface ()
3292 (dun-dos-boot-msg)
3293 (setq dungeon-mode 'dos)
3294 (while (eq dungeon-mode 'dos)
3295 (dun-dos-prompt)
3296 (setq line (downcase (dun-read-line)))
3297 (if (eq (dun-parse2 nil dun-dos-verbs line) -1)
3298 (progn
3299 (sleep-for 1)
3300 (dun-mprincl "Bad command or file name"))))
3301 (goto-char (point-max))
3302 (dun-mprinc "\n"))
3303
3304 (defun dun-batch-unix-interface ()
3305 (dun-login)
3306 (if dun-logged-in
3307 (progn
3308 (setq dungeon-mode 'unix)
3309 (while (eq dungeon-mode 'unix)
3310 (dun-mprinc "$ ")
3311 (setq line (downcase (dun-read-line)))
3312 (if (eq (dun-parse2 nil dun-unix-verbs line) -1)
3313 (let (esign)
3314 (if (setq esign (string-match "=" line))
3315 (dun-doassign line esign)
3316 (dun-mprinc (car line-list))
3317 (dun-mprincl ": not found.")))))
3318 (goto-char (point-max))
3319 (dun-mprinc "\n"))))
3320
3321 (defun dungeon-nil (arg)
3322 "noop"
3323 (interactive "*p")
3324 nil)
3325
3326 (defun dun-batch-dungeon ()
3327 (load "dun-batch")
3328 (setq dun-visited '(27))
3329 (dun-mprinc "\n")
3330 (dun-batch-loop))
3331
3332 (unless (not noninteractive)
3333 (fset 'dun-mprinc 'dun-batch-mprinc)
3334 (fset 'dun-mprincl 'dun-batch-mprincl)
3335 (fset 'dun-vparse 'dun-batch-parse)
3336 (fset 'dun-parse2 'dun-batch-parse2)
3337 (fset 'dun-read-line 'dun-batch-read-line)
3338 (fset 'dun-dos-interface 'dun-batch-dos-interface)
3339 (fset 'dun-unix-interface 'dun-batch-unix-interface)
3340 (dun-mprinc "\n")
3341 (setq dun-batch-mode t)
3342 (dun-batch-loop))
3343
3344 (provide 'dunnet)
3345
3346 ;;; dunnet.el ends here
3347
3348 ;; Local Variables:
3349 ;; byte-compile-warnings: (not free-vars lexical)
3350 ;; End: