home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume14 / dunnet / part02 < prev    next >
Encoding:
Text File  |  1992-08-30  |  49.6 KB  |  1,607 lines

  1. Path: uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v14i029:  dunnet - emacs-lisp text adventure, Part02/02
  5. Message-ID: <3324@master.CNA.TEK.COM>
  6. Date: 4 Aug 92 19:59:55 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1596
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: ronnie@eddie.mit.edu (Ron Schnell)
  12. Posting-number: Volume 14, Issue 29
  13. Archive-name: dunnet/Part02
  14. Environment: gnu-emacs, emacs-lisp
  15.  
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 2 (of 2)."
  24. # Contents:  COPYRIGHT dun-batch.el dun-commands.el dun-main.el
  25. #   dun-save.el dun-util.el dunnet dunnet.window
  26. # Wrapped by billr@saab on Tue Aug  4 12:57:55 1992
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'COPYRIGHT' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'COPYRIGHT'\"
  30. else
  31. echo shar: Extracting \"'COPYRIGHT'\" \(908 characters\)
  32. sed "s/^X//" >'COPYRIGHT' <<'END_OF_FILE'
  33. X
  34. X;; dunnet - elisp text adventure game.  The following applies to
  35. X;;           these files contained in this archive:
  36. X;;              dun-batch.el
  37. X;;              dun-commands.el
  38. X;;              dun-globals.el
  39. X;;              dun-main.el
  40. X;;              dun-save.el
  41. X;;              dun-unix.el
  42. X;;              dun-util.el
  43. X
  44. X;; Copyright (C) 1992 by Ron Schnell
  45. X;; (ronnie@eddie.mit.edu)
  46. X
  47. X;; This software is not part of GNU Emacs.
  48. X
  49. X;; It is distributed in the hope that it will be fun.
  50. X;; It is without any warranty.  No author or distributor
  51. X;; accepts responsibility to anyone for the consequences of using it
  52. X;; or for whether it serves any particular purpose, or works at all.
  53. X
  54. X;; Everyone is granted permission to copy, modify, and redistribute
  55. X;; this software, but only so long as it is not for commercial
  56. X;; purposes.
  57. X
  58. X;; This file must be distributed along with all copies, in an unmodified
  59. X;; form.
  60. END_OF_FILE
  61. if test 908 -ne `wc -c <'COPYRIGHT'`; then
  62.     echo shar: \"'COPYRIGHT'\" unpacked with wrong size!
  63. fi
  64. # end of 'COPYRIGHT'
  65. fi
  66. if test -f 'dun-batch.el' -a "${1}" != "-c" ; then 
  67.   echo shar: Will not clobber existing file \"'dun-batch.el'\"
  68. else
  69. echo shar: Extracting \"'dun-batch.el'\" \(1691 characters\)
  70. sed "s/^X//" >'dun-batch.el' <<'END_OF_FILE'
  71. X;;;;;;;;;;;;;;;;;;;
  72. X;;;;;;;;;;;;;;;;;;;
  73. X
  74. X
  75. X; These are functions, and function re-definitions so that dungeon can
  76. X; be run in batch mode.
  77. X
  78. X(defun mprinc (arg)
  79. X
  80. X   (if (stringp arg)
  81. X       (send-string-to-terminal arg)
  82. X     (send-string-to-terminal (prin1-to-string arg))))
  83. X(defun mprincl (arg)
  84. X
  85. X   (if (stringp arg)
  86. X       (progn
  87. X           (send-string-to-terminal arg)
  88. X           (send-string-to-terminal "\n"))
  89. X     (send-string-to-terminal (prin1-to-string arg))
  90. X     (send-string-to-terminal "\n")))
  91. X(defun parse (ignore verblist line)
  92. X  (setq line-list (listify-string (concat line " ")))
  93. X  (doverb ignore verblist (car line-list) (cdr line-list)))
  94. X
  95. X(defun parse2 (ignore verblist line)
  96. X  (setq line-list (listify-string2 (concat line " ")))
  97. X  (doverb ignore verblist (car line-list) (cdr line-list)))
  98. X
  99. X(defun read-line ()
  100. X  (read-string ""))
  101. X
  102. X(setq batch-mode t)
  103. X
  104. X(defun dungeon-batch-loop ()
  105. X  (setq dead nil)
  106. X  (setq room 0)
  107. X  (while (not dead)
  108. X    (if (eq dungeon-mode 'dungeon)
  109. X    (progn
  110. X      (if (not (= room current-room))
  111. X          (progn
  112. X        (describe-room current-room)
  113. X        (setq room current-room)))
  114. X      (mprinc ">")
  115. X      (setq line (downcase (read-string "")))
  116. X      (if (eq (parse ignore verblist line) -1)
  117. X          (mprinc "I don't understand that.\n"))))))
  118. X
  119. X  (defun unix-interface ()
  120. X    (login)
  121. X    (if logged-in
  122. X    (progn
  123. X      (setq dungeon-mode 'unix)
  124. X      (while (eq dungeon-mode 'unix)
  125. X        (mprinc "$ ")
  126. X        (setq line (downcase (read-string "")))
  127. X        (if (eq (parse2 nil unix-verbs line) -1)
  128. X        (progn
  129. X          (if (setq esign (string-match "=" line))
  130. X              (doassign line)        
  131. X            (mprinc (car line-list))
  132. X            (mprincl ": not found.")))))
  133. X      (goto-char (point-max))
  134. X      (mprinc "\n"))))
  135. X
  136. END_OF_FILE
  137. if test 1691 -ne `wc -c <'dun-batch.el'`; then
  138.     echo shar: \"'dun-batch.el'\" unpacked with wrong size!
  139. fi
  140. # end of 'dun-batch.el'
  141. fi
  142. if test -f 'dun-commands.el' -a "${1}" != "-c" ; then 
  143.   echo shar: Will not clobber existing file \"'dun-commands.el'\"
  144. else
  145. echo shar: Extracting \"'dun-commands.el'\" \(28022 characters\)
  146. sed "s/^X//" >'dun-commands.el' <<'END_OF_FILE'
  147. X;;
  148. X;; This file contains all of the verbs and commands.
  149. X;;
  150. X
  151. X(require 'cl)
  152. X;;;; Give long description of room if haven't been there yet.  Otherwise
  153. X;;;; short.  Also give long if we were called with negative room number.
  154. X
  155. X(defun describe-room (room)
  156. X  (if (and (not (member (abs room) light-rooms)) (not (member 1 inventory)))
  157. X      (mprincl "It is pitch dark.  You are likely to be eaten by a grue.")
  158. X    (mprincl (cadr (nth (abs room) rooms)))
  159. X    (if (and (and (or (member room visited) 
  160. X              (string= mode "superb")) (> room 0))
  161. X         (not (string= mode "long")))
  162. X    nil
  163. X      (mprinc (car (nth (abs room) rooms)))
  164. X    (mprinc "\n"))
  165. X    (if (not (string= mode "long"))
  166. X    (if (not (member (abs room) visited))
  167. X        (setq visited (append (list (abs room)) visited))))
  168. X    (dolist (xobjs (nth current-room room-objects))
  169. X      (if (= xobjs 255)
  170. X      (special-object)
  171. X    (if (>= xobjs 0)
  172. X        (mprincl (car (nth xobjs objects)))
  173. X      (if (not (and (= xobjs -18) inbus))
  174. X          (progn
  175. X        (mprincl (car (nth (abs xobjs) perm-objects)))))))
  176. X      (if (and (= xobjs 19) jar)
  177. X      (progn
  178. X        (mprincl "The jar contains:")
  179. X        (dolist (x jar)
  180. X          (mprinc "     ")
  181. X          (mprincl (car (nth x objects)))))))
  182. X    (if (and (member -18 (nth current-room room-objects)) inbus)
  183. X    (mprincl "You are on the bus."))))
  184. X
  185. X;;; There is a special object in the room.  This object's description,
  186. X;;; or lack thereof, depends on certain conditions.
  187. X
  188. X(defun special-object ()
  189. X  (if (= current-room 10)
  190. X      (if computer
  191. X      (mprincl 
  192. X"The panel lights are flashing in a seemingly organized pattern.")
  193. X    (mprincl "The panel lights are steady and motionless.")))
  194. X  (if (and (= current-room 46) (not (member 13 (nth 46 room-objects))))
  195. X      (mprincl "There is a hole in the floor here."))
  196. X  (if (and (= current-room 86) black)
  197. X      (mprincl 
  198. X"The room is lit by a black light, causing the fish to give off an
  199. Xeerie glow."))
  200. X  (if (and (= current-room 77) hole)
  201. X      (progn
  202. X    (mprincl"You fall into a hole in the ground.")
  203. X    (setq current-room 89)
  204. X    (describe-room 89)))
  205. X
  206. X  (if (> current-room 95)
  207. X      (progn
  208. X    (if (not correct-answer)
  209. X        (endgame-question)
  210. X      (mprincl "Your question is:")
  211. X      (mprincl endgame-question))))
  212. X
  213. X  (if (= current-room 14)
  214. X      (progn
  215. X    (mprincl (nth sauna-level '(
  216. X"It is normal room termperature in here."
  217. X"It is luke warm in here."
  218. X"It is comfortably hot in here."
  219. X"It is refreshingly hot in here."
  220. X"You are dead now.")))
  221. X    (if (and (= sauna-level 3) 
  222. X         (or (member 6 inventory)
  223. X             (member 6 (nth current-room room-objects))))
  224. X        (progn
  225. X          (mprincl 
  226. X"You notice the wax on your statuette beginning to melt, until it completely
  227. Xmelts off.  You are left with a beautiful diamond!")
  228. X          (if (member 6 inventory)
  229. X          (progn
  230. X            (remove-obj-from-inven 6)
  231. X            (setq inventory (append inventory (list 7))))
  232. X        (remove-obj-from-room current-room 6)
  233. X        (replace room-objects current-room
  234. X             (append (nth current-room room-objects)
  235. X                 (list 7))))))))
  236. X
  237. X)
  238. X
  239. X;;;;;;;;;;;;;;;;;;;;;; Commands start here
  240. X
  241. X(defun die (murderer)
  242. X  (mprinc "\n")
  243. X  (if murderer
  244. X      (mprincl "You are dead."))
  245. X  (do-logfile 'die murderer)
  246. X  (score nil)
  247. X  (setq dead t))
  248. X
  249. X(defun quit (args)
  250. X  (die nil))
  251. X
  252. X;; Print every object in player's inventory.  Special case for the jar,
  253. X;; as we must also print what is in it.
  254. X
  255. X(defun inven (args)
  256. X  (mprinc "You currently have:")
  257. X  (mprinc "\n")
  258. X  (dolist (curobj inventory)
  259. X    (if curobj
  260. X    (progn
  261. X      (mprincl (cadr (nth curobj objects)))
  262. X      (if (and (= curobj 19) jar)
  263. X          (progn
  264. X        (mprincl "The jar contains:")
  265. X        (dolist (x jar)
  266. X          (mprinc "     ")
  267. X          (mprincl (cadr (nth x objects))))))))))
  268. X
  269. X(defun shake (obj)
  270. X  (let (objnum)
  271. X    (when (setq objnum (objnum-from-args-std obj))
  272. X      (if (member objnum inventory)
  273. X      (progn
  274. X;;;    If shaking anything will do anything, put here.
  275. X        (mprinc "Shaking ")
  276. X        (mprinc (downcase (cadr (nth objnum objects))))
  277. X        (mprinc " seems to have no effect.")
  278. X        (mprinc "\n")
  279. X        )
  280. X    (if (and (not (member objnum (nth current-room room-silents)))
  281. X         (not (member objnum (nth current-room room-objects))))
  282. X        (mprincl "I don't see that here.")
  283. X;;;     Shaking trees can be deadly
  284. X      (if (= objnum -2)
  285. X          (progn
  286. X        (mprinc
  287. X "You begin to shake a tree, and notice a coconut begin to fall from the air.
  288. XAs you try to get your hand up to block it, you feel the impact as it lands
  289. Xon your head.")
  290. X        (die "a coconut"))
  291. X        (if (= objnum -3)
  292. X        (progn
  293. X          (mprinc
  294. X"As you go up to the bear, it removes your head and places it on the ground.")
  295. X          (die "a bear"))
  296. X          (if (< objnum 0)
  297. X          (mprincl "You cannot shake that.")
  298. X        (mprincl "You don't have that.")))))))))
  299. X
  300. X
  301. X(defun drop (obj)
  302. X  (if inbus
  303. X      (mprincl "You can't drop anything while on the bus.")
  304. X  (let (objnum)
  305. X    (when (setq objnum (objnum-from-args-std obj))
  306. X      (if (not (setq ptr (member objnum inventory)))
  307. X      (mprincl "You don't have that.")
  308. X    (progn
  309. X      (remove-obj-from-inven objnum)
  310. X      (replace room-objects current-room
  311. X           (append (nth current-room room-objects)
  312. X               (list objnum)))
  313. X      (mprincl "Done.")
  314. X      (if (member objnum '(3 8 19))
  315. X          (drop-check objnum))))))))
  316. X
  317. X;; Dropping certain things causes things to happen.
  318. X
  319. X(defun drop-check (objnum)
  320. X  (if (and (= objnum 3) (= room 7) (member -3 (nth 7 room-objects)))
  321. X      (progn
  322. X    (mprincl
  323. X"The bear takes the food and runs away with it. He left something behind.")
  324. X    (remove-obj-from-room current-room -3)
  325. X    (remove-obj-from-room current-room 3)
  326. X    (replace room-objects current-room
  327. X         (append (nth current-room room-objects)
  328. X             (list 4)))))
  329. X
  330. X  (if (and (= objnum 19) (member 21 jar) (member 22 jar))
  331. X      (progn
  332. X    (mprincl "As the jar impacts the ground it explodes into many pieces.")
  333. X    (setq jar nil)
  334. X    (remove-obj-from-room current-room 19)
  335. X    (if (= current-room 77)
  336. X        (progn
  337. X          (setq hole t)
  338. X          (setq current-room 89)
  339. X          (mprincl 
  340. X"The explosion causes a hole to open up in the ground, which you fall
  341. Xthrough.")))))
  342. X
  343. X  (if (and (= objnum 8) (= current-room 17))
  344. X      (mprincl "A passageway opens.")))
  345. X
  346. X;;; Give long description of current room, or an object.
  347. X      
  348. X(defun examine (obj)
  349. X  (let (objnum)
  350. X    (setq objnum (objnum-from-args obj))
  351. X    (if (eq objnum 255)
  352. X    (describe-room (* current-room -1))
  353. X      (if (eq objnum nil)
  354. X      (mprincl "I don't know what that is.")
  355. X    (if (and (not (member objnum (nth current-room room-objects)))
  356. X         (not (member objnum (nth current-room room-silents)))
  357. X         (not (member objnum inventory)))
  358. X        (mprincl "I don't see that here.")
  359. X      (if (>= objnum 0)
  360. X          (if (and (= objnum 20) (= current-room 86) black)
  361. X          (mprincl 
  362. X"In this light you can see some writing on the bone.  It says:
  363. XFor an explosive time, go to Fourth St. and Vermont.")
  364. X        (if (nth objnum physobj-desc)
  365. X            (mprincl (nth objnum physobj-desc))
  366. X          (mprincl "I see nothing special about that.")))
  367. X        (if (nth (abs objnum) permobj-desc)
  368. X        (progn
  369. X          (mprincl (nth (abs objnum) permobj-desc)))
  370. X          (mprincl "I see nothing special about that."))))))))
  371. X
  372. X(defun take (obj)
  373. X  (if inbus
  374. X      (mprincl "You can't take anything while on the bus.")
  375. X  (setq obj (firstword obj))
  376. X  (if (not obj)
  377. X      (mprincl "You must supply an object.")
  378. X    (if (string= obj "all")
  379. X    (let (gotsome)
  380. X      (setq gotsome nil)
  381. X      (dolist (x (nth current-room room-objects))
  382. X        (if (and (>= x 0) (not (= x 255)))
  383. X        (progn
  384. X          (setq gotsome t)
  385. X          (mprinc (cadr (nth x objects)))
  386. X          (mprinc ": ")
  387. X          (take-object x))))
  388. X      (if (not gotsome)
  389. X          (mprincl "Nothing to take.")))
  390. X      (progn
  391. X    (setq objnum (cdr (assq (intern obj) objnames)))
  392. X    (if (eq objnum nil)
  393. X        (progn
  394. X          (mprinc "I don't know what that is.")
  395. X          (mprinc "\n"))
  396. X      (take-object objnum)))))))
  397. X
  398. X(defun take-object (objnum)
  399. X  (if (and (member objnum jar) (member 19 inventory))
  400. X      (progn
  401. X    (mprincl "You remove it from the jar.")
  402. X    (setq newjar nil)
  403. X    (dolist (x jar)
  404. X      (if (not (= x objnum))
  405. X          (setq newjar (append newjar (list x)))))
  406. X    (setq jar newjar)
  407. X    (setq inventory (append inventory (list objnum))))
  408. X    (if (not (member objnum (nth current-room room-objects)))
  409. X    (if (not (member objnum (nth current-room room-silents)))
  410. X        (mprinc "I do not see that here.")
  411. X      (try-take objnum))
  412. X      (if (>= objnum 0)
  413. X      (progn
  414. X        (if (and (car inventory) 
  415. X             (> (+ (inven-weight) (nth objnum object-lbs)) 11))
  416. X        (mprinc "Your load would be too heavy.")
  417. X          (setq inventory (append inventory (list objnum)))
  418. X          (remove-obj-from-room current-room objnum)
  419. X          (mprinc "Taken.  ")
  420. X          (if (and (= objnum 13) (= current-room 46))
  421. X          (mprinc "Taking the towel reveals a hole in the floor."))))
  422. X    (try-take objnum)))
  423. X    (mprinc "\n")))
  424. X
  425. X(defun inven-weight ()
  426. X  (let (total)
  427. X    (setq total 0)
  428. X    (dolist (x jar)
  429. X      (setq total (+ total (nth x object-lbs))))
  430. X    (dolist (x inventory)
  431. X      (setq total (+ total (nth x object-lbs)))) total))
  432. X
  433. X;;; We try to take an object that is untakable.  Print a message
  434. X;;; depending on what it is.
  435. X
  436. X(defun try-take (obj)
  437. X  (mprinc "You cannot take that."))
  438. X
  439. X
  440. X(defun dig (args)
  441. X  (if inbus
  442. X      (mprincl "You can't dig while on the bus.")
  443. X  (if (not (member 0 inventory))
  444. X      (mprincl "You have nothing with which to dig.")
  445. X    (if (not (nth current-room diggables))
  446. X    (mprincl "Digging here reveals nothing.")
  447. X      (mprincl "I think you found something.")
  448. X      (replace room-objects current-room
  449. X           (append (nth current-room room-objects)
  450. X               (nth current-room diggables)))
  451. X      (replace diggables current-room nil)))))
  452. X
  453. X(defun climb (args)
  454. X  (if (not (member -2 (nth current-room room-silents)))
  455. X      (mprincl "There is nothing here to climb.")
  456. X    (mprincl
  457. X"You manage to get about two feet up the tree and fall back down.  You
  458. Xnotice that the tree is very unsteady.")))
  459. X
  460. X(defun eat (obj)
  461. X  (let (objnum)
  462. X    (when (setq objnum (objnum-from-args-std obj))
  463. X      (if (not (member objnum inventory))
  464. X      (mprincl "You don't have that.")
  465. X    (if (not (= objnum 3))
  466. X        (progn
  467. X          (mprinc "You forcefully shove ")
  468. X          (mprinc (downcase (cadr (nth objnum objects))))
  469. X          (mprincl " down your throat, and start choking.")
  470. X          (die "choking"))
  471. X      (mprincl "That tasted horrible.")
  472. X      (remove-obj-from-inven 3))))))
  473. X
  474. X(defun dput (args)
  475. X  (if inbus
  476. X      (mprincl "You can't do that while on the bus")
  477. X    (let (newargs objnum objnum2)
  478. X      (setq newargs (firstwordl args))
  479. X      (if (not newargs)
  480. X      (mprincl "You must supply an object")
  481. X    (setq obj (intern (car newargs)))
  482. X    (setq objnum (cdr (assq obj objnames)))
  483. X    (if (not objnum)
  484. X        (mprincl "I don't know what that object is.")
  485. X      (if (not (member objnum inventory))
  486. X          (mprincl "You don't have that.")
  487. X        (setq newargs (firstwordl (cdr newargs)))
  488. X        (setq newargs (firstwordl (cdr newargs)))
  489. X        (if (not newargs)
  490. X        (mprincl "You must supply an indirect object.")
  491. X          (setq objnum2 (cdr (assq (intern (car newargs)) objnames)))
  492. X          (if (not objnum2)
  493. X          (mprincl "I don't know what that indirect object is.")
  494. X        (if (and (not (member objnum2 (nth current-room room-objects)))
  495. X             (not (member objnum2 (nth current-room room-silents)))
  496. X             (not (member objnum2 inventory)))
  497. X            (mprincl "That indirect object is not here.")
  498. X          (put-objs objnum objnum2))))))))))
  499. X
  500. X(defun put-objs (obj1 obj2)
  501. X  (if (and (= obj2 -17) (not nomail))
  502. X      (setq obj2 -9))
  503. X
  504. X  (if (= obj2 -26) (setq obj2 -9))
  505. X
  506. X  (if (and (= obj1 2) (= obj2 -5))     ;; Put board in cabinet
  507. X      (progn
  508. X    (remove-obj-from-inven 2)
  509. X    (setq computer t)
  510. X    (mprincl
  511. X"As you put the CPU board in the computer, it immediately springs to life.
  512. XThe lights start flashing, and the fans seem to startup."))
  513. X    (if (and (= obj1 8) (= obj2 -8))   ;; Put weight on button
  514. X    (drop '("weight"))
  515. X      (if (= obj2 19)                 ;; Put something in jar
  516. X      (if (not (member obj1 '(5 7 10 16 17 18 21 22)))
  517. X          (mprincl "That will not fit in the jar.")
  518. X        (remove-obj-from-inven obj1)
  519. X        (setq jar (append jar (list obj1)))
  520. X        (mprincl "Done."))
  521. X    (if (= obj2 -9)                 ;; Put something in chute
  522. X        (progn
  523. X          (remove-obj-from-inven obj1)
  524. X          (mprincl 
  525. X"You hear it slide down the chute and off into the distance.")
  526. X          (put-objs-in-treas (list obj1)))
  527. X      (if (= obj2 -15)
  528. X          (if (= obj1 4)
  529. X          (progn
  530. X            (mprincl
  531. X"As you drop the key, the box begins to shake.  Finally it explodes
  532. Xwith a bang.  The key seems to have vanished!")
  533. X            (remove-obj-from-inven obj1)
  534. X            (replace room-objects 10 (append
  535. X                            (nth 10 room-objects)
  536. X                            (list obj1)))
  537. X            (remove-obj-from-room current-room -15)
  538. X            (setq key-level (1+ key-level))))
  539. X        (if (= obj2 -12)
  540. X        (progn
  541. X          (remove-obj-from-inven obj1)
  542. X          (replace room-objects 36 (append (nth 36 room-objects)
  543. X                           (list obj1)))
  544. X          (mprincl
  545. X           "You hear it plop down in some water below."))
  546. X          (if (= obj2 -17)
  547. X          (mprincl "The mail chute is locked.")
  548. X        (if (member obj1 inventory)
  549. X            (mprincl 
  550. X"I don't know how to combine those objects.  Perhaps you should
  551. Xjust try dropping it.")
  552. X        (mprincl"You can't put that there."))))))))))
  553. X
  554. X(defun type (args)
  555. X  (if (not (= current-room 10))
  556. X      (mprincl "There is nothing here on which you could type.")
  557. X    (if (not computer)
  558. X    (mprincl 
  559. X"You type on the keyboard, but your characters do not even echo.")
  560. X      (unix-interface))))
  561. X
  562. X;;;; Various movement directions
  563. X
  564. X(defun n (args)
  565. X  (move 0))
  566. X
  567. X(defun s (args)
  568. X  (move 1))
  569. X
  570. X(defun e (args)
  571. X  (move 2))
  572. X
  573. X(defun w (args)
  574. X  (move 3))
  575. X
  576. X(defun ne (args)
  577. X  (move 4))
  578. X
  579. X(defun se (args)
  580. X  (move 5))
  581. X
  582. X(defun nw (args)
  583. X  (move 6))
  584. X
  585. X(defun sw (args)
  586. X  (move 7))
  587. X
  588. X(defun up (args)
  589. X  (move 8))
  590. X
  591. X(defun down (args)
  592. X  (move 9))
  593. X
  594. X(defun in (args)
  595. X  (move 10))
  596. X
  597. X(defun out (args)
  598. X  (move 11))
  599. X
  600. X(defun go (args)
  601. X  (if (or (not (car args)) 
  602. X      (eq (doverb ignore verblist (car args) (cdr (cdr args))) -1))
  603. X      (mprinc "I don't understand where you want me to go.\n")))
  604. X
  605. X(defun move (dir)
  606. X  (if (and (not (member current-room light-rooms)) (not (member 1 inventory)))
  607. X      (progn
  608. X    (mprinc 
  609. X"You trip over a grue and fall into a pit and break every bone in your
  610. Xbody.")
  611. X    (die "a grue"))
  612. X    (let (newroom)
  613. X      (setq newroom (nth dir (nth current-room dungeon-map)))
  614. X      (if (eq newroom -1)
  615. X      (mprinc "You can't go that way.\n")
  616. X    (if (eq newroom 255)
  617. X        (special-move dir)
  618. X      (setq room -1)
  619. X      (setq lastdir dir)
  620. X      (if inbus
  621. X          (progn
  622. X        (if (or (< newroom 58) (> newroom 83))
  623. X            (mprincl "The bus cannot go this way.")
  624. X          (mprincl 
  625. X           "The bus lurches ahead and comes to a screeching halt.")
  626. X          (remove-obj-from-room current-room -18)
  627. X          (setq current-room newroom)
  628. X          (replace room-objects newroom
  629. X               (append (nth newroom room-objects) (list -18)))))
  630. X        (setq current-room newroom)))))))
  631. X
  632. X;; Movement in this direction causes something special to happen if the
  633. X;; right conditions exist.  It may be that you can't go this way unless
  634. X;; you have a key, or a passage has been opened.
  635. X
  636. X;; coding note: Each check of the current room is on the same 'if' level,
  637. X;; i.e. there aren't else's.  If two rooms next to each other have
  638. X;; specials, and they are connected by specials, this could cause
  639. X;; a problem.  Be careful when adding them to consider this, and
  640. X;; perhaps use else's.
  641. X
  642. X(defun special-move (dir)
  643. X  (if (= current-room 5)
  644. X      (if (not (member 4 inventory))
  645. X      (mprincl "You don't have a key that can open this door.")
  646. X    (setq current-room 8))
  647. X    (if (= current-room 7)
  648. X    (if (member -3 (nth 7 room-objects))
  649. X        (progn
  650. X          (mprinc 
  651. X"The bear is very annoyed that you would be so presumptuous as to try
  652. Xand walk right by it.  He tells you so by tearing your head off.
  653. X")
  654. X          (die "a bear"))
  655. X      (mprincl "You can't go that way.")))
  656. X
  657. X    (if (= current-room 89)
  658. X    (progn
  659. X      (mprincl
  660. X"As you board the train it immediately leaves the station.  It is a very
  661. Xbumpy ride.  It is shaking from side to side, and up and down.  You
  662. Xsit down in one of the chairs in order to be more comfortable.")
  663. X      (mprincl
  664. X"\nFinally the train comes to a sudden stop, and the doors open, and some
  665. Xforce throws you out.  The train speeds away.\n")
  666. X      (setq current-room 90)))
  667. X
  668. X    (if (= current-room 8)
  669. X    (if (and (member 4 inventory)
  670. X         (> key-level 0))
  671. X        (setq current-room 11)
  672. X      (mprincl "You don't have a key that can open this door.")))
  673. X
  674. X    (if (and (= current-room 17) (= dir 6))
  675. X    (if (member 8 (nth 17 room-objects))
  676. X        (setq current-room 18)
  677. X      (mprincl "You can't go that way.")))
  678. X
  679. X    (if (and (= current-room 17) (= dir 8))
  680. X    (if (member 8 (nth 17 room-objects))
  681. X        (mprincl "You can't go that way.")
  682. X      (setq current-room 16)))
  683. X
  684. X    (if (= current-room 88)
  685. X    (mprincl "The door is locked."))
  686. X
  687. X    (if (or (= current-room 25) (= current-room 26))
  688. X    (swim nil))
  689. X
  690. X    (if (= current-room 32)
  691. X    (if (> key-level 0)
  692. X        (setq current-room 57)
  693. X      (mprincl "You don't have a key that can open that door.")))
  694. X
  695. X    (if (= current-room 23)
  696. X    (if (not (= sauna-level 3))
  697. X        (setq current-room 24)
  698. X      (mprincl
  699. X"As you exit the building, you notice some flames coming out of one of the
  700. Xwindows.  Suddenly, the building explodes in a huge ball of fire.  The flames
  701. Xengulf you, and you burn to death.")
  702. X      (die "burning")))
  703. X
  704. X    (if (= current-room 46)
  705. X    (if (not (member 13 (nth 46 room-objects)))
  706. X        (setq current-room 47)
  707. X      (mprincl "You can't go that way.")))
  708. X
  709. X    (if (and (> dir 9) (> current-room 57) (< current-room 84))
  710. X    (if (not (member -18 (nth current-room room-objects)))
  711. X        (mprincl "You can't go that way.")
  712. X      (if (= dir 10)
  713. X          (if (member 16 inventory)
  714. X          (progn
  715. X            (mprincl "You board the bus and get in the driver's seat.")
  716. X            (setq nomail t)
  717. X            (setq inbus t))
  718. X        (mprincl "You are not licensed for this type of vehicle."))
  719. X        (mprincl "You hop off the bus.")
  720. X        (setq inbus nil)))
  721. X      (if (= current-room 80)
  722. X      (if (not inbus)
  723. X          (progn
  724. X        (mprincl "You fall down the cliff and land on your head.")
  725. X        (die "a cliff"))
  726. X        (mprincl
  727. X"The bus flies off the cliff, and plunges to the bottom, where it explodes.")
  728. X        (die "a bus accident")))
  729. X      (if (= current-room 59)
  730. X      (progn
  731. X        (if (not inbus)
  732. X        (mprincl "The gate will not open.")
  733. X          (mprincl
  734. X"As the bus approaches, the gate opens and you drive through.")
  735. X          (remove-obj-from-room 59 -18)
  736. X          (replace room-objects 83 (append (nth 83 room-objects)
  737. X                            (list -18)))
  738. X          (setq current-room 83)))))
  739. X    (if (= current-room 28)
  740. X    (progn
  741. X      (mprincl
  742. X"As you enter the room you hear a rumbling noise.  You look back to see
  743. Xhuge rocks sliding down from the ceiling, and blocking your way out.\n")
  744. X      (setq current-room 29)))))
  745. X
  746. X(defun long (args)
  747. X  (setq mode "long"))
  748. X
  749. X(defun turn (obj)
  750. X  (let (objnum direction)
  751. X    (when (setq objnum (objnum-from-args-std obj))
  752. X      (if (not (or (member objnum (nth current-room room-objects))
  753. X           (member objnum (nth current-room room-silents))))
  754. X      (mprincl "I don't see that here.")
  755. X    (if (not (= objnum -7))
  756. X        (mprincl "You can't turn that.")
  757. X      (setq direction (firstword (cdr obj)))
  758. X      (if (or (not direction) 
  759. X          (not (or (string= direction "clockwise")
  760. X               (string= direction "counterclockwise"))))
  761. X          (mprincl "You must indicate clockwise or counterclockwise.")
  762. X        (if (string= direction "clockwise")
  763. X        (setq sauna-level (+ sauna-level 1))
  764. X          (setq sauna-level (- sauna-level 1)))
  765. X        
  766. X        (if (< sauna-level 0)
  767. X        (progn
  768. X          (mprincl 
  769. X           "The dial will not turn further in that direction.")
  770. X          (setq sauna-level 0))
  771. X          (sauna-heat))))))))
  772. X
  773. X(defun sauna-heat ()
  774. X  (if (= sauna-level 0)
  775. X      (mprincl "The termperature has returned to normal room termperature."))
  776. X  (if (= sauna-level 1)
  777. X      (mprincl "It is now luke warm in here.  You begin to sweat."))
  778. X  (if (= sauna-level 2)
  779. X      (mprincl "It is pretty hot in here.  It is still very comfortable."))
  780. X  (if (= sauna-level 3)
  781. X      (progn
  782. X    (mprincl 
  783. X"It is now very hot.  There is something very refreshing about this.")
  784. X    (if (or (member 6 inventory) 
  785. X        (member 6 (nth current-room room-objects)))
  786. X        (progn
  787. X          (mprincl 
  788. X"You notice the wax on your statuette beginning to melt, until it completely
  789. Xmelts off.  You are left with a beautiful diamond!")
  790. X          (if (member 6 inventory)
  791. X          (progn
  792. X            (remove-obj-from-inven 6)
  793. X            (setq inventory (append inventory (list 7))))
  794. X        (remove-obj-from-room current-room 6)
  795. X        (replace room-objects current-room
  796. X             (append (nth current-room room-objects)
  797. X                 (list 7))))))))
  798. X  (if (= sauna-level 4)
  799. X      (progn
  800. X    (mprincl 
  801. X"As the dial clicks into place, you immediately burst into flames.")
  802. X    (die "burning"))))
  803. X
  804. X(defun press (obj)
  805. X  (let (objnum)
  806. X    (when (setq objnum (objnum-from-args-std obj))
  807. X      (if (not (or (member objnum (nth current-room room-objects))
  808. X           (member objnum (nth current-room room-silents))))
  809. X      (mprincl "I don't see that here.")
  810. X    (if (not (member objnum '(-8 -24)))
  811. X        (progn
  812. X          (mprinc "You can't ")
  813. X          (mprinc (car line-list))
  814. X          (mprincl " that."))
  815. X      (if (= objnum -8)
  816. X          (mprincl
  817. X"As you press the button, you notice a passageway open up, but
  818. Xas you release it, the passageway closes."))
  819. X      (if (= objnum -24)
  820. X          (if black
  821. X          (progn
  822. X            (mprincl "The button is now in the off position.")
  823. X            (setq black nil))
  824. X        (mprincl "The button is now in the on position.")
  825. X        (setq black t))))))))
  826. X
  827. X(defun swim (args)
  828. X  (if (not (member current-room '(25 26)))
  829. X      (mprincl "I see no water!")
  830. X    (if (not (member 9 inventory))
  831. X    (progn
  832. X      (mprincl 
  833. X"You dive in the water, and at first notice it is quite cold.  You then
  834. Xstart to get used to it as you realize that you never really learned how
  835. Xto swim.")
  836. X      (die "drowning"))
  837. X      (if (= current-room 25)
  838. X      (setq current-room 26)
  839. X    (setq current-room 25)))))
  840. X
  841. X
  842. X(defun score (args)
  843. X  (if (not endgame)
  844. X      (let (total)
  845. X    (setq total (reg-score))
  846. X    (mprinc "You have scored ")
  847. X    (mprinc total)
  848. X    (mprincl " out of a possible 90 points.") total)
  849. X    (mprinc "You have scored ")
  850. X    (mprinc (endgame-score))
  851. X    (mprincl " endgame points out of a possible 110.")
  852. X    (if (= (endgame-score) 110)
  853. X    (mprincl 
  854. X"\n\nCongratulations.  You have won.  The wizard password is 'moby'"))))
  855. X
  856. X(defun help (args)
  857. X  (mprincl
  858. X"Welcome to dunnet (1.0), by Ron Schnell (ronnie@eddie.mit.edu).
  859. XThis is a pre-release version.  Here is some useful information (read
  860. Xcarefully because there are one or more clues in here):
  861. X
  862. X- If you have a key that can open a door, you do not need to explicitly
  863. X  open it.  You may just use 'in' or walk in the direction of the door.
  864. X
  865. X- If you have a lamp, it is always lit.
  866. X
  867. X- You will not get any points until you manage to get treasures to a certain
  868. X  place.  Simply finding the treasures is not good enough.  There is more
  869. X  than one way to get a treasure to the special place.  It is also
  870. X  important that the objects get to the special place *unharmed* and
  871. X  *untarnished*.  You can tell if you have successfully transported the
  872. X  object by looking at your score, as it changes immediately.  Note that
  873. X  an object can become harmed even after you have received points for it.
  874. X  If this happens, your score will decrease, and in many cases you can never
  875. X  get credit for it again.
  876. X
  877. X- You can save your game with the 'save' command, and use restore it
  878. X  with the 'restore' command.
  879. X
  880. X- There are no limits on lengths of object names.
  881. X
  882. X- Directions are: north,south,east,west,northeast,southeast,northwest,
  883. X                  southwest,up,down,in,out.
  884. X
  885. X- These can be abbreviated: n,s,e,w,ne,se,nw,sw,u,d,in,out.
  886. X
  887. X- If you go down a hole in the floor without an aid such as a ladder,
  888. X  you probably won't be able to get back up the way you came, if at all.
  889. X
  890. X- It is possible to get the maximum points.
  891. X
  892. XIf you have questions or comments, contact ronnie@eddie.mit.edu."))
  893. X
  894. X(defun flush (args)
  895. X  (if (not (= current-room 35))
  896. X      (mprincl "I see nothing to flush.")
  897. X    (mprincl "Whoooosh!!")
  898. X    (put-objs-in-treas (nth 36 room-objects))
  899. X    (replace room-objects 36 nil)))
  900. X
  901. X(defun piss (args)
  902. X  (if (not (= current-room 35))
  903. X      (mprincl "You can't do that here, don't even bother trying.")
  904. X    (if (not gottago)
  905. X    (mprincl "I'm afraid you don't have to go now.")
  906. X      (mprincl "That was refreshing.")
  907. X      (setq gottago nil)
  908. X      (replace room-objects 36 (append (nth 36 room-objects) (list -13))))))
  909. X
  910. X
  911. X(defun sleep (args)
  912. X  (if (not (= current-room 34))
  913. X      (mprincl
  914. X"You try to go to sleep while standing up here, but can't seem to do it.")
  915. X    (setq gottago t)
  916. X    (mprincl
  917. X"As soon as you start to doze off you begin dreaming.  You see images of
  918. Xworkers digging caves, slaving in the humid heat.  Then you see yourself
  919. Xas one of these workers.  While no one is looking, you leave the group
  920. Xand walk into a room.  The room is bare except for a horseshoe
  921. Xshaped piece of stone in the center.  You see yourself digging a hole in
  922. Xthe ground, then putting some kind of treasure in it, and filling the hole
  923. Xwith dirt again.  After this, you immediately wake up.")))
  924. X
  925. X(defun break (obj)
  926. X  (let (objnum)
  927. X    (if (not (member 14 inventory))
  928. X    (mprincl "You have nothing you can use to break things.")
  929. X      (when (setq objnum (objnum-from-args-std obj))
  930. X    (if (member objnum inventory)
  931. X        (progn
  932. X          (mprincl
  933. X"You take the object in your hands and swing the axe.  Unfortunately, you miss
  934. Xthe object and slice off your hand.  You bleed to death.")
  935. X          (die "an axe"))
  936. X      (if (not (or (member objnum (nth current-room room-objects))
  937. X               (member objnum (nth current-room room-silents))))
  938. X          (mprincl "I don't see that here.")
  939. X        (if (= objnum -16)
  940. X        (progn
  941. X          (mprincl 
  942. X"As you break the ethernet cable, everything starts to blur.  You collapse
  943. Xfor a moment, then straighten yourself up.
  944. X")
  945. X          (replace room-objects 57 (append (nth 36 room-objects)
  946. X                           inventory))
  947. X          (if (member 4 inventory)
  948. X              (progn
  949. X            (setq inventory '(4))
  950. X            (remove-obj-from-room 57 4))
  951. X            (setq inventory nil))
  952. X          (setq current-room 10)
  953. X          (setq ethernet nil)
  954. X          (mprincl "Connection closed.")
  955. X          (unix-interface))
  956. X          (if (< objnum 0)
  957. X          (progn
  958. X            (mprincl "Your axe shatters into a million pieces.")
  959. X            (remove-obj-from-inven 14))
  960. X        (mprincl "Your axe breaks it into a million pieces.")
  961. X        (remove-obj-from-room current-room objnum)))))))))
  962. X
  963. X(defun drive (args)
  964. X  (if (not inbus)
  965. X      (mprincl "You cannot drive when you aren't in a vehicle.")
  966. X    (mprincl "To drive while you are in the bus, just give a direction.")))
  967. X
  968. X(defun superb (args)
  969. X  (setq mode 'superb))
  970. X
  971. X(defun reg-score ()
  972. X  (let (total)
  973. X    (setq total 0)
  974. X    (dolist (x (nth 0 room-objects))
  975. X      (setq total (+ total (nth x object-pts))))
  976. X    (if (member -13 (nth 0 room-objects))
  977. X    (setq total 0)) total))
  978. X
  979. X(defun endgame-score ()
  980. X  (let (total)
  981. X    (setq total 0)
  982. X    (dolist (x (nth 102 room-objects))
  983. X      (setq total (+ total (nth x object-pts)))) total))
  984. X
  985. X(defun answer (args)
  986. X  (if (not correct-answer)
  987. X      (mprincl "I don't believe anyone asked you anything.")
  988. X    (setq args (car args))
  989. X    (if (not args)
  990. X    (mprincl "You must give the answer on the same line.")
  991. X      (if (members args correct-answer)
  992. X      (progn
  993. X        (mprincl "Correct.")
  994. X        (if (= lastdir 0)
  995. X        (setq current-room (1+ current-room))
  996. X          (setq current-room (- current-room 1)))
  997. X        (setq correct-answer nil))
  998. X    (mprincl "That answer is incorrect.")))))
  999. X
  1000. X(defun endgame-question ()
  1001. X(if (not endgame-questions)
  1002. X    (progn
  1003. X      (mprincl "Your question is:")
  1004. X      (mprincl "No more questions, just do 'answer foo'.")
  1005. X      (setq correct-answer '("foo")))
  1006. X  (let (which i newques)
  1007. X    (setq i 0)
  1008. X    (setq newques nil)
  1009. X    (setq which (% (abs (random)) (length endgame-questions)))
  1010. X    (mprincl "Your question is:")
  1011. X    (mprincl (setq endgame-question (car (nth which endgame-questions))))
  1012. X    (setq correct-answer (cdr (nth which endgame-questions)))
  1013. X    (while (< i which)
  1014. X      (setq newques (append newques (list (nth i endgame-questions))))
  1015. X      (setq i (1+ i)))
  1016. X    (setq i (1+ which))
  1017. X    (while (< i (length endgame-questions))
  1018. X      (setq newques (append newques (list (nth i endgame-questions))))
  1019. X      (setq i (1+ i)))
  1020. X    (setq endgame-questions newques))))
  1021. END_OF_FILE
  1022. if test 28022 -ne `wc -c <'dun-commands.el'`; then
  1023.     echo shar: \"'dun-commands.el'\" unpacked with wrong size!
  1024. fi
  1025. # end of 'dun-commands.el'
  1026. fi
  1027. if test -f 'dun-main.el' -a "${1}" != "-c" ; then 
  1028.   echo shar: Will not clobber existing file \"'dun-main.el'\"
  1029. else
  1030. echo shar: Extracting \"'dun-main.el'\" \(2311 characters\)
  1031. sed "s/^X//" >'dun-main.el' <<'END_OF_FILE'
  1032. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1033. X;                                                                      ;
  1034. X;                       dunnet.el  Version 1.0                         ;
  1035. X;                                                                      ;
  1036. X;                   Ron Schnell (ronnie@eddie.mit.edu)                 ;
  1037. X;                                                                      ;
  1038. X;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1039. X
  1040. X
  1041. X;; This is the startup file.  It loads in the other files, and sets up
  1042. X;; the functions to be bound to keys if you play in window-mode.
  1043. X
  1044. X;;;;;  The log file should be set for your system, and it must
  1045. X;;;;;  be writeable by all.
  1046. X
  1047. X      (setq log-file "/user0/rschnell/score/score") 
  1048. X
  1049. X(defun dungeon-mode ()
  1050. X  "Major mode for running dungeon"
  1051. X  (interactive)
  1052. X  (text-mode)
  1053. X  (use-local-map dungeon-mode-map)
  1054. X  (setq major-mode 'dungeon-mode)
  1055. X  (setq mode-name "Dungeon")
  1056. X)
  1057. X
  1058. X(defun dungeon-parse (arg)
  1059. X  "foo"
  1060. X  (interactive "*p")
  1061. X  (beginning-of-line)
  1062. X  (setq beg (+ (point) 1))
  1063. X  (end-of-line)
  1064. X  (if (and (not (= beg (point)))
  1065. X       (string= ">" (buffer-substring (- beg 1) beg)))
  1066. X      (progn
  1067. X    (setq line (downcase (buffer-substring beg (point))))
  1068. X    (princ line)
  1069. X    (if (eq (parse ignore verblist line) -1)
  1070. X        (mprinc "I don't understand that.\n")))
  1071. X    (goto-char (point-max))
  1072. X    (mprinc "\n"))
  1073. X    (dungeon-messages))
  1074. X    
  1075. X(defun dungeon-messages ()
  1076. X  (if dead
  1077. X      (text-mode)
  1078. X    (if (eq dungeon-mode 'dungeon)
  1079. X    (progn
  1080. X      (if (not (= room current-room))
  1081. X          (progn
  1082. X        (describe-room current-room)
  1083. X        (setq room current-room)))
  1084. X      (mprinc ">")))))
  1085. X
  1086. X(defun dungeon-start ()
  1087. X  (interactive)
  1088. X  (switch-to-buffer "*dungeon*")
  1089. X  (dungeon-mode)
  1090. X  (setq dead nil)
  1091. X  (setq room 0)
  1092. X  (dungeon-messages))
  1093. X
  1094. X(require 'cl)
  1095. X
  1096. X(defun batch-dungeon ()
  1097. X  (setq load-path (append load-path (list ".")))
  1098. X  (load "dun-batch")
  1099. X  (setq visited '(27))
  1100. X  (mprinc "\n")
  1101. X  (dungeon-batch-loop))
  1102. X
  1103. X(setq load-path (append load-path (list ".")))
  1104. X
  1105. X(load "dun-commands")
  1106. X(load "dun-util")
  1107. X(if (setq glob (get-glob-dat))
  1108. X    (load-d glob)
  1109. X  (load "dun-globals"))
  1110. X
  1111. X(load "dun-unix")
  1112. X(load "dun-save")
  1113. X(setq tloc (+ 60 (% (abs (random)) 18)))
  1114. X(replace room-objects tloc (append (nth tloc room-objects) (list 18)))
  1115. X(dungeon-start)
  1116. END_OF_FILE
  1117. if test 2311 -ne `wc -c <'dun-main.el'`; then
  1118.     echo shar: \"'dun-main.el'\" unpacked with wrong size!
  1119. fi
  1120. # end of 'dun-main.el'
  1121. fi
  1122. if test -f 'dun-save.el' -a "${1}" != "-c" ; then 
  1123.   echo shar: Will not clobber existing file \"'dun-save.el'\"
  1124. else
  1125. echo shar: Extracting \"'dun-save.el'\" \(4075 characters\)
  1126. sed "s/^X//" >'dun-save.el' <<'END_OF_FILE'
  1127. X
  1128. X;;;;;;;;;;;;;;;;;;;
  1129. X;
  1130. X;
  1131. X;  Save and restore
  1132. X;
  1133. X;
  1134. X;;;;;;;;;;;;;;;;;;;
  1135. X
  1136. X(defun save-game (filename)
  1137. X  (if (not (setq filename (car filename)))
  1138. X      (mprincl "You must supply a filename for the save.")
  1139. X    (if (file-exists-p filename)
  1140. X    (mprincl "File already exists.")
  1141. X      (setq numsaves (1+ numsaves))
  1142. X      (make-save-buffer)
  1143. X      (save-val "current-room")
  1144. X      (save-val "computer")
  1145. X      (save-val "door1")
  1146. X      (save-val "visited")
  1147. X      (save-val "diggables")
  1148. X      (save-val "key-level")
  1149. X      (save-val "numsaves")
  1150. X      (save-val "numcmds")
  1151. X      (save-val "logged-in")
  1152. X      (save-val "dungeon-mode")
  1153. X      (save-val "jar")
  1154. X      (save-val "lastdir")
  1155. X      (save-val "black")
  1156. X      (save-val "nomail")
  1157. X      (save-val "unix-verbs")
  1158. X      (save-val "hole")
  1159. X      (save-val "uncompressed")
  1160. X      (save-val "ethernet")
  1161. X      (save-val "sauna-level")
  1162. X      (save-val "room-objects")
  1163. X      (save-val "room-silents")
  1164. X      (save-val "inventory")
  1165. X      (save-val "endgame-question")
  1166. X      (save-val "endgame")
  1167. X      (save-val "endgame-questions")
  1168. X      (save-val "cdroom")
  1169. X      (save-val "cdpath")
  1170. X      (save-val "correct-answer")
  1171. X      (save-val "inbus")
  1172. X      (compile-save-out filename)
  1173. X      (do-logfile 'save nil)
  1174. X      (switch-to-buffer "*dungeon*")
  1175. X      (princ "")
  1176. X      (mprincl "Done."))))
  1177. X
  1178. X(defun make-save-buffer ()
  1179. X  (switch-to-buffer (get-buffer-create "*save-dungeon*"))
  1180. X  (erase-buffer))
  1181. X
  1182. X;; If you don't have the crypt program, rename this function to
  1183. X;; compile-save-out, and get rid of the next function.
  1184. X
  1185. X(defun compile-save-out-nocrypt (filename)
  1186. X  (write-region 1 (point-max) filename nil 1)
  1187. X  (kill-buffer (current-buffer)))
  1188. X
  1189. X(defun compile-save-out (filename)
  1190. X  (let (key dir ferror)
  1191. X    (setq ferror nil)
  1192. X    (if (< lastdir 10)
  1193. X    (setq dir (+ lastdir 10))
  1194. X      (setq dir lastdir))
  1195. X    (setq key (prin1-to-string dir))
  1196. X    (condition-case nil
  1197. X    (crypt-buffer key)
  1198. X      (error (setq ferror t)))
  1199. X    (if (not ferror)
  1200. X    (progn
  1201. X      (goto-char (point-min))
  1202. X      (insert key)))
  1203. X    (write-region 1 (point-max) filename nil 1)
  1204. X    (kill-buffer (current-buffer))))
  1205. X
  1206. X(defun save-val (varname)
  1207. X  (let (value)
  1208. X    (setq varname (intern varname))
  1209. X    (setq value (eval varname))
  1210. X    (minsert "(setq ")
  1211. X    (minsert varname)
  1212. X    (minsert " ")
  1213. X    (if (or (listp value)
  1214. X        (symbolp value))
  1215. X    (minsert "'"))
  1216. X    (if (stringp value)
  1217. X    (minsert "\""))
  1218. X    (minsert value)
  1219. X    (if (stringp value)
  1220. X    (minsert "\""))
  1221. X    (minsertl ")")))
  1222. X
  1223. X
  1224. X;; If you don't have the crypt program, rename this function to 'restore'
  1225. X;; and get rid of the next function.
  1226. X
  1227. X(defun restore-nocrypt (args)
  1228. X  (let (file ferrror)
  1229. X    (setq ferror nil)
  1230. X    (if (not (setq file (car args)))
  1231. X    (mprincl "You must supply a filename.")
  1232. X      (condition-case nil
  1233. X      (load-file file)
  1234. X    (error (setq ferror t)))
  1235. X      (if ferror
  1236. X      (mprinc "Could not load restore file.")
  1237. X    (mprincl "Done.")
  1238. X    (setq room 0)))))
  1239. X
  1240. X(defun restore (args)
  1241. X  (let (file)
  1242. X    (if (not (setq file (car args)))
  1243. X    (mprincl "You must supply a filename.")
  1244. X      (if (not (load-d file))
  1245. X      (mprincl "Could not load restore file.")
  1246. X    (mprincl "Done.")
  1247. X    (setq room 0)))))
  1248. X
  1249. X
  1250. X(defun do-logfile (type how)
  1251. X  (let (ferror)
  1252. X    (setq ferror nil)
  1253. X    (switch-to-buffer (get-buffer-create "*score*"))
  1254. X    (erase-buffer)
  1255. X    (condition-case nil
  1256. X    (insert-file-contents log-file)
  1257. X      (error (setq ferror t)))
  1258. X    (unless ferror
  1259. X        (goto-char (point-max))
  1260. X        (minsert (user-login-name))
  1261. X        (minsert " ")
  1262. X        (if (eq type 'save)
  1263. X        (minsert "saved ")
  1264. X          (if (= (endgame-score) 110)
  1265. X          (minsert "won ")
  1266. X        (if (not how)
  1267. X            (minsert "quit ")
  1268. X          (minsert "killed by ")
  1269. X          (minsert how)
  1270. X          (minsert " "))))
  1271. X        (minsert "at ")
  1272. X        (minsert (cadr (nth (abs room) rooms)))
  1273. X        (minsert ". score: ")
  1274. X        (if (> (endgame-score) 0)
  1275. X        (minsert (setq newscore (+ 90 (endgame-score))))
  1276. X          (minsert (setq newscore (reg-score))))
  1277. X        (minsert " saves: ")
  1278. X        (minsert numsaves)
  1279. X        (minsert " commands: ")
  1280. X        (minsert numcmds)
  1281. X        (minsert "\n")
  1282. X        (write-region 1 (point-max) log-file nil 1))
  1283. X    (kill-buffer (current-buffer))))
  1284. END_OF_FILE
  1285. if test 4075 -ne `wc -c <'dun-save.el'`; then
  1286.     echo shar: \"'dun-save.el'\" unpacked with wrong size!
  1287. fi
  1288. # end of 'dun-save.el'
  1289. fi
  1290. if test -f 'dun-util.el' -a "${1}" != "-c" ; then 
  1291.   echo shar: Will not clobber existing file \"'dun-util.el'\"
  1292. else
  1293. echo shar: Extracting \"'dun-util.el'\" \(7730 characters\)
  1294. sed "s/^X//" >'dun-util.el' <<'END_OF_FILE'
  1295. X(require 'cl)
  1296. X
  1297. X;;;;;;;;;;;;;;;;;;;;; Utility functions
  1298. X
  1299. X;;; Function which takes a verb and a list of other words.  Calls proper
  1300. X;;; function associated with the verb, and passes along the other words.
  1301. X
  1302. X(defun doverb (ignore verblist verb rest)
  1303. X  (if (not verb)
  1304. X      nil
  1305. X    (if (member (intern verb) ignore)
  1306. X    (if (not (car rest)) -1
  1307. X      (doverb ignore verblist (car rest) (cdr rest)))
  1308. X      (if (not (cdr (assq (intern verb) verblist))) -1
  1309. X    (setq numcmds (1+ numcmds))
  1310. X    (eval (list (cdr (assq (intern verb) verblist)) (quote rest)))))))
  1311. X
  1312. X
  1313. X;;; Function to take a string and change it into a list of lowercase words.
  1314. X
  1315. X(defun listify-string (strin)
  1316. X  (let (pos ret-list end-pos)
  1317. X    (setq pos 0)
  1318. X    (setq ret-list nil)
  1319. X    (while (setq end-pos (string-match "[ ,:;]" (substring strin pos)))
  1320. X      (setq end-pos (+ end-pos pos))
  1321. X      (if (not (= end-pos pos))
  1322. X      (setq ret-list (append ret-list (list 
  1323. X                       (downcase
  1324. X                        (substring strin pos end-pos))))))
  1325. X      (setq pos (+ end-pos 1))) ret-list))
  1326. X
  1327. X(defun listify-string2 (strin)
  1328. X  (let (pos ret-list end-pos)
  1329. X    (setq pos 0)
  1330. X    (setq ret-list nil)
  1331. X    (while (setq end-pos (string-match " " (substring strin pos)))
  1332. X      (setq end-pos (+ end-pos pos))
  1333. X      (if (not (= end-pos pos))
  1334. X      (setq ret-list (append ret-list (list 
  1335. X                       (downcase
  1336. X                        (substring strin pos end-pos))))))
  1337. X      (setq pos (+ end-pos 1))) ret-list))
  1338. X
  1339. X(defun replace (list n number)
  1340. X  (rplaca (nthcdr n list) number))
  1341. X
  1342. X
  1343. X;;; Get the first non-ignored word from a list.
  1344. X
  1345. X(defun firstword (list)
  1346. X  (if (not (car list))
  1347. X      nil
  1348. X    (while (and list (member (intern (car list)) ignore))
  1349. X      (setq list (cdr list)))
  1350. X    (car list)))
  1351. X
  1352. X(defun firstwordl (list)
  1353. X  (if (not (car list))
  1354. X      nil
  1355. X    (while (and list (member (intern (car list)) ignore))
  1356. X      (setq list (cdr list)))
  1357. X    list))
  1358. X
  1359. X;; parse a line passed in as a string  Call the proper verb with the
  1360. X;; rest of the line passed in as a list.
  1361. X
  1362. X(defun parse (ignore verblist line)
  1363. X  (mprinc "\n")
  1364. X  (setq line-list (listify-string (concat line " ")))
  1365. X  (doverb ignore verblist (car line-list) (cdr line-list)))
  1366. X
  1367. X(defun parse2 (ignore verblist line)
  1368. X  (mprinc "\n")
  1369. X  (setq line-list (listify-string2 (concat line " ")))
  1370. X  (doverb ignore verblist (car line-list) (cdr line-list)))
  1371. X
  1372. X(defun read-line ()
  1373. X  (let (line)
  1374. X    (setq line (read-string ""))
  1375. X    (mprinc line) line))
  1376. X
  1377. X(defun minsert (string)
  1378. X  (if (stringp string)
  1379. X      (insert string)
  1380. X    (insert (prin1-to-string string))))
  1381. X
  1382. X(defun mprinc (string)
  1383. X  (if (stringp string)
  1384. X      (insert string)
  1385. X    (insert (prin1-to-string string))))
  1386. X
  1387. X(defun minsertl (string)
  1388. X  (minsert string)
  1389. X  (minsert "\n"))
  1390. X
  1391. X(defun mprincl (string)
  1392. X  (mprinc string)
  1393. X  (mprinc "\n"))
  1394. X
  1395. X;;;; Function which will get an object number given the list of
  1396. X;;;; words in the command, except for the verb.
  1397. X
  1398. X(defun objnum-from-args (obj)
  1399. X  (let (objnum)
  1400. X    (setq obj (firstword obj))
  1401. X    (if (not obj)
  1402. X    255
  1403. X      (setq objnum (cdr (assq (intern obj) objnames))))))
  1404. X
  1405. X(defun objnum-from-args-std (obj)
  1406. X  (let (result)
  1407. X  (if (eq (setq result (objnum-from-args obj)) 255)
  1408. X      (mprincl "You must supply an object."))
  1409. X  (if (eq result nil)
  1410. X      (mprincl "I don't know what that is."))
  1411. X  (if (eq result 255)
  1412. X      nil
  1413. X    result)))
  1414. X
  1415. X;; Take a short room description, and change spaces and slashes to dashes.
  1416. X
  1417. X(defun space-to-hyphen (string)
  1418. X  (let (space)
  1419. X    (if (setq space (string-match "[ /]" string))
  1420. X    (progn
  1421. X      (setq string (concat (substring string 0 space) "-"
  1422. X                   (substring string (1+ space))))
  1423. X      (space-to-hyphen string))
  1424. X      string)))
  1425. X
  1426. X;; Given a unix style pathname, build a list of path components (recursive)
  1427. X
  1428. X(defun get-path (dirstring startlist)
  1429. X  (let (slash pos)
  1430. X    (if (= (length dirstring) 0)
  1431. X    startlist
  1432. X      (if (string= (substring dirstring 0 1) "/")
  1433. X      (get-path (substring dirstring 1) (append startlist (list "/")))
  1434. X    (if (not (setq slash (string-match "/" dirstring)))
  1435. X        (append startlist (list dirstring))
  1436. X      (get-path (substring dirstring (1+ slash))
  1437. X            (append startlist
  1438. X                (list (substring dirstring 0 slash)))))))))
  1439. X
  1440. X
  1441. X(defun members (string string-list)
  1442. X  (let (found)
  1443. X    (setq found nil)
  1444. X    (dolist (x string-list)
  1445. X      (if (string= x string)
  1446. X      (setq found t))) found))
  1447. X
  1448. X(defun put-objs-in-treas (objlist)
  1449. X  (let (oscore newscore)
  1450. X    (setq oscore (reg-score))
  1451. X    (replace room-objects 0 (append (nth 0 room-objects) objlist))
  1452. X    (setq newscore (reg-score))
  1453. X    (if (not (= oscore newscore))
  1454. X    (score nil))))
  1455. X
  1456. X(defun load-d (filename)
  1457. X  (let (old-buffer key result)
  1458. X    (setq result t)
  1459. X    (setq old-buffer (current-buffer))
  1460. X    (switch-to-buffer (get-buffer-create "*loadc*"))
  1461. X    (erase-buffer)
  1462. X    (condition-case nil
  1463. X    (insert-file-contents filename)
  1464. X      (error (setq result nil)))
  1465. X    (unless (not result)
  1466. X        (setq key (buffer-substring (point-min) (+ (point-min) 2)))
  1467. X        (delete-char 2 t)
  1468. X        (condition-case nil
  1469. X        (crypt-buffer key)
  1470. X          (error (yank)))
  1471. X        (eval-current-buffer)
  1472. X        (kill-buffer (current-buffer))
  1473. X        (switch-to-buffer old-buffer))
  1474. X    result))
  1475. X
  1476. X(defun compile-globals ()
  1477. X  (switch-to-buffer (get-buffer-create "*compd*"))
  1478. X  (erase-buffer)
  1479. X  (insert-file-contents "dun-globals.el")
  1480. X  (setq key (concat (prin1-to-string (% (abs (random)) 9))
  1481. X            (prin1-to-string (% (abs (random)) 9))))
  1482. X  (crypt-buffer key)
  1483. X  (goto-char (point-min))
  1484. X  (insert key)
  1485. X  (write-region 1 (point-max) "dun-globals.dat")
  1486. X  (kill-buffer (current-buffer)))
  1487. X
  1488. X;; Functions to remove an object either from a room, or from inventory.
  1489. X
  1490. X(defun remove-obj-from-room (room objnum)
  1491. X  (let (newroom)
  1492. X    (setq newroom nil)
  1493. X    (dolist (x (nth room room-objects))
  1494. X      (if (not (= x objnum))
  1495. X      (setq newroom (append newroom (list x)))))
  1496. X    (rplaca (nthcdr room room-objects) newroom)))
  1497. X
  1498. X(defun remove-obj-from-inven (objnum)
  1499. X  (let (new-inven)
  1500. X    (setq new-inven nil)
  1501. X    (dolist (x inventory)
  1502. X      (if (not (= x objnum))
  1503. X      (setq new-inven (append new-inven (list x)))))
  1504. X    (setq inventory new-inven)))
  1505. X
  1506. X(defun get-glob-dat ()
  1507. X  (let (result)
  1508. X    (setq result nil)
  1509. X    (dolist (x load-path)
  1510. X        (if (file-exists-p (concat x "/dun-globals.dat"))
  1511. X        (setq result (concat x "/dun-globals.dat"))))
  1512. X    result))
  1513. X
  1514. X;;;
  1515. X;;; This is a small part copied from crypt.el by kyle@cs.odu.edu, with
  1516. X;;; a small change.
  1517. X
  1518. X
  1519. X;;; Compaction, compression and encryption for GNU Emacs
  1520. X;;; Copyright (C) 1988, 1989, 1990 Kyle E. Jones
  1521. X;;;
  1522. X;;; This program is free software; you can redistribute it and/or modify
  1523. X;;; it under the terms of the GNU General Public License as published by
  1524. X;;; the Free Software Foundation; either version 1, or (at your option)
  1525. X;;; any later version.
  1526. X;;;
  1527. X;;; This program is distributed in the hope that it will be useful,
  1528. X;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  1529. X;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1530. X;;; GNU General Public License for more details.
  1531. X;;;
  1532. X;;; A copy of the GNU General Public License can be obtained from this
  1533. X;;; program's author (send electronic mail to kyle@cs.odu.edu) or from
  1534. X;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
  1535. X;;; 02139, USA.
  1536. X;;;
  1537. X;;; Send bug reports to kyle@cs.odu.edu.
  1538. X
  1539. X;;; Changes for dungeon - 
  1540. X;;; ronnie@eddie.mit.edu - changed shell to use /bin/sh explicitly.
  1541. X;;;                        Otherwise user's 'rc' file might produce
  1542. X;;;                        output that gets stuffed into buffer.
  1543. X
  1544. X(defun crypt-region (start end key)
  1545. X   (let ((opoint-max (point-max)))
  1546. X     (call-process-region start end "/bin/sh" t t nil "-c"
  1547. X              (concat "crypt \"" key "\""))
  1548. X     (if (not (= opoint-max (point-max)))
  1549. X     (error "crypt command failed!"))))
  1550. X
  1551. X(defun crypt-buffer (key &optional buffer)
  1552. X  (crypt-region (point-min) (point-max) key))
  1553. END_OF_FILE
  1554. if test 7730 -ne `wc -c <'dun-util.el'`; then
  1555.     echo shar: \"'dun-util.el'\" unpacked with wrong size!
  1556. fi
  1557. # end of 'dun-util.el'
  1558. fi
  1559. if test -f 'dunnet' -a "${1}" != "-c" ; then 
  1560.   echo shar: Will not clobber existing file \"'dunnet'\"
  1561. else
  1562. echo shar: Extracting \"'dunnet'\" \(55 characters\)
  1563. sed "s/^X//" >'dunnet' <<'END_OF_FILE'
  1564. X#! /bin/sh
  1565. X
  1566. X    emacs -batch -l dun-main -f batch-dungeon
  1567. END_OF_FILE
  1568. if test 55 -ne `wc -c <'dunnet'`; then
  1569.     echo shar: \"'dunnet'\" unpacked with wrong size!
  1570. fi
  1571. chmod +x 'dunnet'
  1572. # end of 'dunnet'
  1573. fi
  1574. if test -f 'dunnet.window' -a "${1}" != "-c" ; then 
  1575.   echo shar: Will not clobber existing file \"'dunnet.window'\"
  1576. else
  1577. echo shar: Extracting \"'dunnet.window'\" \(32 characters\)
  1578. sed "s/^X//" >'dunnet.window' <<'END_OF_FILE'
  1579. X#! /bin/sh
  1580. X
  1581. X    emacs -l dun-main
  1582. X
  1583. END_OF_FILE
  1584. if test 32 -ne `wc -c <'dunnet.window'`; then
  1585.     echo shar: \"'dunnet.window'\" unpacked with wrong size!
  1586. fi
  1587. chmod +x 'dunnet.window'
  1588. # end of 'dunnet.window'
  1589. fi
  1590. echo shar: End of archive 2 \(of 2\).
  1591. cp /dev/null ark2isdone
  1592. MISSING=""
  1593. for I in 1 2 ; do
  1594.     if test ! -f ark${I}isdone ; then
  1595.     MISSING="${MISSING} ${I}"
  1596.     fi
  1597. done
  1598. if test "${MISSING}" = "" ; then
  1599.     echo You have unpacked both archives.
  1600.     rm -f ark[1-9]isdone
  1601. else
  1602.     echo You still need to unpack the following archives:
  1603.     echo "        " ${MISSING}
  1604. fi
  1605. ##  End of shell archive.
  1606. exit 0
  1607.