PageRenderTime 78ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/lisp/play/dunnet.el

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