home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume18 / dunnet2 / part02 / dun-commands.el < prev    next >
Lisp/Scheme  |  1993-07-12  |  33KB  |  973 lines

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