home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / emacs / sources / 559 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  32.9 KB

  1. Path: sparky!uunet!olivea!news.bbn.com!micro-heart-of-gold.mit.edu!mit-eddie!eddie.mit.edu!ronnie
  2. From: ronnie@eddie.mit.edu (Ron Schnell)
  3. Newsgroups: gnu.emacs.sources
  4. Subject: dunnet - text adventure for e-lisp (1/3)
  5. Message-ID: <1992Jul29.012337.19018@eddie.mit.edu>
  6. Date: 29 Jul 92 01:23:37 GMT
  7. Sender: news@eddie.mit.edu (Usenet News)
  8. Reply-To: ronnie@eddie.mit.edu (Ron Schnell)
  9. Organization: MIT EECS/ECF Facility, Cambridge Mass
  10. Lines: 1023
  11.  
  12. This is dunnet - a text adventure written for emacs-lisp.  It requires
  13. gnu-emacs and its associated lisp libraries.  You can also find it in the
  14. elisp-archive on archive.cis.ohio-state.edu in games/dunnet.tar.Z.
  15.  
  16. Please e-mail me any questions or comments, especially if you find it
  17. too hard or too easy.
  18.  
  19. -------
  20.  
  21. #! /bin/sh
  22. # This is a shell archive, meaning:
  23. # 1. Remove everything above the #! /bin/sh line.
  24. # 2. Save the resulting text in a file.
  25. # 3. Execute the file with /bin/sh (not csh) to create the files:
  26. #    README
  27. #    COPYRIGHT
  28. #    LCD-entry
  29. #    dun-commands.el
  30. # This archive created: Tue Jul 28 14:47:42 1992
  31. export PATH; PATH=/bin:$PATH
  32. if test -f 'README'
  33. then
  34.     echo shar: will not over-write existing file "'README'"
  35. else
  36. cat << \SHAR_EOF > 'README'
  37. This is "dunnet", a text adventure game written in emacs-lisp.  I decided it
  38. would be interesting to write an elisp program, so for fun I wrote this
  39. one.  Try to play it without looking at the code, for two reasons:
  40.  
  41. 1. It's more fun if you don't cheat.
  42. 2. Since I haven't written much lisp, I'm not confident of the quality
  43.    of the code.
  44.  
  45. You'll notice some really different things about this dungeon.  Without
  46. giving anything away, let's just say that like much lisp code seems to
  47. be, this dungeon is sort of recursive in a way.  A minimal knowledge of
  48. UNIX, and some internet experience is assumed.
  49.  
  50. INSTALLATION
  51. ------------
  52.  
  53. Modify the first line of dun-main.el to have a logfile that is writable
  54. by all.  You only need to do this if you want to log where everyone died
  55. or saved, or won.  You will also need to create this file as an empty file,
  56. if it doesn't already exist.
  57.  
  58. You can use the 'makefile' to compile everything and encrypt the appropriate
  59. portions of dunnet.  You may, of course, just run the code as-is.  In either
  60. case, all of the files must be put in your load-path directory, or they
  61. must be in your current directory when it is run.  If you do
  62. run make, all of the compiled/encrypted files are put in ../bin.
  63.  
  64. *IMPORTANT*
  65.  
  66. There are two ways to run the program:
  67.  
  68. 1. dunnet
  69. 2. dunnet.window
  70.  
  71. I strongly suggest using the non-window version, because otherwise stuff will
  72. scroll off the screen, and you'll need to be scrolling back a lot.  These
  73. files are Unix shellscripts, and one of them should be put in a normal
  74. bin directory.  If you are on a non-unix machine, it should be simple to
  75. set up similar script files.
  76.  
  77. NOTE: It may be necessary to modify the script files in order to run out
  78.       of the current directory.  If it can't seem to find the load file,
  79.       change the "-l dun-main" to "-l `pwd`/dun-main" for Unix.  For other
  80.       platforms, use whatever method appropriate to indicate the complete
  81.       pathname.
  82.  
  83. I have included part of crypt.el by Kyle E. Jones.  It is needed in order to
  84. encrypt and decrypt save files and one of the data files.
  85.  
  86. crypt.el assumes that you can run the "crypt" command.  If you cannot,
  87. edit the file 'save.el', and replace the functions 'compile-save-out'
  88. and 'restore' with 'compile-save-out-nocrypt' and 'restore-nocrypt'.  If
  89. you aren't using crypt you will also have to make sure to copy
  90. 'dun-globals.el' to the load-path or current directory if you are
  91. using 'make' to compile.
  92.  
  93. This software assumes you have "cl.el" (necessary) and "yow.el" (not critical)
  94. in the load-path directory.  These come standard with gnu-emacs.
  95.  
  96. Some hints and tips.
  97.  
  98. Read the help carefully.
  99. Save the game often.
  100. An abbreviation for examine is 'x'.
  101. You can use 'get all', but not 'drop all'.
  102.  
  103. Questions or comments to ronnie@eddie.mit.edu.
  104.  
  105. SHAR_EOF
  106. fi # end of overwriting check
  107. if test -f 'COPYRIGHT'
  108. then
  109.     echo shar: will not over-write existing file "'COPYRIGHT'"
  110. else
  111. cat << \SHAR_EOF > 'COPYRIGHT'
  112.  
  113. ;; dunnet - elisp text adventure game.  The following applies to
  114. ;;           these files contained in this archive:
  115. ;;              dun-batch.el
  116. ;;              dun-commands.el
  117. ;;              dun-globals.el
  118. ;;              dun-main.el
  119. ;;              dun-save.el
  120. ;;              dun-unix.el
  121. ;;              dun-util.el
  122.  
  123. ;; Copyright (C) 1992 by Ron Schnell
  124. ;; (ronnie@eddie.mit.edu)
  125.  
  126. ;; This software is not part of GNU Emacs.
  127.  
  128. ;; It is distributed in the hope that it will be fun.
  129. ;; It is without any warranty.  No author or distributor
  130. ;; accepts responsibility to anyone for the consequences of using it
  131. ;; or for whether it serves any particular purpose, or works at all.
  132.  
  133. ;; Everyone is granted permission to copy, modify, and redistribute
  134. ;; this software, but only so long as it is not for commercial
  135. ;; purposes.
  136.  
  137. ;; This file must be distributed along with all copies, in an unmodified
  138. ;; form.
  139. SHAR_EOF
  140. fi # end of overwriting check
  141. if test -f 'LCD-entry'
  142. then
  143.     echo shar: will not over-write existing file "'LCD-entry'"
  144. else
  145. cat << \SHAR_EOF > 'LCD-entry'
  146. ;; LCD Archive Entry:
  147. ;; dunnet|Ron Schnell|ronnie@eddie.mit.edu
  148. ;; |Text adventure.
  149. ;; |92-07-25|Version: 1.0|~/games/dunnet.tar.Z|
  150. SHAR_EOF
  151. fi # end of overwriting check
  152. if test -f 'dun-commands.el'
  153. then
  154.     echo shar: will not over-write existing file "'dun-commands.el'"
  155. else
  156. cat << \SHAR_EOF > 'dun-commands.el'
  157. ;;
  158. ;; This file contains all of the verbs and commands.
  159. ;;
  160.  
  161. (require 'cl)
  162. ;;;; Give long description of room if haven't been there yet.  Otherwise
  163. ;;;; short.  Also give long if we were called with negative room number.
  164.  
  165. (defun describe-room (room)
  166.   (if (and (not (member (abs room) light-rooms)) (not (member 1 inventory)))
  167.       (mprincl "It is pitch dark.  You are likely to be eaten by a grue.")
  168.     (mprincl (cadr (nth (abs room) rooms)))
  169.     (if (and (and (or (member room visited) 
  170.               (string= mode "superb")) (> room 0))
  171.          (not (string= mode "long")))
  172.     nil
  173.       (mprinc (car (nth (abs room) rooms)))
  174.     (mprinc "\n"))
  175.     (if (not (string= mode "long"))
  176.     (if (not (member (abs room) visited))
  177.         (setq visited (append (list (abs room)) visited))))
  178.     (dolist (xobjs (nth current-room room-objects))
  179.       (if (= xobjs 255)
  180.       (special-object)
  181.     (if (>= xobjs 0)
  182.         (mprincl (car (nth xobjs objects)))
  183.       (if (not (and (= xobjs -18) inbus))
  184.           (progn
  185.         (mprincl (car (nth (abs xobjs) perm-objects)))))))
  186.       (if (and (= xobjs 19) jar)
  187.       (progn
  188.         (mprincl "The jar contains:")
  189.         (dolist (x jar)
  190.           (mprinc "     ")
  191.           (mprincl (car (nth x objects)))))))
  192.     (if (and (member -18 (nth current-room room-objects)) inbus)
  193.     (mprincl "You are on the bus."))))
  194.  
  195. ;;; There is a special object in the room.  This object's description,
  196. ;;; or lack thereof, depends on certain conditions.
  197.  
  198. (defun special-object ()
  199.   (if (= current-room 10)
  200.       (if computer
  201.       (mprincl 
  202. "The panel lights are flashing in a seemingly organized pattern.")
  203.     (mprincl "The panel lights are steady and motionless.")))
  204.   (if (and (= current-room 46) (not (member 13 (nth 46 room-objects))))
  205.       (mprincl "There is a hole in the floor here."))
  206.   (if (and (= current-room 86) black)
  207.       (mprincl 
  208. "The room is lit by a black light, causing the fish to give off an
  209. eerie glow."))
  210.   (if (and (= current-room 77) hole)
  211.       (progn
  212.     (mprincl"You fall into a hole in the ground.")
  213.     (setq current-room 89)
  214.     (describe-room 89)))
  215.  
  216.   (if (> current-room 95)
  217.       (progn
  218.     (if (not correct-answer)
  219.         (endgame-question)
  220.       (mprincl "Your question is:")
  221.       (mprincl endgame-question))))
  222.  
  223.   (if (= current-room 14)
  224.       (progn
  225.     (mprincl (nth sauna-level '(
  226. "It is normal room termperature in here."
  227. "It is luke warm in here."
  228. "It is comfortably hot in here."
  229. "It is refreshingly hot in here."
  230. "You are dead now.")))
  231.     (if (and (= sauna-level 3) 
  232.          (or (member 6 inventory)
  233.              (member 6 (nth current-room room-objects))))
  234.         (progn
  235.           (mprincl 
  236. "You notice the wax on your statuette beginning to melt, until it completely
  237. melts off.  You are left with a beautiful diamond!")
  238.           (if (member 6 inventory)
  239.           (progn
  240.             (remove-obj-from-inven 6)
  241.             (setq inventory (append inventory (list 7))))
  242.         (remove-obj-from-room current-room 6)
  243.         (replace room-objects current-room
  244.              (append (nth current-room room-objects)
  245.                  (list 7))))))))
  246.  
  247. )
  248.  
  249. ;;;;;;;;;;;;;;;;;;;;;; Commands start here
  250.  
  251. (defun die (murderer)
  252.   (mprinc "\n")
  253.   (if murderer
  254.       (mprincl "You are dead."))
  255.   (do-logfile 'die murderer)
  256.   (score nil)
  257.   (setq dead t))
  258.  
  259. (defun quit (args)
  260.   (die nil))
  261.  
  262. ;; Print every object in player's inventory.  Special case for the jar,
  263. ;; as we must also print what is in it.
  264.  
  265. (defun inven (args)
  266.   (mprinc "You currently have:")
  267.   (mprinc "\n")
  268.   (dolist (curobj inventory)
  269.     (if curobj
  270.     (progn
  271.       (mprincl (cadr (nth curobj objects)))
  272.       (if (and (= curobj 19) jar)
  273.           (progn
  274.         (mprincl "The jar contains:")
  275.         (dolist (x jar)
  276.           (mprinc "     ")
  277.           (mprincl (cadr (nth x objects))))))))))
  278.  
  279. (defun shake (obj)
  280.   (let (objnum)
  281.     (when (setq objnum (objnum-from-args-std obj))
  282.       (if (member objnum inventory)
  283.       (progn
  284. ;;;    If shaking anything will do anything, put here.
  285.         (mprinc "Shaking ")
  286.         (mprinc (downcase (cadr (nth objnum objects))))
  287.         (mprinc " seems to have no effect.")
  288.         (mprinc "\n")
  289.         )
  290.     (if (and (not (member objnum (nth current-room room-silents)))
  291.          (not (member objnum (nth current-room room-objects))))
  292.         (mprincl "I don't see that here.")
  293. ;;;     Shaking trees can be deadly
  294.       (if (= objnum -2)
  295.           (progn
  296.         (mprinc
  297.  "You begin to shake a tree, and notice a coconut begin to fall from the air.
  298. As you try to get your hand up to block it, you feel the impact as it lands
  299. on your head.")
  300.         (die "a coconut"))
  301.         (if (= objnum -3)
  302.         (progn
  303.           (mprinc
  304. "As you go up to the bear, it removes your head and places it on the ground.")
  305.           (die "a bear"))
  306.           (if (< objnum 0)
  307.           (mprincl "You cannot shake that.")
  308.         (mprincl "You don't have that.")))))))))
  309.  
  310.  
  311. (defun drop (obj)
  312.   (if inbus
  313.       (mprincl "You can't drop anything while on the bus.")
  314.   (let (objnum)
  315.     (when (setq objnum (objnum-from-args-std obj))
  316.       (if (not (setq ptr (member objnum inventory)))
  317.       (mprincl "You don't have that.")
  318.     (progn
  319.       (remove-obj-from-inven objnum)
  320.       (replace room-objects current-room
  321.            (append (nth current-room room-objects)
  322.                (list objnum)))
  323.       (mprincl "Done.")
  324.       (if (member objnum '(3 8 19))
  325.           (drop-check objnum))))))))
  326.  
  327. ;; Dropping certain things causes things to happen.
  328.  
  329. (defun drop-check (objnum)
  330.   (if (and (= objnum 3) (= room 7) (member -3 (nth 7 room-objects)))
  331.       (progn
  332.     (mprincl
  333. "The bear takes the food and runs away with it. He left something behind.")
  334.     (remove-obj-from-room current-room -3)
  335.     (remove-obj-from-room current-room 3)
  336.     (replace room-objects current-room
  337.          (append (nth current-room room-objects)
  338.              (list 4)))))
  339.  
  340.   (if (and (= objnum 19) (member 21 jar) (member 22 jar))
  341.       (progn
  342.     (mprincl "As the jar impacts the ground it explodes into many pieces.")
  343.     (setq jar nil)
  344.     (remove-obj-from-room current-room 19)
  345.     (if (= current-room 77)
  346.         (progn
  347.           (setq hole t)
  348.           (setq current-room 89)
  349.           (mprincl 
  350. "The explosion causes a hole to open up in the ground, which you fall
  351. through.")))))
  352.  
  353.   (if (and (= objnum 8) (= current-room 17))
  354.       (mprincl "A passageway opens.")))
  355.  
  356. ;;; Give long description of current room, or an object.
  357.       
  358. (defun examine (obj)
  359.   (let (objnum)
  360.     (setq objnum (objnum-from-args obj))
  361.     (if (eq objnum 255)
  362.     (describe-room (* current-room -1))
  363.       (if (eq objnum nil)
  364.       (mprincl "I don't know what that is.")
  365.     (if (and (not (member objnum (nth current-room room-objects)))
  366.          (not (member objnum (nth current-room room-silents)))
  367.          (not (member objnum inventory)))
  368.         (mprincl "I don't see that here.")
  369.       (if (>= objnum 0)
  370.           (if (and (= objnum 20) (= current-room 86) black)
  371.           (mprincl 
  372. "In this light you can see some writing on the bone.  It says:
  373. For an explosive time, go to Fourth St. and Vermont.")
  374.         (if (nth objnum physobj-desc)
  375.             (mprincl (nth objnum physobj-desc))
  376.           (mprincl "I see nothing special about that.")))
  377.         (if (nth (abs objnum) permobj-desc)
  378.         (progn
  379.           (mprincl (nth (abs objnum) permobj-desc)))
  380.           (mprincl "I see nothing special about that."))))))))
  381.  
  382. (defun take (obj)
  383.   (if inbus
  384.       (mprincl "You can't take anything while on the bus.")
  385.   (setq obj (firstword obj))
  386.   (if (not obj)
  387.       (mprincl "You must supply an object.")
  388.     (if (string= obj "all")
  389.     (let (gotsome)
  390.       (setq gotsome nil)
  391.       (dolist (x (nth current-room room-objects))
  392.         (if (and (>= x 0) (not (= x 255)))
  393.         (progn
  394.           (setq gotsome t)
  395.           (mprinc (cadr (nth x objects)))
  396.           (mprinc ": ")
  397.           (take-object x))))
  398.       (if (not gotsome)
  399.           (mprincl "Nothing to take.")))
  400.       (progn
  401.     (setq objnum (cdr (assq (intern obj) objnames)))
  402.     (if (eq objnum nil)
  403.         (progn
  404.           (mprinc "I don't know what that is.")
  405.           (mprinc "\n"))
  406.       (take-object objnum)))))))
  407.  
  408. (defun take-object (objnum)
  409.   (if (and (member objnum jar) (member 19 inventory))
  410.       (progn
  411.     (mprincl "You remove it from the jar.")
  412.     (setq newjar nil)
  413.     (dolist (x jar)
  414.       (if (not (= x objnum))
  415.           (setq newjar (append newjar (list x)))))
  416.     (setq jar newjar)
  417.     (setq inventory (append inventory (list objnum))))
  418.     (if (not (member objnum (nth current-room room-objects)))
  419.     (if (not (member objnum (nth current-room room-silents)))
  420.         (mprinc "I do not see that here.")
  421.       (try-take objnum))
  422.       (if (>= objnum 0)
  423.       (progn
  424.         (if (and (car inventory) 
  425.              (> (+ (inven-weight) (nth objnum object-lbs)) 11))
  426.         (mprinc "Your load would be too heavy.")
  427.           (setq inventory (append inventory (list objnum)))
  428.           (remove-obj-from-room current-room objnum)
  429.           (mprinc "Taken.  ")
  430.           (if (and (= objnum 13) (= current-room 46))
  431.           (mprinc "Taking the towel reveals a hole in the floor."))))
  432.     (try-take objnum)))
  433.     (mprinc "\n")))
  434.  
  435. (defun inven-weight ()
  436.   (let (total)
  437.     (setq total 0)
  438.     (dolist (x jar)
  439.       (setq total (+ total (nth x object-lbs))))
  440.     (dolist (x inventory)
  441.       (setq total (+ total (nth x object-lbs)))) total))
  442.  
  443. ;;; We try to take an object that is untakable.  Print a message
  444. ;;; depending on what it is.
  445.  
  446. (defun try-take (obj)
  447.   (mprinc "You cannot take that."))
  448.  
  449.  
  450. (defun dig (args)
  451.   (if inbus
  452.       (mprincl "You can't dig while on the bus.")
  453.   (if (not (member 0 inventory))
  454.       (mprincl "You have nothing with which to dig.")
  455.     (if (not (nth current-room diggables))
  456.     (mprincl "Digging here reveals nothing.")
  457.       (mprincl "I think you found something.")
  458.       (replace room-objects current-room
  459.            (append (nth current-room room-objects)
  460.                (nth current-room diggables)))
  461.       (replace diggables current-room nil)))))
  462.  
  463. (defun climb (args)
  464.   (if (not (member -2 (nth current-room room-silents)))
  465.       (mprincl "There is nothing here to climb.")
  466.     (mprincl
  467. "You manage to get about two feet up the tree and fall back down.  You
  468. notice that the tree is very unsteady.")))
  469.  
  470. (defun eat (obj)
  471.   (let (objnum)
  472.     (when (setq objnum (objnum-from-args-std obj))
  473.       (if (not (member objnum inventory))
  474.       (mprincl "You don't have that.")
  475.     (if (not (= objnum 3))
  476.         (progn
  477.           (mprinc "You forcefully shove ")
  478.           (mprinc (downcase (cadr (nth objnum objects))))
  479.           (mprincl " down your throat, and start choking.")
  480.           (die "choking"))
  481.       (mprincl "That tasted horrible.")
  482.       (remove-obj-from-inven 3))))))
  483.  
  484. (defun dput (args)
  485.   (if inbus
  486.       (mprincl "You can't do that while on the bus")
  487.     (let (newargs objnum objnum2)
  488.       (setq newargs (firstwordl args))
  489.       (if (not newargs)
  490.       (mprincl "You must supply an object")
  491.     (setq obj (intern (car newargs)))
  492.     (setq objnum (cdr (assq obj objnames)))
  493.     (if (not objnum)
  494.         (mprincl "I don't know what that object is.")
  495.       (if (not (member objnum inventory))
  496.           (mprincl "You don't have that.")
  497.         (setq newargs (firstwordl (cdr newargs)))
  498.         (setq newargs (firstwordl (cdr newargs)))
  499.         (if (not newargs)
  500.         (mprincl "You must supply an indirect object.")
  501.           (setq objnum2 (cdr (assq (intern (car newargs)) objnames)))
  502.           (if (not objnum2)
  503.           (mprincl "I don't know what that indirect object is.")
  504.         (if (and (not (member objnum2 (nth current-room room-objects)))
  505.              (not (member objnum2 (nth current-room room-silents)))
  506.              (not (member objnum2 inventory)))
  507.             (mprincl "That indirect object is not here.")
  508.           (put-objs objnum objnum2))))))))))
  509.  
  510. (defun put-objs (obj1 obj2)
  511.   (if (and (= obj2 -17) (not nomail))
  512.       (setq obj2 -9))
  513.  
  514.   (if (= obj2 -26) (setq obj2 -9))
  515.  
  516.   (if (and (= obj1 2) (= obj2 -5))     ;; Put board in cabinet
  517.       (progn
  518.     (remove-obj-from-inven 2)
  519.     (setq computer t)
  520.     (mprincl
  521. "As you put the CPU board in the computer, it immediately springs to life.
  522. The lights start flashing, and the fans seem to startup."))
  523.     (if (and (= obj1 8) (= obj2 -8))   ;; Put weight on button
  524.     (drop '("weight"))
  525.       (if (= obj2 19)                 ;; Put something in jar
  526.       (if (not (member obj1 '(5 7 10 16 17 18 21 22)))
  527.           (mprincl "That will not fit in the jar.")
  528.         (remove-obj-from-inven obj1)
  529.         (setq jar (append jar (list obj1)))
  530.         (mprincl "Done."))
  531.     (if (= obj2 -9)                 ;; Put something in chute
  532.         (progn
  533.           (remove-obj-from-inven obj1)
  534.           (mprincl 
  535. "You hear it slide down the chute and off into the distance.")
  536.           (put-objs-in-treas (list obj1)))
  537.       (if (= obj2 -15)
  538.           (if (= obj1 4)
  539.           (progn
  540.             (mprincl
  541. "As you drop the key, the box begins to shake.  Finally it explodes
  542. with a bang.  The key seems to have vanished!")
  543.             (remove-obj-from-inven obj1)
  544.             (replace room-objects 10 (append
  545.                             (nth 10 room-objects)
  546.                             (list obj1)))
  547.             (remove-obj-from-room current-room -15)
  548.             (setq key-level (1+ key-level))))
  549.         (if (= obj2 -12)
  550.         (progn
  551.           (remove-obj-from-inven obj1)
  552.           (replace room-objects 36 (append (nth 36 room-objects)
  553.                            (list obj1)))
  554.           (mprincl
  555.            "You hear it plop down in some water below."))
  556.           (if (= obj2 -17)
  557.           (mprincl "The mail chute is locked.")
  558.         (if (member obj1 inventory)
  559.             (mprincl 
  560. "I don't know how to combine those objects.  Perhaps you should
  561. just try dropping it.")
  562.         (mprincl"You can't put that there."))))))))))
  563.  
  564. (defun type (args)
  565.   (if (not (= current-room 10))
  566.       (mprincl "There is nothing here on which you could type.")
  567.     (if (not computer)
  568.     (mprincl 
  569. "You type on the keyboard, but your characters do not even echo.")
  570.       (unix-interface))))
  571.  
  572. ;;;; Various movement directions
  573.  
  574. (defun n (args)
  575.   (move 0))
  576.  
  577. (defun s (args)
  578.   (move 1))
  579.  
  580. (defun e (args)
  581.   (move 2))
  582.  
  583. (defun w (args)
  584.   (move 3))
  585.  
  586. (defun ne (args)
  587.   (move 4))
  588.  
  589. (defun se (args)
  590.   (move 5))
  591.  
  592. (defun nw (args)
  593.   (move 6))
  594.  
  595. (defun sw (args)
  596.   (move 7))
  597.  
  598. (defun up (args)
  599.   (move 8))
  600.  
  601. (defun down (args)
  602.   (move 9))
  603.  
  604. (defun in (args)
  605.   (move 10))
  606.  
  607. (defun out (args)
  608.   (move 11))
  609.  
  610. (defun go (args)
  611.   (if (or (not (car args)) 
  612.       (eq (doverb ignore verblist (car args) (cdr (cdr args))) -1))
  613.       (mprinc "I don't understand where you want me to go.\n")))
  614.  
  615. (defun move (dir)
  616.   (if (and (not (member current-room light-rooms)) (not (member 1 inventory)))
  617.       (progn
  618.     (mprinc 
  619. "You trip over a grue and fall into a pit and break every bone in your
  620. body.")
  621.     (die "a grue"))
  622.     (let (newroom)
  623.       (setq newroom (nth dir (nth current-room dungeon-map)))
  624.       (if (eq newroom -1)
  625.       (mprinc "You can't go that way.\n")
  626.     (if (eq newroom 255)
  627.         (special-move dir)
  628.       (setq room -1)
  629.       (setq lastdir dir)
  630.       (if inbus
  631.           (progn
  632.         (if (or (< newroom 58) (> newroom 83))
  633.             (mprincl "The bus cannot go this way.")
  634.           (mprincl 
  635.            "The bus lurches ahead and comes to a screeching halt.")
  636.           (remove-obj-from-room current-room -18)
  637.           (setq current-room newroom)
  638.           (replace room-objects newroom
  639.                (append (nth newroom room-objects) (list -18)))))
  640.         (setq current-room newroom)))))))
  641.  
  642. ;; Movement in this direction causes something special to happen if the
  643. ;; right conditions exist.  It may be that you can't go this way unless
  644. ;; you have a key, or a passage has been opened.
  645.  
  646. ;; coding note: Each check of the current room is on the same 'if' level,
  647. ;; i.e. there aren't else's.  If two rooms next to each other have
  648. ;; specials, and they are connected by specials, this could cause
  649. ;; a problem.  Be careful when adding them to consider this, and
  650. ;; perhaps use else's.
  651.  
  652. (defun special-move (dir)
  653.   (if (= current-room 5)
  654.       (if (not (member 4 inventory))
  655.       (mprincl "You don't have a key that can open this door.")
  656.     (setq current-room 8))
  657.     (if (= current-room 7)
  658.     (if (member -3 (nth 7 room-objects))
  659.         (progn
  660.           (mprinc 
  661. "The bear is very annoyed that you would be so presumptuous as to try
  662. and walk right by it.  He tells you so by tearing your head off.
  663. ")
  664.           (die "a bear"))
  665.       (mprincl "You can't go that way.")))
  666.  
  667.     (if (= current-room 89)
  668.     (progn
  669.       (mprincl
  670. "As you board the train it immediately leaves the station.  It is a very
  671. bumpy ride.  It is shaking from side to side, and up and down.  You
  672. sit down in one of the chairs in order to be more comfortable.")
  673.       (mprincl
  674. "\nFinally the train comes to a sudden stop, and the doors open, and some
  675. force throws you out.  The train speeds away.\n")
  676.       (setq current-room 90)))
  677.  
  678.     (if (= current-room 8)
  679.     (if (and (member 4 inventory)
  680.          (> key-level 0))
  681.         (setq current-room 11)
  682.       (mprincl "You don't have a key that can open this door.")))
  683.  
  684.     (if (and (= current-room 17) (= dir 6))
  685.     (if (member 8 (nth 17 room-objects))
  686.         (setq current-room 18)
  687.       (mprincl "You can't go that way.")))
  688.  
  689.     (if (and (= current-room 17) (= dir 8))
  690.     (if (member 8 (nth 17 room-objects))
  691.         (mprincl "You can't go that way.")
  692.       (setq current-room 16)))
  693.  
  694.     (if (= current-room 88)
  695.     (mprincl "The door is locked."))
  696.  
  697.     (if (or (= current-room 25) (= current-room 26))
  698.     (swim nil))
  699.  
  700.     (if (= current-room 32)
  701.     (if (> key-level 0)
  702.         (setq current-room 57)
  703.       (mprincl "You don't have a key that can open that door.")))
  704.  
  705.     (if (= current-room 23)
  706.     (if (not (= sauna-level 3))
  707.         (setq current-room 24)
  708.       (mprincl
  709. "As you exit the building, you notice some flames coming out of one of the
  710. windows.  Suddenly, the building explodes in a huge ball of fire.  The flames
  711. engulf you, and you burn to death.")
  712.       (die "burning")))
  713.  
  714.     (if (= current-room 46)
  715.     (if (not (member 13 (nth 46 room-objects)))
  716.         (setq current-room 47)
  717.       (mprincl "You can't go that way.")))
  718.  
  719.     (if (and (> dir 9) (> current-room 57) (< current-room 84))
  720.     (if (not (member -18 (nth current-room room-objects)))
  721.         (mprincl "You can't go that way.")
  722.       (if (= dir 10)
  723.           (if (member 16 inventory)
  724.           (progn
  725.             (mprincl "You board the bus and get in the driver's seat.")
  726.             (setq nomail t)
  727.             (setq inbus t))
  728.         (mprincl "You are not licensed for this type of vehicle."))
  729.         (mprincl "You hop off the bus.")
  730.         (setq inbus nil)))
  731.       (if (= current-room 80)
  732.       (if (not inbus)
  733.           (progn
  734.         (mprincl "You fall down the cliff and land on your head.")
  735.         (die "a cliff"))
  736.         (mprincl
  737. "The bus flies off the cliff, and plunges to the bottom, where it explodes.")
  738.         (die "a bus accident")))
  739.       (if (= current-room 59)
  740.       (progn
  741.         (if (not inbus)
  742.         (mprincl "The gate will not open.")
  743.           (mprincl
  744. "As the bus approaches, the gate opens and you drive through.")
  745.           (remove-obj-from-room 59 -18)
  746.           (replace room-objects 83 (append (nth 83 room-objects)
  747.                             (list -18)))
  748.           (setq current-room 83)))))
  749.     (if (= current-room 28)
  750.     (progn
  751.       (mprincl
  752. "As you enter the room you hear a rumbling noise.  You look back to see
  753. huge rocks sliding down from the ceiling, and blocking your way out.\n")
  754.       (setq current-room 29)))))
  755.  
  756. (defun long (args)
  757.   (setq mode "long"))
  758.  
  759. (defun turn (obj)
  760.   (let (objnum direction)
  761.     (when (setq objnum (objnum-from-args-std obj))
  762.       (if (not (or (member objnum (nth current-room room-objects))
  763.            (member objnum (nth current-room room-silents))))
  764.       (mprincl "I don't see that here.")
  765.     (if (not (= objnum -7))
  766.         (mprincl "You can't turn that.")
  767.       (setq direction (firstword (cdr obj)))
  768.       (if (or (not direction) 
  769.           (not (or (string= direction "clockwise")
  770.                (string= direction "counterclockwise"))))
  771.           (mprincl "You must indicate clockwise or counterclockwise.")
  772.         (if (string= direction "clockwise")
  773.         (setq sauna-level (+ sauna-level 1))
  774.           (setq sauna-level (- sauna-level 1)))
  775.         
  776.         (if (< sauna-level 0)
  777.         (progn
  778.           (mprincl 
  779.            "The dial will not turn further in that direction.")
  780.           (setq sauna-level 0))
  781.           (sauna-heat))))))))
  782.  
  783. (defun sauna-heat ()
  784.   (if (= sauna-level 0)
  785.       (mprincl "The termperature has returned to normal room termperature."))
  786.   (if (= sauna-level 1)
  787.       (mprincl "It is now luke warm in here.  You begin to sweat."))
  788.   (if (= sauna-level 2)
  789.       (mprincl "It is pretty hot in here.  It is still very comfortable."))
  790.   (if (= sauna-level 3)
  791.       (progn
  792.     (mprincl 
  793. "It is now very hot.  There is something very refreshing about this.")
  794.     (if (or (member 6 inventory) 
  795.         (member 6 (nth current-room room-objects)))
  796.         (progn
  797.           (mprincl 
  798. "You notice the wax on your statuette beginning to melt, until it completely
  799. melts off.  You are left with a beautiful diamond!")
  800.           (if (member 6 inventory)
  801.           (progn
  802.             (remove-obj-from-inven 6)
  803.             (setq inventory (append inventory (list 7))))
  804.         (remove-obj-from-room current-room 6)
  805.         (replace room-objects current-room
  806.              (append (nth current-room room-objects)
  807.                  (list 7))))))))
  808.   (if (= sauna-level 4)
  809.       (progn
  810.     (mprincl 
  811. "As the dial clicks into place, you immediately burst into flames.")
  812.     (die "burning"))))
  813.  
  814. (defun press (obj)
  815.   (let (objnum)
  816.     (when (setq objnum (objnum-from-args-std obj))
  817.       (if (not (or (member objnum (nth current-room room-objects))
  818.            (member objnum (nth current-room room-silents))))
  819.       (mprincl "I don't see that here.")
  820.     (if (not (member objnum '(-8 -24)))
  821.         (progn
  822.           (mprinc "You can't ")
  823.           (mprinc (car line-list))
  824.           (mprincl " that."))
  825.       (if (= objnum -8)
  826.           (mprincl
  827. "As you press the button, you notice a passageway open up, but
  828. as you release it, the passageway closes."))
  829.       (if (= objnum -24)
  830.           (if black
  831.           (progn
  832.             (mprincl "The button is now in the off position.")
  833.             (setq black nil))
  834.         (mprincl "The button is now in the on position.")
  835.         (setq black t))))))))
  836.  
  837. (defun swim (args)
  838.   (if (not (member current-room '(25 26)))
  839.       (mprincl "I see no water!")
  840.     (if (not (member 9 inventory))
  841.     (progn
  842.       (mprincl 
  843. "You dive in the water, and at first notice it is quite cold.  You then
  844. start to get used to it as you realize that you never really learned how
  845. to swim.")
  846.       (die "drowning"))
  847.       (if (= current-room 25)
  848.       (setq current-room 26)
  849.     (setq current-room 25)))))
  850.  
  851.  
  852. (defun score (args)
  853.   (if (not endgame)
  854.       (let (total)
  855.     (setq total (reg-score))
  856.     (mprinc "You have scored ")
  857.     (mprinc total)
  858.     (mprincl " out of a possible 90 points.") total)
  859.     (mprinc "You have scored ")
  860.     (mprinc (endgame-score))
  861.     (mprincl " endgame points out of a possible 110.")
  862.     (if (= (endgame-score) 110)
  863.     (mprincl 
  864. "\n\nCongratulations.  You have won.  The wizard password is 'moby'"))))
  865.  
  866. (defun help (args)
  867.   (mprincl
  868. "Welcome to dunnet (1.0), by Ron Schnell (ronnie@eddie.mit.edu).
  869. This is a pre-release version.  Here is some useful information (read
  870. carefully because there are one or more clues in here):
  871.  
  872. - If you have a key that can open a door, you do not need to explicitly
  873.   open it.  You may just use 'in' or walk in the direction of the door.
  874.  
  875. - If you have a lamp, it is always lit.
  876.  
  877. - You will not get any points until you manage to get treasures to a certain
  878.   place.  Simply finding the treasures is not good enough.  There is more
  879.   than one way to get a treasure to the special place.  It is also
  880.   important that the objects get to the special place *unharmed* and
  881.   *untarnished*.  You can tell if you have successfully transported the
  882.   object by looking at your score, as it changes immediately.  Note that
  883.   an object can become harmed even after you have received points for it.
  884.   If this happens, your score will decrease, and in many cases you can never
  885.   get credit for it again.
  886.  
  887. - You can save your game with the 'save' command, and use restore it
  888.   with the 'restore' command.
  889.  
  890. - There are no limits on lengths of object names.
  891.  
  892. - Directions are: north,south,east,west,northeast,southeast,northwest,
  893.                   southwest,up,down,in,out.
  894.  
  895. - These can be abbreviated: n,s,e,w,ne,se,nw,sw,u,d,in,out.
  896.  
  897. - If you go down a hole in the floor without an aid such as a ladder,
  898.   you probably won't be able to get back up the way you came, if at all.
  899.  
  900. - It is possible to get the maximum points.
  901.  
  902. If you have questions or comments, contact ronnie@eddie.mit.edu."))
  903.  
  904. (defun flush (args)
  905.   (if (not (= current-room 35))
  906.       (mprincl "I see nothing to flush.")
  907.     (mprincl "Whoooosh!!")
  908.     (put-objs-in-treas (nth 36 room-objects))
  909.     (replace room-objects 36 nil)))
  910.  
  911. (defun piss (args)
  912.   (if (not (= current-room 35))
  913.       (mprincl "You can't do that here, don't even bother trying.")
  914.     (if (not gottago)
  915.     (mprincl "I'm afraid you don't have to go now.")
  916.       (mprincl "That was refreshing.")
  917.       (setq gottago nil)
  918.       (replace room-objects 36 (append (nth 36 room-objects) (list -13))))))
  919.  
  920.  
  921. (defun sleep (args)
  922.   (if (not (= current-room 34))
  923.       (mprincl
  924. "You try to go to sleep while standing up here, but can't seem to do it.")
  925.     (setq gottago t)
  926.     (mprincl
  927. "As soon as you start to doze off you begin dreaming.  You see images of
  928. workers digging caves, slaving in the humid heat.  Then you see yourself
  929. as one of these workers.  While no one is looking, you leave the group
  930. and walk into a room.  The room is bare except for a horseshoe
  931. shaped piece of stone in the center.  You see yourself digging a hole in
  932. the ground, then putting some kind of treasure in it, and filling the hole
  933. with dirt again.  After this, you immediately wake up.")))
  934.  
  935. (defun break (obj)
  936.   (let (objnum)
  937.     (if (not (member 14 inventory))
  938.     (mprincl "You have nothing you can use to break things.")
  939.       (when (setq objnum (objnum-from-args-std obj))
  940.     (if (member objnum inventory)
  941.         (progn
  942.           (mprincl
  943. "You take the object in your hands and swing the axe.  Unfortunately, you miss
  944. the object and slice off your hand.  You bleed to death.")
  945.           (die "an axe"))
  946.       (if (not (or (member objnum (nth current-room room-objects))
  947.                (member objnum (nth current-room room-silents))))
  948.           (mprincl "I don't see that here.")
  949.         (if (= objnum -16)
  950.         (progn
  951.           (mprincl 
  952. "As you break the ethernet cable, everything starts to blur.  You collapse
  953. for a moment, then straighten yourself up.
  954. ")
  955.           (replace room-objects 57 (append (nth 36 room-objects)
  956.                            inventory))
  957.           (if (member 4 inventory)
  958.               (progn
  959.             (setq inventory '(4))
  960.             (remove-obj-from-room 57 4))
  961.             (setq inventory nil))
  962.           (setq current-room 10)
  963.           (setq ethernet nil)
  964.           (mprincl "Connection closed.")
  965.           (unix-interface))
  966.           (if (< objnum 0)
  967.           (progn
  968.             (mprincl "Your axe shatters into a million pieces.")
  969.             (remove-obj-from-inven 14))
  970.         (mprincl "Your axe breaks it into a million pieces.")
  971.         (remove-obj-from-room current-room objnum)))))))))
  972.  
  973. (defun drive (args)
  974.   (if (not inbus)
  975.       (mprincl "You cannot drive when you aren't in a vehicle.")
  976.     (mprincl "To drive while you are in the bus, just give a direction.")))
  977.  
  978. (defun superb (args)
  979.   (setq mode 'superb))
  980.  
  981. (defun reg-score ()
  982.   (let (total)
  983.     (setq total 0)
  984.     (dolist (x (nth 0 room-objects))
  985.       (setq total (+ total (nth x object-pts))))
  986.     (if (member -13 (nth 0 room-objects))
  987.     (setq total 0)) total))
  988.  
  989. (defun endgame-score ()
  990.   (let (total)
  991.     (setq total 0)
  992.     (dolist (x (nth 102 room-objects))
  993.       (setq total (+ total (nth x object-pts)))) total))
  994.  
  995. (defun answer (args)
  996.   (if (not correct-answer)
  997.       (mprincl "I don't believe anyone asked you anything.")
  998.     (setq args (car args))
  999.     (if (not args)
  1000.     (mprincl "You must give the answer on the same line.")
  1001.       (if (members args correct-answer)
  1002.       (progn
  1003.         (mprincl "Correct.")
  1004.         (if (= lastdir 0)
  1005.         (setq current-room (1+ current-room))
  1006.           (setq current-room (- current-room 1)))
  1007.         (setq correct-answer nil))
  1008.     (mprincl "That answer is incorrect.")))))
  1009.  
  1010. (defun endgame-question ()
  1011. (if (not endgame-questions)
  1012.     (progn
  1013.       (mprincl "Your question is:")
  1014.       (mprincl "No more questions, just do 'answer foo'.")
  1015.       (setq correct-answer '("foo")))
  1016.   (let (which i newques)
  1017.     (setq i 0)
  1018.     (setq newques nil)
  1019.     (setq which (% (abs (random)) (length endgame-questions)))
  1020.     (mprincl "Your question is:")
  1021.     (mprincl (setq endgame-question (car (nth which endgame-questions))))
  1022.     (setq correct-answer (cdr (nth which endgame-questions)))
  1023.     (while (< i which)
  1024.       (setq newques (append newques (list (nth i endgame-questions))))
  1025.       (setq i (1+ i)))
  1026.     (setq i (1+ which))
  1027.     (while (< i (length endgame-questions))
  1028.       (setq newques (append newques (list (nth i endgame-questions))))
  1029.       (setq i (1+ i)))
  1030.     (setq endgame-questions newques))))
  1031. SHAR_EOF
  1032. fi # end of overwriting check
  1033. #    End of shell archive
  1034. exit 0
  1035.