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