home *** CD-ROM | disk | FTP | other *** search
/ Sunny 1,000 Collection / SUNNY1000.iso / Files / Dos / infoco3 / TAD2EX.ZIP / ADV.T next >
Encoding:
Text File  |  1994-02-06  |  111.5 KB  |  3,958 lines

  1. /* $Header: c:/tads/tads2/RCS/adv.t 1.3 93/01/08 04:36:27 mroberts Prod Locker: mroberts $ */
  2. /* Copyright (c) 1988, 1993 by Michael J. Roberts.  All Rights Reserved. */
  3. /*
  4.    adv.t  - standard adventure definitions for TADS games
  5.    Version 2.1
  6.  
  7.    This file is part of TADS:  The Text Adventure Development System.
  8.    Please see the file LICENSE.DOC (which should be part of the TADS
  9.    distribution) for information on using this file, and for information
  10.    on reaching High Energy Software, the developers of TADS.
  11.  
  12.    This file defines the basic classes and functions used by most TADS
  13.    adventure games.  It is generally #include'd at the start of each game
  14.    source file.
  15. */
  16.  
  17. /*
  18.  *   Define compound prepositions.  Since prepositions that appear in
  19.  *   parsed sentences must be single words, we must define any logical
  20.  *   prepositions that consist of two or more words here.  Note that
  21.  *   only two words can be pasted together at once; to paste more, use
  22.  *   a second step.  For example,  'out from under' must be defined in
  23.  *   two steps:
  24.  *
  25.  *     compoundWord 'out' 'from' 'outfrom';
  26.  *     compoundWord 'outfrom' 'under' 'outfromunder';
  27.  *
  28.  *   Listed below are the compound prepositions that were built in to
  29.  *   version 1.0 of the TADS run-time.
  30.  */
  31. compoundWord 'on' 'to' 'onto';           /* on to --> onto */
  32. compoundWord 'in' 'to' 'into';           /* in to --> into */
  33. compoundWord 'in' 'between' 'inbetween'; /* and so forth */
  34. compoundWord 'down' 'in' 'downin';
  35. compoundWord 'down' 'on' 'downon';
  36. compoundWord 'up' 'on' 'upon';
  37. compoundWord 'out' 'of' 'outof';
  38. compoundWord 'off' 'of' 'offof';
  39. ;
  40.  
  41. /*
  42.  *   Format strings:  these associate keywords with properties.  When
  43.  *   a keyword appears in output between percent signs (%), the matching
  44.  *   property of the current command's actor is evaluated and substituted
  45.  *   for the keyword (and the percent signs).  For example, if you have:
  46.  *
  47.  *      formatstring 'you' fmtYou;
  48.  *
  49.  *   and the command being processed is:
  50.  *
  51.  *      fred, pick up the paper
  52.  *
  53.  *   and the "fred" actor has fmtYou = "he", and this string is output:
  54.  *
  55.  *      "%You% can't see that here."
  56.  *
  57.  *   Then the actual output is:  "He can't see that here."
  58.  *
  59.  *   The format strings are chosen to look like normal output (minus the
  60.  *   percent signs, of course) when the actor is Me.
  61.  */
  62. formatstring 'you' fmtYou;
  63. formatstring 'your' fmtYour;
  64. formatstring 'you\'re' fmtYoure;
  65. formatstring 'youm' fmtYoum;
  66. formatstring 'you\'ve' fmtYouve;
  67. formatstring 's' fmtS;
  68. formatstring 'es' fmtEs;
  69. formatstring 'have' fmtHave;
  70. formatstring 'do' fmtDo;
  71. formatstring 'are' fmtAre;
  72. ;
  73.  
  74. /*
  75.  *   Special Word List: This list defines the special words that the
  76.  *   parser needs for input commands.  If the list is not provided, the
  77.  *   parser uses the old defaults.  The list below is the same as the old
  78.  *   defaults.  Note - the words in this list must appear in the order
  79.  *   shown below.
  80.  */
  81. specialWords
  82.    'of',                        /* used in phrases such as "piece of paper" */
  83.    'and',             /* conjunction for noun lists or to separate commands */
  84.    'then',                              /* conjunction to separate commands */
  85.    'all' = 'everything',               /* refers to every accessible object */
  86.    'both',      /* used with plurals, or to answer disambiguation questions */
  87.    'but' = 'except',                      /* used to exclude items from ALL */
  88.    'one',                       /* used to answer questions:  "the red one" */
  89.    'ones',                        /* likewise for plurals:  "the blue ones" */
  90.    'it',                        /* refers to last single direct object used */
  91.    'them',                             /* refers to last direct object list */
  92.    'him',                       /* refers to last masculine actor mentioned */
  93.    'her'                         /* refers to last feminine actor mentioned */
  94. ;
  95.   
  96.  
  97. /*
  98.  *   Forward-declare functions.  This is not required in most cases,
  99.  *   but it doesn't hurt.  Providing these forward declarations ensures
  100.  *   that the compiler knows that we want these symbols to refer to
  101.  *   functions rather than objects.
  102.  */
  103. checkDoor: function;
  104. checkReach: function;
  105. itemcnt: function;
  106. listcont: function;
  107. listcontcont: function;
  108. turncount: function;
  109. addweight: function;
  110. addbulk: function;
  111. incscore: function;
  112. darkTravel: function;
  113. scoreRank: function;
  114. terminate: function;
  115. goToSleep: function;
  116. initSearch: function;
  117. reachableList: function;
  118. initRestart: function;
  119. ;
  120.  
  121. /*
  122.  *   initRestart - flag when a restart has occurred by setting a flag
  123.  *   in global.
  124.  */
  125. initRestart: function(parm)
  126. {
  127.     global.restarting := true;
  128. }
  129.  
  130. /*
  131.  *   checkDoor:  if the door d is open, this function silently returns
  132.  *   the room r.  Otherwise, print a message ("The door is closed.") and
  133.  *   return nil.
  134.  */
  135. checkDoor: function( d, r )
  136. {
  137.     if ( d.isopen ) return( r );
  138.     else
  139.     {
  140.         setit( d );
  141.     caps(); d.thedesc; " is closed. ";
  142.     return( nil );
  143.     }
  144. }
  145.  
  146. /*
  147.  *   checkReach:  determines whether the object obj can be reached by
  148.  *   actor in location loc, using the verb v.  This routine returns true
  149.  *   if obj is a special object (numObj or strObj), if obj is in actor's
  150.  *   inventory or actor's location, or if it's in the 'reachable' list
  151.  *   for loc.
  152.  */
  153. checkReach: function( loc, actor, v, obj )
  154. {
  155.     if ( obj=numObj or obj=strObj ) return;
  156.     if ( not ( actor.isCarrying( obj ) or obj.isIn( actor.location )))
  157.     {
  158.         if (find( loc.reachable, obj ) <> nil ) return;
  159.         "%You% can't reach "; obj.thedesc; " from "; loc.thedesc; ". ";
  160.         exit;
  161.     }
  162. }
  163.  
  164. /*
  165.  *  itemcnt: function( list )
  166.  *
  167.  *  Returns a count of the "listable" objects in list.  An
  168.  *  object is listable (that is, it shows up in a room's description)
  169.  *  if its isListed property is true.  This function is
  170.  *  useful for determining how many objects (if any) will be listed
  171.  *  in a room's description.
  172.  */
  173. itemcnt: function( list )
  174. {
  175.     local cnt, tot, i;
  176.     tot := length( list );
  177.     cnt := 0;
  178.     i := 1;
  179.     while ( i <= tot )
  180.     {
  181.         if ( list[i].isListed ) cnt := cnt+1;
  182.         i := i+1;
  183.     }
  184.     return( cnt );
  185. }
  186.  
  187. /*
  188.  *  listcont: function( obj )
  189.  *
  190.  *  This function displays the contents of an object, separated by
  191.  *  commas.  The thedesc properties of the contents are used.
  192.  *  It is up to the caller to provide the introduction to the list
  193.  *  (usually something to the effect of "The box contains" is
  194.  *  displayed before calling listcont) and finishing the
  195.  *  sentence (usually by displaying a period).  An object is listed
  196.  *  only if its isListed property is true.
  197.  */
  198. listcont: function( obj )
  199. {
  200.     local i, count, tot, list, cur, disptot;
  201.     count := 0;
  202.     list := obj.contents;
  203.     tot := length( list );
  204.     disptot := itemcnt( list );
  205.     i := 1;
  206.     while ( i <= tot )
  207.     {
  208.         cur := list[i];
  209.         if ( cur.isListed )
  210.         {
  211.             if ( count > 0 )
  212.             {
  213.                 if ( count+1 < disptot )
  214.                     ", ";
  215.                 else if (count = 1)
  216.                     " and ";
  217.                 else
  218.                     ", and ";
  219.             }
  220.             count := count + 1;
  221.             cur.adesc;               // list this object
  222.             if ( cur.isworn ) " (being worn)";
  223.             if ( cur.islamp and cur.islit ) " (providing light)";
  224.         }
  225.         i := i + 1;
  226.     }
  227. }
  228.  
  229. /*
  230.  *   showcontcont:  list the contents of the object, plus the contents of
  231.  *   an fixeditem's contained by the object.  A complete sentence is shown.
  232.  *   This is an internal routine used by listcontcont and listfixedcontcont.
  233.  */
  234. showcontcont: function( obj )
  235. {
  236.     if (itemcnt( obj.contents ))
  237.     {
  238.         if ( obj.issurface and not obj.isqsurface )
  239.         {
  240.             "Sitting on "; obj.thedesc;" is "; listcont( obj );
  241.             ". ";
  242.         }
  243.         else if ( obj.contentsVisible and not obj.isqcontainer )
  244.         {
  245.             caps();
  246.             obj.thedesc; " seems to contain ";
  247.             listcont( obj );
  248.             ". ";
  249.         }
  250.     }
  251.     if ( obj.contentsVisible and not obj.isqcontainer )
  252.         listfixedcontcont( obj );
  253. }
  254.  
  255. /*
  256.  *  listfixedcontcont: function( obj )
  257.  *
  258.  *  List the contents of the contents of any fixeditem objects
  259.  *  in the contents list of the object obj.  This routine
  260.  *  makes sure that all objects that can be taken are listed somewhere
  261.  *  in a room's description.  This routine recurses down the contents
  262.  *  tree, following each branch until either something has been listed
  263.  *  or the branch ends without anything being listable.  This routine
  264.  *  displays a complete sentence, so no introductory or closing text
  265.  *  is needed.
  266.  */
  267. listfixedcontcont: function( obj )
  268. {
  269.     local list, i, tot, thisobj;
  270.  
  271.     list := obj.contents;
  272.     tot := length( list );
  273.     i := 1;
  274.     while ( i <= tot )
  275.     {
  276.         thisobj := list[i];
  277.         if ( thisobj.isfixed and thisobj.contentsVisible and
  278.       not thisobj.isqcontainer )
  279.             showcontcont( thisobj );
  280.     i := i + 1;
  281.     }
  282. }
  283.  
  284. /*
  285.  *  listcontcont: function( obj )
  286.  *
  287.  *  This function lists the contents of the contents of an object.
  288.  *  It displays full sentences, so no introductory or closing text
  289.  *  is required.  Any item in the contents list of the object
  290.  *  obj whose contentsVisible property is true has
  291.  *  its contents listed.  An Object whose isqcontainer or
  292.  *  isqsurface property is true will not have its
  293.  *  contents listed.
  294.  */
  295. listcontcont: function( obj )
  296. {
  297.     local list, i, tot;
  298.     list := obj.contents;
  299.     tot := length( list );
  300.     i := 1;
  301.     while ( i <= tot )
  302.     {
  303.         showcontcont( list[i] );
  304.     i := i + 1;
  305.     }
  306. }
  307.  
  308. /*
  309.  *  scoreStatus: function(points, turns)
  310.  *
  311.  *  This function updates the score on the status line.  This implementation
  312.  *  simply calls the built-in function setscore() with the same information.
  313.  *  The call to setscore() has been isolated in this function to make it
  314.  *  easier to replace with a customized version; to replace the status line
  315.  *  score display, simply replace this routine.
  316.  */
  317. scoreStatus: function(points, turns)
  318. {
  319.     setscore(points, turns);
  320. }
  321.  
  322. /*
  323.  *  turncount: function( parm )
  324.  *
  325.  *  This function can be used as a daemon (normally set up in the init
  326.  *  function) to update the turn counter after each turn.  This routine
  327.  *  increments global.turnsofar, and then calls setscore to
  328.  *  update the status line with the new turn count.
  329.  */
  330. turncount: function( parm )
  331. {
  332.     incturn();
  333.     global.turnsofar := global.turnsofar + 1;
  334.     scoreStatus( global.score, global.turnsofar );
  335. }
  336.  
  337. /*
  338.  *  addweight: function( list )
  339.  *
  340.  *  Adds the weights of the objects in list and returns the sum.
  341.  *  The weight of an object is given by its weight property.  This
  342.  *  routine includes the weights of all of the contents of each object,
  343.  *  and the weights of their contents, and so forth.
  344.  */
  345. addweight: function( l )
  346. {
  347.     local tot, i, c, totweight;
  348.  
  349.     tot := length( l );
  350.     i := 1;
  351.     totweight := 0;
  352.     while ( i <= tot )
  353.     {
  354.         c := l[i];
  355.         totweight := totweight + c.weight;
  356.         if (length( c.contents ))
  357.             totweight := totweight + addweight( c.contents );
  358.         i := i + 1;
  359.     }
  360.     return( totweight );
  361. }
  362.  
  363. /*
  364.  *  addbulk: function( list )
  365.  *
  366.  *  This function returns the sum of the bulks (given by the bulk
  367.  *  property) of each object in list.  The value returned includes
  368.  *  only the bulk of each object in the list, and not of the contents
  369.  *  of the objects, as it is assumed that an object does not change in
  370.  *  size when something is put inside it.  You can easily change this
  371.  *  assumption for special objects (such as a bag that stretches as
  372.  *  things are put inside) by writing an appropriate bulk method
  373.  *  for that object.
  374.  */
  375. addbulk: function( list )
  376. {
  377.     local i, tot, totbulk, rem, cur;
  378.  
  379.     tot := length( list );
  380.     i := 1;
  381.     totbulk := 0;
  382.     while( i <= tot )
  383.     {
  384.         cur := list[i];
  385.         if ( not cur.isworn )
  386.             totbulk := totbulk + cur.bulk;
  387.         i := i + 1;
  388.     }
  389.     return( totbulk );
  390. }
  391.  
  392. /*
  393.  *  incscore: function( amount )
  394.  *
  395.  *  Adds amount to the total score, and updates the status line
  396.  *  to reflect the new score.  The total score is kept in global.score.
  397.  *  Always use this routine rather than changing global.score
  398.  *  directly, since this routine ensures that the status line is
  399.  *  updated with the new value.
  400.  */
  401. incscore: function( amount )
  402. {
  403.     global.score := global.score + amount;
  404.     scoreStatus( global.score, global.turnsofar );
  405. }
  406.  
  407. /*
  408.  *  initSearch: function
  409.  *
  410.  *  Initializes the containers of objects with a searchLoc, underLoc,
  411.  *  and behindLoc by setting up searchCont, underCont, and
  412.  *  behindCont lists, respectively.  You should call this function once in
  413.  *  your preinit (or init, if you prefer) function to ensure that
  414.  *  the underable, behindable, and searchable objects are set up correctly.
  415.  *  
  416.  *  As a bonus, we take this opportunity to initialize global.floatingList
  417.  *  with a list of all objects of class floatingItem.  It is necessary to
  418.  *  initialize this list, so that validDoList and validIoList include objects
  419.  *  with variable location properties.  Note that, for this to work,
  420.  *  all objects with variable location properties must be declared
  421.  *  to be of class floatingItem.
  422.  */
  423. initSearch: function
  424. {
  425.     local o;
  426.     
  427.     o := firstobj(hiddenItem);
  428.     while (o <> nil)
  429.     {
  430.     if (o.searchLoc)
  431.         o.searchLoc.searchCont := o.searchLoc.searchCont + o;
  432.     else if (o.underLoc)
  433.         o.underLoc.underCont := o.underLoc.underCont + o;
  434.     else if (o.behindLoc)
  435.         o.behindLoc.behindCont := o.behindLoc.behindCont + o;
  436.     o := nextobj(o, hiddenItem);
  437.     }
  438.     
  439.     global.floatingList := [];
  440.     for (o := firstobj(floatingItem) ; o ; o := nextobj(o, floatingItem))
  441.     global.floatingList += o;
  442. }
  443.  
  444. /*
  445.  *  reachableList: function
  446.  *
  447.  *  Returns a list of all the objects reachable from a given object.
  448.  *  That is, if the object is open or is not an openable, it returns the
  449.  *  contents of the object, plus the reachableList result of each object;
  450.  *  if the object is closed, it returns an empty list.
  451.  */
  452. reachableList: function(obj)
  453. {
  454.     local ret := [];
  455.     local i, lst, len;
  456.     
  457.     if (not isclass(obj, openable)
  458.     or (isclass(obj, openable) and obj.isopen))
  459.     {
  460.     lst := obj.contents;
  461.     len := length(lst);
  462.     ret += lst;
  463.     for (i := 1 ; i <= len ; ++i)
  464.         ret += reachableList(lst[i]);
  465.     }
  466.  
  467.     return(ret);
  468. }
  469.  
  470. /*
  471.  *  visibleList: function
  472.  *
  473.  *  This function is similar to reachableList, but returns the
  474.  *  list of objects visible within a given object.
  475.  */
  476. visibleList: function(obj)
  477. {
  478.     local ret := [];
  479.     local i, lst, len;
  480.     
  481.     if (not isclass(obj, openable)
  482.     or (isclass(obj, openable) and obj.isopen)
  483.     or obj.contentsVisible)
  484.     {
  485.     lst := obj.contents;
  486.     len := length(lst);
  487.     ret += lst;
  488.     for (i := 1 ; i <= len ; ++i)
  489.         ret += visibleList(lst[i]);
  490.     }
  491.  
  492.     return(ret);
  493. }
  494.  
  495. /*
  496.  *  nestedroom: room
  497.  *
  498.  *  A special kind of room that is inside another room; chairs and
  499.  *  some types of vehicles, such as inflatable rafts, fall into this
  500.  *  category.  Note that a room can be within another room without
  501.  *  being a nestedroom, simply by setting its location property
  502.  *  to another room.  The nestedroom is different from an ordinary
  503.  *  room, though, in that it's an "open" room; that is, when inside it,
  504.  *  the actor is still really inside the enclosing room for purposes of
  505.  *  descriptions.  Hence, the player sees "Laboratory, in the chair."
  506.  *  In addition, a nestedroom is an object in its own right,
  507.  *  visible to the player; for example, a chair is an object in a
  508.  *  room in addition to being a room itself.  The statusPrep
  509.  *  property displays the preposition in the status description; by
  510.  *  default, it will be "in," but some subclasses and instances
  511.  *  will want to change this to a more appropriate preposition.
  512.  *  outOfPrep is used to report what happens when the player
  513.  *  gets out of the object:  it should be "out of" or "off of" as
  514.  *  appropriate to this object.
  515.  */
  516. class nestedroom: room
  517.     statusPrep = "in"
  518.     outOfPrep = "out of"
  519.     islit =
  520.     {
  521.         if ( self.location ) return( self.location.islit );
  522.         return( nil );
  523.     }
  524.     statusLine =
  525.     {
  526.     "<<self.location.sdesc>>, <<self.statusPrep>> <<self.thedesc>>\n\t";
  527.     }
  528.     lookAround( verbosity ) =
  529.     {
  530.         self.statusLine;
  531.     self.location.nrmLkAround( verbosity );
  532.     }
  533.     roomDrop( obj ) =
  534.     {
  535.         if ( self.location = nil or self.isdroploc ) pass roomDrop;
  536.     else self.location.roomDrop( obj );
  537.     }
  538. ;
  539.  
  540. /*
  541.  *  chairitem: fixeditem, nestedroom, surface
  542.  *
  543.  *  Acts like a chair:  actors can sit on the object.  While sitting
  544.  *  on the object, an actor can't go anywhere until standing up, and
  545.  *  can only reach objects that are on the chair and in the chair's
  546.  *  reachable list.  By default, nothing is in the reachable
  547.  *  list.  Note that there is no real distinction made between chairs
  548.  *  and beds, so you can sit or lie on either; the only difference is
  549.  *  the message displayed describing the situation.
  550.  */
  551. class chairitem: fixeditem, nestedroom, surface
  552.     reachable = ([] + self) // list of all containers reachable from here;
  553.                             //  normally, you can only reach carried items
  554.                             //  from a chair, but this makes special allowances
  555.     ischair = true          // it is a chair by default; for beds or other
  556.                             //  things you lie down on, make it false
  557.     outOfPrep = "out of"
  558.     roomAction( actor, v, dobj, prep, io ) =
  559.     {
  560.         if ( dobj<>nil and v<>inspectVerb )
  561.             checkReach( self, actor, v, dobj );
  562.         if ( io<>nil and v<>askVerb and v<>tellVerb )
  563.             checkReach( self, actor, v, io );
  564.     pass roomAction;
  565.     }
  566.     enterRoom( actor ) = {}
  567.     noexit =
  568.     {
  569.         "%You're% not going anywhere until %you%
  570.         get%s% <<outOfPrep>> <<thedesc>>. ";
  571.         return( nil );
  572.     }
  573.     verDoBoard( actor ) = { self.verDoSiton( actor ); }
  574.     doBoard( actor ) = { self.doSiton( actor ); }
  575.     verDoSiton( actor ) =
  576.     {
  577.         if ( actor.location = self )
  578.         {
  579.             "%You're% already on "; self.thedesc; "! ";
  580.         }
  581.     }
  582.     doSiton( actor ) =
  583.     {
  584.         "Okay, %you're% now sitting on "; self.thedesc; ". ";
  585.         actor.travelTo( self );
  586.     }
  587.     verDoLieon( actor ) =
  588.     {
  589.         self.verDoSiton( actor );
  590.     }
  591.     doLieon( actor ) =
  592.     {
  593.         self.doSiton( actor );
  594.     }
  595. ;
  596.  
  597. /*
  598.  *  beditem: chairitem
  599.  *
  600.  *  This object is the same as a chairitem, except that the player
  601.  *  is described as lying on, rather than sitting in, the object.
  602.  */
  603. class beditem: chairitem
  604.     ischair = nil
  605.     isbed = true
  606.     sdesc = "bed"
  607.     statusPrep = "on"
  608.     outOfPrep = "out of"
  609.     doLieon(actor) =
  610.     {
  611.         "Okay, %you're% now lying on <<self.thedesc>>.";
  612.     actor.travelTo(self);
  613.     }
  614. ;
  615.     
  616. /*
  617.  *  floatingItem: object
  618.  *
  619.  *  This class doesn't do anything apart from mark an object as having a
  620.  *  variable location property.  It is necessary to mark all such
  621.  *  items by making them a member of this class, so that the objects are
  622.  *  added to global.floatingList, which is necessary so that floating
  623.  *  objects are included in validDoList and validIoList values (see
  624.  *  the deepverb class for a description of these methods).
  625.  */
  626. class floatingItem: object
  627. ;
  628.  
  629. /*
  630.  *  thing: object
  631.  *
  632.  *  The basic class for objects in a game.  The property contents
  633.  *  is a list that specifies what is in the object; this property is
  634.  *  automatically set up by the system after the game is compiled to
  635.  *  contain a list of all objects that have this object as their
  636.  *  location property.  The contents property is kept
  637.  *  consistent with the location properties of referenced objects
  638.  *  by the moveInto method; always use moveInto rather than
  639.  *  directly setting a location property for this reason.  The
  640.  *  adesc method displays the name of the object with an indefinite
  641.  *  article; the default is to display "a" followed by the sdesc,
  642.  *  but objects that need a different indefinite article (such as "an"
  643.  *  or "some") should override this method.  Likewise, thedesc
  644.  *  displays the name with a definite article; by default, thedesc
  645.  *  displays "the" followed by the object's sdesc.  The sdesc
  646.  *  simply displays the object's name ("short description") without
  647.  *  any articles.  The ldesc is the long description, normally
  648.  *  displayed when the object is examined by the player; by default,
  649.  *  the ldesc displays "It looks like an ordinary sdesc."
  650.  *  The isIn(object) method returns true if the
  651.  *  object's location is the specified object or the object's
  652.  *  location is an object whose contentsVisible property is
  653.  *  true and that object's isIn(object) method is
  654.  *  true.  Note that if isIn is true, it doesn't
  655.  *  necessarily mean the object is reachable, because isIn is
  656.  *  true if the object is merely visible within the location.
  657.  *  The thrudesc method displays a message for when the
  658.  *  player looks through the object (objects such as windows would
  659.  *  use this property).  The moveInto(object) method
  660.  *  moves the object to be inside the specified object.
  661.  *  To make an object disappear, move it into nil.
  662.  */
  663. class thing: object
  664.     weight = 0
  665.     bulk = 1
  666.     isListed = true         // shows up in room/inventory listings
  667.     contents = []           // set up automatically by system - do not set
  668.     verGrab( obj ) = {}
  669.     Grab( obj ) = {}
  670.     adesc =
  671.     {
  672.         "a "; self.sdesc;   // default is "a <name>"; "self" is current object
  673.     }
  674.     thedesc =
  675.     {
  676.         "the "; self.sdesc; // default is "the <name>"
  677.     }
  678.     ldesc = { "It looks like an ordinary "; self.sdesc; " to me."; }
  679.     readdesc = { "%You% can't read "; self.adesc; ". "; }
  680.     actorAction( v, d, p, i ) =
  681.     {
  682.         "You have lost your mind. ";
  683.         exit;
  684.     }
  685.     contentsVisible = { return( true ); }
  686.     contentsReachable = { return( true ); }
  687.     isIn( obj ) =
  688.     {
  689.         local myloc;
  690.  
  691.         myloc := self.location;
  692.         if ( myloc )
  693.         {
  694.             if ( myloc = obj ) return( true );
  695.             if ( myloc.contentsVisible ) return( myloc.isIn( obj ));
  696.         }
  697.         return( nil );
  698.     }
  699.     thrudesc = { "%You% can't see much through "; self.thedesc; ".\n"; }
  700.     moveInto( obj ) =
  701.     {
  702.         local loc;
  703.  
  704.     /*
  705.      *   For the object containing me, and its container, and so forth,
  706.      *   tell it via a Grab message that I'm going away.
  707.      */
  708.     loc := self.location;
  709.     while ( loc )
  710.     {
  711.         loc.Grab( self );
  712.         loc := loc.location;
  713.     }
  714.  
  715.         if ( self.location )
  716.             self.location.contents := self.location.contents - self;
  717.         self.location := obj;
  718.         if ( obj ) obj.contents := obj.contents + self;
  719.     }
  720.     verDoSave( actor ) =
  721.     {
  722.         "Please specify the name of the game to save in double quotes,
  723.         for example, SAVE \"GAME1\". ";
  724.     }
  725.     verDoRestore( actor ) =
  726.     {
  727.         "Please specify the name of the game to restore in double quotes,
  728.         for example, RESTORE \"GAME1\". ";
  729.     }
  730.     verDoScript( actor ) =
  731.     {
  732.         "You should type the name of a file to write the transcript to
  733.         in quotes, for example, SCRIPT \"LOG1\". ";
  734.     }
  735.     verDoSay( actor ) =
  736.     {
  737.         "You should say what you want to say in double quotes, for example,
  738.         SAY \"HELLO\". ";
  739.     }
  740.     verDoPush( actor ) =
  741.     {
  742.         "Pushing "; self.thedesc; " doesn't do anything. ";
  743.     }
  744.     verDoWear( actor ) =
  745.     {
  746.         "%You% can't wear "; self.thedesc; ". ";
  747.     }
  748.     verDoTake( actor ) =
  749.     {
  750.         if ( self.location = actor )
  751.         {
  752.             "%You% already %have% "; self.thedesc; "! ";
  753.         }
  754.         else self.verifyRemove( actor );
  755.     }
  756.     verifyRemove( actor ) =
  757.     {
  758.       /*
  759.      *   Check with each container to make sure that the container
  760.      *   doesn't object to the object's removal.
  761.      */
  762.         local loc;
  763.  
  764.         loc := self.location;
  765.         while ( loc )
  766.         {
  767.             if ( loc <> actor ) loc.verGrab( self );
  768.             loc := loc.location;
  769.         }
  770.     }
  771.     isVisible( vantage ) =
  772.     {
  773.         local loc;
  774.  
  775.         loc := self.location;
  776.         if ( loc = nil ) return( nil );
  777.  
  778.         /* if it's in the vantage, it's visible */
  779.         if ( loc = vantage ) return( true );
  780.  
  781.         /*
  782.          *   if its location's contents are visible, and its location is
  783.          *   itself visible, it's visible
  784.          */
  785.         if ( loc.contentsVisible and loc.isVisible( vantage )) return( true );
  786.  
  787.         /*
  788.          *   If the vantage has a location, and the vantage's location's
  789.          *   contents are visible (if you can see me I can see you), and
  790.          *   the object is visible from the vantage's location, the object
  791.          *   is visible
  792.          */
  793.         if ( vantage.location <> nil and vantage.location.contentsVisible and
  794.          self.isVisible( vantage.location ))
  795.             return( true );
  796.  
  797.         /* all tests failed:  it's not visible */
  798.         return( nil );
  799.     }
  800.     cantReach( actor ) =
  801.     {
  802.         if ( self.location = nil )
  803.         {
  804.             if ( actor.location.location )
  805.                "%You% can't reach that from << actor.location.thedesc >>. ";
  806.             return;
  807.         }
  808.         if ( not self.location.isopenable or self.location.isopen )
  809.             self.location.cantReach( actor );
  810.         else "%You%'ll have to open << self.location.thedesc >> first. ";
  811.     }
  812.     isReachable( actor ) =
  813.     {
  814.         local loc;
  815.  
  816.         /* if the object is in the room's 'reachable' list, it's reachable */
  817.         if (find( actor.location.reachable, self ) <> nil )
  818.             return( true );
  819.  
  820.         /*
  821.          *   If the object's container's contents are reachable, and the
  822.          *   container is reachable, the object is reachable.
  823.          */
  824.         loc := self.location;
  825.     if (find( actor.location.reachable, self ) <> nil )
  826.         return( true );
  827.     if ( loc = nil ) return( nil );
  828.     if ( loc = actor or loc = actor.location ) return( true );
  829.     if ( loc.contentsReachable )
  830.         return( loc.isReachable( actor ));
  831.     return( nil );
  832.         return( nil );
  833.     }
  834.     doTake( actor ) =
  835.     {
  836.         local totbulk, totweight;
  837.  
  838.         totbulk := addbulk( actor.contents ) + self.bulk;
  839.         totweight := addweight( actor.contents );
  840.         if ( not actor.isCarrying( self ))
  841.             totweight := totweight + self.weight + addweight(self.contents);
  842.  
  843.         if ( totweight > actor.maxweight )
  844.             "%Your% load is too heavy. ";
  845.         else if ( totbulk > actor.maxbulk )
  846.             "%You've% already got %your% hands full. ";
  847.         else
  848.         {
  849.             self.moveInto( actor );
  850.             "Taken. ";
  851.         }
  852.     }
  853.     verDoDrop( actor ) =
  854.     {
  855.         if ( not actor.isCarrying( self ))
  856.         {
  857.             "%You're% not carrying "; self.thedesc; "! ";
  858.         }
  859.         else self.verifyRemove( actor );
  860.     }
  861.     doDrop( actor ) =
  862.     {
  863.         actor.location.roomDrop( self );
  864.     }
  865.     verDoUnwear( actor ) =
  866.     {
  867.         "%You're% not wearing "; self.thedesc; "! ";
  868.     }
  869.     verIoPutIn( actor ) =
  870.     {
  871.         "%You% can't put anything into "; self.thedesc; ". ";
  872.     }
  873.     circularMessage(io) =
  874.     {
  875.         local cont;
  876.  
  877.     "%You% can't put <<thedesc>> in <<io.thedesc>>, because
  878.     <<io.thedesc>> is <<io.location = self ? "already" : ""
  879.         >> <<io.location.issurface ? "on" : "in">> <<io.location.thedesc>>";
  880.     for (cont := io.location ; cont <> self ; cont := cont.location)
  881.     {
  882.         ", which is ";
  883.             if (cont.location = self) "already ";
  884.             "<<cont.location.issurface ? "on" : "in"
  885.             >> <<cont.location.thedesc>>";
  886.     }
  887.     ".";
  888.     }
  889.     verDoPutIn( actor, io ) =
  890.     {
  891.         if ( io = nil ) return;
  892.  
  893.         if ( self.location = io )
  894.         {
  895.             caps(); self.thedesc; " is already in "; io.thedesc; "! ";
  896.         }
  897.         else if (io = self)
  898.         {
  899.             "%You% can't put "; self.thedesc; " in itself! ";
  900.         }
  901.         else if (io.isIn(self))
  902.         self.circularMessage(io);
  903.         else
  904.             self.verifyRemove( actor );
  905.     }
  906.     doPutIn( actor, io ) =
  907.     {
  908.         self.moveInto( io );
  909.         "Done. ";
  910.     }
  911.     verIoPutOn( actor ) =
  912.     {
  913.         "There's no good surface on "; self.thedesc; ". ";
  914.     }
  915.     verDoPutOn( actor, io ) =
  916.     {
  917.         if ( io = nil ) return;
  918.  
  919.         if ( self.location = io )
  920.         {
  921.             caps(); self.thedesc; " is already on "; io.thedesc; "! ";
  922.         }
  923.     else if (io = self)
  924.         {
  925.             "%You% can't put "; self.thedesc; " on itself! ";
  926.         }
  927.     else if (io.isIn(self))
  928.         self.circularMessage(io);
  929.         else
  930.         self.verifyRemove( actor );
  931.     }
  932.     doPutOn( actor, io ) =
  933.     {
  934.         self.moveInto( io );
  935.         "Done. ";
  936.     }
  937.     verIoTakeOut( actor ) = {}
  938.     ioTakeOut( actor, dobj ) =
  939.     {
  940.         dobj.doTakeOut( actor, self );
  941.     }
  942.     verDoTakeOut( actor, io ) =
  943.     {
  944.         if ( io <> nil and not self.isIn( io ))
  945.         {
  946.             caps(); self.thedesc; " isn't in "; io.thedesc; ". ";
  947.         }
  948.     self.verDoTake(actor);         /* ensure object can be taken at all */
  949.     }
  950.     doTakeOut( actor, io ) =
  951.     {
  952.         self.doTake( actor );
  953.     }
  954.     verIoTakeOff( actor ) = {}
  955.     ioTakeOff( actor, dobj ) =
  956.     {
  957.         dobj.doTakeOff( actor, self );
  958.     }
  959.     verDoTakeOff( actor, io ) =
  960.     {
  961.         if ( io <> nil and not self.isIn( io ))
  962.         {
  963.             caps(); self.thedesc; " isn't on "; io.thedesc; "! ";
  964.         }
  965.     self.verDoTake(actor);         /* ensure object can be taken at all */
  966.     }
  967.     doTakeOff( actor, io ) =
  968.     {
  969.         self.doTake( actor );
  970.     }
  971.     verIoPlugIn( actor ) =
  972.     {
  973.         "%You% can't plug anything into "; self.thedesc; ". ";
  974.     }
  975.     verDoPlugIn( actor, io ) =
  976.     {
  977.         "%You% can't plug "; self.thedesc; " into anything. ";
  978.     }
  979.     verIoUnplugFrom( actor ) =
  980.     {
  981.         "It's not plugged into "; self.thedesc; ". ";
  982.     }
  983.     verDoUnplugFrom( actor, io ) =
  984.     {
  985.         if ( io <> nil ) { "It's not plugged into "; io.thedesc; ". "; }
  986.     }
  987.     verDoLookin( actor ) =
  988.     {
  989.         "There's nothing in "; self.thedesc; ". ";
  990.     }
  991.     verDoLookthru( actor ) =
  992.     {
  993.         "%You% can't see anything through "; self.thedesc; ". ";
  994.     }
  995.     verDoLookunder( actor ) =
  996.     {
  997.         "There's nothing under "; self.thedesc; ". ";
  998.     }
  999.     verDoInspect( actor ) = {}
  1000.     doInspect( actor ) =
  1001.     {
  1002.         self.ldesc;
  1003.     }
  1004.     verDoRead( actor ) =
  1005.     {
  1006.         "I don't know how to read "; self.thedesc; ". ";
  1007.     }
  1008.     verDoLookbehind( actor ) =
  1009.     {
  1010.         "There's nothing behind "; self.thedesc; ". ";
  1011.     }
  1012.     verDoTurn( actor ) =
  1013.     {
  1014.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1015.     }
  1016.     verDoTurnWith( actor, io ) =
  1017.     {
  1018.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1019.     }
  1020.     verDoTurnTo( actor, io ) =
  1021.     {
  1022.         "Turning "; self.thedesc; " doesn't have any effect. ";
  1023.     }
  1024.     verIoTurnTo( actor ) =
  1025.     {
  1026.         "I don't know how to do that. ";
  1027.     }
  1028.     verDoTurnon( actor ) =
  1029.     {
  1030.         "I don't know how to turn "; self.thedesc; " on. ";
  1031.     }
  1032.     verDoTurnoff( actor ) =
  1033.     {
  1034.         "I don't know how to turn "; self.thedesc; " off. ";
  1035.     }
  1036.     verIoAskAbout( actor ) = {}
  1037.     ioAskAbout( actor, dobj ) =
  1038.     {
  1039.         dobj.doAskAbout( actor, self );
  1040.     }
  1041.     verDoAskAbout( actor, io ) =
  1042.     {
  1043.         "Surely, %you% can't think "; self.thedesc; " knows anything
  1044.         about it! ";
  1045.     }
  1046.     verIoTellAbout( actor ) = {}
  1047.     ioTellAbout( actor, dobj ) =
  1048.     {
  1049.         dobj.doTellAbout( actor, self );
  1050.     }
  1051.     verDoTellAbout( actor, io ) =
  1052.     {
  1053.         "It doesn't look as though "; self.thedesc; " is interested. ";
  1054.     }
  1055.     verDoUnboard( actor ) =
  1056.     {
  1057.         if ( actor.location <> self )
  1058.         {
  1059.             "%You're% not in "; self.thedesc; "! ";
  1060.         }
  1061.         else if ( self.location=nil )
  1062.         {
  1063.             "%You% can't get out of "; self.thedesc; "! ";
  1064.         }
  1065.     }
  1066.     doUnboard( actor ) =
  1067.     {
  1068.         if ( self.fastenitem )
  1069.     {
  1070.         "%You%'ll have to unfasten "; actor.location.fastenitem.thedesc;
  1071.         " first. ";
  1072.     }
  1073.     else
  1074.     {
  1075.             "Okay, %you're% no longer in "; self.thedesc; ". ";
  1076.             self.leaveRoom( actor );
  1077.         actor.moveInto( self.location );
  1078.     }
  1079.     }
  1080.     verDoAttackWith( actor, io ) =
  1081.     {
  1082.         "Attacking "; self.thedesc; " doesn't appear productive. ";
  1083.     }
  1084.     verIoAttackWith( actor ) =
  1085.     {
  1086.         "It's not very effective to attack with "; self.thedesc; ". ";
  1087.     }
  1088.     verDoEat( actor ) =
  1089.     {
  1090.         caps(); self.thedesc; " doesn't appear appetizing. ";
  1091.     }
  1092.     verDoDrink( actor ) =
  1093.     {
  1094.         caps(); self.thedesc; " doesn't appear appetizing. ";
  1095.     }
  1096.     verDoGiveTo( actor, io ) =
  1097.     {
  1098.         if ( not actor.isCarrying( self ))
  1099.         {
  1100.             "%You're% not carrying "; self.thedesc; ". ";
  1101.         }
  1102.         else self.verifyRemove( actor );
  1103.     }
  1104.     doGiveTo( actor, io ) =
  1105.     {
  1106.         self.moveInto( io );
  1107.         "Done. ";
  1108.     }
  1109.     verDoPull( actor ) =
  1110.     {
  1111.         "Pulling "; self.thedesc; " doesn't have any effect. ";
  1112.     }
  1113.     verDoThrowAt( actor, io ) =
  1114.     {
  1115.         if ( not actor.isCarrying( self ))
  1116.         {
  1117.             "%You're% not carrying "; self.thedesc; ". ";
  1118.         }
  1119.         else self.verifyRemove( actor );
  1120.     }
  1121.     doThrowAt( actor, io ) =
  1122.     {
  1123.         "%You% miss%es%. ";
  1124.         self.moveInto( actor.location );
  1125.     }
  1126.     verIoThrowAt( actor ) =
  1127.     {
  1128.         if ( actor.isCarrying( self ))
  1129.         {
  1130.             "%You% could at least drop "; self.thedesc; " first. ";
  1131.         }
  1132.     }
  1133.     ioThrowAt( actor, dobj ) =
  1134.     {
  1135.         dobj.doThrowAt( actor, self );
  1136.     }
  1137.     verDoThrowTo( actor, io ) =
  1138.     {
  1139.         if ( not actor.isCarrying( self ))
  1140.         {
  1141.             "%You're% not carrying "; self.thedesc; ". ";
  1142.         }
  1143.         else self.verifyRemove( actor );
  1144.     }
  1145.     doThrowTo( actor, io ) =
  1146.     {
  1147.         "%You% miss%es%. ";
  1148.         self.moveInto( actor.location );
  1149.     }
  1150.     verDoThrow( actor ) =
  1151.     {
  1152.         if ( not actor.isCarrying( self ))
  1153.         {
  1154.             "%You're% not carrying "; self.thedesc; ". ";
  1155.         }
  1156.         else self.verifyRemove( actor );
  1157.     }
  1158.     doThrow( actor ) =
  1159.     {
  1160.         "Thrown. ";
  1161.         self.moveInto( actor.location );
  1162.     }
  1163.     verDoShowTo( actor, io ) =
  1164.     {
  1165.     }
  1166.     doShowTo( actor, io ) =
  1167.     {
  1168.         if ( io <> nil ) { caps(); io.thedesc; " isn't impressed. "; }
  1169.     }
  1170.     verIoShowTo( actor ) =
  1171.     {
  1172.         caps(); self.thedesc; " isn't impressed. ";
  1173.     }
  1174.     verDoClean( actor ) =
  1175.     {
  1176.         caps(); self.thedesc; " looks a bit cleaner now. ";
  1177.     }
  1178.     verDoCleanWith( actor, io ) = {}
  1179.     doCleanWith( actor, io ) =
  1180.     {
  1181.         caps(); self.thedesc; " looks a bit cleaner now. ";
  1182.     }
  1183.     verDoMove( actor ) =
  1184.     {
  1185.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1186.     }
  1187.     verDoMoveTo( actor, io ) =
  1188.     {
  1189.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1190.     }
  1191.     verIoMoveTo( actor ) =
  1192.     {
  1193.         "That doesn't get us anywhere. ";
  1194.     }
  1195.     verDoMoveWith( actor, io ) =
  1196.     {
  1197.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1198.     }
  1199.     verIoMoveWith( actor ) =
  1200.     {
  1201.         caps(); self.thedesc; " doesn't seem to help. ";
  1202.     }
  1203.     verDoTypeOn( actor, io ) =
  1204.     {
  1205.         "You should say what you want to type in double quotes, for
  1206.         example, TYPE \"HELLO\" ON KEYBOARD. ";
  1207.     }
  1208.     verDoTouch( actor ) =
  1209.     {
  1210.         "Touching "; self.thedesc; " doesn't seem to have any effect. ";
  1211.     }
  1212.     verDoPoke( actor ) =
  1213.     {
  1214.         "Poking "; self.thedesc; " doesn't seem to have any effect. ";
  1215.     }
  1216.     genMoveDir = { "%You% can't seem to do that. "; }
  1217.     verDoMoveN( actor ) = { self.genMoveDir; }
  1218.     verDoMoveS( actor ) = { self.genMoveDir; }
  1219.     verDoMoveE( actor ) = { self.genMoveDir; }
  1220.     verDoMoveW( actor ) = { self.genMoveDir; }
  1221.     verDoMoveNE( actor ) = { self.genMoveDir; }
  1222.     verDoMoveNW( actor ) = { self.genMoveDir; }
  1223.     verDoMoveSE( actor ) = { self.genMoveDir; }
  1224.     verDoMoveSW( actor ) = { self.genMoveDir; }
  1225.     verDoSearch( actor ) =
  1226.     {
  1227.         "%You% find%s% nothing of interest. ";
  1228.     }
  1229. ;
  1230.  
  1231. /*
  1232.  *  item: thing
  1233.  *
  1234.  *  A basic item which can be picked up by the player.  It has no weight
  1235.  *  (0) and minimal bulk (1).  The weight property should be set
  1236.  *  to a non-zero value for heavy objects.  The bulk property
  1237.  *  should be set to a value greater than 1 for bulky objects, and to
  1238.  *  zero for objects that are very small and take essentially no effort
  1239.  *  to hold---or, more precisely, don't detract at all from the player's
  1240.  *  ability to hold other objects (for example, a piece of paper).
  1241.  */
  1242. class item: thing
  1243.     weight = 0
  1244.     bulk = 1
  1245. ;
  1246.     
  1247. /*
  1248.  *  lightsource: item
  1249.  *
  1250.  *  A portable lamp, candle, match, or other source of light.  The
  1251.  *  light source can be turned on and off with the islit property.
  1252.  *  If islit is true, the object provides light, otherwise it's
  1253.  *  just an ordinary object.
  1254.  */
  1255. class lightsource: item
  1256.     islamp = true
  1257. ;
  1258.  
  1259. /*
  1260.  *  hiddenItem: object
  1261.  *
  1262.  *  This is an object that is hidden with one of the hider classes. 
  1263.  *  A hiddenItem object doesn't have any special properties in its
  1264.  *  own right, but all objects hidden with one of the hider classes
  1265.  *  must be of class hiddenItem so that initSearch can find
  1266.  *  them.
  1267.  */
  1268. class hiddenItem: object
  1269. ;
  1270.  
  1271. /*
  1272.  *  hider: item
  1273.  *
  1274.  *  This is a basic class of object that can hide other objects in various
  1275.  *  ways.  The underHider, behindHider, and searchHider classes
  1276.  *  are examples of hider subclasses.  The class defines
  1277.  *  the method searchObj(actor, list), which is given the list
  1278.  *  of hidden items contained in the object (for example, this would be the
  1279.  *  underCont property, in the case of an underHider), and "finds"
  1280.  *  the object or objects. Its action is dependent upon a couple of other
  1281.  *  properties of the hider object.  The serialSearch property,
  1282.  *  if true, indicates that items in the list are to be found one at
  1283.  *  a time; if nil (the default), the entire list is found on the
  1284.  *  first try.  The autoTake property, if true, indicates that
  1285.  *  the actor automatically takes the item or items found; if nil, the
  1286.  *  item or items are moved to the actor's location.  The searchObj method
  1287.  *  returns the list with the found object or objects removed; the
  1288.  *  caller should assign this returned value back to the appropriate
  1289.  *  property (for example, underHider will assign the return value
  1290.  *  to underCont).
  1291.  *  
  1292.  *  Note that because the hider is hiding something, this class
  1293.  *  overrides the normal verDoSearch method to display the
  1294.  *  message, "You'll have to be more specific about how you want
  1295.  *  to search that."  The reason is that the normal verDoSearch
  1296.  *  message ("You find nothing of interest") leads players to believe
  1297.  *  that the object was exhaustively searched, and we want to avoid
  1298.  *  misleading the player.  On the other hand, we don't want a general
  1299.  *  search to be exhaustive for most hider objects.  So, we just
  1300.  *  display a message letting the player know that the search was not
  1301.  *  enough, but we don't give away what they have to do instead.
  1302.  *  
  1303.  *  The objects hidden with one of the hider classes must be
  1304.  *  of class hiddenItem.
  1305.  */
  1306. class hider: item
  1307.     verDoSearch(actor) =
  1308.     {
  1309.     "%You%'ll have to be more specific about how %you% want%s%
  1310.     to search that. ";
  1311.     }
  1312.     searchObj(actor, list) =
  1313.     {
  1314.     local found, dest, i, tot;
  1315.  
  1316.     /* see how much we get this time */
  1317.     if (self.serialSearch)
  1318.     {
  1319.         found := [] + car(list);
  1320.         list := cdr(list);
  1321.     }
  1322.     else
  1323.     {
  1324.         found := list;
  1325.         list := nil;
  1326.     }
  1327.  
  1328.     /* set it(them) to the found item(s) */
  1329.         if (length(found) = 1)
  1330.         setit(found[1]);    // only one item - set 'it'
  1331.     else
  1332.         setit(found);       // multiple items - set 'them'
  1333.  
  1334.     /* figure destination */
  1335.     dest := actor;
  1336.     if (not self.autoTake) dest := dest.location;
  1337.     
  1338.     /* note what we found, and move it to destination */
  1339.     "%You% find%s% ";
  1340.     tot := length(found);
  1341.     i := 1;
  1342.     while (i <= tot)
  1343.     {
  1344.         found[i].adesc;
  1345.         if (i+1 < tot) ", ";
  1346.         else if (i = 1 and tot = 2) " and ";
  1347.         else if (i+1 = tot and tot > 2) ", and ";
  1348.         
  1349.         found[i].moveInto(dest);
  1350.         i := i + 1;
  1351.     }
  1352.  
  1353.     /* say what happened */
  1354.     if (self.autoTake) ", which %you% take%s%. ";
  1355.     else "! ";
  1356.  
  1357.     if (list<>nil and length(list)=0) list := nil;
  1358.     return(list);
  1359.     }
  1360.     serialSearch = nil             /* find everything in one try by default */
  1361.     autoTake = true               /* actor takes item when found by default */
  1362. ;
  1363.  
  1364. /*
  1365.  *  underHider: hider
  1366.  *
  1367.  *  This is an object that can have other objects placed under it.  The
  1368.  *  objects placed under it can only be found by looking under the object;
  1369.  *  see the description of hider for more information.  You should
  1370.  *  set the underLoc property of each hidden object to point to
  1371.  *  the underHider.
  1372.  *  
  1373.  *  Note that an underHider doesn't allow the player to put anything
  1374.  *  under the object during the game.  Instead, it's to make it easy for the
  1375.  *  game writer to set up hidden objects while implementing the game.  All you
  1376.  *  need to do to place an object under another object is declare the top
  1377.  *  object as an underHider, then declare the hidden object normally,
  1378.  *  except use underLoc rather than location to specify the
  1379.  *  location of the hidden object.  The behindHider and searchHider
  1380.  *  objects work similarly.
  1381.  *  
  1382.  *  The objects hidden with underHider must be of class hiddenItem.
  1383.  */
  1384. class underHider: hider
  1385.     underCont = []         /* list of items under me (set up by initSearch) */
  1386.     verDoLookunder(actor) = {}
  1387.     doLookunder(actor) =
  1388.     {
  1389.     if (self.underCont = nil)
  1390.         "There's nothing else under <<self.thedesc>>. ";
  1391.     else
  1392.         self.underCont := self.searchObj(actor, self.underCont);
  1393.     }
  1394. ;
  1395.  
  1396. /*
  1397.  *  behindHider: hider
  1398.  *
  1399.  *  This is just like an underHider, except that objects are hidden
  1400.  *  behind this object.  Objects to be behind this object should have their
  1401.  *  behindLoc property set to point to this object.
  1402.  *  
  1403.  *  The objects hidden with behindHider must be of class hiddenItem.
  1404.  */
  1405. class behindHider: hider
  1406.     behindCont = []
  1407.     verDoLookbehind(actor) = {}
  1408.     doLookbehind(actor) =
  1409.     {
  1410.     if (self.behindCont = nil)
  1411.         "There's nothing else behind <<self.thedesc>>. ";
  1412.     else
  1413.         self.behindCont := self.searchObj(actor, self.behindCont);
  1414.     }
  1415. ;
  1416.     
  1417. /*
  1418.  *  searchHider: hider
  1419.  *
  1420.  *  This is just like an underHider, except that objects are hidden
  1421.  *  within this object in such a way that the object must be looked in
  1422.  *  or searched.  Objects to be hidden in this object should have their
  1423.  *  searchLoc property set to point to this object.  Note that this
  1424.  *  is different from a normal container, in that the objects hidden within
  1425.  *  this object will not show up until the object is explicitly looked in
  1426.  *  or searched.
  1427.  *  
  1428.  *  The items hidden with searchHider must be of class hiddenItem.
  1429.  */
  1430. class searchHider: hider
  1431.     searchCont = []
  1432.     verDoSearch(actor) = {}
  1433.     doSearch(actor) =
  1434.     {
  1435.     if (self.searchCont = nil)
  1436.         "There's nothing else in <<self.thedesc>>. ";
  1437.     else
  1438.         self.searchCont := self.searchObj(actor, self.searchCont);
  1439.     }
  1440.     verDoLookin(actor) =
  1441.     {
  1442.     if (self.searchCont = nil)
  1443.         pass verDoLookin;
  1444.     }
  1445.     doLookin(actor) =
  1446.     {
  1447.     if (self.searchCont = nil)
  1448.         pass doLookin;
  1449.     else
  1450.         self.searchCont := self.searchObj(actor, self.searchCont);
  1451.     }
  1452. ;
  1453.     
  1454.  
  1455. /*
  1456.  *  fixeditem: thing
  1457.  *
  1458.  *  An object that cannot be taken or otherwise moved from its location.
  1459.  *  Note that a fixeditem is sometimes part of a movable object;
  1460.  *  this can be done to make one object part of another, ensuring that
  1461.  *  they cannot be separated.  By default, the functions that list a room's
  1462.  *  contents do not automatically describe fixeditem objects (because
  1463.  *  the isListed property is set to nil).  Instead, the game author
  1464.  *  will generally describe the fixeditem objects separately as part of
  1465.  *  the room's ldesc.  
  1466.  */
  1467. class fixeditem: thing      // An immovable object
  1468.     isListed = nil          // not listed in room/inventory displays
  1469.     isfixed = true          // Item can't be taken
  1470.     weight = 0              // no actual weight
  1471.     bulk = 0
  1472.     verDoTake( actor ) =
  1473.     {
  1474.         "%You% can't have "; self.thedesc; ". ";
  1475.     }
  1476.     verDoTakeOut( actor, io ) =
  1477.     {
  1478.         self.verDoTake( actor );
  1479.     }
  1480.     verDoDrop( actor ) =
  1481.     {
  1482.         "%You% can't drop "; self.thedesc; ". ";
  1483.     }
  1484.     verDoTakeOff( actor, io ) =
  1485.     {
  1486.         self.verDoTake( actor );
  1487.     }
  1488.     verDoPutIn( actor, io ) =
  1489.     {
  1490.         "%You% can't put "; self.thedesc; " anywhere. ";
  1491.     }
  1492.     verDoPutOn( actor, io ) =
  1493.     {
  1494.         "%You% can't put "; self.thedesc; " anywhere. ";
  1495.     }
  1496.     verDoMove( actor ) =
  1497.     {
  1498.         "%You% can't move "; self.thedesc; ". ";
  1499.     }
  1500.     verDoThrowAt(actor, iobj) =
  1501.     {
  1502.         "%You% can't throw <<self.thedesc>>.";
  1503.     }
  1504. ;
  1505.  
  1506. /*
  1507.  *  readable: item
  1508.  *
  1509.  *  An item that can be read.  The readdesc property is displayed
  1510.  *  when the item is read.  By default, the readdesc is the same
  1511.  *  as the ldesc, but the readdesc can be overridden to give
  1512.  *  a different message.
  1513.  */
  1514. class readable: item
  1515.     verDoRead( actor ) =
  1516.     {
  1517.     }
  1518.     doRead( actor ) =
  1519.     {
  1520.         self.readdesc;
  1521.     }
  1522.     readdesc =
  1523.     {
  1524.         self.ldesc;
  1525.     }
  1526. ;
  1527.  
  1528. /*
  1529.  *  fooditem: item
  1530.  *
  1531.  *  An object that can be eaten.  When eaten, the object is removed from
  1532.  *  the game, and global.lastMealTime is decremented by the
  1533.  *  foodvalue property.  By default, the foodvalue property
  1534.  *  is global.eatTime, which is the time between meals.  So, the
  1535.  *  default fooditem will last for one "nourishment interval."
  1536.  */
  1537. class fooditem: item
  1538.     verDoEat( actor ) =
  1539.     {
  1540.         self.verifyRemove( actor );
  1541.     }
  1542.     doEat( actor ) =
  1543.     {
  1544.         "That was delicious! ";
  1545.         global.lastMealTime := global.lastMealTime - self.foodvalue;
  1546.         self.moveInto( nil );
  1547.     }
  1548.     foodvalue = { return( global.eatTime ); }
  1549. ;
  1550.  
  1551. /*
  1552.  *  dialItem: fixeditem
  1553.  *
  1554.  *  This class is used for making "dials," which are controls in
  1555.  *  your game that can be turned to a range of numbers.  You must
  1556.  *  define the property maxsetting as a number specifying the
  1557.  *  highest number to which the dial can be turned; the lowest number
  1558.  *  on the dial is always 1.  The setting property is the dial's
  1559.  *  current setting, and can be changed by the player by typing the
  1560.  *  command "turn dial to number."  By default, the ldesc
  1561.  *  method displays the current setting.
  1562.  */
  1563. class dialItem: fixeditem
  1564.     maxsetting = 10 // it has settings from 1 to this number
  1565.     setting = 1     // the current setting
  1566.     ldesc =
  1567.     {
  1568.         caps(); self.thedesc; " can be turned to settings
  1569.         numbered from 1 to << self.maxsetting >>. It's
  1570.         currently set to << self.setting >>. ";
  1571.     }
  1572.     verDoTurn( actor ) = {}
  1573.     doTurn( actor ) =
  1574.     {
  1575.         askio( toPrep );
  1576.     }
  1577.     verDoTurnTo( actor, io ) = {}
  1578.     doTurnTo( actor, io ) =
  1579.     {
  1580.         if ( io = numObj )
  1581.         {
  1582.             if ( numObj.value < 1 or numObj.value > self.maxsetting )
  1583.             {
  1584.                 "There's no such setting! ";
  1585.             }
  1586.             else if ( numObj.value <> self.setting )
  1587.             {
  1588.                 self.setting := numObj.value;
  1589.                 "Okay, it's now turned to "; say( self.setting ); ". ";
  1590.             }
  1591.             else
  1592.             {
  1593.                 "It's already set to "; say( self.setting ); "! ";
  1594.             }
  1595.         }
  1596.         else
  1597.         {
  1598.             "I don't know how to turn "; self.thedesc;
  1599.             " to that. ";
  1600.         }
  1601.     }
  1602. ;
  1603.  
  1604. /*
  1605.  *  switchItem: fixeditem
  1606.  *
  1607.  *  This is a class for things that can be turned on and off by the
  1608.  *  player.  The only special property is isActive, which is nil
  1609.  *  if the switch is turned off and true when turned on.  The object
  1610.  *  accepts the commands "turn it on" and "turn it off,'' as well as
  1611.  *  synonymous constructions, and updates isActive accordingly.
  1612.  */
  1613. class switchItem: fixeditem
  1614.     verDoSwitch( actor ) = {}
  1615.     doSwitch( actor ) =
  1616.     {
  1617.         self.isActive := not self.isActive;
  1618.         "Okay, "; self.thedesc; " is now switched ";
  1619.         if ( self.isActive ) "on"; else "off";
  1620.         ". ";
  1621.     }
  1622.     verDoTurnon( actor ) =
  1623.     {
  1624.         /*
  1625.            You can't turn on something in the dark unless you're carrying
  1626.            it.  You also can't turn something on if it's already on.
  1627.         */
  1628.     if (not actor.location.islit and not actor.isCarrying(self))
  1629.         "It's pitch black.";
  1630.         else if ( self.isActive )
  1631.             "It's already turned on! ";
  1632.     }
  1633.     doTurnon( actor ) =
  1634.     {
  1635.         self.isActive := true;
  1636.         "Okay, it's now turned on. ";
  1637.     }
  1638.     verDoTurnoff( actor ) =
  1639.     {
  1640.         if ( not self.isActive ) "It's already turned off! ";
  1641.     }
  1642.     doTurnoff( actor ) =
  1643.     {
  1644.         self.isActive := nil;
  1645.         "Okay, it's now turned off. ";
  1646.     }
  1647. ;
  1648.  
  1649. /*
  1650.  *  room: thing
  1651.  *
  1652.  *  A location in the game.  By default, the islit property is
  1653.  *  true, which means that the room is lit (no light source is
  1654.  *  needed while in the room).  You should create a darkroom
  1655.  *  object rather than a room with islit set to nil if you
  1656.  *  want a dark room, because other methods are affected as well.
  1657.  *  The isseen property records whether the player has entered
  1658.  *  the room before; initially it's nil, and is set to true
  1659.  *  the first time the player enters.  The roomAction(actor,
  1660.  *  verb, directObject, preposition, indirectObject) method is
  1661.  *  activated for each player command; by default, all it does is
  1662.  *  call the room's location's roomAction method if the room
  1663.  *  is inside another room.  The lookAround(verbosity)
  1664.  *  method displays the room's description for a given verbosity
  1665.  *  level; true means a full description, nil means only
  1666.  *  the short description (just the room name plus a list of the
  1667.  *  objects present).  roomDrop(object) is called when
  1668.  *  an object is dropped within the room; normally, it just moves
  1669.  *  the object to the room and displays "Dropped."  The firstseen
  1670.  *  method is called when isseen is about to be set true
  1671.  *  for the first time (i.e., when the player first sees the room);
  1672.  *  by default, this routine does nothing, but it's a convenient
  1673.  *  place to put any special code you want to execute when a room
  1674.  *  is first entered.  The firstseen method is called after
  1675.  *  the room's description is displayed.
  1676.  */
  1677. class room: thing
  1678.     /*
  1679.      *   'reachable' is the list of explicitly reachable objects, over and
  1680.      *   above the objects that are here.  This is mostly used in nested
  1681.      *   rooms to make objects in the containing room accessible.  Most
  1682.      *   normal rooms will leave this as an empty list.
  1683.      */
  1684.     reachable = []
  1685.     
  1686.     /*
  1687.      *   roomCheck is true if the verb is valid in the room.  This
  1688.      *   is a first pass; generally, its only function is to disallow
  1689.      *   certain commands in a dark room.
  1690.      */
  1691.     roomCheck( v ) = { return( true ); }
  1692.     islit = true            // rooms are lit unless otherwise specified
  1693.     isseen = nil            // room has not been seen yet
  1694.     enterRoom( actor ) =    // sent to room as actor is entering it
  1695.     {
  1696.         self.lookAround(( not self.isseen ) or global.verbose );
  1697.         if ( self.islit )
  1698.     {
  1699.         if (not self.isseen) self.firstseen;
  1700.         self.isseen := true;
  1701.     }
  1702.     }
  1703.     roomAction( a, v, d, p, i ) =
  1704.     {
  1705.         if ( self.location ) self.location.roomAction( a, v, d, p, i );
  1706.     }
  1707.  
  1708.     /*
  1709.      *   Whenever a normal object (i.e., one that does not override the
  1710.      *   default doDrop provided by 'thing') is dropped, the actor's
  1711.      *   location is sent roomDrop(object being dropped).  By default, 
  1712.      *   we move the object into this room.
  1713.      */
  1714.     roomDrop( obj ) =
  1715.     {
  1716.         "Dropped. ";
  1717.     obj.moveInto( self );
  1718.     }
  1719.  
  1720.     /*
  1721.      *   Whenever an actor leaves this room, we run through the leaveList.
  1722.      *   This is a list of objects that have registered themselves with us
  1723.      *   via addLeaveList().  For each object in the leaveList, we send
  1724.      *   a "leaving" message, with the actor as the parameter.  It should
  1725.      *   return true if it wants to be removed from the leaveList, nil
  1726.      *   if it wants to stay.
  1727.      */
  1728.     leaveList = []
  1729.     addLeaveList( obj ) =
  1730.     {
  1731.         self.leaveList := self.leaveList + obj;
  1732.     }
  1733.     leaveRoom( actor ) =
  1734.     {
  1735.         local tmplist, thisobj, i, tot;
  1736.  
  1737.         tmplist := self.leaveList;
  1738.     tot := length( tmplist );
  1739.     i := 1;
  1740.         while ( i <= tot )
  1741.         {
  1742.         thisobj := tmplist[i];
  1743.             if ( thisobj.leaving( actor ))
  1744.                 self.leaveList := self.leaveList - thisobj;
  1745.             i := i + 1;
  1746.         }
  1747.     }
  1748.     /*
  1749.      *   lookAround describes the room.  If verbosity is true, the full
  1750.      *   description is given, otherwise an abbreviated description (without
  1751.      *   the room's ldesc) is displayed.
  1752.      */
  1753.     nrmLkAround( verbosity ) =      // lookAround without location status
  1754.     {
  1755.         local l, cur, i, tot;
  1756.  
  1757.         if ( verbosity )
  1758.         {
  1759.             "\n\t"; self.ldesc;
  1760.  
  1761.             l := self.contents;
  1762.         tot := length( l );
  1763.         i := 1;
  1764.             while ( i <= tot )
  1765.             {
  1766.             cur := l[i];
  1767.                 if ( cur.isfixed ) cur.heredesc;
  1768.                 i := i + 1;
  1769.             }
  1770.         }
  1771.         "\n\t";
  1772.         if (itemcnt( self.contents ))
  1773.         {
  1774.             "You see "; listcont( self ); " here. ";
  1775.         }
  1776.         listcontcont( self ); "\n";
  1777.  
  1778.         l := self.contents;
  1779.     tot := length( l );
  1780.     i := 1;
  1781.         while ( i <= tot )
  1782.         {
  1783.         cur := l[i];
  1784.             if ( cur.isactor )
  1785.             {
  1786.                 if ( cur <> Me )
  1787.                 {
  1788.                     "\n\t";
  1789.                     cur.actorDesc;
  1790.                 }
  1791.             }
  1792.             i := i + 1;
  1793.         }
  1794.     }
  1795.     statusLine =
  1796.     {
  1797.         self.sdesc; "\n\t";
  1798.     }
  1799.     lookAround( verbosity ) =
  1800.     {
  1801.         self.statusLine;
  1802.         self.nrmLkAround( verbosity );
  1803.     }
  1804.     
  1805.     /*
  1806.      *   Direction handlers.  The directions are all set up to
  1807.      *   the default, which is no travel allowed.  To make travel
  1808.      *   possible in a direction, just assign a room to the direction
  1809.      *   property.
  1810.      */
  1811.     north = { return( self.noexit ); }
  1812.     south = { return( self.noexit ); }
  1813.     east  = { return( self.noexit ); }
  1814.     west  = { return( self.noexit ); }
  1815.     up    = { return( self.noexit ); }
  1816.     down  = { return( self.noexit ); }
  1817.     ne    = { return( self.noexit ); }
  1818.     nw    = { return( self.noexit ); }
  1819.     se    = { return( self.noexit ); }
  1820.     sw    = { return( self.noexit ); }
  1821.     in    = { return( self.noexit ); }
  1822.     out   = { return( self.noexit ); }
  1823.     
  1824.     /*
  1825.      *   noexit displays a message when the player attempts to travel
  1826.      *   in a direction in which travel is not possible.
  1827.      */
  1828.     noexit = { "%You% can't go that way. "; return( nil ); }
  1829. ;
  1830.  
  1831. /*
  1832.  *  darkroom: room
  1833.  *
  1834.  *  A dark room.  The player must have some object that can act as a
  1835.  *  light source in order to move about and perform most operations
  1836.  *  while in this room.  Note that the room's lights can be turned
  1837.  *  on by setting the room's lightsOn property to true;
  1838.  *  do this instead of setting islit, because islit is
  1839.  *  a method which checks for the presence of a light source.
  1840.  */
  1841. class darkroom: room        // An enterable area which might be dark
  1842.     islit =                 // true ONLY if something is lighting the room
  1843.     {
  1844.         local rem, cur, tot, i;
  1845.  
  1846.     if ( self.lightsOn ) return( true );
  1847.  
  1848.     rem := global.lamplist;
  1849.     tot := length( rem );
  1850.     i := 1;
  1851.     while ( i <= tot )
  1852.     {
  1853.         cur := rem[i];
  1854.         if ( cur.isIn( self ) and cur.islit ) return( true );
  1855.         i := i + 1;
  1856.     }
  1857.     return( nil );
  1858.     }
  1859.     roomAction( actor, v, dobj, prep, io ) =
  1860.     {
  1861.         if ( not self.islit and not v.isDarkVerb )
  1862.     {
  1863.         "%You% can't see a thing. ";
  1864.         exit;
  1865.     }
  1866.     else pass roomAction;
  1867.     }
  1868.     statusLine =
  1869.     {
  1870.         if ( self.islit ) pass statusLine;
  1871.     else "In the dark.";
  1872.     }
  1873.     lookAround( verbosity ) =
  1874.     {
  1875.         if ( self.islit ) pass lookAround;
  1876.     else "It's pitch black. ";
  1877.     }
  1878.     noexit =
  1879.     {
  1880.         if ( self.islit ) pass noexit;
  1881.     else
  1882.     {
  1883.         darkTravel();
  1884.         return( nil );
  1885.     }
  1886.     }
  1887.     roomCheck( v ) =
  1888.     {
  1889.         if ( self.islit or v.isDarkVerb ) return( true );
  1890.     else
  1891.     {
  1892.         "It's pitch black.\n";
  1893.         return( nil );
  1894.     }
  1895.     }
  1896. ;
  1897.  
  1898. /*
  1899.  *  theFloor is a special item that appears in every room (hence
  1900.  *  the non-standard location property).  This object is included
  1901.  *  mostly for completeness, so that the player can refer to the
  1902.  *  floor; otherwise, it doesn't do much.  Dropping an item on the
  1903.  *  floor, for example, moves it to the current room.
  1904.  */
  1905. theFloor: beditem, floatingItem
  1906.     noun = 'floor' 'ground'
  1907.     sdesc = "ground"
  1908.     adesc = "the ground"
  1909.     statusPrep = "on"
  1910.     outOfPrep = "off of"
  1911.     location =
  1912.     {
  1913.         if ( Me.location = self )
  1914.             return( self.sitloc );
  1915.         else
  1916.             return( Me.location );
  1917.     }
  1918.     locationOK = true        // suppress warning about location being a method
  1919.     doSiton( actor ) =
  1920.     {
  1921.         "Okay, %you're% now sitting on "; self.thedesc; ". ";
  1922.         self.sitloc := actor.location;
  1923.         actor.moveInto( self );
  1924.     }
  1925.     doLieon( actor ) =
  1926.     {
  1927.         self.doSiton( actor );
  1928.     }
  1929.     ioPutOn( actor, dobj ) =
  1930.     {
  1931.         dobj.doDrop( actor );
  1932.     }
  1933.     ioPutIn( actor, dobj ) =
  1934.     {
  1935.         dobj.doDrop( actor );
  1936.     }
  1937. ;
  1938.  
  1939. /*
  1940.  *  Actor: fixeditem, movableActor
  1941.  *
  1942.  *  A character in the game.  The maxweight property specifies
  1943.  *  the maximum weight that the character can carry, and the maxbulk
  1944.  *  property specifies the maximum bulk the character can carry.  The
  1945.  *  actorAction(verb, directObject, preposition, indirectObject)
  1946.  *  method specifies what happens when the actor is given a command by
  1947.  *  the player; by default, the actor ignores the command and displays
  1948.  *  a message to this effect.  The isCarrying(object)
  1949.  *  method returns true if the object is being carried by
  1950.  *  the actor.  The actorDesc method displays a message when the
  1951.  *  actor is in the current room; this message is displayed along with
  1952.  *  a room's description when the room is entered or examined.  The
  1953.  *  verGrab(object) method is called when someone tries to
  1954.  *  take an object the actor is carrying; by default, an actor won't
  1955.  *  let other characters take its possessions.
  1956.  *  
  1957.  *  If you want the player to be able to follow the actor when it
  1958.  *  leaves the room, you should define a follower object to shadow
  1959.  *  the character, and set the actor's myfollower property to
  1960.  *  the follower object.  The follower is then automatically
  1961.  *  moved around just behind the actor by the actor's moveInto
  1962.  *  method.
  1963.  *  
  1964.  *  The isHim property should return true if the actor can
  1965.  *  be referred to by the player as "him," and likewise isHer
  1966.  *  should be set to true if the actor can be referred to as "her."
  1967.  *  Note that both or neither can be set; if neither is set, the actor
  1968.  *  can only be referred to as "it," and if both are set, any of "him,''
  1969.  *  "her," or "it'' will be accepted.
  1970.  */
  1971. class Actor: fixeditem, movableActor
  1972. ;
  1973.  
  1974. /*
  1975.  *  movableActor: qcontainer
  1976.  *
  1977.  *  Just like an Actor object, except that the player can
  1978.  *  manipulate the actor like an ordinary item.  Useful for certain
  1979.  *  types of actors, such as small animals.
  1980.  */
  1981. class movableActor: qcontainer // A character in the game
  1982.     isListed = nil          // described separately from room's contents
  1983.     weight = 10             // actors are pretty heavy
  1984.     bulk = 10               // and pretty bulky
  1985.     maxweight = 50          // Weight that can be carried at once
  1986.     maxbulk = 20            // Number of objects that can be carried at once
  1987.     isactor = true          // flag that this is an actor
  1988.     actorAction( v, d, p, i ) =
  1989.     {
  1990.         caps(); self.thedesc; " doesn't appear interested. ";
  1991.         exit;
  1992.     }
  1993.     isCarrying( obj ) = { return( obj.isIn( self )); }
  1994.     actorDesc =
  1995.     {
  1996.         caps(); self.adesc; " is here. ";
  1997.     }
  1998.     verGrab( item ) =
  1999.     {
  2000.         caps(); self.thedesc; " is carrying "; item.thedesc;
  2001.         " and won't let %youm% have it. ";
  2002.     }
  2003.     verDoFollow( actor ) =
  2004.     {
  2005.         "But "; self.thedesc; " is right here! ";
  2006.     }
  2007.     moveInto( obj ) =
  2008.     {
  2009.         if ( self.myfollower ) self.myfollower.moveInto( self.location );
  2010.     pass moveInto;
  2011.     }
  2012.     // these properties are for the format strings
  2013.     fmtYou = "he"
  2014.     fmtYour = "his"
  2015.     fmtYoure = "he's"
  2016.     fmtYoum = "him"
  2017.     fmtYouve = "he's"
  2018.     fmtS = "s"
  2019.     fmtEs = "es"
  2020.     fmtHave = "has"
  2021.     fmtDo = "does"
  2022.     fmtAre = "is"
  2023.     askWord(word, lst) = { return(nil); }
  2024.     verDoAskAbout(actor, iobj) = {}
  2025.     doAskAbout(actor, iobj) =
  2026.     {
  2027.     local lst, i, tot;
  2028.  
  2029.     lst := objwords(2);       // get actual words asked about
  2030.     tot := length(lst);
  2031.     if ((tot = 1 and (find(['it' 'them' 'him' 'her'], lst[1]) <> nil))
  2032.         or tot = 0)
  2033.     {
  2034.         "\"Could you be more specific?\"";
  2035.         return;
  2036.     }
  2037.  
  2038.     // try to find a response for each word
  2039.     for (i := 1 ; i <= tot ; ++i)
  2040.     {
  2041.         if (self.askWord(lst[i], lst))
  2042.             return;
  2043.         }
  2044.  
  2045.     // didn't find anything to talk about
  2046.     self.disavow;
  2047.     }
  2048.     disavow = "\"I don't know much about that.\""
  2049.     verIoPutIn(actor) =
  2050.     {
  2051.         "If you want to give that to << thedesc >>, just say so.";
  2052.     }
  2053.  
  2054.     // move to a new location, notifying player of coming and going
  2055.     travelTo(room) =
  2056.     {
  2057.         /* notify player if leaving player's location (and it's not dark) */
  2058.         if (self.location = Me.location and self.location.islit)
  2059.             self.sayLeaving;
  2060.  
  2061.         /* move to my new location */
  2062.         self.moveInto(room);
  2063.  
  2064.         /* notify player if arriving at player's location */
  2065.         if (self.location = Me.location and self.location.islit)
  2066.             self.sayArriving;
  2067.     }
  2068.  
  2069.     // sayLeaving and sayArriving announce the actor's departure and arrival
  2070.     // in the same room as the player.
  2071.     sayLeaving = "\n\t\^<<self.thedesc>> leaves the area."
  2072.     sayArriving = "\n\t\^<<self.thedesc>> enters the area."
  2073. ;
  2074.  
  2075. /*
  2076.  *  follower: Actor
  2077.  *
  2078.  *  This is a special object that can "shadow" the movements of a
  2079.  *  character as it moves from room to room.  The purpose of a follower
  2080.  *  is to allow the player to follow an actor as it leaves a room by
  2081.  *  typing a "follow" command.  Each actor that is to be followed must
  2082.  *  have its own follower object.  The follower object should
  2083.  *  define all of the same vocabulary words (nouns and adjectives) as the
  2084.  *  actual actor to which it refers.  The follower must also
  2085.  *  define the myactor property to be the Actor object that
  2086.  *  the follower follows.  The follower will always stay
  2087.  *  one room behind the character it follows; no commands are effective
  2088.  *  with a follower except for "follow."
  2089.  */
  2090. class follower: Actor
  2091.     sdesc = { self.myactor.sdesc; }
  2092.     isfollower = true
  2093.     ldesc = { caps(); self.thedesc; " is no longer here. "; }
  2094.     actorAction( v, d, p, i ) = { self.ldesc; exit; }
  2095.     actorDesc = {}
  2096.     myactor = nil   // set to the Actor to be followed
  2097.     verDoFollow( actor ) = {}
  2098.     doFollow( actor ) =
  2099.     {
  2100.         actor.travelTo( self.myactor.location );
  2101.     }
  2102.     dobjGen(a, v, i, p) =
  2103.     {
  2104.         if (v <> followVerb)
  2105.     {
  2106.         "\^<< self.myactor.thedesc >> is no longer here.";
  2107.         exit;
  2108.     }
  2109.     }
  2110.     iobjGen(a, v, d, p) =
  2111.     {
  2112.         "\^<< self.myactor.thedesc >> is no longer here.";
  2113.     exit;
  2114.     }
  2115. ;
  2116.  
  2117. /*
  2118.  *  basicMe: Actor
  2119.  *
  2120.  *  A default implementation of the Me object, which is the
  2121.  *  player character.  adv.t defines basicMe instead of
  2122.  *  Me to allow your game to override parts of the default
  2123.  *  implementation while still using the rest, and without changing
  2124.  *  adv.t itself.  To use basicMe unchanged as your player
  2125.  *  character, include this in your game:  "Me: basicMe;".
  2126.  *  
  2127.  *  The basicMe object defines all of the methods and properties
  2128.  *  required for an actor, with appropriate values for the player
  2129.  *  character.  The nouns "me" and "myself'' are defined ("I''
  2130.  *  is not defined, because it conflicts with the "inventory"
  2131.  *  command's minimal abbreviation of "i" in certain circumstances,
  2132.  *  and is generally not compatible with the syntax of most player
  2133.  *  commands anyway).  The sdesc is "you"; the thedesc
  2134.  *  and adesc are "yourself," which is appropriate for most
  2135.  *  contexts.  The maxbulk and maxweight properties are
  2136.  *  set to 10 each; a more sophisticated Me might include the
  2137.  *  player's state of health in determining the maxweight and
  2138.  *  maxbulk properties.
  2139.  */
  2140. class basicMe: Actor, floatingItem
  2141.     roomCheck( v ) = { return( self.location.roomCheck( v )); }
  2142.     noun = 'me' 'myself'
  2143.     sdesc = "you"
  2144.     thedesc = "yourself"
  2145.     adesc = "yourself"
  2146.     ldesc = "You look about the same as always. "
  2147.     maxweight = 10
  2148.     maxbulk = 10
  2149.     verDoFollow( actor ) =
  2150.     {
  2151.         if ( actor = self ) "You can't follow yourself! ";
  2152.     }
  2153.     actorAction( verb, dobj, prep, iobj ) = 
  2154.     {
  2155.     }
  2156.     travelTo( room ) =
  2157.     {
  2158.         if ( room )
  2159.         {
  2160.         if ( room.isobstacle )
  2161.         {
  2162.             self.travelTo( room.destination );
  2163.         }
  2164.         else if ( not ( self.location.islit or room.islit ))
  2165.         {
  2166.             darkTravel();
  2167.         }
  2168.         else
  2169.         {
  2170.                 if ( self.location ) self.location.leaveRoom( self );
  2171.                 self.location := room;
  2172.                 room.enterRoom( self );
  2173.         }
  2174.         }
  2175.     }
  2176.     moveInto( room ) =
  2177.     {
  2178.         self.location := room;
  2179.     }
  2180.     // these properties are for the format strings
  2181.     fmtYou = "you"
  2182.     fmtYour = "your"
  2183.     fmtYoure = "you're"
  2184.     fmtYoum = "you"
  2185.     fmtYouve = "you've"
  2186.     fmtS = ""
  2187.     fmtEs = ""
  2188.     fmtHave = "have"
  2189.     fmtDo = "do"
  2190.     fmtAre = "are"
  2191. ;
  2192.  
  2193. /*
  2194.  *  decoration: fixeditem
  2195.  *
  2196.  *  An item that doesn't have any function in the game, apart from
  2197.  *  having been mentioned in the room description.  These items
  2198.  *  are immovable and can't be manipulated in any way, but can be
  2199.  *  referred to and inspected.  Liberal use of decoration items
  2200.  *  can improve a game's playability by helping the parser recognize
  2201.  *  all the words the game uses in its descriptions of rooms.
  2202.  */
  2203. class decoration: fixeditem
  2204.     ldesc = "That's not important."
  2205.     dobjGen(a, v, i, p) =
  2206.     {
  2207.         if (v <> inspectVerb)
  2208.     {
  2209.         "\^<<self.thedesc>> isn't important.";
  2210.         exit;
  2211.     }
  2212.     }
  2213.     iobjGen(a, v, d, p) =
  2214.     {
  2215.         "\^<<self.thedesc>> isn't important.";
  2216.     exit;
  2217.     }
  2218. ;
  2219.  
  2220. /*
  2221.  *  distantItem: fixeditem
  2222.  *
  2223.  *  This is an item that is too far away to manipulate, but can be seen.
  2224.  *  The class uses dobjGen and iobjGen to prevent any verbs from being
  2225.  *  used on the object apart from inspectVerb; using any other verb results
  2226.  *  in the message "It's too far away."  Instances of this class should
  2227.  *  provide the normal item properties:  sdesc, ldesc, location,
  2228.  *  and vocabulary.
  2229.  */
  2230. class distantItem: fixeditem
  2231.     dobjGen(a, v, i, p) =
  2232.     {
  2233.         if (v <> inspectVerb)
  2234.         {
  2235.             "It's too far away.";
  2236.             exit;
  2237.         }
  2238.     }
  2239.     iobjGen(a, v, d, p) = { self.dobjGen(a, v, d, p); }
  2240. ;
  2241.  
  2242. /*
  2243.  *  buttonitem: fixeditem
  2244.  *
  2245.  *  A button (the type you push).  The individual button's action method
  2246.  *  doPush(actor), which must be specified in
  2247.  *  the button, carries out the function of the button.  Note that
  2248.  *  all buttons have the noun "button" defined.
  2249.  */
  2250. class buttonitem: fixeditem
  2251.     noun = 'button'
  2252.     plural = 'buttons'
  2253.     verDoPush( actor ) = {}
  2254. ;
  2255.  
  2256. /*
  2257.  *  clothingItem: item
  2258.  *
  2259.  *  Something that can be worn.  By default, the only thing that
  2260.  *  happens when the item is worn is that its isworn property
  2261.  *  is set to true.  If you want more to happen, override the
  2262.  *  doWear(actor) property.  Note that, when a clothingItem
  2263.  *  is being worn, certain operations will cause it to be removed (for
  2264.  *  example, dropping it causes it to be removed).  If you want
  2265.  *  something else to happen, override the checkDrop method;
  2266.  *  if you want to disallow such actions while the object is worn,
  2267.  *  use an exit statement in the checkDrop method.
  2268.  */
  2269. class clothingItem: item
  2270.     checkDrop =
  2271.     {
  2272.         if ( self.isworn )
  2273.     {
  2274.         "(Taking off "; self.thedesc; " first)\n";
  2275.         self.isworn := nil;
  2276.     }
  2277.     }
  2278.     doDrop( actor ) =
  2279.     {
  2280.         self.checkDrop;
  2281.     pass doDrop;
  2282.     }
  2283.     doPutIn( actor, io ) =
  2284.     {
  2285.         self.checkDrop;
  2286.     pass doPutIn;
  2287.     }
  2288.     doPutOn( actor, io ) =
  2289.     {
  2290.         self.checkDrop;
  2291.     pass doPutOn;
  2292.     }
  2293.     doGiveTo( actor, io ) =
  2294.     {
  2295.         self.checkDrop;
  2296.     pass doGiveTo;
  2297.     }
  2298.     doThrowAt( actor, io ) =
  2299.     {
  2300.         self.checkDrop;
  2301.     pass doThrowAt;
  2302.     }
  2303.     doThrowTo( actor, io ) =
  2304.     {
  2305.         self.checkDrop;
  2306.     pass doThrowTo;
  2307.     }
  2308.     doThrow( actor ) =
  2309.     {
  2310.         self.checkDrop;
  2311.     pass doThrow;
  2312.     }
  2313.     moveInto( obj ) =
  2314.     {
  2315.         /*
  2316.      *   Catch any other movements with moveInto; this won't stop the
  2317.      *   movement from happening, but it will prevent any anamolous
  2318.      *   consequences caused by the object moving but still being worn.
  2319.      */
  2320.         self.isworn := nil;
  2321.     pass moveInto;
  2322.     }
  2323.     verDoWear( actor ) =
  2324.     {
  2325.         if ( self.isworn )
  2326.         {
  2327.             "%You're% already wearing "; self.thedesc; "! ";
  2328.         }
  2329.         else if ( not actor.isCarrying( self ))
  2330.         {
  2331.             "%You% %do%n't have "; self.thedesc; ". ";
  2332.         }
  2333.     }
  2334.     doWear( actor ) =
  2335.     {
  2336.         "Okay, %you're% now wearing "; self.thedesc; ". ";
  2337.         self.isworn := true;
  2338.     }
  2339.     verDoUnwear( actor ) =
  2340.     {
  2341.         if ( not self.isworn )
  2342.         {
  2343.             "%You're% not wearing "; self.thedesc; ". ";
  2344.         }
  2345.     }
  2346.     verDoTake(actor) =
  2347.     {
  2348.         if (self.isworn) self.verDoUnwear(actor);
  2349.     else pass verDoTake;
  2350.     }
  2351.     doTake(actor) =
  2352.     {
  2353.         if (self.isworn) self.doUnwear(actor);
  2354.     else pass doTake;
  2355.     }
  2356.     doUnwear( actor ) =
  2357.     {
  2358.         "Okay, %you're% no longer wearing "; self.thedesc; ". ";
  2359.         self.isworn := nil;
  2360.     }
  2361.     doSynonym('Unwear') = 'Unboard'
  2362. ;
  2363.  
  2364. /*
  2365.  *  obstacle: object
  2366.  *
  2367.  *  An obstacle is used in place of a room for a direction
  2368.  *  property.  The destination property specifies the room that
  2369.  *  is reached if the obstacle is successfully negotiated; when the
  2370.  *  obstacle is not successfully negotiated, destination should
  2371.  *  display an appropriate message and return nil.
  2372.  */
  2373. class obstacle: object
  2374.     isobstacle = true
  2375. ;
  2376.  
  2377. /*
  2378.  *  doorway: fixeditem, obstacle
  2379.  *
  2380.  *  A doorway is an obstacle that impedes progress when it is closed.
  2381.  *  When the door is open (isopen is true), the user ends up in
  2382.  *  the room specified in the doordest property upon going through
  2383.  *  the door.  Since a doorway is an obstacle, use the door object for
  2384.  *  a direction property of the room containing the door.
  2385.  *  
  2386.  *  If noAutoOpen is not set to true, the door will automatically
  2387.  *  be opened when the player tries to walk through the door, unless the
  2388.  *  door is locked (islocked = true).  If the door is locked,
  2389.  *  it can be unlocked simply by typing "unlock door", unless the
  2390.  *  mykey property is set, in which case the object specified in
  2391.  *  mykey must be used to unlock the door.  Note that the door can
  2392.  *  only be relocked by the player under the circumstances that allow
  2393.  *  unlocking, plus the property islockable must be set to true.
  2394.  *  By default, the door is closed; set isopen to true if the door
  2395.  *  is to start out open (and be sure to open the other side as well).
  2396.  *  
  2397.  *  otherside specifies the corresponding doorway object in the
  2398.  *  destination room (doordest), if any.  If otherside is
  2399.  *  specified, its isopen and islocked properties will be
  2400.  *  kept in sync automatically.
  2401.  */
  2402. class doorway: fixeditem, obstacle
  2403.     isdoor = true           // Item can be opened and closed
  2404.     destination =
  2405.     {
  2406.         if ( self.isopen ) return( self.doordest );
  2407.     else if ( not self.islocked and not self.noAutoOpen )
  2408.     {
  2409.         self.isopen := true;
  2410.         if ( self.otherside ) self.otherside.isopen := true;
  2411.         "(Opening << self.thedesc >>)\n";
  2412.         return( self.doordest );
  2413.     }
  2414.     else
  2415.     {
  2416.         "%You%'ll have to open << self.thedesc >> first. ";
  2417.         setit( self );
  2418.         return( nil );
  2419.     }
  2420.     }
  2421.     verDoOpen( actor ) =
  2422.     {
  2423.         if ( self.isopen ) "It's already open. ";
  2424.     else if ( self.islocked ) "It's locked. ";
  2425.     }
  2426.     doOpen( actor ) =
  2427.     {
  2428.         "Opened. ";
  2429.     self.isopen := true;
  2430.     if ( self.otherside ) self.otherside.isopen := true;
  2431.     }
  2432.     verDoClose( actor ) =
  2433.     {
  2434.         if ( not self.isopen ) "It's already closed. ";
  2435.     }
  2436.     doClose( actor ) =
  2437.     {
  2438.         "Closed. ";
  2439.     self.isopen := nil;
  2440.     if ( self.otherside ) self.otherside.isopen := nil;
  2441.     }
  2442.     verDoLock( actor ) =
  2443.     {
  2444.         if ( self.islocked ) "It's already locked! ";
  2445.     else if ( not self.islockable ) "It can't be locked. ";
  2446.     else if ( self.isopen ) "%You%'ll have to close it first. ";
  2447.     }
  2448.     doLock( actor ) =
  2449.     {
  2450.         if ( self.mykey = nil )
  2451.     {
  2452.         "Locked. ";
  2453.         self.islocked := true;
  2454.         if ( self.otherside ) self.otherside.islocked := true;
  2455.     }
  2456.     else
  2457.             askio( withPrep );
  2458.     }
  2459.     verDoUnlock( actor ) =
  2460.     {
  2461.         if ( not self.islocked ) "It's not locked! ";
  2462.     }
  2463.     doUnlock( actor ) =
  2464.     {
  2465.         if ( self.mykey = nil )
  2466.     {
  2467.         "Unlocked. ";
  2468.         self.islocked := nil;
  2469.         if ( self.otherside ) self.otherside.islocked := nil;
  2470.     }
  2471.     else
  2472.         askio( withPrep );
  2473.     }
  2474.     verDoLockWith( actor, io ) =
  2475.     {
  2476.         if ( self.islocked ) "It's already locked. ";
  2477.     else if ( not self.islockable ) "It can't be locked. ";
  2478.     else if ( self.mykey = nil )
  2479.         "%You% %do%n't need anything to lock it. ";
  2480.     else if ( self.isopen ) "%You%'ll have to close it first. ";
  2481.     }
  2482.     doLockWith( actor, io ) =
  2483.     {
  2484.         if ( io = self.mykey )
  2485.     {
  2486.         "Locked. ";
  2487.         self.islocked := true;
  2488.         if ( self.otherside ) self.otherside.islocked := true;
  2489.     }
  2490.     else "It doesn't fit the lock. ";
  2491.     }
  2492.     verDoUnlockWith( actor, io ) =
  2493.     {
  2494.         if ( not self.islocked ) "It's not locked! ";
  2495.     else if ( self.mykey = nil )
  2496.         "%You% %do%n't need anything to unlock it. ";
  2497.     }
  2498.     doUnlockWith( actor, io ) =
  2499.     {
  2500.         if ( io = self.mykey )
  2501.     {
  2502.         "Unlocked. ";
  2503.         self.islocked := nil;
  2504.         if ( self.otherside ) self.otherside.islocked := nil;
  2505.     }
  2506.     else "It doesn't fit the lock. ";
  2507.     }
  2508.     ldesc =
  2509.     {
  2510.     if ( self.isopen ) "It's open. ";
  2511.     else
  2512.     {
  2513.         if ( self.islocked ) "It's closed and locked. ";
  2514.         else "It's closed. ";
  2515.     }
  2516.     }
  2517. ;
  2518.  
  2519. /*
  2520.  *  lockableDoorway: doorway
  2521.  *
  2522.  *  This is just a normal doorway with the islockable and
  2523.  *  islocked properties set to true.  Fill in the other
  2524.  *  properties (otherside and doordest) as usual.  If
  2525.  *  the door has a key, set property mykey to the key object.
  2526.  */
  2527. class lockableDoorway: doorway
  2528.     islockable = true
  2529.     islocked = true
  2530. ;
  2531.  
  2532. /*
  2533.  *  vehicle: item, nestedroom
  2534.  *
  2535.  *  This is an object that an actor can board.  An actor cannot go
  2536.  *  anywhere while on board a vehicle (except where the vehicle goes);
  2537.  *  the actor must get out first.
  2538.  */
  2539. class vehicle: item, nestedroom
  2540.     reachable = ([] + self)
  2541.     isvehicle = true
  2542.     verDoEnter( actor ) = { self.verDoBoard( actor ); }
  2543.     doEnter( actor ) = { self.doBoard( actor ); }
  2544.     verDoBoard( actor ) =
  2545.     {
  2546.         if ( actor.location = self )
  2547.         {
  2548.             "%You're% already in "; self.thedesc; "! ";
  2549.         }
  2550.     else if (actor.isCarrying(self))
  2551.     {
  2552.         "%You%'ll have to drop <<thedesc>> first!";
  2553.     }
  2554.     }
  2555.     doBoard( actor ) =
  2556.     {
  2557.         "Okay, %you're% now in "; self.thedesc; ". ";
  2558.         actor.moveInto( self );
  2559.     }
  2560.     noexit =
  2561.     {
  2562.         "%You're% not going anywhere until %you% get%s% out of ";
  2563.       self.thedesc; ". ";
  2564.         return( nil );
  2565.     }
  2566.     out = ( self.location )
  2567.     verDoTake(actor) =
  2568.     {
  2569.         if (actor.isIn(self))
  2570.         "%You%'ll have to get <<self.outOfPrep>> <<self.thedesc>> first.";
  2571.     else
  2572.         pass verDoTake;
  2573.     }
  2574.     dobjGen(a, v, i, p) =
  2575.     {
  2576.         if (a.isIn(self) and v <> inspectVerb and v <> getOutVerb
  2577.         and v <> outVerb)
  2578.     {
  2579.         "%You%'ll have to get out of << thedesc >> first.";
  2580.         exit;
  2581.     }
  2582.     }
  2583.     iobjGen(a, v, d, p) =
  2584.     {
  2585.         if (a.isIn(self) and v <> putVerb)
  2586.     {
  2587.         "%You%'ll have to get out of << thedesc >> first.";
  2588.         exit;
  2589.     }
  2590.     }
  2591. ;
  2592.  
  2593. /*
  2594.  *  surface: item
  2595.  *
  2596.  *  Objects can be placed on a surface.  Apart from using the
  2597.  *  preposition "on" rather than "in'' to refer to objects
  2598.  *  contained by the object, a surface is identical to a
  2599.  *  container.  Note: an object cannot be both a
  2600.  *  surface and a container, because there is no
  2601.  *  distinction between the two internally.
  2602.  */
  2603. class surface: item
  2604.     issurface = true        // Item can hold objects on its surface
  2605.     ldesc =
  2606.     {
  2607.         if (itemcnt( self.contents ))
  2608.         {
  2609.             "On "; self.thedesc; " %you% see%s% "; listcont( self ); ". ";
  2610.         }
  2611.         else
  2612.         {
  2613.             "There's nothing on "; self.thedesc; ". ";
  2614.         }
  2615.     }
  2616.     verIoPutOn( actor ) = {}
  2617.     ioPutOn( actor, dobj ) =
  2618.     {
  2619.         dobj.doPutOn( actor, self );
  2620.     }
  2621. ;
  2622.  
  2623. /*
  2624.  *  container: item
  2625.  *
  2626.  *  This object can contain other objects.  The iscontainer property
  2627.  *  is set to true.  The default ldesc displays a list of the
  2628.  *  objects inside the container, if any.  The maxbulk property
  2629.  *  specifies the maximum amount of bulk the container can contain.
  2630.  */
  2631. class container: item
  2632.     maxbulk = 10            // maximum bulk the container can contain
  2633.     isopen = true           // in fact, it can't be closed at all
  2634.     iscontainer = true      // Item can contain other items
  2635.     ldesc =
  2636.     {
  2637.         if ( self.contentsVisible and itemcnt( self.contents ) <> 0 )
  2638.         {
  2639.             "In "; self.thedesc; " %you% see%s% "; listcont( self ); ". ";
  2640.         }
  2641.         else
  2642.         {
  2643.             "There's nothing in "; self.thedesc; ". ";
  2644.         }
  2645.     }
  2646.     verIoPutIn( actor ) =
  2647.     {
  2648.     }
  2649.     ioPutIn( actor, dobj ) =
  2650.     {
  2651.         if (addbulk( self.contents ) + dobj.bulk > self.maxbulk )
  2652.         {
  2653.             "%You% can't fit that in "; self.thedesc; ". ";
  2654.         }
  2655.         else
  2656.         {
  2657.         dobj.doPutIn( actor, self );
  2658.         }
  2659.     }
  2660.     verDoLookin( actor ) = {}
  2661.     doLookin( actor ) =
  2662.     {
  2663.         self.ldesc;
  2664.     }
  2665. ;
  2666.  
  2667. /*
  2668.  *  openable: container
  2669.  *
  2670.  *  A container that can be opened and closed.  The isopenable
  2671.  *  property is set to true.  The default ldesc displays
  2672.  *  the contents of the container if the container is open, otherwise
  2673.  *  a message saying that the object is closed.
  2674.  */
  2675. class openable: container
  2676.     contentsReachable = { return( self.isopen ); }
  2677.     contentsVisible = { return( self.isopen ); }
  2678.     isopenable = true
  2679.     ldesc =
  2680.     {
  2681.         caps(); self.thedesc;
  2682.         if ( self.isopen )
  2683.     {
  2684.         " is open. ";
  2685.         pass ldesc;
  2686.     }
  2687.         else
  2688.     {
  2689.         " is closed. ";
  2690.  
  2691.         /* if it's transparent, list its contents anyway */
  2692.         if (isclass(self, transparentItem)) pass ldesc;
  2693.     }
  2694.     }
  2695.     isopen = true
  2696.     verDoOpen( actor ) =
  2697.     {
  2698.         if ( self.isopen )
  2699.     {
  2700.         caps(); self.thedesc; " is already open! ";
  2701.     }
  2702.     }
  2703.     doOpen( actor ) =
  2704.     {
  2705.         if (itemcnt( self.contents ))
  2706.     {
  2707.         "Opening "; self.thedesc; " reveals "; listcont( self ); ". ";
  2708.     }
  2709.     else "Opened. ";
  2710.     self.isopen := true;
  2711.     }
  2712.     verDoClose( actor ) =
  2713.     {
  2714.         if ( not self.isopen )
  2715.     {
  2716.         caps(); self.thedesc; " is already closed! ";
  2717.     }
  2718.     }
  2719.     doClose( actor ) =
  2720.     {
  2721.         "Closed. ";
  2722.     self.isopen := nil;
  2723.     }
  2724.     verIoPutIn( actor ) =
  2725.     {
  2726.         if ( not self.isopen )
  2727.     {
  2728.         caps(); self.thedesc; " is closed. ";
  2729.     }
  2730.     }
  2731.     verDoLookin( actor ) =
  2732.     {
  2733.         /* we can look in it if either it's open or it's transparent */
  2734.         if (not self.isopen and not isclass(self, transparentItem))
  2735.            "It's closed. ";
  2736.     }
  2737. ;
  2738.  
  2739. /*
  2740.  *  qcontainer: container
  2741.  *
  2742.  *  A "quiet" container:  its contents are not listed when it shows
  2743.  *  up in a room description or inventory list.  The isqcontainer
  2744.  *  property is set to true.
  2745.  */
  2746. class qcontainer: container
  2747.     isqcontainer = true
  2748. ;
  2749.  
  2750. /*
  2751.  *  lockable: openable
  2752.  *
  2753.  *  A container that can be locked and unlocked.  The islocked
  2754.  *  property specifies whether the object can be opened or not.  The
  2755.  *  object can be locked and unlocked without the need for any other
  2756.  *  object; if you want a key to be involved, use a keyedLockable.
  2757.  */
  2758. class lockable: openable
  2759.     verDoOpen( actor ) =
  2760.     {
  2761.         if ( self.islocked )
  2762.         {
  2763.             "It's locked. ";
  2764.         }
  2765.         else pass verDoOpen;
  2766.     }
  2767.     verDoLock( actor ) =
  2768.     {
  2769.         if ( self.islocked )
  2770.         {
  2771.             "It's already locked! ";
  2772.         }
  2773.     }
  2774.     doLock( actor ) =
  2775.     {
  2776.         if ( self.isopen )
  2777.         {
  2778.             "%You%'ll have to close "; self.thedesc; " first. ";
  2779.         }
  2780.         else
  2781.         {
  2782.             "Locked. ";
  2783.             self.islocked := true;
  2784.         }
  2785.     }
  2786.     verDoUnlock( actor ) =
  2787.     {
  2788.         if ( not self.islocked ) "It's not locked! ";
  2789.     }
  2790.     doUnlock( actor ) =
  2791.     {
  2792.         "Unlocked. ";
  2793.         self.islocked := nil;
  2794.     }
  2795.     verDoLockWith( actor, io ) =
  2796.     {
  2797.         if ( self.islocked ) "It's already locked. ";
  2798.     }
  2799.     verDoUnlockWith( actor, io ) =
  2800.     {
  2801.         if ( not self.islocked ) "It's not locked! ";
  2802.     }
  2803. ;
  2804.  
  2805. /*
  2806.  *  keyedLockable: lockable
  2807.  *
  2808.  *  This subclass of lockable allows you to create an object
  2809.  *  that can only be locked and unlocked with a corresponding key.
  2810.  *  Set the property mykey to the keyItem object that can
  2811.  *  lock and unlock the object.
  2812.  */
  2813. class keyedLockable: lockable
  2814.     mykey = nil     // set 'mykey' to the key which locks/unlocks me
  2815.     doLock( actor ) =
  2816.     {
  2817.         askio( withPrep );
  2818.     }
  2819.     doUnlock( actor ) =
  2820.     {
  2821.         askio( withPrep );
  2822.     }
  2823.     doLockWith( actor, io ) =
  2824.     {
  2825.         if ( self.isopen )
  2826.         {
  2827.             "%You% can't lock << self.thedesc >> when it's open. ";
  2828.         }
  2829.         else if ( io = self.mykey )
  2830.         {
  2831.             "Locked. ";
  2832.             self.islocked := true;
  2833.         }
  2834.         else "It doesn't fit the lock. ";
  2835.     }
  2836.     doUnlockWith( actor, io ) =
  2837.     {
  2838.         if ( io = self.mykey )
  2839.         {
  2840.             "Unlocked. ";
  2841.             self.islocked := nil;
  2842.         }
  2843.         else "It doesn't fit the lock. ";
  2844.     }
  2845. ;
  2846.  
  2847. /*
  2848.  *  keyItem: item
  2849.  *
  2850.  *  This is an object that can be used as a key for a keyedLockable
  2851.  *  or lockableDoorway object.  It otherwise behaves as an ordinary item.
  2852.  */
  2853. class keyItem: item
  2854.     verIoUnlockWith( actor ) = {}
  2855.     ioUnlockWith( actor, dobj ) =
  2856.     {
  2857.         dobj.doUnlockWith( actor, self );
  2858.     }
  2859.     verIoLockWith( actor ) = {}
  2860.     ioLockWith( actor, dobj ) =
  2861.     {
  2862.         dobj.doLockWith( actor, self );
  2863.     }
  2864. ;
  2865.  
  2866. /*
  2867.  *  transparentItem: item
  2868.  *
  2869.  *  An object whose contents are visible, even when the object is
  2870.  *  closed.  Whether the contents are reachable is decided in the
  2871.  *  normal fashion.  This class is useful for items such as glass
  2872.  *  bottles, whose contents can be seen when the bottle is closed
  2873.  *  but cannot be reached.
  2874.  */
  2875. class transparentItem: item
  2876.     contentsVisible = { return( true ); }
  2877.     ldesc =
  2878.     {
  2879.         if (self.contentsVisible and itemcnt(self.contents) <> 0)
  2880.         {
  2881.             "In "; self.thedesc; " %you% see%s% "; listcont(self); ". ";
  2882.         }
  2883.         else
  2884.         {
  2885.             "There's nothing in "; self.thedesc; ". ";
  2886.         }
  2887.     }
  2888.     verGrab( obj ) =
  2889.     {
  2890.         if ( self.isopenable and not self.isopen )
  2891.             "%You% will have to open << self.thedesc >> first. ";
  2892.     }
  2893.     doOpen( actor ) =
  2894.     {
  2895.         self.isopen := true;
  2896.         "Opened. ";
  2897.     }
  2898.     verDoLookin(actor) = {}
  2899.     doLookin(actor) = { self.ldesc; }
  2900. ;
  2901.  
  2902. /*
  2903.  *  basicNumObj: object
  2904.  *
  2905.  *  This object provides a default implementation for numObj.
  2906.  *  To use this default unchanged in your game, include in your
  2907.  *  game this line:  "numObj: basicNumObj".
  2908.  */
  2909. class basicNumObj: object   // when a number is used in a player command,
  2910.     value = 0               //  this is set to its value
  2911.     sdesc = "<<value>>"
  2912.     adesc = "a number"
  2913.     thedesc = "the number <<value>>"
  2914.     verDoTypeOn( actor, io ) = {}
  2915.     doTypeOn( actor, io ) = { "\"Tap, tap, tap, tap...\" "; }
  2916.     verIoTurnTo( actor ) = {}
  2917.     ioTurnTo( actor, dobj ) = { dobj.doTurnTo( actor, self ); }
  2918. ;
  2919.  
  2920. /*
  2921.  *  basicStrObj: object
  2922.  *
  2923.  *  This object provides a default implementation for strObj.
  2924.  *  To use this default unchanged in your game, include in your
  2925.  *  game this line:  "strObj: basicStrObj".
  2926.  */
  2927. class basicStrObj: object   // when a string is used in a player command,
  2928.     value = ''              //  this is set to its value
  2929.     sdesc = "\"<<value>>\""
  2930.     adesc = "\"<<value>>\""
  2931.     thedesc = "\"<<value>>\""
  2932.     verDoTypeOn( actor, io ) = {}
  2933.     doTypeOn( actor, io ) = { "\"Tap, tap, tap, tap...\" "; }
  2934.     doSynonym('TypeOn') = 'EnterOn' 'EnterIn' 'EnterWith'
  2935.     verDoSave( actor ) = {}
  2936.     doSave( actor ) =
  2937.     {
  2938.         if (save( self.value ))
  2939.             "Save failed. ";
  2940.         else
  2941.             "Saved. ";
  2942.     abort;
  2943.     }
  2944.     verDoRestore( actor ) = {}
  2945.     doRestore( actor ) =
  2946.     {
  2947.         if (restore( self.value ))
  2948.             "Restore failed. ";
  2949.         else
  2950.     {
  2951.             "Restored.\b";
  2952.         scoreStatus( global.score, global.turnsofar );
  2953.         Me.location.lookAround(true);
  2954.     }
  2955.         abort;
  2956.     }
  2957.     verDoScript( actor ) = {}
  2958.     doScript( actor ) =
  2959.     {
  2960.         logging( self.value );
  2961.         "Writing script file. ";
  2962.         abort;
  2963.     }
  2964.     verDoSay( actor ) = {}
  2965.     doSay( actor ) =
  2966.     {
  2967.         "Okay, \""; say( self.value ); "\".";
  2968.     }
  2969. ;
  2970.  
  2971. /*
  2972.  *  deepverb: object
  2973.  *
  2974.  *  A "verb object" that is referenced by the parser when the player
  2975.  *  uses an associated vocabulary word.  A deepverb contains both
  2976.  *  the vocabulary of the verb and a description of available syntax.
  2977.  *  The verb property lists the verb vocabulary words;
  2978.  *  one word (such as 'take') or a pair (such as 'pick up')
  2979.  *  can be used.  In the latter case, the second word must be a
  2980.  *  preposition, and may move to the end of the sentence in a player's
  2981.  *  command, as in "pick it up."  The action(actor)
  2982.  *  method specifies what happens when the verb is used without any
  2983.  *  objects; its absence specifies that the verb cannot be used without
  2984.  *  an object.  The doAction specifies the root of the message
  2985.  *  names (in single quotes) sent to the direct object when the verb
  2986.  *  is used with a direct object; its absence means that a single object
  2987.  *  is not allowed.  Likewise, the ioAction(preposition)
  2988.  *  specifies the root of the message name sent to the direct and
  2989.  *  indirect objects when the verb is used with both a direct and
  2990.  *  indirect object; its absence means that this syntax is illegal.
  2991.  *  Several ioAction properties may be present:  one for each
  2992.  *  preposition that can be used with an indirect object with the verb.
  2993.  *  
  2994.  *  The validDo(actor, object, seqno) method returns true
  2995.  *  if the indicated object is valid as a direct object for this actor.
  2996.  *  The validIo(actor, object, seqno) method does likewise
  2997.  *  for indirect objects.  The seqno parameter is a "sequence
  2998.  *  number," starting with 1 for the first object tried for a given
  2999.  *  verb, 2 for the second, and so forth; this parameter is normally
  3000.  *  ignored, but can be used for some special purposes.  For example,
  3001.  *  askVerb does not distinguish between objects matching vocabulary
  3002.  *  words, and therefore accepts only the first from a set of ambiguous
  3003.  *  objects.  These methods do not normally need to be changed; by
  3004.  *  default, they return true if the object is accessible to the
  3005.  *  actor.
  3006.  *  
  3007.  *  The doDefault(actor, prep, indirectObject) and
  3008.  *  ioDefault(actor, prep) methods return a list of the
  3009.  *  default direct and indirect objects, respectively.  These lists
  3010.  *  are used for determining which objects are meant by "all" and which
  3011.  *  should be used when the player command is missing an object.  These
  3012.  *  normally return a list of all objects that are applicable to the
  3013.  *  current command.
  3014.  *  
  3015.  *  The validDoList(actor, prep, indirectObject) and
  3016.  *  validIoList(actor, prep, directObject) methods return
  3017.  *  a list of all of the objects for which validDo would be true.
  3018.  *  Remember to include floating objects, which are generally
  3019.  *  accessible.  Note that the objects returned by this list will
  3020.  *  still be submitted by the parser to validDo, so it's okay for
  3021.  *  this routine to return too many objects.  In fact, this
  3022.  *  routine is entirely unnecessary; if you omit it altogether, or
  3023.  *  make it return nil, the parser will simply submit every
  3024.  *  object matching the player's vocabulary words to validDo.
  3025.  *  The reason to provide this method is that it can significantly
  3026.  *  improve parsing speed when the game has lots of objects that
  3027.  *  all have the same vocabulary word, because it cuts down on the
  3028.  *  number of times that validDo has to be called (each call
  3029.  *  to validDo is fairly time-consuming).
  3030.  */
  3031. class deepverb: object                // A deep-structure verb.
  3032.     validDo( actor, obj, seqno ) =
  3033.     {
  3034.         return( obj.isReachable( actor ));
  3035.     }
  3036.     validDoList(actor, prep, iobj) =
  3037.     {
  3038.     local ret;
  3039.     local loc;
  3040.  
  3041.     loc := actor.location;
  3042.     while (loc.location) loc := loc.location;
  3043.     ret := visibleList(actor) + visibleList(loc)
  3044.            + global.floatingList;
  3045.     return(ret);
  3046.     }
  3047.     validIo( actor, obj, seqno ) =
  3048.     {
  3049.         return( obj.isReachable( actor ));
  3050.     }
  3051.     validIoList(actor, prep, dobj) = (self.validDoList(actor, prep, dobj))
  3052.     doDefault( actor, prep, io ) =
  3053.     {
  3054.         return( actor.contents + actor.location.contents );
  3055.     }
  3056.     ioDefault( actor, prep ) =
  3057.     {
  3058.         return( actor.contents + actor.location.contents );
  3059.     }
  3060. ;
  3061.  
  3062. /*
  3063.    Dark verb - a verb that can be used in the dark.  Travel verbs
  3064.    are all dark verbs, as are system verbs (quit, save, etc.).
  3065.    In addition, certain special verbs are usable in the dark:  for
  3066.    example, you can drop objects you are carrying, and you can turn
  3067.    on light sources you are carrying. 
  3068. */
  3069.  
  3070. class darkVerb: deepverb
  3071.    isDarkVerb = true
  3072. ;
  3073.  
  3074. /*
  3075.  *   Various verbs.
  3076.  */
  3077. inspectVerb: deepverb
  3078.     verb = 'inspect' 'examine' 'look at' 'l at' 'x'
  3079.     sdesc = "inspect"
  3080.     doAction = 'Inspect'
  3081.     validDo( actor, obj, seqno ) =
  3082.     {
  3083.         return( obj.isVisible( actor ));
  3084.     }
  3085. ;
  3086. askVerb: deepverb
  3087.     verb = 'ask'
  3088.     sdesc = "ask"
  3089.     prepDefault = aboutPrep
  3090.     ioAction( aboutPrep ) = 'AskAbout'
  3091.     validIo( actor, obj, seqno ) = { return( seqno = 1 ); }
  3092.     validIoList = nil
  3093. ;
  3094. tellVerb: deepverb
  3095.     verb = 'tell'
  3096.     sdesc = "tell"
  3097.     prepDefault = aboutPrep
  3098.     ioAction( aboutPrep ) = 'TellAbout'
  3099.     validIo( actor, obj, seqno ) = { return( seqno = 1 ); }
  3100.     validIoList(actor, prep, dobj) = (nil)
  3101.     ioDefault( actor, prep ) =
  3102.     {
  3103.         if (prep = aboutPrep)
  3104.         return([]);
  3105.     else
  3106.         return(actor.contents + actor.location.contents);
  3107.     }
  3108. ;
  3109. followVerb: deepverb
  3110.     sdesc = "follow"
  3111.     verb = 'follow'
  3112.     doAction = 'Follow'
  3113. ;
  3114. digVerb: deepverb
  3115.     verb = 'dig' 'dig in'
  3116.     sdesc = "dig in"
  3117.     prepDefault = withPrep
  3118.     ioAction( withPrep ) = 'DigWith'
  3119. ;
  3120. jumpVerb: deepverb
  3121.     verb = 'jump' 'jump over' 'jump off'
  3122.     sdesc = "jump"
  3123.     doAction = 'Jump'
  3124.     action(actor) = { "Wheeee!"; }
  3125. ;
  3126. pushVerb: deepverb
  3127.     verb = 'push' 'press'
  3128.     sdesc = "push"
  3129.     doAction = 'Push'
  3130. ;
  3131. attachVerb: deepverb
  3132.     verb = 'attach' 'connect'
  3133.     sdesc = "attach"
  3134.     prepDefault = toPrep
  3135.     ioAction( toPrep ) = 'AttachTo'
  3136. ;
  3137. wearVerb: deepverb
  3138.     verb = 'wear' 'put on'
  3139.     sdesc = "wear"
  3140.     doAction = 'Wear'
  3141. ;
  3142. dropVerb: deepverb, darkVerb
  3143.     verb = 'drop' 'put down'
  3144.     sdesc = "drop"
  3145.     ioAction( onPrep ) = 'PutOn'
  3146.     doAction = 'Drop'
  3147.     doDefault( actor, prep, io ) =
  3148.     {
  3149.         return( actor.contents );
  3150.     }
  3151. ;
  3152. removeVerb: deepverb
  3153.     verb = 'take off'
  3154.     sdesc = "take off"
  3155.     doAction = 'Unwear'
  3156.     ioAction( fromPrep ) = 'RemoveFrom'
  3157. ;
  3158. openVerb: deepverb
  3159.     verb = 'open'
  3160.     sdesc = "open"
  3161.     doAction = 'Open'
  3162. ;
  3163. closeVerb: deepverb
  3164.     verb = 'close'
  3165.     sdesc = "close"
  3166.     doAction = 'Close'
  3167. ;
  3168. putVerb: deepverb
  3169.     verb = 'put' 'place'
  3170.     sdesc = "put"
  3171.     prepDefault = inPrep
  3172.     ioAction( inPrep ) = 'PutIn'
  3173.     ioAction( onPrep ) = 'PutOn'
  3174.     doDefault( actor, prep, io ) =
  3175.     {
  3176.         return( takeVerb.doDefault( actor, prep, io ) + actor.contents );
  3177.     }
  3178. ;
  3179. takeVerb: deepverb                   // This object defines how to take things
  3180.     verb = 'take' 'pick up' 'get' 'remove'
  3181.     sdesc = "take"
  3182.     ioAction( offPrep ) = 'TakeOff'
  3183.     ioAction( outPrep ) = 'TakeOut'
  3184.     ioAction( fromPrep ) = 'TakeOut'
  3185.     ioAction( inPrep ) = 'TakeOut'
  3186.     ioAction( onPrep ) = 'TakeOff'
  3187.     doAction = 'Take'
  3188.     doDefault( actor, prep, io ) =
  3189.     {
  3190.         local ret, rem, cur, rem2, cur2, tot, i, tot2, j;
  3191.     
  3192.     ret := [];
  3193.         
  3194.     /*
  3195.      *   For "take all out/off of <iobj>", return the (non-fixed)
  3196.      *   contents of the indirect object.  Same goes for "take all in
  3197.      *   <iobj>", "take all on <iobj>", and "take all from <iobj>".
  3198.      */
  3199.     if (( prep=outPrep or prep=offPrep or prep=inPrep or prep=onPrep
  3200.      or prep=fromPrep ) and io<>nil )
  3201.     {
  3202.         rem := io.contents;
  3203.         i := 1;
  3204.         tot := length( rem );
  3205.         while ( i <= tot )
  3206.         {
  3207.             cur := rem[i];
  3208.             if (not cur.isfixed and self.validDo(actor, cur, i))
  3209.             ret += cur;
  3210.         ++i;
  3211.         }
  3212.             return( ret );
  3213.     }
  3214.  
  3215.         /*
  3216.      *   In the general case, return everything that's not fixed
  3217.      *   in the actor's location, or everything inside fixed containers
  3218.      *   that isn't itself fixed.
  3219.      */
  3220.         rem := actor.location.contents;
  3221.     tot := length( rem );
  3222.     i := 1;
  3223.         while ( i <= tot )
  3224.         {
  3225.         cur := rem[i];
  3226.             if ( cur.isfixed )
  3227.             {
  3228.                 if ((( cur.isopenable and cur.isopen ) or
  3229.                   ( not cur.isopenable )) and ( not cur.isactor ))
  3230.                 {
  3231.                     rem2 := cur.contents;
  3232.             tot2 := length( rem2 );
  3233.             j := 1;
  3234.                     while ( j <= tot2 )
  3235.                     {
  3236.                 cur2 := rem2[j];
  3237.                         if ( not cur2.isfixed and not cur2.notakeall )
  3238.             {
  3239.                 ret := ret + cur2;
  3240.             }
  3241.                         j := j + 1;
  3242.                     }
  3243.                 }
  3244.             }
  3245.             else if ( not cur.notakeall )
  3246.         {
  3247.             ret := ret + cur;
  3248.         }
  3249.  
  3250.         i := i + 1;            
  3251.         }
  3252.         return( ret );
  3253.     }
  3254. ;
  3255. plugVerb: deepverb
  3256.     verb = 'plug'
  3257.     sdesc = "plug"
  3258.     prepDefault = inPrep
  3259.     ioAction( inPrep ) = 'PlugIn'
  3260. ;
  3261. lookInVerb: deepverb
  3262.     verb = 'look in' 'look on' 'l in' 'l on'
  3263.     sdesc = "look in"
  3264.     doAction = 'Lookin'
  3265. ;
  3266. screwVerb: deepverb
  3267.     verb = 'screw'
  3268.     sdesc = "screw"
  3269.     ioAction( withPrep ) = 'ScrewWith'
  3270.     doAction = 'Screw'
  3271. ;
  3272. unscrewVerb: deepverb
  3273.     verb = 'unscrew'
  3274.     sdesc = "unscrew"
  3275.     ioAction( withPrep ) = 'UnscrewWith'
  3276.     doAction = 'Unscrew'
  3277. ;
  3278. turnVerb: deepverb
  3279.     verb = 'turn' 'rotate' 'twist'
  3280.     sdesc = "turn"
  3281.     ioAction( toPrep ) = 'TurnTo'
  3282.     ioAction( withPrep ) = 'TurnWith'
  3283.     doAction = 'Turn'
  3284. ;
  3285. switchVerb: deepverb
  3286.     verb = 'switch'
  3287.     sdesc = "switch"
  3288.     doAction = 'Switch'
  3289. ;
  3290. flipVerb: deepverb
  3291.     verb = 'flip'
  3292.     sdesc = "flip"
  3293.     doAction = 'Flip'
  3294. ;
  3295. turnOnVerb: deepverb, darkVerb
  3296.     verb = 'activate' 'turn on' 'switch on'
  3297.     sdesc = "turn on"
  3298.     doAction = 'Turnon'
  3299. ;
  3300. turnOffVerb: deepverb
  3301.     verb = 'turn off' 'deactiv' 'switch off'
  3302.     sdesc = "turn off"
  3303.     doAction = 'Turnoff'
  3304. ;
  3305. lookVerb: deepverb
  3306.     verb = 'look' 'l' 'look around' 'l around'
  3307.     action( actor ) =
  3308.     {
  3309.         actor.location.lookAround( true );
  3310.     }
  3311. ;
  3312. sitVerb: deepverb
  3313.     verb = 'sit on' 'sit in' 'sit' 'sit down' 'sit downin' 'sit downon'
  3314.     sdesc = "sit on"
  3315.     doAction = 'Siton'
  3316. ;
  3317. lieVerb: deepverb
  3318.     verb = 'lie' 'lie on' 'lie in' 'lie down' 'lie downon' 'lie downin'
  3319.     sdesc = "lie on"
  3320.     doAction = 'Lieon'
  3321. ;
  3322. getOutVerb: deepverb
  3323.     verb = 'get out' 'get outof' 'get off' 'get offof'
  3324.     sdesc = "get out of"
  3325.     doAction = 'Unboard'
  3326.     action(actor) = { askdo; }
  3327.     doDefault( actor, prep, io ) =
  3328.     {
  3329.         if ( actor.location and actor.location.location )
  3330.             return( [] + actor.location );
  3331.         else return( [] );
  3332.     }
  3333. ;
  3334. boardVerb: deepverb
  3335.     verb = 'get in' 'get into' 'board' 'get on'
  3336.     sdesc = "get on"
  3337.     doAction = 'Board'
  3338. ;
  3339. againVerb: deepverb         // Required verb:  repeats last command.  No
  3340.                             // action routines are necessary; this one's
  3341.                             // handled internally by the parser.
  3342.     verb = 'again' 'g'
  3343. ;
  3344. waitVerb: deepverb
  3345.     verb = 'wait' 'z'
  3346.     action( actor ) =
  3347.     {
  3348.         "Time passes...\n";
  3349.     }
  3350. ;
  3351. iVerb: deepverb
  3352.     verb = 'inventory' 'i'
  3353.     action( actor ) =
  3354.     {
  3355.         if (length( actor.contents ))
  3356.         {
  3357.             "%You% %have% "; listcont( actor ); ". ";
  3358.             listcontcont( actor );
  3359.         }
  3360.     else
  3361.             "%You% %are% empty-handed.\n";
  3362.     }
  3363. ;
  3364. lookThruVerb: deepverb
  3365.     verb = 'look through' 'look thru' 'l through' 'l thru'
  3366.     sdesc = "look through"
  3367.     doAction = 'Lookthru'
  3368. ;
  3369. attackVerb: deepverb
  3370.     verb = 'attack' 'kill' 'hit'
  3371.     sdesc = "attack"
  3372.     prepDefault = withPrep
  3373.     ioAction( withPrep ) = 'AttackWith'
  3374. ;
  3375. climbVerb: deepverb
  3376.     verb = 'climb'
  3377.     sdesc = "climb"
  3378.     doAction = 'Climb'
  3379. ;
  3380. eatVerb: deepverb
  3381.     verb = 'eat' 'consume'
  3382.     sdesc = "eat"
  3383.     doAction = 'Eat'
  3384. ;
  3385. drinkVerb: deepverb
  3386.     verb = 'drink'
  3387.     sdesc = "drink"
  3388.     doAction = 'Drink'
  3389. ;
  3390. giveVerb: deepverb
  3391.     verb = 'give' 'offer'
  3392.     sdesc = "give"
  3393.     prepDefault = toPrep
  3394.     ioAction( toPrep ) = 'GiveTo'
  3395.     doDefault( actor, prep, io ) =
  3396.     {
  3397.         return( actor.contents );
  3398.     }
  3399. ;
  3400. pullVerb: deepverb
  3401.     verb = 'pull'
  3402.     sdesc = "pull"
  3403.     doAction = 'Pull'
  3404. ;
  3405. readVerb: deepverb
  3406.     verb = 'read'
  3407.     sdesc = "read"
  3408.     doAction = 'Read'
  3409. ;
  3410. throwVerb: deepverb
  3411.     verb = 'throw' 'toss'
  3412.     sdesc = "throw"
  3413.     prepDefault = atPrep
  3414.     ioAction( atPrep ) = 'ThrowAt'
  3415.     ioAction( toPrep ) = 'ThrowTo'
  3416. ;
  3417. standOnVerb: deepverb
  3418.     verb = 'stand on'
  3419.     sdesc = "stand on"
  3420.     doAction = 'Standon'
  3421. ;
  3422. standVerb: deepverb
  3423.     verb = 'stand' 'stand up' 'get up'
  3424.     sdesc = "stand"
  3425.     action( actor ) =
  3426.     {
  3427.         if ( actor.location=nil or actor.location.location = nil )
  3428.             "%You're% already standing! ";
  3429.         else
  3430.         {
  3431.         actor.location.doUnboard( actor );
  3432.         }
  3433.     }
  3434. ;
  3435. helloVerb: deepverb
  3436.     verb = 'hello' 'hi' 'greetings'
  3437.     action( actor ) =
  3438.     {
  3439.         "Nice weather we've been having.\n";
  3440.     }
  3441. ;
  3442. showVerb: deepverb
  3443.     verb = 'show'
  3444.     sdesc = "show"
  3445.     prepDefault = toPrep
  3446.     ioAction( toPrep ) = 'ShowTo'
  3447.     doDefault( actor, prep, io ) =
  3448.     {
  3449.         return( actor.contents );
  3450.     }
  3451. ;
  3452. cleanVerb: deepverb
  3453.     verb = 'clean'
  3454.     sdesc = "clean"
  3455.     ioAction( withPrep ) = 'CleanWith'
  3456.     doAction = 'Clean'
  3457. ;
  3458. sayVerb: deepverb
  3459.     verb = 'say'
  3460.     sdesc = "say"
  3461.     doAction = 'Say'
  3462. ;
  3463. yellVerb: deepverb
  3464.     verb = 'yell' 'shout' 'yell at' 'shout at'
  3465.     action( actor ) =
  3466.     {
  3467.         "%Your% throat is a bit sore now. ";
  3468.     }
  3469. ;
  3470. moveVerb: deepverb
  3471.     verb = 'move'
  3472.     sdesc = "move"
  3473.     ioAction( withPrep ) = 'MoveWith'
  3474.     ioAction( toPrep ) = 'MoveTo'
  3475.     doAction = 'Move'
  3476. ;
  3477. fastenVerb: deepverb
  3478.     verb = 'fasten' 'buckle' 'buckle up'
  3479.     sdesc = "fasten"
  3480.     doAction = 'Fasten'
  3481. ;
  3482. unfastenVerb: deepverb
  3483.     verb = 'unfasten' 'unbuckle'
  3484.     sdesc = "unfasten"
  3485.     doAction = 'Unfasten'
  3486. ;
  3487. unplugVerb: deepverb
  3488.     verb = 'unplug'
  3489.     sdesc = "unplug"
  3490.     ioAction( fromPrep ) = 'UnplugFrom'
  3491.     doAction = 'Unplug'
  3492. ;
  3493. lookUnderVerb: deepverb
  3494.     verb = 'look under' 'look beneath' 'l under' 'l beneath'
  3495.     sdesc = "look under"
  3496.     doAction = 'Lookunder'
  3497. ;
  3498. lookBehindVerb: deepverb
  3499.     verb = 'look behind' 'l behind'
  3500.     sdesc = "look behind"
  3501.     doAction = 'Lookbehind'
  3502. ;
  3503. typeVerb: deepverb
  3504.     verb = 'type'
  3505.     sdesc = "type"
  3506.     prepDefault = onPrep
  3507.     ioAction( onPrep ) = 'TypeOn'
  3508. ;
  3509. lockVerb: deepverb
  3510.     verb = 'lock'
  3511.     sdesc = "lock"
  3512.     ioAction( withPrep ) = 'LockWith'
  3513.     doAction = 'Lock'
  3514.     prepDefault = withPrep
  3515. ;
  3516. unlockVerb: deepverb
  3517.     verb = 'unlock'
  3518.     sdesc = "unlock"
  3519.     ioAction( withPrep ) = 'UnlockWith'
  3520.     doAction = 'Unlock'
  3521.     prepDefault = withPrep
  3522. ;
  3523. detachVerb: deepverb
  3524.     verb = 'detach' 'disconnect'
  3525.     prepDefault = fromPrep
  3526.     ioAction( fromPrep ) = 'DetachFrom'
  3527.     doAction = 'Detach'
  3528.     sdesc = "detach"
  3529. ;
  3530. sleepVerb: deepverb
  3531.     action( actor ) =
  3532.     {
  3533.         if ( actor.cantSleep )
  3534.             "%You% %are% much too anxious worrying about %your% continued
  3535.             survival to fall asleep now. ";
  3536.         else if ( global.awakeTime+1 < global.sleepTime )
  3537.             "%You're% not tired. ";
  3538.         else if ( not ( actor.location.isbed or actor.location.ischair ))
  3539.             "I don't know about you, but I can never sleep
  3540.             standing up. %You% should find a nice comfortable
  3541.             bed somewhere. ";
  3542.         else
  3543.         {
  3544.             "%You% quickly drift%s% off into dreamland...\b";
  3545.             goToSleep();
  3546.         }
  3547.     }
  3548.     verb = 'sleep'
  3549. ;
  3550. pokeVerb: deepverb
  3551.     verb = 'poke' 'jab'
  3552.     sdesc = "poke"
  3553.     doAction = 'Poke'
  3554. ;
  3555. touchVerb: deepverb
  3556.     verb = 'touch'
  3557.     sdesc = "touch"
  3558.     doAction = 'Touch'
  3559. ;
  3560. moveNVerb: deepverb
  3561.     verb = 'move north' 'move n' 'push north' 'push n'
  3562.     sdesc = "move north"
  3563.     doAction = 'MoveN'
  3564. ;
  3565. moveSVerb: deepverb
  3566.     verb = 'move south' 'move s' 'push south' 'push s'
  3567.     sdesc = "move south"
  3568.     doAction = 'MoveS'
  3569. ;
  3570. moveEVerb: deepverb
  3571.     verb = 'move east' 'move e' 'push east' 'push e'
  3572.     sdesc = "move east"
  3573.     doAction = 'MoveE'
  3574. ;
  3575. moveWVerb: deepverb
  3576.     verb = 'move west' 'move w' 'push west' 'push w'
  3577.     sdesc = "move west"
  3578.     doAction = 'MoveW'
  3579. ;
  3580. moveNEVerb: deepverb
  3581.     verb = 'move northeast' 'move ne' 'push northeast' 'push ne'
  3582.     sdesc = "move northeast"
  3583.     doAction = 'MoveNE'
  3584. ;
  3585. moveNWVerb: deepverb
  3586.     verb = 'move northwest' 'move nw' 'push northwest' 'push nw'
  3587.     sdesc = "move northwest"
  3588.     doAction = 'MoveNW'
  3589. ;
  3590. moveSEVerb: deepverb
  3591.     verb = 'move southeast' 'move se' 'push southeast' 'push se'
  3592.     sdesc = "move southeast"
  3593.     doAction = 'MoveSE'
  3594. ;
  3595. moveSWVerb: deepverb
  3596.     verb = 'move southwest' 'move sw' 'push southwest' 'push sw'
  3597.     sdesc = "move southwest"
  3598.     doAction = 'MoveSW'
  3599. ;
  3600. centerVerb: deepverb
  3601.     verb = 'center'
  3602.     sdesc = "center"
  3603.     doAction = 'Center'
  3604. ;
  3605. searchVerb: deepverb
  3606.     verb = 'search'
  3607.     sdesc = "search"
  3608.     doAction = 'Search'
  3609. ;
  3610.  
  3611. /*
  3612.  *   Travel verbs  - these verbs allow the player to move about.
  3613.  *   All travel verbs have the property isTravelVerb set true.
  3614.  */
  3615. class travelVerb: deepverb, darkVerb
  3616.     isTravelVerb = true
  3617. ;
  3618.  
  3619. eVerb: travelVerb
  3620.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3621.     verb = 'e' 'east' 'go east'
  3622.     travelDir( actor ) = { return( actor.location.east ); }
  3623. ;
  3624. sVerb: travelVerb
  3625.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3626.     verb = 's' 'south' 'go south'
  3627.     travelDir( actor ) = { return( actor.location.south ); }
  3628. ;
  3629. nVerb: travelVerb
  3630.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3631.     verb = 'n' 'north' 'go north'
  3632.     travelDir( actor ) = { return( actor.location.north ); }
  3633. ;
  3634. wVerb: travelVerb
  3635.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3636.     verb = 'w' 'west' 'go west'
  3637.     travelDir( actor ) = { return( actor.location.west ); }
  3638. ;
  3639. neVerb: travelVerb
  3640.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3641.     verb = 'ne' 'northeast' 'go ne' 'go northeast'
  3642.     travelDir( actor ) = { return( actor.location.ne ); }
  3643. ;
  3644. nwVerb: travelVerb
  3645.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3646.     verb = 'nw' 'northwest' 'go nw' 'go northwest'
  3647.     travelDir( actor ) = { return( actor.location.nw ); }
  3648. ;
  3649. seVerb: travelVerb
  3650.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3651.     verb = 'se' 'southeast' 'go se' 'go southeast'
  3652.     travelDir( actor ) = { return( actor.location.se ); }
  3653. ;
  3654. swVerb: travelVerb
  3655.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3656.     verb = 'sw' 'southwest' 'go sw' 'go southwest'
  3657.     travelDir( actor ) = { return( actor.location.sw ); }
  3658. ;
  3659. inVerb: travelVerb
  3660.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3661.     verb = 'in' 'go in' 'enter'
  3662.     sdesc = "enter"
  3663.     doAction = 'Enter'
  3664.     travelDir( actor ) = { return( actor.location.in ); }
  3665.     ioAction(onPrep) = 'EnterOn'
  3666.     ioAction(inPrep) = 'EnterIn'
  3667.     ioAction(withPrep) = 'EnterWith'
  3668. ;
  3669. outVerb: travelVerb
  3670.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3671.     verb = 'out' 'go out' 'exit' 'leave'
  3672.     travelDir( actor ) = { return( actor.location.out ); }
  3673. ;
  3674. dVerb: travelVerb
  3675.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3676.     verb = 'd' 'down' 'go down'
  3677.     travelDir( actor ) = { return( actor.location.down ); }
  3678. ;
  3679. uVerb: travelVerb
  3680.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3681.     verb = 'u' 'up' 'go up'
  3682.     travelDir( actor ) = { return( actor.location.up ); }
  3683. ;
  3684.  
  3685. /*
  3686.  *   sysverb:  A system verb.  Verbs of this class are special verbs that
  3687.  *   can be executed without certain normal validations.  For example,
  3688.  *   a system verb can be executed in a dark room.  System verbs are
  3689.  *   for operations such as saving, restoring, and quitting, which are
  3690.  *   not really part of the game.
  3691.  */
  3692. class sysverb: deepverb, darkVerb
  3693.     issysverb = true
  3694. ;
  3695.  
  3696. quitVerb: sysverb
  3697.     verb = 'quit'
  3698.     action( actor ) =
  3699.     {
  3700.         local yesno;
  3701.  
  3702.         scoreRank();
  3703.         "\bDo you really want to quit? (YES or NO) > ";
  3704.         yesno := yorn();
  3705.         "\b";
  3706.         if ( yesno = 1 )
  3707.         {
  3708.             terminate();    // allow user good-bye message
  3709.         quit();
  3710.         }
  3711.         else
  3712.         {
  3713.             "Okay. ";
  3714.         }
  3715.     abort;
  3716.     }
  3717. ;
  3718. verboseVerb: sysverb
  3719.     verb = 'verbose'
  3720.     action( actor ) =
  3721.     {
  3722.         "Okay, now in VERBOSE mode.\n";
  3723.         global.verbose := true;
  3724.     Me.location.lookAround( true );
  3725.     abort;
  3726.     }
  3727. ;
  3728. terseVerb: sysverb
  3729.     verb = 'brief' 'terse'
  3730.     action( actor ) =
  3731.     {
  3732.         "Okay, now in TERSE mode.\n";
  3733.         global.verbose := nil;
  3734.     abort;
  3735.     }
  3736. ;
  3737. scoreVerb: sysverb
  3738.     verb = 'score' 'status'
  3739.     action( actor ) =
  3740.     {
  3741.         scoreRank();
  3742.     abort;
  3743.     }
  3744. ;
  3745. saveVerb: sysverb
  3746.     verb = 'save'
  3747.     sdesc = "save"
  3748.     doAction = 'Save'
  3749.     action( actor ) =
  3750.     {
  3751.         local savefile;
  3752.     
  3753.     savefile := askfile( 'File to save game in' );
  3754.     if ( savefile = nil or savefile = '' )
  3755.         "Failed. ";
  3756.     else if (save( savefile ))
  3757.         "Saved failed. ";
  3758.     else
  3759.         "Saved. ";
  3760.     abort;
  3761.     }
  3762. ;
  3763. restoreVerb: sysverb
  3764.     verb = 'restore'
  3765.     sdesc = "restore"
  3766.     doAction = 'Restore'
  3767.     action( actor ) =
  3768.     {
  3769.         local savefile;
  3770.     
  3771.     savefile := askfile( 'File to restore game from' );
  3772.     if ( savefile = nil or savefile = '' )
  3773.         "Failed. ";
  3774.     else if (restore( savefile ))
  3775.         "Restore failed. ";
  3776.     else
  3777.     {
  3778.         scoreStatus(global.score, global.turnsofar);
  3779.         "Restored.\b";
  3780.         Me.location.lookAround(true);
  3781.     }
  3782.     abort;
  3783.     }
  3784. ;
  3785. scriptVerb: sysverb
  3786.     verb = 'script'
  3787.     doAction = 'Script'
  3788.     action( actor ) =
  3789.     {
  3790.         local scriptfile;
  3791.     
  3792.     scriptfile := askfile( 'File to write transcript to' );
  3793.     if ( scriptfile = nil or scriptfile = '' )
  3794.         "Failed. ";
  3795.     else
  3796.     {
  3797.         logging( scriptfile );
  3798.         "All text will now be saved to the script file.
  3799.             Type UNSCRIPT at any time to discontinue scripting.";
  3800.     }
  3801.     abort;
  3802.     }
  3803. ;
  3804. unscriptVerb: sysverb
  3805.     verb = 'unscript'
  3806.     action( actor ) =
  3807.     {
  3808.         logging( nil );
  3809.         "Script closed.\n";
  3810.         abort;
  3811.     }
  3812. ;
  3813. restartVerb: sysverb
  3814.     verb = 'restart'
  3815.     action( actor ) =
  3816.     {
  3817.         local yesno;
  3818.         while ( true )
  3819.         {
  3820.             "Are you sure you want to start over? (YES or NO) > ";
  3821.             yesno := yorn();
  3822.             if ( yesno = 1 )
  3823.             {
  3824.                 "\n";
  3825.         scoreStatus(0, 0);
  3826.                 restart(initRestart, global.initRestartParam);
  3827.                 abort;
  3828.             }
  3829.             else if ( yesno = 0 )
  3830.             {
  3831.                 "\nOkay.\n";
  3832.                 abort;
  3833.             }
  3834.         }
  3835.     }
  3836. ;
  3837. versionVerb: sysverb
  3838.     verb = 'version'
  3839.     action( actor ) =
  3840.     {
  3841.         version.sdesc;
  3842.         abort;
  3843.     }
  3844. ;
  3845. debugVerb: sysverb
  3846.     verb = 'debug'
  3847.     action( actor ) =
  3848.     {
  3849.     if (debugTrace())
  3850.         "You can't think this game has any bugs left in it... ";
  3851.     abort;
  3852.     }
  3853. ;
  3854.  
  3855. undoVerb: sysverb
  3856.     verb = 'undo'
  3857.     action(actor) =
  3858.     {
  3859.     /* do TWO undo's - one for this 'undo', one for previous command */
  3860.     if (undo() and undo())
  3861.     {
  3862.         "(Undoing one command)\b";
  3863.         Me.location.lookAround(true);
  3864.         scoreStatus(global.score, global.turnsofar);
  3865.     }
  3866.     else
  3867.         "No more undo information is available. ";
  3868.  
  3869.     abort;
  3870.     }
  3871. ;
  3872.  
  3873. /*
  3874.  *  Prep: object
  3875.  *
  3876.  *  A preposition.  The preposition property specifies the
  3877.  *  vocabulary word.
  3878.  */
  3879. class Prep: object
  3880. ;
  3881.  
  3882. /*
  3883.  *   Various prepositions
  3884.  */
  3885. aboutPrep: Prep
  3886.     preposition = 'about'
  3887.     sdesc = "about"
  3888. ;
  3889. withPrep: Prep
  3890.     preposition = 'with'
  3891.     sdesc = "with"
  3892. ;
  3893. toPrep: Prep
  3894.     preposition = 'to'
  3895.     sdesc = "to"
  3896. ;
  3897. onPrep: Prep
  3898.     preposition = 'on' 'onto' 'downon' 'upon'
  3899.     sdesc = "on"
  3900. ;
  3901. inPrep: Prep
  3902.     preposition = 'in' 'into' 'downin'
  3903.     sdesc = "in"
  3904. ;
  3905. offPrep: Prep
  3906.     preposition = 'off' 'offof'
  3907.     sdesc = "off"
  3908. ;
  3909. outPrep: Prep
  3910.     preposition = 'out' 'outof'
  3911.     sdesc = "out"
  3912. ;
  3913. fromPrep: Prep
  3914.     preposition = 'from'
  3915.     sdesc = "from"
  3916. ;
  3917. betweenPrep: Prep
  3918.     preposition = 'between' 'inbetween'
  3919.     sdesc = "between"
  3920. ;
  3921. overPrep: Prep
  3922.     preposition = 'over'
  3923.     sdesc = "over"
  3924. ;
  3925. atPrep: Prep
  3926.     preposition = 'at'
  3927.     sdesc = "at"
  3928. ;
  3929. aroundPrep: Prep
  3930.     preposition = 'around'
  3931.     sdesc = "around"
  3932. ;
  3933. thruPrep: Prep
  3934.     preposition = 'through' 'thru'
  3935.     sdesc = "through"
  3936. ;
  3937. dirPrep: Prep
  3938.     preposition = 'north' 'south' 'east' 'west' 'up' 'down' 'northeast' 'ne'
  3939.                   'northwest' 'nw' 'southeast' 'se' 'southwest' 'sw'
  3940.     sdesc = "north"         // Shouldn't ever need this, but just in case
  3941. ;
  3942. underPrep: Prep
  3943.     preposition = 'under' 'beneath'
  3944.     sdesc = "under"
  3945. ;
  3946. behindPrep: Prep
  3947.     preposition = 'behind'
  3948.     sdesc = "behind"
  3949. ;
  3950.  
  3951. /*
  3952.  *   articles:  the "built-in" articles.  "The," "a," and "an" are
  3953.  *   defined.
  3954.  */
  3955. articles: object
  3956.     article = 'the' 'a' 'an'
  3957. ;
  3958.