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