Spelling fixes
[emacs.git] / lisp / play / dunnet.el
blob2f4536c0820a0efbca7cc75519932a93834b43f7
1 ;;; dunnet.el --- text adventure for Emacs
3 ;; Copyright (C) 1992-1993, 2001-2015 Free Software Foundation, Inc.
5 ;; Author: Ron Schnell <ronnie@driver-aces.com>
6 ;; Created: 25 Jul 1992
7 ;; Version: 2.01
8 ;; Keywords: games
10 ;; This file is part of GNU Emacs.
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.
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.
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/>.
25 ;;; Commentary:
27 ;; This game can be run in batch mode. To do this, use:
28 ;; emacs -batch -l dunnet
30 ;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31 ;;; The log file should be set for your system, and it must
32 ;;; be writable by all.
34 ;;; Code:
36 (defgroup dunnet nil
37 "Text adventure for Emacs."
38 :prefix "dun-"
39 :group 'games)
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)
46 ;;;; Mode definitions for interactive mode
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))
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))
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 ">")))))
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))
94 ;;;;
95 ;;;; This section contains all of the verbs and commands.
96 ;;;;
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.
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")))
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."))))
133 ;;; There is a special object in the room. This object's description,
134 ;;; or lack thereof, depends on certain conditions.
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.")))
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."))
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")))))
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))))
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))))))))
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))
213 (defun dun-quit (args)
214 (dun-die nil))
216 ;;; Print every object in player's inventory. Special case for the jar,
217 ;;; as we must also print what is in it.
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))))))))))
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")
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.")))))))))
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))))))))
281 ;;; Dropping certain things causes things to happen.
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)))))
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.")))))
310 (if (and (= objnum obj-weight) (= dun-current-room maze-button-room))
311 (dun-mprincl "A passageway opens.")))
313 ;;; Give long description of current room, or an object.
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.")))))))))
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)))))))
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")))
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))
412 ;;; We try to take an object that is untakable. Print a message
413 ;;; depending on what it is.
415 (defun dun-try-take (obj)
416 (dun-mprinc "You cannot take that."))
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)))))
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."))
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.")))))
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))))))
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)))))))))
494 (defun dun-put-objs (obj1 obj2)
495 (if (and (= obj2 obj-drop) (not dun-nomail))
496 (setq obj2 obj-chute))
498 (if (= obj2 obj-disposal) (setq obj2 obj-chute))
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!"))
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."))
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.")))))))))))
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))))
568 ;;; Various movement directions
570 (defun dun-n (args)
571 (dun-move north))
573 (defun dun-s (args)
574 (dun-move south))
576 (defun dun-e (args)
577 (dun-move east))
579 (defun dun-w (args)
580 (dun-move west))
582 (defun dun-ne (args)
583 (dun-move northeast))
585 (defun dun-se (args)
586 (dun-move southeast))
588 (defun dun-nw (args)
589 (dun-move northwest))
591 (defun dun-sw (args)
592 (dun-move southwest))
594 (defun dun-up (args)
595 (dun-move up))
597 (defun dun-down (args)
598 (dun-move down))
600 (defun dun-in (args)
601 (dun-move in))
603 (defun dun-out (args)
604 (dun-move out))
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")))
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.
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)))))))
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.
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.
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."))))
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.
681 (dun-die "a bear"))
682 (dun-mprincl "You can't go that way.")))
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)))
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.")))
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.")))
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)))
711 (if (= dun-current-room classroom)
712 (dun-mprincl "The door is locked."))
714 (if (or (= dun-current-room lakefront-north)
715 (= dun-current-room lakefront-south))
716 (dun-swim nil))
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")))
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.")))
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)))))
777 (defun dun-long (args)
778 (setq dun-mode "long"))
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)))
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))))))))
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))))))
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"))))
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))))))))
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)))))
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'"))))
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.
907 - If you have a lamp, it is always lit.
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.
919 - You can save your game with the 'save' command, and use restore it
920 with the 'restore' command.
922 - There are no limits on lengths of object names.
924 - Directions are: north,south,east,west,northeast,southeast,northwest,
925 southwest,up,down,in,out.
927 - These can be abbreviated: n,s,e,w,ne,se,nw,sw,u,d,in,out.
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.
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!
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
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)))
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))))))
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.")))
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.
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)))))))))
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.")))
1020 (defun dun-superb (args)
1021 (setq dun-mode 'dun-superb))
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))
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))
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.")))))
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))))
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))))
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."))))))
1099 ;;;;
1100 ;;;; This section defines various utility functions used
1101 ;;;; by dunnet.
1102 ;;;;
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.
1108 (defun dun-doverb (dun-ignore dun-verblist verb rest)
1109 (if (not verb)
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)))))))
1119 ;;; Function to take a string and change it into a list of lowercase words.
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))
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))
1145 (defun dun-replace (list n number)
1146 (rplaca (nthcdr n list) number))
1149 ;;; Get the first non-ignored word from a list.
1151 (defun dun-firstword (list)
1152 (if (not (car list))
1154 (while (and list (member (intern (car list)) dun-ignore))
1155 (setq list (cdr list)))
1156 (car list)))
1158 (defun dun-firstwordl (list)
1159 (if (not (car list))
1161 (while (and list (member (intern (car list)) dun-ignore))
1162 (setq list (cdr list)))
1163 list))
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.
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)))
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)))
1178 ;;; Read a line, in window mode
1180 (defun dun-read-line ()
1181 (let (line)
1182 (setq line (read-string ""))
1183 (dun-mprinc line) line))
1185 ;;; Insert something into the window buffer
1187 (defun dun-minsert (string)
1188 (if (stringp string)
1189 (insert string)
1190 (insert (prin1-to-string string))))
1192 ;;; Print something out, in window mode
1194 (defun dun-mprinc (string)
1195 (if (stringp string)
1196 (insert string)
1197 (insert (prin1-to-string string))))
1199 ;;; In window mode, keep screen from jumping by keeping last line at
1200 ;;; the bottom of the screen.
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))
1208 ;;; Insert something into the buffer, followed by newline.
1210 (defun dun-minsertl (string)
1211 (dun-minsert string)
1212 (dun-minsert "\n"))
1214 ;;; Print something, followed by a newline.
1216 (defun dun-mprincl (string)
1217 (dun-mprinc string)
1218 (dun-mprinc "\n"))
1220 ;;; Function which will get an object number given the list of
1221 ;;; words in the command, except for the verb.
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))))))
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)
1238 result)))
1240 ;;; Take a short room description, and change spaces and slashes to dashes.
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)))
1251 ;;; Given a unix style pathname, build a list of path components (recursive)
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)))))))))
1266 ;;; Is a string a member of a string list?
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))
1275 ;;; Function to put objects in the treasure room. Also prints current
1276 ;;; score to let user know he has scored.
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))))
1286 ;;; Load an encrypted file, and eval it.
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))
1306 ;;; Functions to remove an object either from a room, or from inventory.
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)))
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)))
1325 (let ((i 0) (lower "abcdefghijklmnopqrstuvwxyz") upper)
1326 (setq dun-translate-table (make-vector 256 0))
1327 (while (< i 256)
1328 (aset dun-translate-table i i)
1329 (setq i (1+ i)))
1330 (setq lower (concat lower lower))
1331 (setq upper (upcase lower))
1332 (setq i 0)
1333 (while (< i 26)
1334 (aset dun-translate-table (+ ?a i) (aref lower (+ i 13)))
1335 (aset dun-translate-table (+ ?A i) (aref upper (+ i 13)))
1336 (setq i (1+ i))))
1338 (defun dun-rot13 ()
1339 (let (str len (i 0))
1340 (setq str (buffer-substring (point-min) (point-max)))
1341 (setq len (length str))
1342 (while (< i len)
1343 (aset str i (aref dun-translate-table (aref str i)))
1344 (setq i (1+ i)))
1345 (erase-buffer)
1346 (insert str)))
1348 ;;;;
1349 ;;;; This section defines the globals that are used in dunnet.
1350 ;;;;
1351 ;;;; IMPORTANT
1352 ;;;; All globals which can change must be saved from 'save-game. Add
1353 ;;;; all new globals to bottom of file.
1355 (setq dun-visited '(27))
1356 (setq dun-current-room 1)
1357 (setq dun-exitf nil)
1358 (setq dun-badcd nil)
1359 (define-obsolete-variable-alias 'dungeon-mode-map 'dun-mode-map "22.1")
1360 (define-key dun-mode-map "\r" 'dun-parse)
1361 (defvar dungeon-batch-map (make-keymap))
1362 (if (string= (substring emacs-version 0 2) "18")
1363 (let (n)
1364 (setq n 32)
1365 (while (< 0 (setq n (- n 1)))
1366 (aset dungeon-batch-map n 'dungeon-nil)))
1367 (let (n)
1368 (setq n 32)
1369 (while (< 0 (setq n (- n 1)))
1370 (aset (car (cdr dungeon-batch-map)) n 'dungeon-nil))))
1371 (define-key dungeon-batch-map "\r" 'exit-minibuffer)
1372 (define-key dungeon-batch-map "\n" 'exit-minibuffer)
1373 (setq dun-computer nil)
1374 (setq dun-floppy nil)
1375 (setq dun-key-level 0)
1376 (setq dun-hole nil)
1377 (setq dun-correct-answer nil)
1378 (setq dun-lastdir 0)
1379 (setq dun-numsaves 0)
1380 (setq dun-jar nil)
1381 (setq dun-dead nil)
1382 (setq room 0)
1383 (setq dun-numcmds 0)
1384 (setq dun-wizard nil)
1385 (setq dun-endgame-question nil)
1386 (setq dun-logged-in nil)
1387 (setq dungeon-mode 'dungeon)
1388 (setq dun-unix-verbs '((ls . dun-ls) (ftp . dun-ftp) (echo . dun-echo)
1389 (exit . dun-uexit) (cd . dun-cd) (pwd . dun-pwd)
1390 (rlogin . dun-rlogin) (ssh . dun-rlogin)
1391 (uncompress . dun-uncompress) (cat . dun-cat)))
1393 (setq dun-dos-verbs '((dir . dun-dos-dir) (type . dun-dos-type)
1394 (exit . dun-dos-exit) (command . dun-dos-spawn)
1395 (b: . dun-dos-invd) (c: . dun-dos-invd)
1396 (a: . dun-dos-nil)))
1399 (setq dun-batch-mode nil)
1401 (setq dun-cdpath "/usr/toukmond")
1402 (setq dun-cdroom -10)
1403 (setq dun-uncompressed nil)
1404 (setq dun-ethernet t)
1405 (setq dun-restricted
1406 '(dun-room-objects dungeon-map dun-rooms
1407 dun-room-silents dun-combination))
1408 (setq dun-ftptype 'ascii)
1409 (setq dun-endgame nil)
1410 (setq dun-gottago t)
1411 (setq dun-black nil)
1413 (setq dun-rooms '(
1415 "You are in the treasure room. A door leads out to the north."
1416 "Treasure room"
1419 "You are at a dead end of a dirt road. The road goes to the east.
1420 In the distance you can see that it will eventually fork off. The
1421 trees here are very tall royal palms, and they are spaced equidistant
1422 from each other."
1423 "Dead end"
1426 "You are on the continuation of a dirt road. There are more trees on
1427 both sides of you. The road continues to the east and west."
1428 "E/W Dirt road"
1431 "You are at a fork of two passages, one to the northeast, and one to the
1432 southeast. The ground here seems very soft. You can also go back west."
1433 "Fork"
1436 "You are on a northeast/southwest road."
1437 "NE/SW road"
1440 "You are at the end of the road. There is a building in front of you
1441 to the northeast, and the road leads back to the southwest."
1442 "Building front"
1445 "You are on a southeast/northwest road."
1446 "SE/NW road"
1449 "You are standing at the end of a road. A passage leads back to the
1450 northwest."
1451 "Bear hangout"
1454 "You are in the hallway of an old building. There are rooms to the east
1455 and west, and doors leading out to the north and south."
1456 "Old Building hallway"
1459 "You are in a mailroom. There are many bins where the mail is usually
1460 kept. The exit is to the west."
1461 "Mailroom"
1464 "You are in a computer room. It seems like most of the equipment has
1465 been removed. There is a VAX 11/780 in front of you, however, with
1466 one of the cabinets wide open. A sign on the front of the machine
1467 says: This VAX is named 'pokey'. To type on the console, use the
1468 'type' command. The exit is to the east."
1469 "Computer room"
1472 "You are in a meadow in the back of an old building. A small path leads
1473 to the west, and a door leads to the south."
1474 "Meadow"
1477 "You are in a round, stone room with a door to the east. There
1478 is a sign on the wall that reads: 'receiving room'."
1479 "Receiving room"
1482 "You are at the south end of a hallway that leads to the north. There
1483 are rooms to the east and west."
1484 "Northbound Hallway"
1487 "You are in a sauna. There is nothing in the room except for a dial
1488 on the wall. A door leads out to west."
1489 "Sauna"
1492 "You are at the end of a north/south hallway. You can go back to the south,
1493 or off to a room to the east."
1494 "End of N/S Hallway"
1497 "You are in an old weight room. All of the equipment is either destroyed
1498 or completely broken. There is a door out to the west, and there is a ladder
1499 leading down a hole in the floor."
1500 "Weight room" ;16
1503 "You are in a maze of twisty little passages, all alike.
1504 There is a button on the ground here."
1505 "Maze button room"
1508 "You are in a maze of little twisty passages, all alike."
1509 "Maze"
1512 "You are in a maze of thirsty little passages, all alike."
1513 "Maze" ;19
1516 "You are in a maze of twenty little passages, all alike."
1517 "Maze"
1520 "You are in a daze of twisty little passages, all alike."
1521 "Maze" ;21
1524 "You are in a maze of twisty little cabbages, all alike."
1525 "Maze" ;22
1528 "You are in a reception area for a health and fitness center. The place
1529 appears to have been recently ransacked, and nothing is left. There is
1530 a door out to the south, and a crawlspace to the southeast."
1531 "Reception area"
1534 "You are outside a large building to the north which used to be a health
1535 and fitness center. A road leads to the south."
1536 "Health Club front"
1539 "You are at the north side of a lake. On the other side you can see
1540 a road which leads to a cave. The water appears very deep."
1541 "Lakefront North"
1544 "You are at the south side of a lake. A road goes to the south."
1545 "Lakefront South"
1548 "You are in a well-hidden area off to the side of a road. Back to the
1549 northeast through the brush you can see the bear hangout."
1550 "Hidden area"
1553 "The entrance to a cave is to the south. To the north, a road leads
1554 towards a deep lake. On the ground nearby there is a chute, with a sign
1555 that says 'put treasures here for points'."
1556 "Cave Entrance" ;28
1559 "You are in a misty, humid room carved into a mountain.
1560 To the north is the remains of a rockslide. To the east, a small
1561 passage leads away into the darkness." ;29
1562 "Misty Room"
1565 "You are in an east/west passageway. The walls here are made of
1566 multicolored rock and are quite beautiful."
1567 "Cave E/W passage" ;30
1570 "You are at the junction of two passages. One goes north/south, and
1571 the other goes west."
1572 "N/S/W Junction" ;31
1575 "You are at the north end of a north/south passageway. There are stairs
1576 leading down from here. There is also a door leading west."
1577 "North end of cave passage" ;32
1580 "You are at the south end of a north/south passageway. There is a hole
1581 in the floor here, into which you could probably fit."
1582 "South end of cave passage" ;33
1585 "You are in what appears to be a worker's bedroom. There is a queen-
1586 sized bed in the middle of the room, and a painting hanging on the
1587 wall. A door leads to another room to the south, and stairways
1588 lead up and down."
1589 "Bedroom" ;34
1592 "You are in a bathroom built for workers in the cave. There is a
1593 urinal hanging on the wall, and some exposed pipes on the opposite
1594 wall where a sink used to be. To the north is a bedroom."
1595 "Bathroom" ;35
1598 "This is a marker for the urinal. User will not see this, but it
1599 is a room that can contain objects."
1600 "Urinal" ;36
1603 "You are at the northeast end of a northeast/southwest passageway.
1604 Stairs lead up out of sight."
1605 "NE end of NE/SW cave passage" ;37
1608 "You are at the junction of northeast/southwest and east/west passages."
1609 "NE/SW-E/W junction" ;38
1612 "You are at the southwest end of a northeast/southwest passageway."
1613 "SW end of NE/SW cave passage" ;39
1616 "You are at the east end of an E/W passage. There are stairs leading up
1617 to a room above."
1618 "East end of E/W cave passage" ;40
1621 "You are at the west end of an E/W passage. There is a hole on the ground
1622 which leads down out of sight."
1623 "West end of E/W cave passage" ;41
1626 "You are in a room which is bare, except for a horseshoe shaped boulder
1627 in the center. Stairs lead down from here." ;42
1628 "Horseshoe boulder room"
1631 "You are in a room which is completely empty. Doors lead out to the north
1632 and east."
1633 "Empty room" ;43
1636 "You are in an empty room. Interestingly enough, the stones in this
1637 room are painted blue. Doors lead out to the east and south." ;44
1638 "Blue room"
1641 "You are in an empty room. Interestingly enough, the stones in this
1642 room are painted yellow. Doors lead out to the south and west." ;45
1643 "Yellow room"
1646 "You are in an empty room. Interestingly enough, the stones in this room
1647 are painted red. Doors lead out to the west and north."
1648 "Red room" ;46
1651 "You are in the middle of a long north/south hallway." ;47
1652 "Long n/s hallway"
1655 "You are 3/4 of the way towards the north end of a long north/south hallway."
1656 "3/4 north" ;48
1659 "You are at the north end of a long north/south hallway. There are stairs
1660 leading upwards."
1661 "North end of long hallway" ;49
1664 "You are 3/4 of the way towards the south end of a long north/south hallway."
1665 "3/4 south" ;50
1668 "You are at the south end of a long north/south hallway. There is a hole
1669 to the south."
1670 "South end of long hallway" ;51
1673 "You are at a landing in a stairwell which continues up and down."
1674 "Stair landing" ;52
1677 "You are at the continuation of an up/down staircase."
1678 "Up/down staircase" ;53
1681 "You are at the top of a staircase leading down. A crawlway leads off
1682 to the northeast."
1683 "Top of staircase." ;54
1686 "You are in a crawlway that leads northeast or southwest."
1687 "NE crawlway" ;55
1690 "You are in a small crawlspace. There is a hole in the ground here, and
1691 a small passage back to the southwest."
1692 "Small crawlspace" ;56
1695 "You are in the Gamma Computing Center. An IBM 3090/600s is whirring
1696 away in here. There is an ethernet cable coming out of one of the units,
1697 and going through the ceiling. There is no console here on which you
1698 could type."
1699 "Gamma computing center" ;57
1702 "You are near the remains of a post office. There is a mail drop on the
1703 face of the building, but you cannot see where it leads. A path leads
1704 back to the east, and a road leads to the north."
1705 "Post office" ;58
1708 "You are at the intersection of Main Street and Maple Ave. Main street
1709 runs north and south, and Maple Ave runs east off into the distance.
1710 If you look north and east you can see many intersections, but all of
1711 the buildings that used to stand here are gone. Nothing remains except
1712 street signs.
1713 There is a road to the northwest leading to a gate that guards a building."
1714 "Main-Maple intersection" ;59
1717 "You are at the intersection of Main Street and the west end of Oaktree Ave."
1718 "Main-Oaktree intersection" ;60
1721 "You are at the intersection of Main Street and the west end of Vermont Ave."
1722 "Main-Vermont intersection" ;61
1725 "You are at the north end of Main Street at the west end of Sycamore Ave." ;62
1726 "Main-Sycamore intersection"
1729 "You are at the south end of First Street at Maple Ave." ;63
1730 "First-Maple intersection"
1733 "You are at the intersection of First Street and Oaktree Ave." ;64
1734 "First-Oaktree intersection"
1737 "You are at the intersection of First Street and Vermont Ave." ;65
1738 "First-Vermont intersection"
1741 "You are at the north end of First Street at Sycamore Ave." ;66
1742 "First-Sycamore intersection"
1745 "You are at the south end of Second Street at Maple Ave." ;67
1746 "Second-Maple intersection"
1749 "You are at the intersection of Second Street and Oaktree Ave." ;68
1750 "Second-Oaktree intersection"
1753 "You are at the intersection of Second Street and Vermont Ave." ;69
1754 "Second-Vermont intersection"
1757 "You are at the north end of Second Street at Sycamore Ave." ;70
1758 "Second-Sycamore intersection"
1761 "You are at the south end of Third Street at Maple Ave." ;71
1762 "Third-Maple intersection"
1765 "You are at the intersection of Third Street and Oaktree Ave." ;72
1766 "Third-Oaktree intersection"
1769 "You are at the intersection of Third Street and Vermont Ave." ;73
1770 "Third-Vermont intersection"
1773 "You are at the north end of Third Street at Sycamore Ave." ;74
1774 "Third-Sycamore intersection"
1777 "You are at the south end of Fourth Street at Maple Ave." ;75
1778 "Fourth-Maple intersection"
1781 "You are at the intersection of Fourth Street and Oaktree Ave." ;76
1782 "Fourth-Oaktree intersection"
1785 "You are at the intersection of Fourth Street and Vermont Ave." ;77
1786 "Fourth-Vermont intersection"
1789 "You are at the north end of Fourth Street at Sycamore Ave." ;78
1790 "Fourth-Sycamore intersection"
1793 "You are at the south end of Fifth Street at the east end of Maple Ave." ;79
1794 "Fifth-Maple intersection"
1797 "You are at the intersection of Fifth Street and the east end of Oaktree Ave.
1798 There is a cliff off to the east."
1799 "Fifth-Oaktree intersection" ;80
1802 "You are at the intersection of Fifth Street and the east end of Vermont Ave."
1803 "Fifth-Vermont intersection" ;81
1806 "You are at the north end of Fifth Street and the east end of Sycamore Ave."
1807 "Fifth-Sycamore intersection" ;82
1810 "You are in front of the Museum of Natural History. A door leads into
1811 the building to the north, and a road leads to the southeast."
1812 "Museum entrance" ;83
1815 "You are in the main lobby for the Museum of Natural History. In the center
1816 of the room is the huge skeleton of a dinosaur. Doors lead out to the
1817 south and east."
1818 "Museum lobby" ;84
1821 "You are in the geological display. All of the objects that used to
1822 be on display are missing. There are rooms to the east, west, and
1823 north."
1824 "Geological display" ;85
1827 "You are in the marine life area. The room is filled with fish tanks,
1828 which are filled with dead fish that have apparently died due to
1829 starvation. Doors lead out to the south and east."
1830 "Marine life area" ;86
1833 "You are in some sort of maintenance room for the museum. There is a
1834 switch on the wall labeled 'BL'. There are doors to the west and north."
1835 "Maintenance room" ;87
1838 "You are in a classroom where school children were taught about natural
1839 history. On the blackboard is written, 'No children allowed downstairs.'
1840 There is a door to the east with an 'exit' sign on it. There is another
1841 door to the west."
1842 "Classroom" ;88
1845 "You are at the Vermont St. subway station. A train is sitting here waiting."
1846 "Vermont station" ;89
1849 "You are at the Museum subway stop. A passage leads off to the north."
1850 "Museum station" ;90
1853 "You are in a north/south tunnel."
1854 "N/S tunnel" ;91
1857 "You are at the north end of a north/south tunnel. Stairs lead up and
1858 down from here. There is a garbage disposal here."
1859 "North end of N/S tunnel" ;92
1862 "You are at the top of some stairs near the subway station. There is
1863 a door to the west."
1864 "Top of subway stairs" ;93
1867 "You are at the bottom of some stairs near the subway station. There is
1868 a room to the northeast."
1869 "Bottom of subway stairs" ;94
1872 "You are in another computer room. There is a computer in here larger
1873 than you have ever seen. It has no manufacturers name on it, but it
1874 does have a sign that says: This machine's name is 'endgame'. The
1875 exit is to the southwest. There is no console here on which you could
1876 type."
1877 "Endgame computer room" ;95
1880 "You are in a north/south hallway."
1881 "Endgame N/S hallway" ;96
1884 "You have reached a question room. You must answer a question correctly in
1885 order to get by. Use the 'answer' command to answer the question."
1886 "Question room 1" ;97
1889 "You are in a north/south hallway."
1890 "Endgame N/S hallway" ;98
1893 "You are in a second question room."
1894 "Question room 2" ;99
1897 "You are in a north/south hallway."
1898 "Endgame N/S hallway" ;100
1901 "You are in a third question room."
1902 "Question room 3" ;101
1905 "You are in the endgame treasure room. A door leads out to the north, and
1906 a hallway leads to the south."
1907 "Endgame treasure room" ;102
1910 "You are in the winner's room. A door leads back to the south."
1911 "Winner's room" ;103
1914 "You have reached a dead end. There is a PC on the floor here. Above
1915 it is a sign that reads:
1916 Type the 'reset' command to type on the PC.
1917 A hole leads north."
1918 "PC area" ;104
1922 (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
1923 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
1924 77 78 79 80 81 82 83))
1926 (setq dun-verblist '((die . dun-die) (ne . dun-ne) (north . dun-n)
1927 (south . dun-s) (east . dun-e) (west . dun-w)
1928 (u . dun-up) (d . dun-down) (i . dun-inven)
1929 (inventory . dun-inven) (look . dun-examine) (n . dun-n)
1930 (s . dun-s) (e . dun-e) (w . dun-w) (se . dun-se)
1931 (nw . dun-nw) (sw . dun-sw) (up . dun-up)
1932 (down . dun-down) (in . dun-in) (out . dun-out)
1933 (go . dun-go) (drop . dun-drop) (southeast . dun-se)
1934 (southwest . dun-sw) (northeast . dun-ne)
1935 (northwest . dun-nw) (save . dun-save-game)
1936 (restore . dun-restore) (long . dun-long) (dig . dun-dig)
1937 (shake . dun-shake) (wave . dun-shake)
1938 (examine . dun-examine) (describe . dun-examine)
1939 (climb . dun-climb) (eat . dun-eat) (put . dun-put)
1940 (type . dun-type) (insert . dun-put)
1941 (score . dun-score) (help . dun-help) (quit . dun-quit)
1942 (read . dun-examine) (verbose . dun-long)
1943 (urinate . dun-piss) (piss . dun-piss)
1944 (flush . dun-flush) (sleep . dun-sleep) (lie . dun-sleep)
1945 (x . dun-examine) (break . dun-break) (drive . dun-drive)
1946 (board . dun-in) (enter . dun-in) (turn . dun-turn)
1947 (press . dun-press) (push . dun-press) (swim . dun-swim)
1948 (on . dun-in) (off . dun-out) (chop . dun-break)
1949 (switch . dun-press) (cut . dun-break) (exit . dun-out)
1950 (leave . dun-out) (reset . dun-power) (flick . dun-press)
1951 (superb . dun-superb) (answer . dun-answer)
1952 (throw . dun-drop) (l . dun-examine) (take . dun-take)
1953 (get . dun-take) (feed . dun-feed)))
1955 (setq dun-inbus nil)
1956 (setq dun-nomail nil)
1957 (setq dun-ignore '(the to at))
1958 (setq dun-mode 'moby)
1959 (setq dun-sauna-level 0)
1961 (defconst north 0)
1962 (defconst south 1)
1963 (defconst east 2)
1964 (defconst west 3)
1965 (defconst northeast 4)
1966 (defconst southeast 5)
1967 (defconst northwest 6)
1968 (defconst southwest 7)
1969 (defconst up 8)
1970 (defconst down 9)
1971 (defconst in 10)
1972 (defconst out 11)
1974 (setq dungeon-map '(
1975 ; no so ea we ne se nw sw up do in ot
1976 ( 96 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;0
1977 ( -1 -1 2 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;1
1978 ( -1 -1 3 1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;2
1979 ( -1 -1 -1 2 4 6 -1 -1 -1 -1 -1 -1 ) ;3
1980 ( -1 -1 -1 -1 5 -1 -1 3 -1 -1 -1 -1 ) ;4
1981 ( -1 -1 -1 -1 255 -1 -1 4 -1 -1 255 -1 ) ;5
1982 ( -1 -1 -1 -1 -1 7 3 -1 -1 -1 -1 -1 ) ;6
1983 ( -1 -1 -1 -1 -1 255 6 27 -1 -1 -1 -1 ) ;7
1984 ( 255 5 9 10 -1 -1 -1 5 -1 -1 -1 5 ) ;8
1985 ( -1 -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 ) ;9
1986 ( -1 -1 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;10
1987 ( -1 8 -1 58 -1 -1 -1 -1 -1 -1 -1 -1 ) ;11
1988 ( -1 -1 13 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;12
1989 ( 15 -1 14 12 -1 -1 -1 -1 -1 -1 -1 -1 ) ;13
1990 ( -1 -1 -1 13 -1 -1 -1 -1 -1 -1 -1 -1 ) ;14
1991 ( -1 13 16 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;15
1992 ( -1 -1 -1 15 -1 -1 -1 -1 -1 17 16 -1 ) ;16
1993 ( -1 -1 17 17 17 17 255 17 255 17 -1 -1 ) ;17
1994 ( 18 18 18 18 18 -1 18 18 19 18 -1 -1 ) ;18
1995 ( -1 18 18 19 19 20 19 19 -1 18 -1 -1 ) ;19
1996 ( -1 -1 -1 18 -1 -1 -1 -1 -1 21 -1 -1 ) ;20
1997 ( -1 -1 -1 -1 -1 20 22 -1 -1 -1 -1 -1 ) ;21
1998 ( 18 18 18 18 16 18 23 18 18 18 18 18 ) ;22
1999 ( -1 255 -1 -1 -1 19 -1 -1 -1 -1 -1 -1 ) ;23
2000 ( 23 25 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;24
2001 ( 24 255 -1 -1 -1 -1 -1 -1 -1 -1 255 -1 ) ;25
2002 (255 28 -1 -1 -1 -1 -1 -1 -1 -1 255 -1 ) ;26
2003 ( -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 ) ;27
2004 ( 26 255 -1 -1 -1 -1 -1 -1 -1 -1 255 -1 ) ;28
2005 ( -1 -1 30 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;29
2006 ( -1 -1 31 29 -1 -1 -1 -1 -1 -1 -1 -1 ) ;30
2007 ( 32 33 -1 30 -1 -1 -1 -1 -1 -1 -1 -1 ) ;31
2008 ( -1 31 -1 255 -1 -1 -1 -1 -1 34 -1 -1 ) ;32
2009 ( 31 -1 -1 -1 -1 -1 -1 -1 -1 35 -1 -1 ) ;33
2010 ( -1 35 -1 -1 -1 -1 -1 -1 32 37 -1 -1 ) ;34
2011 ( 34 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;35
2012 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;36
2013 ( -1 -1 -1 -1 -1 -1 -1 38 34 -1 -1 -1 ) ;37
2014 ( -1 -1 40 41 37 -1 -1 39 -1 -1 -1 -1 ) ;38
2015 ( -1 -1 -1 -1 38 -1 -1 -1 -1 -1 -1 -1 ) ;39
2016 ( -1 -1 -1 38 -1 -1 -1 -1 42 -1 -1 -1 ) ;40
2017 ( -1 -1 38 -1 -1 -1 -1 -1 -1 43 -1 -1 ) ;41
2018 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 40 -1 -1 ) ;42
2019 ( 44 -1 46 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;43
2020 ( -1 43 45 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;44
2021 ( -1 46 -1 44 -1 -1 -1 -1 -1 -1 -1 -1 ) ;45
2022 ( 45 -1 -1 43 -1 -1 -1 -1 -1 255 -1 -1 ) ;46
2023 ( 48 50 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;47
2024 ( 49 47 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;48
2025 ( -1 48 -1 -1 -1 -1 -1 -1 52 -1 -1 -1 ) ;49
2026 ( 47 51 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;50
2027 ( 50 104 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;51
2028 ( -1 -1 -1 -1 -1 -1 -1 -1 53 49 -1 -1 ) ;52
2029 ( -1 -1 -1 -1 -1 -1 -1 -1 54 52 -1 -1 ) ;53
2030 ( -1 -1 -1 -1 55 -1 -1 -1 -1 53 -1 -1 ) ;54
2031 ( -1 -1 -1 -1 56 -1 -1 54 -1 -1 -1 54 ) ;55
2032 ( -1 -1 -1 -1 -1 -1 -1 55 -1 31 -1 -1 ) ;56
2033 ( -1 -1 32 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;57
2034 ( 59 -1 11 -1 -1 -1 -1 -1 -1 -1 255 255) ;58
2035 ( 60 58 63 -1 -1 -1 255 -1 -1 -1 255 255) ;59
2036 ( 61 59 64 -1 -1 -1 -1 -1 -1 -1 255 255) ;60
2037 ( 62 60 65 -1 -1 -1 -1 -1 -1 -1 255 255) ;61
2038 ( -1 61 66 -1 -1 -1 -1 -1 -1 -1 255 255) ;62
2039 ( 64 -1 67 59 -1 -1 -1 -1 -1 -1 255 255) ;63
2040 ( 65 63 68 60 -1 -1 -1 -1 -1 -1 255 255) ;64
2041 ( 66 64 69 61 -1 -1 -1 -1 -1 -1 255 255) ;65
2042 ( -1 65 70 62 -1 -1 -1 -1 -1 -1 255 255) ;66
2043 ( 68 -1 71 63 -1 -1 -1 -1 -1 -1 255 255) ;67
2044 ( 69 67 72 64 -1 -1 -1 -1 -1 -1 255 255) ;68
2045 ( 70 68 73 65 -1 -1 -1 -1 -1 -1 255 255) ;69
2046 ( -1 69 74 66 -1 -1 -1 -1 -1 -1 255 255) ;70
2047 ( 72 -1 75 67 -1 -1 -1 -1 -1 -1 255 255) ;71
2048 ( 73 71 76 68 -1 -1 -1 -1 -1 -1 255 255) ;72
2049 ( 74 72 77 69 -1 -1 -1 -1 -1 -1 255 255) ;73
2050 ( -1 73 78 70 -1 -1 -1 -1 -1 -1 255 255) ;74
2051 ( 76 -1 79 71 -1 -1 -1 -1 -1 -1 255 255) ;75
2052 ( 77 75 80 72 -1 -1 -1 -1 -1 -1 255 255) ;76
2053 ( 78 76 81 73 -1 -1 -1 -1 -1 -1 255 255) ;77
2054 ( -1 77 82 74 -1 -1 -1 -1 -1 -1 255 255) ;78
2055 ( 80 -1 -1 75 -1 -1 -1 -1 -1 -1 255 255) ;79
2056 ( 81 79 255 76 -1 -1 -1 -1 -1 -1 255 255) ;80
2057 ( 82 80 -1 77 -1 -1 -1 -1 -1 -1 255 255) ;81
2058 ( -1 81 -1 78 -1 -1 -1 -1 -1 -1 255 255) ;82
2059 ( 84 -1 -1 -1 -1 59 -1 -1 -1 -1 255 255) ;83
2060 ( -1 83 85 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;84
2061 ( 86 -1 87 84 -1 -1 -1 -1 -1 -1 -1 -1 ) ;85
2062 ( -1 85 88 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;86
2063 ( 88 -1 -1 85 -1 -1 -1 -1 -1 -1 -1 -1 ) ;87
2064 ( -1 87 255 86 -1 -1 -1 -1 -1 -1 -1 -1 ) ;88
2065 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 255 -1 ) ;89
2066 ( 91 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;90
2067 ( 92 90 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;91
2068 ( -1 91 -1 -1 -1 -1 -1 -1 93 94 -1 -1 ) ;92
2069 ( -1 -1 -1 88 -1 -1 -1 -1 -1 92 -1 -1 ) ;93
2070 ( -1 -1 -1 -1 95 -1 -1 -1 92 -1 -1 -1 ) ;94
2071 ( -1 -1 -1 -1 -1 -1 -1 94 -1 -1 -1 -1 ) ;95
2072 ( 97 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;96
2073 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;97
2074 ( 99 97 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;98
2075 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;99
2076 ( 101 99 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;100
2077 ( -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;101
2078 ( 103 101 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;102
2079 ( -1 102 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;103
2080 ( 51 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ) ;104
2082 ; no so ea we ne se nw sw up do in ot
2086 ;;; How the user references *all* objects, permanent and regular.
2087 (setq dun-objnames '(
2088 (shovel . 0)
2089 (lamp . 1)
2090 (cpu . 2) (board . 2) (card . 2) (chip . 2)
2091 (food . 3)
2092 (key . 4)
2093 (paper . 5) (slip . 5)
2094 (rms . 6) (statue . 6) (statuette . 6) (stallman . 6)
2095 (diamond . 7)
2096 (weight . 8)
2097 (life . 9) (preserver . 9)
2098 (bracelet . 10) (emerald . 10)
2099 (gold . 11)
2100 (platinum . 12)
2101 (towel . 13) (beach . 13)
2102 (axe . 14)
2103 (silver . 15)
2104 (license . 16)
2105 (coins . 17)
2106 (egg . 18)
2107 (jar . 19)
2108 (bone . 20)
2109 (acid . 21) (nitric . 21)
2110 (glycerine . 22)
2111 (ruby . 23)
2112 (amethyst . 24)
2113 (mona . 25)
2114 (bill . 26)
2115 (floppy . 27) (disk . 27)
2117 (boulder . -1)
2118 (tree . -2) (trees . -2) (palm . -2)
2119 (bear . -3)
2120 (bin . -4) (bins . -4)
2121 (cabinet . -5) (computer . -5) (vax . -5) (ibm . -5)
2122 (protoplasm . -6)
2123 (dial . -7)
2124 (button . -8)
2125 (chute . -9)
2126 (painting . -10)
2127 (bed . -11)
2128 (urinal . -12)
2129 (URINE . -13)
2130 (pipes . -14) (pipe . -14)
2131 (box . -15) (slit . -15)
2132 (cable . -16) (ethernet . -16)
2133 (mail . -17) (drop . -17)
2134 (bus . -18)
2135 (gate . -19)
2136 (cliff . -20)
2137 (skeleton . -21) (dinosaur . -21)
2138 (fish . -22)
2139 (tanks . -23) (tank . -23)
2140 (switch . -24)
2141 (blackboard . -25)
2142 (disposal . -26) (garbage . -26)
2143 (ladder . -27)
2144 (subway . -28) (train . -28)
2145 (pc . -29) (drive . -29) (coconut . -30) (coconuts . -30)
2146 (lake . -32) (water . -32)
2149 (dolist (x dun-objnames)
2150 (let (name)
2151 (setq name (concat "obj-" (prin1-to-string (car x))))
2152 (eval (list 'defconst (intern name) (cdr x)))))
2154 (defconst obj-special 255)
2156 ;;; The initial setup of what objects are in each room.
2157 ;;; Regular objects have whole numbers lower than 255.
2158 ;;; Objects that cannot be taken but might move and are
2159 ;;; described during room description are negative.
2160 ;;; Stuff that is described and might change are 255, and are
2161 ;;; handled specially by 'dun-describe-room.
2163 (setq dun-room-objects (list nil
2165 (list obj-shovel) ;; treasure-room
2166 (list obj-boulder) ;; dead-end
2167 nil nil nil
2168 (list obj-food) ;; se-nw-road
2169 (list obj-bear) ;; bear-hangout
2170 nil nil
2171 (list obj-special) ;; computer-room
2172 (list obj-lamp obj-license obj-silver);; meadow
2173 nil nil
2174 (list obj-special) ;; sauna
2176 (list obj-weight obj-life) ;; weight-room
2177 nil nil
2178 (list obj-rms obj-floppy) ;; thirsty-maze
2179 nil nil nil nil nil nil nil
2180 (list obj-emerald) ;; hidden-area
2182 (list obj-gold) ;; misty-room
2183 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2184 (list obj-towel obj-special) ;; red-room
2185 nil nil nil nil nil
2186 (list obj-box) ;; stair-landing
2187 nil nil nil
2188 (list obj-axe) ;; small-crawlspace
2189 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2190 nil nil nil nil nil
2191 (list obj-special) ;; fourth-vermont-intersection
2192 nil nil
2193 (list obj-coins) ;; fifth-oaktree-intersection
2195 (list obj-bus) ;; fifth-sycamore-intersection
2197 (list obj-bone) ;; museum-lobby
2199 (list obj-jar obj-special obj-ruby) ;; marine-life-area
2200 (list obj-nitric) ;; maintenance-room
2201 (list obj-glycerine) ;; classroom
2202 nil nil nil nil nil
2203 (list obj-amethyst) ;; bottom-of-subway-stairs
2204 nil nil
2205 (list obj-special) ;; question-room-1
2207 (list obj-special) ;; question-room-2
2209 (list obj-special) ;; question-room-three
2211 (list obj-mona) ;; winner's-room
2212 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2213 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2214 nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2215 nil))
2217 ;;; These are objects in a room that are only described in the
2218 ;;; room description. They are permanent.
2220 (setq dun-room-silents (list nil
2221 (list obj-tree obj-coconut) ;; dead-end
2222 (list obj-tree obj-coconut) ;; e-w-dirt-road
2223 nil nil nil nil nil nil
2224 (list obj-bin) ;; mailroom
2225 (list obj-computer) ;; computer-room
2226 nil nil nil
2227 (list obj-dial) ;; sauna
2229 (list obj-ladder) ;; weight-room
2230 (list obj-button obj-ladder) ;; maze-button-room
2231 nil nil nil
2232 nil nil nil nil
2233 (list obj-lake) ;; lakefront-north
2234 (list obj-lake) ;; lakefront-south
2236 (list obj-chute) ;; cave-entrance
2237 nil nil nil nil nil
2238 (list obj-painting obj-bed) ;; bedroom
2239 (list obj-urinal obj-pipes) ;; bathroom
2240 nil nil nil nil nil nil
2241 (list obj-boulder) ;; horseshoe-boulder-room
2242 nil nil nil nil nil nil nil nil nil nil nil nil nil nil
2243 (list obj-computer obj-cable) ;; gamma-computing-center
2244 (list obj-mail) ;; post-office
2245 (list obj-gate) ;; main-maple-intersection
2246 nil nil nil nil nil nil nil nil nil nil nil nil nil
2247 nil nil nil nil nil nil nil
2248 (list obj-cliff) ;; fifth-oaktree-intersection
2249 nil nil nil
2250 (list obj-dinosaur) ;; museum-lobby
2252 (list obj-fish obj-tanks) ;; marine-life-area
2253 (list obj-switch) ;; maintenance-room
2254 (list obj-blackboard) ;; classroom
2255 (list obj-train) ;; vermont-station
2256 nil nil
2257 (list obj-disposal) ;; north-end-of-n-s-tunnel
2258 nil nil
2259 (list obj-computer) ;; endgame-computer-room
2260 nil nil nil nil nil nil nil nil
2261 (list obj-pc) ;; pc-area
2262 nil nil nil nil nil nil
2264 (setq dun-inventory '(1))
2266 ;;; Descriptions of objects, as they appear in the room description, and
2267 ;;; the inventory.
2269 (setq dun-objects '(
2270 ("There is a shovel here." "A shovel") ;0
2271 ("There is a lamp nearby." "A lamp") ;1
2272 ("There is a CPU card here." "A computer board") ;2
2273 ("There is some food here." "Some food") ;3
2274 ("There is a shiny brass key here." "A brass key") ;4
2275 ("There is a slip of paper here." "A slip of paper") ;5
2276 ("There is a wax statuette of Richard Stallman here." ;6
2277 "An RMS statuette")
2278 ("There is a shimmering diamond here." "A diamond") ;7
2279 ("There is a 10 pound weight here." "A weight") ;8
2280 ("There is a life preserver here." "A life preserver");9
2281 ("There is an emerald bracelet here." "A bracelet") ;10
2282 ("There is a gold bar here." "A gold bar") ;11
2283 ("There is a platinum bar here." "A platinum bar") ;12
2284 ("There is a beach towel on the ground here." "A beach towel")
2285 ("There is an axe here." "An axe") ;14
2286 ("There is a silver bar here." "A silver bar") ;15
2287 ("There is a bus driver's license here." "A license") ;16
2288 ("There are some valuable coins here." "Some valuable coins")
2289 ("There is a jewel-encrusted egg here." "A valuable egg") ;18
2290 ("There is a glass jar here." "A glass jar") ;19
2291 ("There is a dinosaur bone here." "A bone") ;20
2292 ("There is a packet of nitric acid here." "Some nitric acid")
2293 ("There is a packet of glycerine here." "Some glycerine") ;22
2294 ("There is a valuable ruby here." "A ruby") ;23
2295 ("There is a valuable amethyst here." "An amethyst") ;24
2296 ("The Mona Lisa is here." "The Mona Lisa") ;25
2297 ("There is a 100 dollar bill here." "A $100 bill") ;26
2298 ("There is a floppy disk here." "A floppy disk") ;27
2302 ;;; Weight of objects
2304 (setq dun-object-lbs
2305 '(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))
2306 (setq dun-object-pts
2307 '(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))
2310 ;;; Unix representation of objects.
2311 (setq dun-objfiles '(
2312 "shovel.o" "lamp.o" "cpu.o" "food.o" "key.o" "paper.o"
2313 "rms.o" "diamond.o" "weight.o" "preserver.o" "bracelet.o"
2314 "gold.o" "platinum.o" "towel.o" "axe.o" "silver.o" "license.o"
2315 "coins.o" "egg.o" "jar.o" "bone.o" "nitric.o" "glycerine.o"
2316 "ruby.o" "amethyst.o"
2319 ;;; These are the descriptions for the negative numbered objects from
2320 ;;; dun-room-objects
2322 (setq dun-perm-objects '(
2324 ("There is a large boulder here.")
2326 ("There is a ferocious bear here!")
2329 ("There is a worthless pile of protoplasm here.")
2336 ("There is a strange smell in this room.")
2339 "There is a box with a slit in it, bolted to the wall here."
2343 ("There is a bus here.")
2350 ;;; These are the descriptions the user gets when regular objects are
2351 ;;; examined.
2353 (setq dun-physobj-desc '(
2354 "It is a normal shovel with a price tag attached that says $19.99."
2355 "The lamp is hand-crafted by Geppetto."
2356 "The CPU board has a VAX chip on it. It seems to have
2357 2 Megabytes of RAM onboard."
2358 "It looks like some kind of meat. Smells pretty bad."
2360 "The paper says: Don't forget to type 'help' for help. Also, remember
2361 this word: 'worms'"
2362 "The statuette is of the likeness of Richard Stallman, the author of the
2363 famous EMACS editor. You notice that he is not wearing any shoes."
2365 "You observe that the weight is heavy."
2366 "It says S. S. Minnow."
2370 "It has a picture of snoopy on it."
2373 "It has your picture on it!"
2374 "They are old coins from the 19th century."
2375 "It is a valuable Fabrege egg."
2376 "It is a plain glass jar."
2385 ;;; These are the descriptions the user gets when non-regular objects
2386 ;;; are examined.
2388 (setq dun-permobj-desc '(
2390 "It is just a boulder. It cannot be moved."
2391 "They are palm trees with a bountiful supply of coconuts in them."
2392 "It looks like a grizzly to me."
2393 "All of the bins are empty. Looking closely you can see that there
2394 are names written at the bottom of each bin, but most of them are
2395 faded away so that you cannot read them. You can only make out three
2396 names:
2397 Jeffrey Collier
2398 Robert Toukmond
2399 Thomas Stock
2402 "It is just a garbled mess."
2403 "The dial points to a temperature scale which has long since faded away."
2406 "It is a velvet painting of Elvis Presley. It seems to be nailed to the
2407 wall, and you cannot move it."
2408 "It is a queen sized bed, with a very firm mattress."
2409 "The urinal is very clean compared with everything else in the cave. There
2410 isn't even any rust. Upon close examination you realize that the drain at the
2411 bottom is missing, and there is just a large hole leading down the
2412 pipes into nowhere. The hole is too small for a person to fit in. The
2413 flush handle is so clean that you can see your reflection in it."
2416 "The box has a slit in the top of it, and on it, in sloppy handwriting, is
2417 written: 'For key upgrade, put key in here.'"
2419 "It says 'express mail' on it."
2420 "It is a 35 passenger bus with the company name 'mobytours' on it."
2421 "It is a large metal gate that is too big to climb over."
2422 "It is a HIGH cliff."
2423 "Unfortunately you do not know enough about dinosaurs to tell very much about
2424 it. It is very big, though."
2425 "The fish look like they were once quite beautiful."
2430 "It is a normal ladder that is permanently attached to the hole."
2431 "It is a passenger train that is ready to go."
2432 "It is a personal computer that has only one floppy disk drive."
2436 (setq dun-diggables
2437 (list nil nil nil (list obj-cpu) nil nil nil nil nil nil nil
2438 nil nil nil nil nil nil nil nil nil nil ;11-20
2439 nil nil nil nil nil nil nil nil nil nil ;21-30
2440 nil nil nil nil nil nil nil nil nil nil ;31-40
2441 nil (list obj-platinum) nil nil nil nil nil nil nil nil))
2443 (setq dun-room-shorts nil)
2444 (dolist (x dun-rooms)
2445 (setq dun-room-shorts
2446 (append dun-room-shorts (list (downcase
2447 (dun-space-to-hyphen
2448 (cadr x)))))))
2450 (setq dun-endgame-questions '(
2452 "What is your password on the machine called 'pokey'?" "robert")
2454 "What password did you use during anonymous ftp to gamma?" "foo")
2456 "Excluding the endgame, how many places are there where you can put
2457 treasures for points?" "4" "four")
2459 "What is your login name on the 'endgame' machine?" "toukmond"
2462 "What is the nearest whole dollar to the price of the shovel?" "20" "twenty")
2464 "What is the name of the bus company serving the town?" "mobytours")
2466 "Give either of the two last names in the mailroom, other than your own."
2467 "collier" "stock")
2469 "What cartoon character is on the towel?" "snoopy")
2471 "What is the last name of the author of EMACS?" "stallman")
2473 "How many megabytes of memory is on the CPU board for the Vax?" "2")
2475 "Which street in town is named after a U.S. state?" "vermont")
2477 "How many pounds did the weight weigh?" "ten" "10")
2479 "Name the STREET which runs right over the subway stop." "fourth" "4" "4th")
2481 "How many corners are there in town (excluding the one with the Post Office)?"
2482 "24" "twentyfour" "twenty-four")
2484 "What type of bear was hiding your key?" "grizzly")
2486 "Name either of the two objects you found by digging." "cpu" "card" "vax"
2487 "board" "platinum")
2489 "What network protocol is used between pokey and gamma?" "tcp/ip" "ip" "tcp")
2492 (let (a)
2493 (setq a 0)
2494 (dolist (x dun-room-shorts)
2495 (eval (list 'defconst (intern x) a))
2496 (setq a (+ a 1))))
2500 ;;;;
2501 ;;;; This section defines the UNIX emulation functions for dunnet.
2502 ;;;;
2504 (defun dun-unix-parse (args)
2505 (interactive "*p")
2506 (beginning-of-line)
2507 (let (beg esign)
2508 (setq beg (+ (point) 2))
2509 (end-of-line)
2510 (if (and (not (= beg (point)))
2511 (string= "$" (buffer-substring (- beg 2) (- beg 1))))
2512 (progn
2513 (setq line (downcase (buffer-substring beg (point))))
2514 (princ line)
2515 (if (eq (dun-parse2 nil dun-unix-verbs line) -1)
2516 (progn
2517 (if (setq esign (string-match "=" line))
2518 (dun-doassign line esign)
2519 (dun-mprinc (car line-list))
2520 (dun-mprincl ": not found.")))))
2521 (goto-char (point-max))
2522 (dun-mprinc "\n"))
2523 (if (eq dungeon-mode 'unix)
2524 (progn
2525 (dun-fix-screen)
2526 (dun-mprinc "$ ")))))
2528 (defun dun-doassign (line esign)
2529 (if (not dun-wizard)
2530 (let (passwd)
2531 (dun-mprinc "Enter wizard password: ")
2532 (setq passwd (dun-read-line))
2533 (if (not dun-batch-mode)
2534 (dun-mprinc "\n"))
2535 (if (string= passwd "moby")
2536 (progn
2537 (setq dun-wizard t)
2538 (dun-doassign line esign))
2539 (dun-mprincl "Incorrect.")))
2541 (let (varname epoint afterq i value)
2542 (setq varname (replace-regexp-in-string " " "" (substring line 0 esign)))
2544 (if (or (= (length varname) 0) (< (- (length line) esign) 2))
2545 (progn
2546 (dun-mprinc line)
2547 (dun-mprincl " : not found."))
2549 (if (not (setq epoint (string-match ")" line)))
2550 (if (string= (substring line (1+ esign) (+ esign 2))
2551 "\"")
2552 (progn
2553 (setq afterq (substring line (+ esign 2)))
2554 (setq epoint (+
2555 (string-match "\"" afterq)
2556 (+ esign 3))))
2558 (if (not (setq epoint (string-match " " line)))
2559 (setq epoint (length line))))
2560 (setq epoint (1+ epoint))
2561 (while (and
2562 (not (= epoint (length line)))
2563 (setq i (string-match ")" (substring line epoint))))
2564 (setq epoint (+ epoint i 1))))
2565 (setq value (substring line (1+ esign) epoint))
2566 (dun-eval varname value)))))
2568 (defun dun-eval (varname value)
2569 (let (eval-error)
2570 (switch-to-buffer (get-buffer-create "*dungeon-eval*"))
2571 (erase-buffer)
2572 (insert "(setq ")
2573 (insert varname)
2574 (insert " ")
2575 (insert value)
2576 (insert ")")
2577 (setq eval-error nil)
2578 (condition-case nil
2579 (eval-buffer)
2580 (error (setq eval-error t)))
2581 (kill-buffer (current-buffer))
2582 (switch-to-buffer "*dungeon*")
2583 (if eval-error
2584 (dun-mprincl "Invalid syntax."))))
2587 (defun dun-unix-interface ()
2588 (dun-login)
2589 (if dun-logged-in
2590 (progn
2591 (setq dungeon-mode 'unix)
2592 (define-key dun-mode-map "\r" 'dun-unix-parse)
2593 (dun-mprinc "$ "))))
2595 (defun dun-login ()
2596 (let (tries username password)
2597 (setq tries 4)
2598 (while (and (not dun-logged-in) (> (setq tries (- tries 1)) 0))
2599 (dun-mprinc "\n\nUNIX System V, Release 2.2 (pokey)\n\nlogin: ")
2600 (setq username (dun-read-line))
2601 (if (not dun-batch-mode)
2602 (dun-mprinc "\n"))
2603 (dun-mprinc "password: ")
2604 (setq password (dun-read-line))
2605 (if (not dun-batch-mode)
2606 (dun-mprinc "\n"))
2607 (if (or (not (string= username "toukmond"))
2608 (not (string= password "robert")))
2609 (dun-mprincl "login incorrect")
2610 (setq dun-logged-in t)
2611 (dun-mprincl "
2612 Welcome to Unix\n
2613 Please clean up your directories. The filesystem is getting full.
2614 Our tcp/ip link to gamma is a little flaky, but seems to work.
2615 The current version of ftp can only send files from your home
2616 directory, and deletes them after they are sent! Be careful.
2618 Note: Restricted bourne shell in use.\n")))
2619 (setq dungeon-mode 'dungeon)))
2621 (defun dun-ls (args)
2622 (if (car args)
2623 (let (ocdpath ocdroom)
2624 (setq ocdpath dun-cdpath)
2625 (setq ocdroom dun-cdroom)
2626 (if (not (eq (dun-cd args) -2))
2627 (dun-ls nil))
2628 (setq dun-cdpath ocdpath)
2629 (setq dun-cdroom ocdroom))
2630 (if (= dun-cdroom -10)
2631 (dun-ls-inven))
2632 (if (= dun-cdroom -2)
2633 (dun-ls-rooms))
2634 (if (= dun-cdroom -3)
2635 (dun-ls-root))
2636 (if (= dun-cdroom -4)
2637 (dun-ls-usr))
2638 (if (> dun-cdroom 0)
2639 (dun-ls-room))))
2641 (defun dun-ls-root ()
2642 (dun-mprincl "total 4
2643 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2644 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..
2645 drwxr-xr-x 3 root staff 2048 Jan 1 1970 usr
2646 drwxr-xr-x 3 root staff 2048 Jan 1 1970 rooms"))
2648 (defun dun-ls-usr ()
2649 (dun-mprincl "total 4
2650 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2651 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..
2652 drwxr-xr-x 3 toukmond restricted 512 Jan 1 1970 toukmond"))
2654 (defun dun-ls-rooms ()
2655 (dun-mprincl "total 16
2656 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2657 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..")
2658 (dolist (x dun-visited)
2659 (dun-mprinc
2660 "drwxr-xr-x 3 root staff 512 Jan 1 1970 ")
2661 (dun-mprincl (nth x dun-room-shorts))))
2663 (defun dun-ls-room ()
2664 (dun-mprincl "total 4
2665 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2666 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..
2667 -rwxr-xr-x 3 root staff 2048 Jan 1 1970 description")
2668 (dolist (x (nth dun-cdroom dun-room-objects))
2669 (if (and (>= x 0) (not (= x 255)))
2670 (progn
2671 (dun-mprinc "-rwxr-xr-x 1 toukmond restricted 0 Jan 1 1970 ")
2672 (dun-mprincl (nth x dun-objfiles))))))
2674 (defun dun-ls-inven ()
2675 (dun-mprinc "total 467
2676 drwxr-xr-x 3 toukmond restricted 512 Jan 1 1970 .
2677 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..")
2678 (dolist (x dun-unix-verbs)
2679 (if (not (eq (car x) 'IMPOSSIBLE))
2680 (progn
2681 (dun-mprinc"
2682 -rwxr-xr-x 1 toukmond restricted 10423 Jan 1 1970 ")
2683 (dun-mprinc (car x)))))
2684 (dun-mprinc "\n")
2685 (if (not dun-uncompressed)
2686 (dun-mprincl
2687 "-rwxr-xr-x 1 toukmond restricted 0 Jan 1 1970 paper.o.Z"))
2688 (dolist (x dun-inventory)
2689 (dun-mprinc
2690 "-rwxr-xr-x 1 toukmond restricted 0 Jan 1 1970 ")
2691 (dun-mprincl (nth x dun-objfiles))))
2693 (defun dun-echo (args)
2694 (let (nomore var)
2695 (setq nomore nil)
2696 (dolist (x args)
2697 (if (not nomore)
2698 (progn
2699 (if (not (string= (substring x 0 1) "$"))
2700 (progn
2701 (dun-mprinc x)
2702 (dun-mprinc " "))
2703 (setq var (intern (substring x 1)))
2704 (if (not (boundp var))
2705 (dun-mprinc " ")
2706 (if (member var dun-restricted)
2707 (progn
2708 (dun-mprinc var)
2709 (dun-mprinc ": Permission denied")
2710 (setq nomore t))
2711 (eval (list 'dun-mprinc var))
2712 (dun-mprinc " ")))))))
2713 (dun-mprinc "\n")))
2716 (defun dun-ftp (args)
2717 (let (host username passwd ident newlist)
2718 (if (not (car args))
2719 (dun-mprincl "ftp: hostname required on command line.")
2720 (setq host (intern (car args)))
2721 (if (not (member host '(gamma dun-endgame)))
2722 (dun-mprincl "ftp: Unknown host.")
2723 (if (eq host 'dun-endgame)
2724 (dun-mprincl "ftp: connection to endgame not allowed")
2725 (if (not dun-ethernet)
2726 (dun-mprincl "ftp: host not responding.")
2727 (dun-mprincl "Connected to gamma. FTP ver 0.9 00:00:00 01/01/70")
2728 (dun-mprinc "Username: ")
2729 (setq username (dun-read-line))
2730 (if (string= username "toukmond")
2731 (if dun-batch-mode
2732 (dun-mprincl "toukmond ftp access not allowed.")
2733 (dun-mprincl "\ntoukmond ftp access not allowed."))
2734 (if (string= username "anonymous")
2735 (if dun-batch-mode
2736 (dun-mprincl
2737 "Guest login okay, send your user ident as password.")
2738 (dun-mprincl
2739 "\nGuest login okay, send your user ident as password."))
2740 (if dun-batch-mode
2741 (dun-mprinc "Password required for ")
2742 (dun-mprinc "\nPassword required for "))
2743 (dun-mprincl username))
2744 (dun-mprinc "Password: ")
2745 (setq ident (dun-read-line))
2746 (if (not (string= username "anonymous"))
2747 (if dun-batch-mode
2748 (dun-mprincl "Login failed.")
2749 (dun-mprincl "\nLogin failed."))
2750 (if (= (length ident) 0)
2751 (if dun-batch-mode
2752 (dun-mprincl "Password is required.")
2753 (dun-mprincl "\nPassword is required."))
2754 (if dun-batch-mode
2755 (dun-mprincl
2756 "Guest login okay, user access restrictions apply.")
2757 (dun-mprincl
2758 "\nGuest login okay, user access restrictions apply."))
2759 (dun-ftp-commands)
2760 (setq newlist
2761 '("What password did you use during anonymous ftp to gamma?"))
2762 (setq newlist (append newlist (list ident)))
2763 (rplaca (nthcdr 1 dun-endgame-questions) newlist))))))))))
2765 (defun dun-ftp-commands ()
2766 (setq dun-exitf nil)
2767 (let (line)
2768 (while (not dun-exitf)
2769 (dun-mprinc "ftp> ")
2770 (setq line (dun-read-line))
2773 (dun-parse2 nil
2774 '((type . dun-ftptype) (binary . dun-bin) (bin . dun-bin)
2775 (send . dun-send) (put . dun-send) (quit . dun-ftpquit)
2776 (help . dun-ftphelp)(ascii . dun-fascii)
2777 ) line)
2779 (dun-mprincl "No such command. Try help.")))
2780 (setq dun-ftptype 'ascii)))
2782 (defun dun-ftptype (args)
2783 (if (not (car args))
2784 (dun-mprincl "Usage: type [binary | ascii]")
2785 (setq args (intern (car args)))
2786 (if (eq args 'binary)
2787 (dun-bin nil)
2788 (if (eq args 'ascii)
2789 (dun-fascii 'nil)
2790 (dun-mprincl "Unknown type.")))))
2792 (defun dun-bin (args)
2793 (dun-mprincl "Type set to binary.")
2794 (setq dun-ftptype 'binary))
2796 (defun dun-fascii (args)
2797 (dun-mprincl "Type set to ascii.")
2798 (setq dun-ftptype 'ascii))
2800 (defun dun-ftpquit (args)
2801 (setq dun-exitf t))
2803 (defun dun-send (args)
2804 (if (not (car args))
2805 (dun-mprincl "Usage: send <filename>")
2806 (setq args (car args))
2807 (let (counter foo)
2808 (setq foo nil)
2809 (setq counter 0)
2811 ;;; User can send commands! Stupid user.
2814 (if (assq (intern args) dun-unix-verbs)
2815 (progn
2816 (rplaca (assq (intern args) dun-unix-verbs) 'IMPOSSIBLE)
2817 (dun-mprinc "Sending ")
2818 (dun-mprinc dun-ftptype)
2819 (dun-mprinc " file for ")
2820 (dun-mprincl args)
2821 (dun-mprincl "Transfer complete."))
2823 (dolist (x dun-objfiles)
2824 (if (string= args x)
2825 (progn
2826 (if (not (member counter dun-inventory))
2827 (progn
2828 (dun-mprincl "No such file.")
2829 (setq foo t))
2830 (dun-mprinc "Sending ")
2831 (dun-mprinc dun-ftptype)
2832 (dun-mprinc " file for ")
2833 (dun-mprinc (downcase (cadr (nth counter dun-objects))))
2834 (dun-mprincl ", (0 bytes)")
2835 (if (not (eq dun-ftptype 'binary))
2836 (progn
2837 (if (not (member obj-protoplasm
2838 (nth receiving-room
2839 dun-room-objects)))
2840 (dun-replace dun-room-objects receiving-room
2841 (append (nth receiving-room
2842 dun-room-objects)
2843 (list obj-protoplasm))))
2844 (dun-remove-obj-from-inven counter))
2845 (dun-remove-obj-from-inven counter)
2846 (dun-replace dun-room-objects receiving-room
2847 (append (nth receiving-room dun-room-objects)
2848 (list counter))))
2849 (setq foo t)
2850 (dun-mprincl "Transfer complete."))))
2851 (setq counter (+ 1 counter)))
2852 (if (not foo)
2853 (dun-mprincl "No such file."))))))
2855 (defun dun-ftphelp (args)
2856 (dun-mprincl
2857 "Possible commands are:\nsend quit type ascii binary help"))
2859 (defun dun-uexit (args)
2860 (setq dungeon-mode 'dungeon)
2861 (dun-mprincl "\nYou step back from the console.")
2862 (define-key dun-mode-map "\r" 'dun-parse)
2863 (if (not dun-batch-mode)
2864 (dun-messages)))
2866 (defun dun-pwd (args)
2867 (dun-mprincl dun-cdpath))
2869 (defun dun-uncompress (args)
2870 (if (not (car args))
2871 (dun-mprincl "Usage: uncompress <filename>")
2872 (setq args (car args))
2873 (if (or dun-uncompressed
2874 (and (not (string= args "paper.o"))
2875 (not (string= args "paper.o.z"))))
2876 (dun-mprincl "Uncompress command failed.")
2877 (setq dun-uncompressed t)
2878 (setq dun-inventory (append dun-inventory (list obj-paper))))))
2880 (defun dun-rlogin (args)
2881 (let (passwd)
2882 (if (not (car args))
2883 (dun-mprincl "Usage: rlogin <hostname>")
2884 (setq args (car args))
2885 (if (string= args "endgame")
2886 (dun-rlogin-endgame)
2887 (if (not (string= args "gamma"))
2888 (if (string= args "pokey")
2889 (dun-mprincl "Can't rlogin back to localhost")
2890 (dun-mprincl "No such host."))
2891 (if (not dun-ethernet)
2892 (dun-mprincl "Host not responding.")
2893 (dun-mprinc "Password: ")
2894 (setq passwd (dun-read-line))
2895 (if (not (string= passwd "worms"))
2896 (dun-mprincl "\nlogin incorrect")
2897 (dun-mprinc
2898 "\nYou begin to feel strange for a moment, and you lose your items."
2900 (dun-replace dun-room-objects computer-room
2901 (append (nth computer-room dun-room-objects)
2902 dun-inventory))
2903 (setq dun-inventory nil)
2904 (setq dun-current-room receiving-room)
2905 (dun-uexit nil))))))))
2907 (defun dun-cd (args)
2908 (let (tcdpath tcdroom path-elements room-check)
2909 (if (not (car args))
2910 (dun-mprincl "Usage: cd <path>")
2911 (setq tcdpath dun-cdpath)
2912 (setq tcdroom dun-cdroom)
2913 (setq dun-badcd nil)
2914 (condition-case nil
2915 (setq path-elements (dun-get-path (car args) nil))
2916 (error (dun-mprincl "Invalid path")
2917 (setq dun-badcd t)))
2918 (dolist (pe path-elements)
2919 (unless dun-badcd
2920 (if (not (string= pe "."))
2921 (if (string= pe "..")
2922 (progn
2923 (if (> tcdroom 0) ;In a room
2924 (progn
2925 (setq tcdpath "/rooms")
2926 (setq tcdroom -2))
2927 ;In /rooms,/usr,root
2928 (if (or
2929 (= tcdroom -2) (= tcdroom -4)
2930 (= tcdroom -3))
2931 (progn
2932 (setq tcdpath "/")
2933 (setq tcdroom -3))
2934 (if (= tcdroom -10) ;In /usr/toukmond
2935 (progn
2936 (setq tcdpath "/usr")
2937 (setq tcdroom -4))))))
2938 (if (string= pe "/")
2939 (progn
2940 (setq tcdpath "/")
2941 (setq tcdroom -3))
2942 (if (= tcdroom -4)
2943 (if (string= pe "toukmond")
2944 (progn
2945 (setq tcdpath "/usr/toukmond")
2946 (setq tcdroom -10))
2947 (dun-nosuchdir))
2948 (if (= tcdroom -10)
2949 (dun-nosuchdir)
2950 (if (> tcdroom 0)
2951 (dun-nosuchdir)
2952 (if (= tcdroom -3)
2953 (progn
2954 (if (string= pe "rooms")
2955 (progn
2956 (setq tcdpath "/rooms")
2957 (setq tcdroom -2))
2958 (if (string= pe "usr")
2959 (progn
2960 (setq tcdpath "/usr")
2961 (setq tcdroom -4))
2962 (dun-nosuchdir))))
2963 (if (= tcdroom -2)
2964 (progn
2965 (dolist (x dun-visited)
2966 (setq room-check
2967 (nth x
2968 dun-room-shorts))
2969 (if (string= room-check pe)
2970 (progn
2971 (setq tcdpath
2972 (concat "/rooms/" room-check))
2973 (setq tcdroom x))))
2974 (if (= tcdroom -2)
2975 (dun-nosuchdir)))))))))))))
2976 (if (not dun-badcd)
2977 (progn
2978 (setq dun-cdpath tcdpath)
2979 (setq dun-cdroom tcdroom)
2981 -2))))
2983 (defun dun-nosuchdir ()
2984 (dun-mprincl "No such directory.")
2985 (setq dun-badcd t))
2987 (defun dun-cat (args)
2988 (let (doto checklist)
2989 (if (not (setq args (car args)))
2990 (dun-mprincl "Usage: cat <ascii-file-name>")
2991 (if (string-match "/" args)
2992 (dun-mprincl "cat: only files in current directory allowed.")
2993 (if (and (> dun-cdroom 0) (string= args "description"))
2994 (dun-mprincl (car (nth dun-cdroom dun-rooms)))
2995 (if (setq doto (string-match "\\.o" args))
2996 (progn
2997 (if (= dun-cdroom -10)
2998 (setq checklist dun-inventory)
2999 (setq checklist (nth dun-cdroom dun-room-objects)))
3000 (if (not (member (cdr
3001 (assq (intern
3002 (substring args 0 doto))
3003 dun-objnames))
3004 checklist))
3005 (dun-mprincl "File not found.")
3006 (dun-mprincl "Ascii files only.")))
3007 (if (assq (intern args) dun-unix-verbs)
3008 (dun-mprincl "Ascii files only.")
3009 (dun-mprincl "File not found."))))))))
3011 (defun dun-rlogin-endgame ()
3012 (if (not (= (dun-score nil) 90))
3013 (dun-mprincl
3014 "You have not achieved enough points to connect to endgame.")
3015 (dun-mprincl"\nWelcome to the endgame. You are a truly noble adventurer.")
3016 (setq dun-current-room treasure-room)
3017 (setq dun-endgame t)
3018 (dun-replace dun-room-objects endgame-treasure-room (list obj-bill))
3019 (dun-uexit nil)))
3022 (setq tloc (+ 60 (random 18)))
3023 (dun-replace dun-room-objects tloc
3024 (append (nth tloc dun-room-objects) (list 18)))
3026 (setq tcomb (+ 100 (random 899)))
3027 (setq dun-combination (prin1-to-string tcomb))
3029 ;;;;
3030 ;;;; This section defines the DOS emulation functions for dunnet
3031 ;;;;
3033 (defun dun-dos-parse (args)
3034 (interactive "*p")
3035 (beginning-of-line)
3036 (let (beg)
3037 (setq beg (+ (point) 3))
3038 (end-of-line)
3039 (if (not (= beg (point)))
3040 (let (line)
3041 (setq line (downcase (buffer-substring beg (point))))
3042 (princ line)
3043 (if (eq (dun-parse2 nil dun-dos-verbs line) -1)
3044 (progn
3045 (sleep-for 1)
3046 (dun-mprincl "Bad command or file name"))))
3047 (goto-char (point-max))
3048 (dun-mprinc "\n"))
3049 (if (eq dungeon-mode 'dos)
3050 (progn
3051 (dun-fix-screen)
3052 (dun-dos-prompt)))))
3054 (defun dun-dos-interface ()
3055 (dun-dos-boot-msg)
3056 (setq dungeon-mode 'dos)
3057 (define-key dun-mode-map "\r" 'dun-dos-parse)
3058 (dun-dos-prompt))
3060 (defun dun-dos-type (args)
3061 (sleep-for 2)
3062 (if (setq args (car args))
3063 (if (string= args "foo.txt")
3064 (dun-dos-show-combination)
3065 (if (string= args "command.com")
3066 (dun-mprincl "Cannot type binary files")
3067 (dun-mprinc "File not found - ")
3068 (dun-mprincl (upcase args))))
3069 (dun-mprincl "Must supply file name")))
3071 (defun dun-dos-invd (args)
3072 (sleep-for 1)
3073 (dun-mprincl "Invalid drive specification"))
3075 (defun dun-dos-dir (args)
3076 (sleep-for 1)
3077 (if (or (not (setq args (car args))) (string= args "\\"))
3078 (dun-mprincl "
3079 Volume in drive A is FOO
3080 Volume Serial Number is 1A16-08C9
3081 Directory of A:\\
3083 COMMAND COM 47845 04-09-91 2:00a
3084 FOO TXT 40 01-20-93 1:01a
3085 2 file(s) 47845 bytes
3086 1065280 bytes free
3088 (dun-mprincl "
3089 Volume in drive A is FOO
3090 Volume Serial Number is 1A16-08C9
3091 Directory of A:\\
3093 File not found")))
3096 (defun dun-dos-prompt ()
3097 (dun-mprinc "A> "))
3099 (defun dun-dos-boot-msg ()
3100 (sleep-for 3)
3101 (dun-mprinc "Current time is ")
3102 (dun-mprincl (substring (current-time-string) 12 20))
3103 (dun-mprinc "Enter new time: ")
3104 (dun-read-line)
3105 (if (not dun-batch-mode)
3106 (dun-mprinc "\n")))
3108 (defun dun-dos-spawn (args)
3109 (sleep-for 1)
3110 (dun-mprincl "Cannot spawn subshell"))
3112 (defun dun-dos-exit (args)
3113 (setq dungeon-mode 'dungeon)
3114 (dun-mprincl "\nYou power down the machine and step back.")
3115 (define-key dun-mode-map "\r" 'dun-parse)
3116 (if (not dun-batch-mode)
3117 (dun-messages)))
3119 (defun dun-dos-no-disk ()
3120 (sleep-for 3)
3121 (dun-mprincl "Boot sector not found"))
3124 (defun dun-dos-show-combination ()
3125 (sleep-for 2)
3126 (dun-mprinc "\nThe combination is ")
3127 (dun-mprinc dun-combination)
3128 (dun-mprinc ".\n"))
3130 (defun dun-dos-nil (args))
3133 ;;;;
3134 ;;;; This section defines the save and restore game functions for dunnet.
3135 ;;;;
3137 (defun dun-save-game (filename)
3138 (if (not (setq filename (car filename)))
3139 (dun-mprincl "You must supply a filename for the save.")
3140 (if (file-exists-p filename)
3141 (delete-file filename))
3142 (setq dun-numsaves (1+ dun-numsaves))
3143 (dun-make-save-buffer)
3144 (dun-save-val "dun-current-room")
3145 (dun-save-val "dun-computer")
3146 (dun-save-val "dun-combination")
3147 (dun-save-val "dun-visited")
3148 (dun-save-val "dun-diggables")
3149 (dun-save-val "dun-key-level")
3150 (dun-save-val "dun-floppy")
3151 (dun-save-val "dun-numsaves")
3152 (dun-save-val "dun-numcmds")
3153 (dun-save-val "dun-logged-in")
3154 (dun-save-val "dungeon-mode")
3155 (dun-save-val "dun-jar")
3156 (dun-save-val "dun-lastdir")
3157 (dun-save-val "dun-black")
3158 (dun-save-val "dun-nomail")
3159 (dun-save-val "dun-unix-verbs")
3160 (dun-save-val "dun-hole")
3161 (dun-save-val "dun-uncompressed")
3162 (dun-save-val "dun-ethernet")
3163 (dun-save-val "dun-sauna-level")
3164 (dun-save-val "dun-room-objects")
3165 (dun-save-val "dun-room-silents")
3166 (dun-save-val "dun-inventory")
3167 (dun-save-val "dun-endgame-questions")
3168 (dun-save-val "dun-endgame")
3169 (dun-save-val "dun-cdroom")
3170 (dun-save-val "dun-cdpath")
3171 (dun-save-val "dun-correct-answer")
3172 (dun-save-val "dun-inbus")
3173 (if (dun-compile-save-out filename)
3174 (dun-mprincl "Error saving to file.")
3175 (dun-do-logfile 'save nil)
3176 (switch-to-buffer "*dungeon*")
3177 (princ "")
3178 (dun-mprincl "Done."))))
3180 (defun dun-make-save-buffer ()
3181 (switch-to-buffer (get-buffer-create "*save-dungeon*"))
3182 (erase-buffer))
3184 (defun dun-compile-save-out (filename)
3185 (let (ferror)
3186 (setq ferror nil)
3187 (condition-case nil
3188 (dun-rot13)
3189 (error (setq ferror t)))
3190 (if (not ferror)
3191 (progn
3192 (goto-char (point-min))))
3193 (condition-case nil
3194 (write-region 1 (point-max) filename nil 1)
3195 (error (setq ferror t)))
3196 (kill-buffer (current-buffer))
3197 ferror))
3200 (defun dun-save-val (varname)
3201 (let (value)
3202 (setq varname (intern varname))
3203 (setq value (eval varname))
3204 (dun-minsert "(setq ")
3205 (dun-minsert varname)
3206 (dun-minsert " ")
3207 (if (or (listp value)
3208 (symbolp value))
3209 (dun-minsert "'"))
3210 (if (stringp value)
3211 (dun-minsert "\""))
3212 (dun-minsert value)
3213 (if (stringp value)
3214 (dun-minsert "\""))
3215 (dun-minsertl ")")))
3218 (defun dun-restore (args)
3219 (let (file)
3220 (if (not (setq file (car args)))
3221 (dun-mprincl "You must supply a filename.")
3222 (if (not (dun-load-d file))
3223 (dun-mprincl "Could not load restore file.")
3224 (dun-mprincl "Done.")
3225 (setq room 0)))))
3228 (defun dun-do-logfile (type how)
3229 (let (ferror newscore)
3230 (setq ferror nil)
3231 (switch-to-buffer (get-buffer-create "*score*"))
3232 (erase-buffer)
3233 (condition-case nil
3234 (insert-file-contents dun-log-file)
3235 (error (setq ferror t)))
3236 (unless ferror
3237 (goto-char (point-max))
3238 (dun-minsert (current-time-string))
3239 (dun-minsert " ")
3240 (dun-minsert (user-login-name))
3241 (dun-minsert " ")
3242 (if (eq type 'save)
3243 (dun-minsert "saved ")
3244 (if (= (dun-endgame-score) 110)
3245 (dun-minsert "won ")
3246 (if (not how)
3247 (dun-minsert "quit ")
3248 (dun-minsert "killed by ")
3249 (dun-minsert how)
3250 (dun-minsert " "))))
3251 (dun-minsert "at ")
3252 (dun-minsert (cadr (nth (abs room) dun-rooms)))
3253 (dun-minsert ". score: ")
3254 (if (> (dun-endgame-score) 0)
3255 (dun-minsert (setq newscore (+ 90 (dun-endgame-score))))
3256 (dun-minsert (setq newscore (dun-reg-score))))
3257 (dun-minsert " saves: ")
3258 (dun-minsert dun-numsaves)
3259 (dun-minsert " commands: ")
3260 (dun-minsert dun-numcmds)
3261 (dun-minsert "\n")
3262 (write-region 1 (point-max) dun-log-file nil 1))
3263 (kill-buffer (current-buffer))))
3266 ;;;;
3267 ;;;; These are functions, and function re-definitions so that dungeon can
3268 ;;;; be run in batch mode.
3271 (defun dun-batch-mprinc (arg)
3272 (if (stringp arg)
3273 (send-string-to-terminal arg)
3274 (send-string-to-terminal (prin1-to-string arg))))
3277 (defun dun-batch-mprincl (arg)
3278 (if (stringp arg)
3279 (progn
3280 (send-string-to-terminal arg)
3281 (send-string-to-terminal "\n"))
3282 (send-string-to-terminal (prin1-to-string arg))
3283 (send-string-to-terminal "\n")))
3285 (defun dun-batch-parse (dun-ignore dun-verblist line)
3286 (setq line-list (dun-listify-string (concat line " ")))
3287 (dun-doverb dun-ignore dun-verblist (car line-list) (cdr line-list)))
3289 (defun dun-batch-parse2 (dun-ignore dun-verblist line)
3290 (setq line-list (dun-listify-string2 (concat line " ")))
3291 (dun-doverb dun-ignore dun-verblist (car line-list) (cdr line-list)))
3293 (defun dun-batch-read-line ()
3294 (read-from-minibuffer "" nil dungeon-batch-map))
3297 (defun dun-batch-loop ()
3298 (setq dun-dead nil)
3299 (setq room 0)
3300 (while (not dun-dead)
3301 (if (eq dungeon-mode 'dungeon)
3302 (progn
3303 (if (not (= room dun-current-room))
3304 (progn
3305 (dun-describe-room dun-current-room)
3306 (setq room dun-current-room)))
3307 (dun-mprinc ">")
3308 (setq line (downcase (dun-read-line)))
3309 (if (eq (dun-vparse dun-ignore dun-verblist line) -1)
3310 (dun-mprinc "I don't understand that.\n"))))))
3312 (defun dun-batch-dos-interface ()
3313 (dun-dos-boot-msg)
3314 (setq dungeon-mode 'dos)
3315 (while (eq dungeon-mode 'dos)
3316 (dun-dos-prompt)
3317 (setq line (downcase (dun-read-line)))
3318 (if (eq (dun-parse2 nil dun-dos-verbs line) -1)
3319 (progn
3320 (sleep-for 1)
3321 (dun-mprincl "Bad command or file name"))))
3322 (goto-char (point-max))
3323 (dun-mprinc "\n"))
3325 (defun dun-batch-unix-interface ()
3326 (dun-login)
3327 (if dun-logged-in
3328 (progn
3329 (setq dungeon-mode 'unix)
3330 (while (eq dungeon-mode 'unix)
3331 (dun-mprinc "$ ")
3332 (setq line (downcase (dun-read-line)))
3333 (if (eq (dun-parse2 nil dun-unix-verbs line) -1)
3334 (let (esign)
3335 (if (setq esign (string-match "=" line))
3336 (dun-doassign line esign)
3337 (dun-mprinc (car line-list))
3338 (dun-mprincl ": not found.")))))
3339 (goto-char (point-max))
3340 (dun-mprinc "\n"))))
3342 (defun dungeon-nil (arg)
3343 "noop"
3344 (interactive "*p")
3345 nil)
3347 (defun dun-batch-dungeon ()
3348 (load "dun-batch")
3349 (setq dun-visited '(27))
3350 (dun-mprinc "\n")
3351 (dun-batch-loop))
3353 (unless (not noninteractive)
3354 (fset 'dun-mprinc 'dun-batch-mprinc)
3355 (fset 'dun-mprincl 'dun-batch-mprincl)
3356 (fset 'dun-vparse 'dun-batch-parse)
3357 (fset 'dun-parse2 'dun-batch-parse2)
3358 (fset 'dun-read-line 'dun-batch-read-line)
3359 (fset 'dun-dos-interface 'dun-batch-dos-interface)
3360 (fset 'dun-unix-interface 'dun-batch-unix-interface)
3361 (dun-mprinc "\n")
3362 (setq dun-batch-mode t)
3363 (dun-batch-loop))
3365 (provide 'dunnet)
3367 ;;; dunnet.el ends here
3369 ;; Local Variables:
3370 ;; byte-compile-warnings: (not free-vars lexical)
3371 ;; End: