Allow 'browse-url-emacs' to fetch URL in the selected window
[emacs.git] / lisp / play / dunnet.el
blob2b8bd9d6b8a6ce66fdf2cc3887e94a168c1b2f39
1 ;;; dunnet.el --- text adventure for Emacs -*- lexical-binding: t -*-
3 ;; Copyright (C) 1992-1993, 2001-2018 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-key dun-mode-map "\r" 'dun-parse)
2353 (defvar dungeon-batch-map (make-keymap))
2354 (if (string= (substring emacs-version 0 2) "18")
2355 (let (n)
2356 (setq n 32)
2357 (while (< 0 (setq n (- n 1)))
2358 (aset dungeon-batch-map n 'dungeon-nil)))
2359 (let (n)
2360 (setq n 32)
2361 (while (< 0 (setq n (- n 1)))
2362 (aset (car (cdr dungeon-batch-map)) n 'dungeon-nil))))
2363 (define-key dungeon-batch-map "\r" 'exit-minibuffer)
2364 (define-key dungeon-batch-map "\n" 'exit-minibuffer)
2366 ;;;;
2367 ;;;; This section defines the UNIX emulation functions for dunnet.
2368 ;;;;
2370 (defun dun-unix-parse (_args)
2371 (interactive "*p")
2372 (beginning-of-line)
2373 (let (beg esign)
2374 (setq beg (+ (point) 2))
2375 (end-of-line)
2376 (if (and (not (= beg (point)))
2377 (string= "$" (buffer-substring (- beg 2) (- beg 1))))
2378 (progn
2379 (setq dun-line (downcase (buffer-substring beg (point))))
2380 (princ dun-line)
2381 (if (eq (dun-parse2 nil dun-unix-verbs dun-line) -1)
2382 (progn
2383 (if (setq esign (string-match "=" dun-line))
2384 (dun-doassign dun-line esign)
2385 (dun-mprinc (car dun-line-list))
2386 (dun-mprincl ": not found.")))))
2387 (goto-char (point-max))
2388 (dun-mprinc "\n"))
2389 (if (eq dungeon-mode 'unix)
2390 (progn
2391 (dun-fix-screen)
2392 (dun-mprinc "$ ")))))
2394 (defun dun-doassign (line esign)
2395 (if (not dun-wizard)
2396 (let (passwd)
2397 (dun-mprinc "Enter wizard password: ")
2398 (setq passwd (dun-read-line))
2399 (if (not dun-batch-mode)
2400 (dun-mprinc "\n"))
2401 (if (string= passwd "moby")
2402 (progn
2403 (setq dun-wizard t)
2404 (dun-doassign line esign))
2405 (dun-mprincl "Incorrect.")))
2407 (let (varname epoint afterq i value)
2408 (setq varname (replace-regexp-in-string " " "" (substring line 0 esign)))
2410 (if (or (= (length varname) 0) (< (- (length line) esign) 2))
2411 (progn
2412 (dun-mprinc line)
2413 (dun-mprincl " : not found."))
2415 (if (not (setq epoint (string-match ")" line)))
2416 (if (string= (substring line (1+ esign) (+ esign 2))
2417 "\"")
2418 (progn
2419 (setq afterq (substring line (+ esign 2)))
2420 (setq epoint (+
2421 (string-match "\"" afterq)
2422 (+ esign 3))))
2424 (if (not (setq epoint (string-match " " line)))
2425 (setq epoint (length line))))
2426 (setq epoint (1+ epoint))
2427 (while (and
2428 (not (= epoint (length line)))
2429 (setq i (string-match ")" (substring line epoint))))
2430 (setq epoint (+ epoint i 1))))
2431 (setq value (substring line (1+ esign) epoint))
2432 (dun-eval varname value)))))
2434 (defun dun-eval (varname value)
2435 (with-temp-buffer
2436 (insert "(setq " varname " " value ")")
2437 (condition-case nil
2438 (eval-buffer)
2439 (error (dun-mprincl "Invalid syntax.")))))
2441 (defun dun-unix-interface ()
2442 (dun-login)
2443 (if dun-logged-in
2444 (progn
2445 (setq dungeon-mode 'unix)
2446 (define-key dun-mode-map "\r" 'dun-unix-parse)
2447 (dun-mprinc "$ "))))
2449 (defun dun-login ()
2450 (let (tries username password)
2451 (setq tries 4)
2452 (while (and (not dun-logged-in) (> (setq tries (- tries 1)) 0))
2453 (dun-mprinc "\n\nUNIX System V, Release 2.2 (pokey)\n\nlogin: ")
2454 (setq username (dun-read-line))
2455 (if (not dun-batch-mode)
2456 (dun-mprinc "\n"))
2457 (dun-mprinc "password: ")
2458 (setq password (dun-read-line))
2459 (if (not dun-batch-mode)
2460 (dun-mprinc "\n"))
2461 (if (or (not (string= username "toukmond"))
2462 (not (string= password "robert")))
2463 (dun-mprincl "login incorrect")
2464 (setq dun-logged-in t)
2465 (dun-mprincl "
2466 Welcome to Unix\n
2467 Please clean up your directories. The filesystem is getting full.
2468 Our tcp/ip link to gamma is a little flaky, but seems to work.
2469 The current version of ftp can only send files from your home
2470 directory, and deletes them after they are sent! Be careful.
2472 Note: Restricted bourne shell in use.\n")))
2473 (setq dungeon-mode 'dungeon)))
2475 (defun dun-ls (args)
2476 (let ((ocdroom dun-cdroom))
2477 (if (car args)
2478 (let ((ocdpath dun-cdpath))
2479 (if (not (eq (dun-cd args) -2))
2480 (dun-ls nil))
2481 (setq dun-cdpath ocdpath)
2482 (setq dun-cdroom ocdroom))
2483 (cond
2484 ((= ocdroom -10) (dun-ls-inven))
2485 ((= ocdroom -2) (dun-ls-rooms))
2486 ((= ocdroom -3) (dun-ls-root))
2487 ((= ocdroom -4) (dun-ls-usr))
2488 ((> ocdroom 0) (dun-ls-room))))))
2490 (defun dun-ls-root ()
2491 (dun-mprincl "total 4
2492 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2493 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..
2494 drwxr-xr-x 3 root staff 2048 Jan 1 1970 usr
2495 drwxr-xr-x 3 root staff 2048 Jan 1 1970 rooms"))
2497 (defun dun-ls-usr ()
2498 (dun-mprincl "total 4
2499 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2500 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..
2501 drwxr-xr-x 3 toukmond restricted 512 Jan 1 1970 toukmond"))
2503 (defun dun-ls-rooms ()
2504 (dun-mprincl "total 16
2505 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2506 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..")
2507 (dolist (x dun-visited)
2508 (dun-mprinc
2509 "drwxr-xr-x 3 root staff 512 Jan 1 1970 ")
2510 (dun-mprincl (nth x dun-room-shorts))))
2512 (defun dun-ls-room ()
2513 (dun-mprincl "total 4
2514 drwxr-xr-x 3 root staff 512 Jan 1 1970 .
2515 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..
2516 -rwxr-xr-x 3 root staff 2048 Jan 1 1970 description")
2517 (dolist (x (nth dun-cdroom dun-room-objects))
2518 (if (and (>= x 0) (not (= x 255)))
2519 (progn
2520 (dun-mprinc "-rwxr-xr-x 1 toukmond restricted 0 Jan 1 1970 ")
2521 (dun-mprincl (nth x dun-objfiles))))))
2523 (defun dun-ls-inven ()
2524 (dun-mprinc "total 467
2525 drwxr-xr-x 3 toukmond restricted 512 Jan 1 1970 .
2526 drwxr-xr-x 3 root staff 2048 Jan 1 1970 ..")
2527 (dolist (x dun-unix-verbs)
2528 (if (not (eq (car x) 'IMPOSSIBLE))
2529 (progn
2530 (dun-mprinc"
2531 -rwxr-xr-x 1 toukmond restricted 10423 Jan 1 1970 ")
2532 (dun-mprinc (car x)))))
2533 (dun-mprinc "\n")
2534 (if (not dun-uncompressed)
2535 (dun-mprincl
2536 "-rwxr-xr-x 1 toukmond restricted 0 Jan 1 1970 paper.o.Z"))
2537 (dolist (x dun-inventory)
2538 (dun-mprinc
2539 "-rwxr-xr-x 1 toukmond restricted 0 Jan 1 1970 ")
2540 (dun-mprincl (nth x dun-objfiles))))
2542 (defun dun-echo (args)
2543 (let (nomore var)
2544 (setq nomore nil)
2545 (dolist (x args)
2546 (if (not nomore)
2547 (progn
2548 (if (not (string= (substring x 0 1) "$"))
2549 (progn
2550 (dun-mprinc x)
2551 (dun-mprinc " "))
2552 (setq var (intern (substring x 1)))
2553 (if (not (boundp var))
2554 (dun-mprinc " ")
2555 (if (member var dun-restricted)
2556 (progn
2557 (dun-mprinc var)
2558 (dun-mprinc ": Permission denied")
2559 (setq nomore t))
2560 (dun-mprinc var)
2561 (dun-mprinc " ")))))))
2562 (dun-mprinc "\n")))
2565 (defun dun-ftp (args)
2566 (let (host username ident newlist)
2567 (if (not (car args))
2568 (dun-mprincl "ftp: hostname required on command line.")
2569 (setq host (intern (car args)))
2570 (if (not (member host '(gamma dun-endgame)))
2571 (dun-mprincl "ftp: Unknown host.")
2572 (if (eq host 'dun-endgame)
2573 (dun-mprincl "ftp: connection to endgame not allowed")
2574 (if (not dun-ethernet)
2575 (dun-mprincl "ftp: host not responding.")
2576 (dun-mprincl "Connected to gamma. FTP ver 0.9 00:00:00 01/01/70")
2577 (dun-mprinc "Username: ")
2578 (setq username (dun-read-line))
2579 (if (string= username "toukmond")
2580 (if dun-batch-mode
2581 (dun-mprincl "toukmond ftp access not allowed.")
2582 (dun-mprincl "\ntoukmond ftp access not allowed."))
2583 (if (string= username "anonymous")
2584 (if dun-batch-mode
2585 (dun-mprincl
2586 "Guest login okay, send your user ident as password.")
2587 (dun-mprincl
2588 "\nGuest login okay, send your user ident as password."))
2589 (if dun-batch-mode
2590 (dun-mprinc "Password required for ")
2591 (dun-mprinc "\nPassword required for "))
2592 (dun-mprincl username))
2593 (dun-mprinc "Password: ")
2594 (setq ident (dun-read-line))
2595 (if (not (string= username "anonymous"))
2596 (if dun-batch-mode
2597 (dun-mprincl "Login failed.")
2598 (dun-mprincl "\nLogin failed."))
2599 (if (= (length ident) 0)
2600 (if dun-batch-mode
2601 (dun-mprincl "Password is required.")
2602 (dun-mprincl "\nPassword is required."))
2603 (if dun-batch-mode
2604 (dun-mprincl
2605 "Guest login okay, user access restrictions apply.")
2606 (dun-mprincl
2607 "\nGuest login okay, user access restrictions apply."))
2608 (dun-ftp-commands)
2609 (setq newlist
2610 '("What password did you use during anonymous ftp to gamma?"))
2611 (setq newlist (append newlist (list ident)))
2612 (rplaca (nthcdr 1 dun-endgame-questions) newlist))))))))))
2614 (defun dun-ftp-commands ()
2615 (setq dun-exitf nil)
2616 (let (line)
2617 (while (not dun-exitf)
2618 (dun-mprinc "ftp> ")
2619 (setq line (dun-read-line))
2622 (dun-parse2 nil
2623 '((type . dun-ftptype) (binary . dun-bin) (bin . dun-bin)
2624 (send . dun-send) (put . dun-send) (quit . dun-ftpquit)
2625 (help . dun-ftphelp)(ascii . dun-fascii)
2626 ) line)
2628 (dun-mprincl "No such command. Try help.")))
2629 (setq dun-ftptype 'ascii)))
2631 (defun dun-ftptype (args)
2632 (if (not (car args))
2633 (dun-mprincl "Usage: type [binary | ascii]")
2634 (setq args (intern (car args)))
2635 (if (eq args 'binary)
2636 (dun-bin nil)
2637 (if (eq args 'ascii)
2638 (dun-fascii 'nil)
2639 (dun-mprincl "Unknown type.")))))
2641 (defun dun-bin (_args)
2642 (dun-mprincl "Type set to binary.")
2643 (setq dun-ftptype 'binary))
2645 (defun dun-fascii (_args)
2646 (dun-mprincl "Type set to ascii.")
2647 (setq dun-ftptype 'ascii))
2649 (defun dun-ftpquit (_args)
2650 (setq dun-exitf t))
2652 (defun dun-send (args)
2653 (if (not (car args))
2654 (dun-mprincl "Usage: send <filename>")
2655 (setq args (car args))
2656 (let (counter foo)
2657 (setq foo nil)
2658 (setq counter 0)
2660 ;;; User can send commands! Stupid user.
2663 (if (assq (intern args) dun-unix-verbs)
2664 (progn
2665 (rplaca (assq (intern args) dun-unix-verbs) 'IMPOSSIBLE)
2666 (dun-mprinc "Sending ")
2667 (dun-mprinc dun-ftptype)
2668 (dun-mprinc " file for ")
2669 (dun-mprincl args)
2670 (dun-mprincl "Transfer complete."))
2672 (dolist (x dun-objfiles)
2673 (if (string= args x)
2674 (progn
2675 (if (not (member counter dun-inventory))
2676 (progn
2677 (dun-mprincl "No such file.")
2678 (setq foo t))
2679 (dun-mprinc "Sending ")
2680 (dun-mprinc dun-ftptype)
2681 (dun-mprinc " file for ")
2682 (dun-mprinc (downcase (cadr (nth counter dun-objects))))
2683 (dun-mprincl ", (0 bytes)")
2684 (if (not (eq dun-ftptype 'binary))
2685 (progn
2686 (if (not (member obj-protoplasm
2687 (nth receiving-room
2688 dun-room-objects)))
2689 (dun-replace dun-room-objects receiving-room
2690 (append (nth receiving-room
2691 dun-room-objects)
2692 (list obj-protoplasm))))
2693 (dun-remove-obj-from-inven counter))
2694 (dun-remove-obj-from-inven counter)
2695 (dun-replace dun-room-objects receiving-room
2696 (append (nth receiving-room dun-room-objects)
2697 (list counter))))
2698 (setq foo t)
2699 (dun-mprincl "Transfer complete."))))
2700 (setq counter (+ 1 counter)))
2701 (if (not foo)
2702 (dun-mprincl "No such file."))))))
2704 (defun dun-ftphelp (_args)
2705 (dun-mprincl
2706 "Possible commands are:\nsend quit type ascii binary help"))
2708 (defun dun-uexit (_args)
2709 (setq dungeon-mode 'dungeon)
2710 (dun-mprincl "\nYou step back from the console.")
2711 (define-key dun-mode-map "\r" 'dun-parse)
2712 (if (not dun-batch-mode)
2713 (dun-messages)))
2715 (defun dun-pwd (_args)
2716 (dun-mprincl dun-cdpath))
2718 (defun dun-uncompress (args)
2719 (if (not (car args))
2720 (dun-mprincl "Usage: uncompress <filename>")
2721 (setq args (car args))
2722 (if (or dun-uncompressed
2723 (and (not (string= args "paper.o"))
2724 (not (string= args "paper.o.z"))))
2725 (dun-mprincl "Uncompress command failed.")
2726 (setq dun-uncompressed t)
2727 (setq dun-inventory (append dun-inventory (list obj-paper))))))
2729 (defun dun-rlogin (args)
2730 (let (passwd)
2731 (if (not (car args))
2732 (dun-mprincl "Usage: rlogin <hostname>")
2733 (setq args (car args))
2734 (if (string= args "endgame")
2735 (dun-rlogin-endgame)
2736 (if (not (string= args "gamma"))
2737 (if (string= args "pokey")
2738 (dun-mprincl "Can't rlogin back to localhost")
2739 (dun-mprincl "No such host."))
2740 (if (not dun-ethernet)
2741 (dun-mprincl "Host not responding.")
2742 (dun-mprinc "Password: ")
2743 (setq passwd (dun-read-line))
2744 (if (not (string= passwd "worms"))
2745 (dun-mprincl "\nlogin incorrect")
2746 (dun-mprinc
2747 "\nYou begin to feel strange for a moment, and you lose your items."
2749 (dun-replace dun-room-objects computer-room
2750 (append (nth computer-room dun-room-objects)
2751 dun-inventory))
2752 (setq dun-inventory nil)
2753 (setq dun-current-room receiving-room)
2754 (dun-uexit nil))))))))
2756 (defun dun-cd (args)
2757 (if (not (car args))
2758 (dun-mprincl "Usage: cd <path>")
2759 (let ((tcdpath dun-cdpath)
2760 (tcdroom dun-cdroom)
2761 path-elements)
2762 (setq dun-badcd nil)
2763 (condition-case nil
2764 (setq path-elements (dun-get-path (car args) nil))
2765 (error (dun-mprincl "Invalid path")
2766 (setq dun-badcd t)))
2767 (dolist (pe path-elements)
2768 (when (and (not dun-badcd)
2769 (not (string= pe ".")))
2770 (cond
2771 ((string= pe "..")
2772 (cond
2773 ((> tcdroom 0) ;In a room
2774 (setq tcdpath "/rooms")
2775 (setq tcdroom -2))
2776 ((memq tcdroom '(-2 -3 -4)) ; In /rooms,/usr,root
2777 (setq tcdpath "/")
2778 (setq tcdroom -3))
2779 ((= tcdroom -10)
2780 (setq tcdpath "/usr")
2781 (setq tcdroom -4))))
2782 ((string= pe "/")
2783 (setq tcdpath "/")
2784 (setq tcdroom -3))
2785 ((= tcdroom -4)
2786 (if (not (string= pe "toukmond"))
2787 (dun-nosuchdir)
2788 (setq tcdpath "/usr/toukmond")
2789 (setq tcdroom -10)))
2790 ((or (= tcdroom -10) (> tcdroom 0)) (dun-nosuchdir))
2791 ((= tcdroom -3)
2792 (cond
2793 ((string= pe "rooms")
2794 (setq tcdpath "/rooms")
2795 (setq tcdroom -2))
2796 ((string= pe "usr")
2797 (setq tcdpath "/usr")
2798 (setq tcdroom -4))
2799 (t (dun-nosuchdir))))
2800 ((= tcdroom -2)
2801 (let (room-check)
2802 (dolist (x dun-visited)
2803 (setq room-check (nth x dun-room-shorts))
2804 (when (string= room-check pe)
2805 (setq tcdpath (concat "/rooms/" room-check))
2806 (setq tcdroom x))))
2807 (when (= tcdroom -2)
2808 (dun-nosuchdir))))))
2809 (if dun-badcd
2811 (setq dun-cdpath tcdpath)
2812 (setq dun-cdroom tcdroom)
2813 0))))
2815 (defun dun-nosuchdir ()
2816 (dun-mprincl "No such directory.")
2817 (setq dun-badcd t))
2819 (defun dun-cat (args)
2820 (cond
2821 ((null (setq args (car args)))
2822 (dun-mprincl "Usage: cat <ascii-file-name>"))
2823 ((string-match-p "/" args)
2824 (dun-mprincl "cat: only files in current directory allowed."))
2825 ((and (> dun-cdroom 0) (string= args "description"))
2826 (dun-mprincl (car (nth dun-cdroom dun-rooms))))
2827 ((string-match "\\.o" args)
2828 (let ((doto (match-beginning 0)) checklist)
2829 (if (= dun-cdroom -10)
2830 (setq checklist dun-inventory)
2831 (setq checklist (nth dun-cdroom dun-room-objects)))
2832 (if (member (cdr (assq (intern (substring args 0 doto)) dun-objnames))
2833 checklist)
2834 (dun-mprincl "Ascii files only.")
2835 (dun-mprincl "File not found."))))
2836 ((assq (intern args) dun-unix-verbs)
2837 (dun-mprincl "Ascii files only."))
2838 (t (dun-mprincl "File not found."))))
2840 (defun dun-rlogin-endgame ()
2841 (if (not (= (dun-score nil) 90))
2842 (dun-mprincl
2843 "You have not achieved enough points to connect to endgame.")
2844 (dun-mprincl "\nWelcome to the endgame. You are a truly noble adventurer.")
2845 (setq dun-current-room treasure-room)
2846 (setq dun-endgame t)
2847 (dun-replace dun-room-objects endgame-treasure-room (list obj-bill))
2848 (dun-uexit nil)))
2851 (let ((tloc (+ 60 (random 18))))
2852 (dun-replace dun-room-objects tloc
2853 (append (nth tloc dun-room-objects) (list 18))))
2855 ;;;;
2856 ;;;; This section defines the DOS emulation functions for dunnet
2857 ;;;;
2859 (defun dun-dos-parse (_args)
2860 (interactive "*p")
2861 (beginning-of-line)
2862 (let (beg)
2863 (setq beg (+ (point) 3))
2864 (end-of-line)
2865 (if (not (= beg (point)))
2866 (let (line)
2867 (setq line (downcase (buffer-substring beg (point))))
2868 (princ line)
2869 (if (eq (dun-parse2 nil dun-dos-verbs line) -1)
2870 (progn
2871 (sleep-for 1)
2872 (dun-mprincl "Bad command or file name"))))
2873 (goto-char (point-max))
2874 (dun-mprinc "\n"))
2875 (if (eq dungeon-mode 'dos)
2876 (progn
2877 (dun-fix-screen)
2878 (dun-dos-prompt)))))
2880 (defun dun-dos-interface ()
2881 (dun-dos-boot-msg)
2882 (setq dungeon-mode 'dos)
2883 (define-key dun-mode-map "\r" 'dun-dos-parse)
2884 (dun-dos-prompt))
2886 (defun dun-dos-type (args)
2887 (sleep-for 2)
2888 (if (setq args (car args))
2889 (if (string= args "foo.txt")
2890 (dun-dos-show-combination)
2891 (if (string= args "command.com")
2892 (dun-mprincl "Cannot type binary files")
2893 (dun-mprinc "File not found - ")
2894 (dun-mprincl (upcase args))))
2895 (dun-mprincl "Must supply file name")))
2897 (defun dun-dos-invd (_args)
2898 (sleep-for 1)
2899 (dun-mprincl "Invalid drive specification"))
2901 (defun dun-dos-dir (args)
2902 (sleep-for 1)
2903 (if (or (not (setq args (car args))) (string= args "\\"))
2904 (dun-mprincl "
2905 Volume in drive A is FOO
2906 Volume Serial Number is 1A16-08C9
2907 Directory of A:\\
2909 COMMAND COM 47845 04-09-91 2:00a
2910 FOO TXT 40 01-20-93 1:01a
2911 2 file(s) 47845 bytes
2912 1065280 bytes free
2914 (dun-mprincl "
2915 Volume in drive A is FOO
2916 Volume Serial Number is 1A16-08C9
2917 Directory of A:\\
2919 File not found")))
2922 (defun dun-dos-prompt ()
2923 (dun-mprinc "A> "))
2925 (defun dun-dos-boot-msg ()
2926 (sleep-for 3)
2927 (dun-mprinc "Current time is ")
2928 (dun-mprincl (format-time-string "%H:%M:%S"))
2929 (dun-mprinc "Enter new time: ")
2930 (dun-read-line)
2931 (if (not dun-batch-mode)
2932 (dun-mprinc "\n")))
2934 (defun dun-dos-spawn (_args)
2935 (sleep-for 1)
2936 (dun-mprincl "Cannot spawn subshell"))
2938 (defun dun-dos-exit (_args)
2939 (setq dungeon-mode 'dungeon)
2940 (dun-mprincl "\nYou power down the machine and step back.")
2941 (define-key dun-mode-map "\r" 'dun-parse)
2942 (if (not dun-batch-mode)
2943 (dun-messages)))
2945 (defun dun-dos-no-disk ()
2946 (sleep-for 3)
2947 (dun-mprincl "Boot sector not found"))
2950 (defun dun-dos-show-combination ()
2951 (sleep-for 2)
2952 (dun-mprinc "\nThe combination is ")
2953 (dun-mprinc dun-combination)
2954 (dun-mprinc ".\n"))
2956 (defun dun-dos-nil (_args))
2959 ;;;;
2960 ;;;; This section defines the save and restore game functions for dunnet.
2961 ;;;;
2963 (defun dun-save-game (filename)
2964 (if (not (setq filename (car filename)))
2965 (dun-mprincl "You must supply a filename for the save.")
2966 (when (file-exists-p filename) (delete-file filename))
2967 (setq dun-numsaves (1+ dun-numsaves))
2968 (with-temp-buffer
2969 (dun-save-val "dun-current-room")
2970 (dun-save-val "dun-computer")
2971 (dun-save-val "dun-combination")
2972 (dun-save-val "dun-visited")
2973 (dun-save-val "dun-diggables")
2974 (dun-save-val "dun-key-level")
2975 (dun-save-val "dun-floppy")
2976 (dun-save-val "dun-numsaves")
2977 (dun-save-val "dun-numcmds")
2978 (dun-save-val "dun-logged-in")
2979 (dun-save-val "dungeon-mode")
2980 (dun-save-val "dun-jar")
2981 (dun-save-val "dun-lastdir")
2982 (dun-save-val "dun-black")
2983 (dun-save-val "dun-nomail")
2984 (dun-save-val "dun-unix-verbs")
2985 (dun-save-val "dun-hole")
2986 (dun-save-val "dun-uncompressed")
2987 (dun-save-val "dun-ethernet")
2988 (dun-save-val "dun-sauna-level")
2989 (dun-save-val "dun-room-objects")
2990 (dun-save-val "dun-room-silents")
2991 (dun-save-val "dun-inventory")
2992 (dun-save-val "dun-endgame-questions")
2993 (dun-save-val "dun-endgame")
2994 (dun-save-val "dun-cdroom")
2995 (dun-save-val "dun-cdpath")
2996 (dun-save-val "dun-correct-answer")
2997 (dun-save-val "dun-inbus")
2998 (if (dun-compile-save-out filename)
2999 (dun-mprincl "Error saving to file.")
3000 (dun-do-logfile 'save nil)))
3001 (princ "")
3002 (dun-mprincl "Done.")))
3004 (defun dun-compile-save-out (filename)
3005 (let (ferror)
3006 (setq ferror nil)
3007 (condition-case nil
3008 (dun-rot13)
3009 (error (setq ferror t)))
3010 (if (not ferror)
3011 (progn
3012 (goto-char (point-min))))
3013 (condition-case nil
3014 (write-region 1 (point-max) filename nil 1)
3015 (error (setq ferror t)))
3016 (kill-buffer (current-buffer))
3017 ferror))
3020 (defun dun-save-val (varname)
3021 (let ((value (symbol-value (intern varname))))
3022 (dun-minsert "(setq " varname " ")
3023 (if (or (listp value)
3024 (symbolp value))
3025 (dun-minsert "'"))
3026 (if (stringp value)
3027 (dun-minsert "\""))
3028 (dun-minsert value)
3029 (if (stringp value)
3030 (dun-minsert "\""))
3031 (dun-minsertl ")")))
3034 (defun dun-restore (args)
3035 (let (file)
3036 (if (not (setq file (car args)))
3037 (dun-mprincl "You must supply a filename.")
3038 (if (not (dun-load-d file))
3039 (dun-mprincl "Could not load restore file.")
3040 (dun-mprincl "Done.")
3041 (setq dun-room 0)))))
3044 ;; See gamegrid-add-score; but that only handles a single integer score.
3045 (defun dun-do-logfile (type how)
3046 (let (ferror)
3047 (with-temp-buffer
3048 (condition-case err
3049 (if (file-exists-p dun-log-file)
3050 (insert-file-contents dun-log-file)
3051 (let ((dir (file-name-directory dun-log-file)))
3052 (if dir (make-directory dir t))))
3053 (error
3054 (setq ferror t)
3055 (dun-mprincl (error-message-string err))))
3056 (when (null ferror)
3057 (goto-char (point-max))
3058 (dun-minsert (current-time-string) " " (user-login-name) " ")
3059 (if (eq type 'save)
3060 (dun-minsert "saved ")
3061 (if (= (dun-endgame-score) 110)
3062 (dun-minsert "won ")
3063 (if (not how)
3064 (dun-minsert "quit ")
3065 (dun-minsert "killed by " how " "))))
3066 (dun-minsert "at " (cadr (nth (abs dun-room) dun-rooms)) ". score: ")
3067 (if (> (dun-endgame-score) 0)
3068 (dun-minsert (+ 90 (dun-endgame-score)))
3069 (dun-minsert (dun-reg-score)))
3070 (dun-minsertl " saves: " dun-numsaves " commands: " dun-numcmds)
3071 (write-region 1 (point-max) dun-log-file nil 1)))))
3074 ;;;;
3075 ;;;; These are functions, and function re-definitions so that dungeon can
3076 ;;;; be run in batch mode.
3079 (defun dun-batch-mprinc (&rest args)
3080 (dolist (arg args)
3081 (if (stringp arg)
3082 (send-string-to-terminal arg)
3083 (send-string-to-terminal (prin1-to-string arg)))))
3086 (defun dun-batch-mprincl (&rest args)
3087 (dolist (arg args)
3088 (if (stringp arg)
3089 (send-string-to-terminal arg)
3090 (send-string-to-terminal (prin1-to-string arg))))
3091 (send-string-to-terminal "\n"))
3093 (defun dun-batch-parse (ignore verblist line)
3094 (setq dun-line-list (dun-listify-string (concat line " ")))
3095 (dun-doverb ignore verblist (car dun-line-list) (cdr dun-line-list)))
3097 (defun dun-batch-parse2 (ignore verblist line)
3098 (setq dun-line-list (dun-listify-string2 (concat line " ")))
3099 (dun-doverb ignore verblist (car dun-line-list) (cdr dun-line-list)))
3101 (defun dun-batch-read-line ()
3102 (read-from-minibuffer "" nil dungeon-batch-map))
3105 (defun dun-batch-loop ()
3106 (setq dun-dead nil)
3107 (setq dun-room 0)
3108 (while (not dun-dead)
3109 (if (eq dungeon-mode 'dungeon)
3110 (progn
3111 (if (not (= dun-room dun-current-room))
3112 (progn
3113 (dun-describe-room dun-current-room)
3114 (setq dun-room dun-current-room)))
3115 (dun-mprinc ">")
3116 (setq dun-line (downcase (dun-read-line)))
3117 (if (eq (dun-vparse dun-ignore dun-verblist dun-line) -1)
3118 (dun-mprinc "I don't understand that.\n"))))))
3120 (defun dun-batch-dos-interface ()
3121 (dun-dos-boot-msg)
3122 (setq dungeon-mode 'dos)
3123 (while (eq dungeon-mode 'dos)
3124 (dun-dos-prompt)
3125 (setq dun-line (downcase (dun-read-line)))
3126 (if (eq (dun-parse2 nil dun-dos-verbs dun-line) -1)
3127 (progn
3128 (sleep-for 1)
3129 (dun-mprincl "Bad command or file name"))))
3130 (goto-char (point-max))
3131 (dun-mprinc "\n"))
3133 (defun dun-batch-unix-interface ()
3134 (dun-login)
3135 (if dun-logged-in
3136 (progn
3137 (setq dungeon-mode 'unix)
3138 (while (eq dungeon-mode 'unix)
3139 (dun-mprinc "$ ")
3140 (setq dun-line (downcase (dun-read-line)))
3141 (if (eq (dun-parse2 nil dun-unix-verbs dun-line) -1)
3142 (let (esign)
3143 (if (setq esign (string-match "=" dun-line))
3144 (dun-doassign dun-line esign)
3145 (dun-mprinc (car dun-line-list))
3146 (dun-mprincl ": not found.")))))
3147 (goto-char (point-max))
3148 (dun-mprinc "\n"))))
3150 (defun dungeon-nil (_arg)
3151 "noop"
3152 (interactive "*p")
3153 nil)
3155 (defun dun-batch-dungeon ()
3156 (load "dun-batch")
3157 (setq dun-visited '(27))
3158 (dun-mprinc "\n")
3159 (dun-batch-loop))
3161 (when noninteractive
3162 (fset 'dun-mprinc 'dun-batch-mprinc)
3163 (fset 'dun-mprincl 'dun-batch-mprincl)
3164 (fset 'dun-vparse 'dun-batch-parse)
3165 (fset 'dun-parse2 'dun-batch-parse2)
3166 (fset 'dun-read-line 'dun-batch-read-line)
3167 (fset 'dun-dos-interface 'dun-batch-dos-interface)
3168 (fset 'dun-unix-interface 'dun-batch-unix-interface)
3169 (dun-mprinc "\n")
3170 (setq dun-batch-mode t)
3171 (dun-batch-loop))
3173 (provide 'dunnet)
3175 ;; Local Variables:
3176 ;; byte-compile-warnings: (not free-vars)
3177 ;; End:
3179 ;;; dunnet.el ends here