Subject: LPMUD SOURCE: Mud Pies!
Message-ID: <24921@shlump.lkg.dec.com>
Date: 24 Jul 91 20:09:47 GMT
Sender: newsdaemon@shlump.lkg.dec.com
Reply-To: fjs@bonz.enet.dec.com (F. Jay Shields)
Organization: Digital Equipment Corporation
Lines: 559


Here's my second installment of source code for interesting lpmud objects.

INTRODUCING: MUD PIES!  (Just what you need in lpMUD!)

This is actually 3 objects: a mud pie, mud, and soap.

The mud pie is designed for some innocent fun. Features:

   - You can throw it at someone. They may or may not get hit with it.
   - Hitting someone with a mud pie does no damage. It WILL cover them in
     mud, though.
   - You can throw the SAME mud pie 5 times (it's magic!)
   - Be forwarned: Hitting someone with a mud pie arms THEM with one, too!
   - And of course, MUD PIES ARE EDIBLE! (We could probably start a whole
     flame war worrying about what a mud pie is, so I won't go into that.)

Mud is yucky, disgusting stuff. The more times you get hit with a mud pie,
the more mud you get on you. Soap is best for getting rid of it, but you
don't HAVE to have it. But watch it, it's continually changing!

Soap comes in several brands, all of which work the same (don't hit me, I'm
only the coder!). WASH yourself to get rid of the mud. Interesting things
happen if you wash too much, though! Eventually, you'll wash your soap into
oblivion.

Use mud pies at your favorite party! Want to get even without actually
hurting someone? Mud pies are the answer. And when the fight's over,
you can chow down on a lovely mud pie!

Bon Appitite!

--
F. Jay Shields
Digital Equipment Corporation
40 Old Bolton Rd OGO1-1/J17
Stow, MA 01775-1215
fjs@bonz.enet.dec.com
(508) 496-8081

PS. You need to change the MYLIB constant in mudpie.c to point to the
directory containing mudpie.c and mud.c

-----------cut here---------------cut here--------------cut here----------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  mud.c mudpie.c soap.c
# Wrapped by fjs@bonz.ogo.dec.com on Wed Jul 24 10:35:51 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'mud.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mud.c'\"
else
echo shar: Extracting \"'mud.c'\" \(4271 characters\)
sed "s/^X//" >'mud.c' <<'END_OF_FILE'
X/* Mud.c                                                                    */
X/* Author: F. Jay Shields                                                   */
X/*                                                                          */
X/* This is the mud object. It can't be dropped, but you can (with a lot     */
X/* of work), wipe it off. Soap is the most effective way to get rid of it   */
X/* though.                                                                  */
X/*                                                                          */
X/*                                                                          */
X/*Copyright (c) 1991 by F. Jay Shields                                      */
X/*                                                                          */
X/*This code is hereby entered into the public domain, subject to the        */
X/*following restrictions:                                                   */
X/*                                                                          */
X/*   1. The author is not responsible for any problems or calamities the    */
X/*      use of this code may entail, whether such problems are the result   */
X/*      of defects in the code or not. Use at your own risk.                */
X/*                                                                          */
X/*   2. This code may be altered in any way you see fit, but must be        */
X/*      clearly marked as such, and may not be represented as the original  */
X/*      code.                                                               */
X/*                                                                          */
X
Xint num_wipes;    /* The number of times this mud has been wiped.           */
Xint max_wipes;    /* How many times must they wipe to remove the mud.       */
X
Xinit()
X{
X   add_action("wipe","wipe");
X}
X
Xreset(arg)
X{
X   if (arg)  return;
X   set_max_wipes(3);
X   num_wipes = 0;
X}
X
Xid(str)
X{
X   return str == "mud";
X}
X
Xshort()
X{
X   int i;
X   string str;
X
X
X   /* Make up a bunch of descriptions & choose one at random.               */
X   i = random(8);
X   str = "Mud";
X   if(i == 1) str = "A large blob of mud";
X   if(i == 2) str = "Some sticky, gooey mud";
X   if(i == 3) str = "A daub of mud";
X   if(i == 4) str = "A clot of mud";
X   if(i == 5) str = "A mud smear";
X   if(i == 6) str = "Smelly mud";
X   if(i == 7) str = "Very wet mud";
X   return str;
X}
X
Xlong()
X{
X   write("A blob of gooey, yucky, oozing, smelly mud!\n"+
X	 "You can try to wipe it off, but soap would probably work better.\n");
X}
X
Xget()
X{
X   return 1;
X}
X
Xdrop()
X{
X   /* Don't let them drop it. */
X   return 1;
X}
X
Xquery_weight() { return 1; }
X
Xquery_value() { return 0; }
X
Xwipe(str)
X{
X   string what;
X
X   if (!str) return 0;
X
X   /* If they just say "wipe mud", give them more of a hint.                */
X   if (id(str))
X   {
X      write("You don't just want to smear it around, do you? "+
X	    "Try to wipe it off.\n");
X      return 1;
X   }
X
X   /* Use "wipe mud off" or "wipe off mud" to remove it.                    */
X   if (sscanf(str,"off %s",what) == 1 ||
X       sscanf(str,"off %s.",what) == 1 ||
X       sscanf(str,"%s off",what) == 1 ||
X       sscanf(str,"%s off.",what) == 1 )
X   {
X      if(!id(what))
X      {
X         /* They tried to wipe something else off.                          */
X	 write("What do you want to wipe off?");
X         return 1;
X      }
X
X      /* If they've reached the threshold, get rid of the mud               */
X      if(++num_wipes == max_wipes) 
X      {
X	 call_out("erase_mud",2);
X      }
X
X      /* Tell them what's happening.                                        */
X      write("You smear the mud around. "+
X	    "You might have even have gotten rid of some!\n");
X      say(capitalize(this_player()->query_name()) + " attempts to wipe some "+
X	  "mud off.\n");
X
X      return 1;
X   }
X   return 0;
X}
X
Xclean_self()
X{
X   /* Call this function from the soap.                                     */
X   say("Mud falls from "+this_player()->query_name()+" in great globs!\n",
X	this_player());
X   destruct(this_object());
X   return 1;
X}
X
Xset_max_wipes(arg)
X{
X   /* Set the number of times the player has to wipe the mud off.           */
X   max_wipes = arg;
X   return 1;
X}
X
Xerase_mud()
X{
X   destruct(this_object());
X}
END_OF_FILE
if test 4271 -ne `wc -c <'mud.c'`; then
    echo shar: \"'mud.c'\" unpacked with wrong size!
fi
# end of 'mud.c'
fi
if test -f 'mudpie.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mudpie.c'\"
else
echo shar: Extracting \"'mudpie.c'\" \(5182 characters\)
sed "s/^X//" >'mudpie.c' <<'END_OF_FILE'
X/* Mudpie.c                                                                 */
X/* Author: F. Jay Shields                                                   */
X/*                                                                          */
X/* Mud pies are neat stuff. Throw them at people, but watch out for their   */
X/* return! Eat them when you're done!                                       */
X/*                                                                          */
X/* Change MYLIB to point to whereever you have the code for mud and mudpies.*/
X/*                                                                          */
X/*                                                                          */
X/*Copyright (c) 1991 by F. Jay Shields                                      */
X/*                                                                          */
X/*This code is hereby entered into the public domain, subject to the        */
X/*following restrictions:                                                   */
X/*                                                                          */
X/*   1. The author is not responsible for any problems or calamities the    */
X/*      use of this code may entail, whether such problems are the result   */
X/*      of defects in the code or not. Use at your own risk.                */
X/*                                                                          */
X/*   2. This code may be altered in any way you see fit, but must be        */
X/*      clearly marked as such, and may not be represented as the original  */
X/*      code.                                                               */
X/*                                                                          */
X#define MYLIB       "players/durc"
X
Xinherit "obj/food";
X
Xint gen;            /* The current generation number of the mudpie          */
Xint max_gen;        /* The generation at which the pie is destructed.       */
Xint threshold;      /* The percent probability that the pie will hit.       */
X
Xreset(arg)
X{
X   if (arg) return;
X
X   /* Set the values for number of times you can throw the pie.             */
X   gen = 1;
X   set_max(5);
X   set_threshold(80);
X
X   /* General stuff for food.                                               */
X   set_name("pie");
X   set_alias("mud pie");
X   set_alt_name("ice cream pie");
X   set_short("A mud pie");
X   set_long("It's a gorgeous mud pie with whipped cream,"+
X	    " perfect for throwing.\n");
X   set_weight(1);
X   set_value(10);
X   set_strength(5);
X   set_eater_mess("You are wafted to heaven as you eat an ice cream bar!\n");
X   set_eating_mess(" eats an ice cream bar.\n");
X}
X
Xinit()
X{
X   if (environment() == this_player()) add_action("throw","throw");
X   ::init();
X}
X
Xthrow(str)
X{
X   object target, newpie, mud;
X   string who, what, thrower;
X   int prob;
X   
X   if (!str) return 0;
X   what = name;
X   if (sscanf(str,"%s at %s",what,who) == 2 ||
X       sscanf(str,"at %s",who) == 1) 
X   {
X      if (!id(what)) 
X      {
X	 write("Throw WHAT at WHOM?\n");
X	 return 1;
X      }
X
X      /* Who's the victim? Only living objs in the current room are ok.     */
X      target = present(who,environment(this_player()));
X      if (!target || !living(target)) 
X      {
X	 write(capitalize(str)+" is not here or not alive.\n");
X	 return 1;
X      }
X      who = capitalize(who);
X      thrower = capitalize(this_player()->query_real_name());
X
X      /* Determine if the throw is a hit.                                   */
X      prob = random(100);
X      if ( prob < threshold ) 
X      { 
X         /* Tell everybody about it.                                        */
X	 tell_object(target, thrower + " hits you with a mud pie!\n"+
X		     "Ugh! You're covered in mud!\n");
X	 write("You hit "+who+" with a mud pie!\n");
X	 say(thrower+" hits "+who+" with a mud pie.\n"+
X	     capitalize(target->query_pronoun())+"is filthy!\n",target);
X
X         /* Create and transfer mud to the victim.                          */
X	 mud = clone_object(MYLIB+"/mud");
X	 transfer(mud,target);
X         /* If the player hit does not have a pie, give them one.           */
X	 if (!present(name,environment(mud))) 
X         {
X	    newpie = clone_object(MYLIB+"/mudpie");
X	    transfer(newpie,target);
X	 }
X      }
X      else
X      /* A miss! But make sure everyone knows about it.                     */
X      {
X	 tell_object(target, thrower +" tries to hit you with a mud pie,"+
X		     "but misses!\n");
X	 write("You throw a mud pie at "+who+". You miss!\n");
X	 say(thrower+" misses "+who+" with a mud pie.\n", target);
X      }
X      inc_gen();  /* Advance the generation number of this pie              */
X      return 1;
X   }
X   return 0;
X}
X
Xinc_gen()
X{
X   /* This function is used to determine the number of times the pie has    */
X   /* been thrown. When it reaches its limit, it is destructed.             */
X   gen += 1;
X   if(gen > max_gen) destruct(this_object());
X}
X
Xset_max(arg)
X{
X   /* Set the maximum number of times the pie can be thrown.                */
X   max_gen = arg;
X   return 1;
X}
X
Xset_threshold(arg)
X{
X   /* Set the percent probability that the pie will hit the victim.         */
X   threshold = arg;
X   return 1;
X}
X
END_OF_FILE
if test 5182 -ne `wc -c <'mudpie.c'`; then
    echo shar: \"'mudpie.c'\" unpacked with wrong size!
fi
# end of 'mudpie.c'
fi
if test -f 'soap.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'soap.c'\"
else
echo shar: Extracting \"'soap.c'\" \(4321 characters\)
sed "s/^X//" >'soap.c' <<'END_OF_FILE'
X/* soap.c                                                                    */
X/* Author: F. Jay Shields                                                   */
X/*                                                                          */
X/* This is a soap object. It can be used to remove things with a            */
X/* clean_self function.                                                     */
X/*                                                                          */
X/*                                                                          */
X/*Copyright (c) 1991 by F. Jay Shields                                      */
X/*                                                                          */
X/*This code is hereby entered into the public domain, subject to the        */
X/*following restrictions:                                                   */
X/*                                                                          */
X/*   1. The author is not responsible for any problems or calamities the    */
X/*      use of this code may entail, whether such problems are the result   */
X/*      of defects in the code or not. Use at your own risk.                */
X/*                                                                          */
X/*   2. This code may be altered in any way you see fit, but must be        */
X/*      clearly marked as such, and may not be represented as the original  */
X/*      code.                                                               */
X/*                                                                          */
X
Xint max_washes;       /* The total number of washes allowed.                */
Xint num_washes;       /* The current number of washes taken                 */
Xstring brand;         /* The brand name of the soap                         */
X
Xstring name;
Xstring short_desc;
Xstring long_desc;
Xint value;
Xint weight;
X
Xinit()
X{
X   if (environment() == this_player()) 
X   {
X      add_action("wash","wash");
X      add_action("wash", "clean");
X      add_action("wash", "lather");
X   }
X}
X
Xreset(arg)
X{
X   int indx;
X
X   if(arg) return;
X   num_washes = 0;
X   set_max_washes(10);
X   value = max_washes;
X   name = "soap";
X   weight = 0;
X
X   /* Give it a brand name */
X   if (!brand) {
X      indx = random(10);
X      if (indx == 0) brand = "dove";
X      if (indx == 1) brand = "zest";
X      if (indx == 2) brand = "dial";
X      if (indx == 3) brand = "lava";
X      if (indx == 4) brand = "irish Spring";
X      if (indx == 5) brand = "camay";
X      if (indx == 6) brand = "herbal";
X      if (indx == 7) brand = "neutrogena";
X      if (indx == 8) brand = "lye";
X      if (indx == 9) brand = "ivory";
X   }
X   short_desc = capitalize(brand)+" soap";
X   long_desc = "A fragrant bar of "+brand+
X               " soap. Perfect for washing off mud!\n";
X}
X
Xwash()
X{
X   object mud;
X
X   /* If they've got mud, get rid of some of it.                            */
X   mud = present("mud",environment()); 
X   if( mud ) 
X   {
X      mud->clean_self();
X      write("You wash yourself with the soap.\n");
X      say(capitalize(this_player()->query_name())+" washes with some soap.\n",
X	  this_player());
X      shave_soap();
X      return 1;
X   }
X
X   /* No mud. Tell them they're clean. Let others know they checked.        */
X   write("You're perfectly clean!\n");
X   say(capitalize(this_player()->query_name())+" sniffs "+
X       this_player()->query_possesive()+" armpit.\n");
X
X   shave_soap();
X   return 1;
X}
X
Xshave_soap()
X{
X   /* Use up some soap */
X   num_washes += 1;
X   value = max_washes - num_washes;
X   if (num_washes >= max_washes)
X   {
X      write("Your soap dwindles to nothing!\n");
X      destruct(this_object());
X   }
X   return 1;
X}   
X
Xset_max_washes(arg)
X{
X   max_washes = arg;
X   return 1;
X}
X
Xshort() {
X   if (!short_desc)
X   return 0;
X   return short_desc;
X}
X
Xlong(str) {
X   write(long_desc);
X}
X
Xid(str)
X{
X   return str == name || str == brand;
X}
X
Xquery_value() { return value; }
X
Xquery_name() { return name; }
X
Xquery_alias() { return brand; }
X
Xget(str)
X{
X   return 1;
X}
X
Xdrop() {
X   return 0;
X}
X
Xquery_weight() { return weight; }
X
Xset_id(n) { name = n; }
Xset_name(n) { name = n; }
Xset_alias(n) { brand = n; }
Xset_short(s) { short_desc = s; long_desc = s + ".\n"; }
Xset_value(v) { value = v; }
Xset_weight(w) { weight = w; }
Xset_long(l) { long_desc = l; }
X
END_OF_FILE
if test 4321 -ne `wc -c <'soap.c'`; then
    echo shar: \"'soap.c'\" unpacked with wrong size!
fi
# end of 'soap.c'
fi
echo shar: End of shell archive.
exit 0
