PageRenderTime 66ms CodeModel.GetById 25ms 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

Large files files are truncated, but you can click here to view the full file

  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 b…

Large files files are truncated, but you can click here to view the full file