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