Newsgroups: rec.arts.int-fiction
Path: nntp.gmd.de!Dortmund.Germany.EU.net!Germany.EU.net!howland.reston.ans.net!vixen.cso.uiuc.edu!usenet.ucs.indiana.edu!news.cs.indiana.edu!shulick@guava.ucs.indiana.edu
From: "Sam Hulick" <shulick@guava.ucs.indiana.edu>
Subject: Inform: Some neat code for you all
Message-ID: <1995Sep2.134514.15756@news.cs.indiana.edu>
Organization: Vallen Software
Date: Sat, 2 Sep 1995 13:45:05 -0500
Lines: 93


Here is my "meet" code, which is used for wandering NPCs in the game.
Before you meet an NPC (i.e. "yellow frog"), its article is "a".  After
you have met him, its article changes to "the" (it makes sense).  So you
see things like:

You can see a yellow frog here.

>z
Time passes.
The yellow frog hops around in circles.   (rather than "A yellow frog..")

Also in future 'look' descriptions, it will say "You can see the yellow
frog here."  Anyway, here is the code to do this:

[ LookRoutine o;
   objectloop (o near player)
   {
      if (o ~= player && o has animate && o hasnt visited) give o visited;
   }
];
!! Note! If an NPC is inside something like a basket or on top of a
!! platform, this routine won't work.  In my game, none of the wandering
!! NPCs start out in a supporter or container, but you may want to
!! modify this routine.  Simply do a check like if (children(o) ~= 0)
!! then pass 'o' into a recursive function to check its children.  Not
!! too challenging.

!! That's that routine.  Now you need to make your creatures conform
!! to the routine.  Here is an example:

Object yfrog "yellow frog"
 with  name "yellow" "frog",
       description "Ribbit.",
       article [;
          if (self hasnt visited)
          {
             if (cap_mode == 1) print "A"; else print "a";
             ! You will need to make 'Global cap_mode = 0;'
             ! This is a weak way out for now.. you may fix this if you wish
          }
          else { if (cap_mode == 1) print "The"; else print "the"; }
       ],
     .... etc. ....

Simple as that.  You could lessen your typing....

[ art_a;
    if (self hasnt visited)
    {
       if (cap_mode == 1) print "A"; else print "a";
   ... the rest is the same as above ....
];

[ art_an;
   if (self hasnt visited)
   {
      if (cap_mode == 1) print "An"; else print "an";
  ....
];

[ art_some; 
  .. you get the idea...
];


  Oops, almost forgot.. here are some indef. article
routines I use as well:

[ An o;
   PrintOrRun(o, article, 1); print " "; PrintShortName(o);
];

[ CAn o;
   cap_mode = 1;
   PrintOrRun(o, article, 1); print " "; PrintShortName(o);
   cap_mode = 0;
];

They are used, of course, like this:

   print (CAn) obj, " comes running along, and stumbles over a rock.^";

So if you have met this person before, it will print "The fool comes
running...", otherwise "A fool comes running...".

Any comments or questions are welcome.

-- 
--- Sam Hulick ------------- shulick@indiana.edu ---------------------
Systems Consultant        | Homepage:
Indiana College Placement |    http://copper.ucs.indiana.edu/~shulick/
  and Assessment Center   | PGP public key available on request
