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