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