/** Descr  : Small function to enhance roleplay (?)
  * Author : Jesse Farinacci <jesse@twcny.rr.com>
  */
void         do_mutter (CHAR_DATA * ch, char *argument)
{
   /* stupidity check */
   if (argument[0] == '\0')
      send_to_char ("Usage: mutter <player> <message>\n\r", ch);

   else
   {
      char         word[MAX_INPUT_LENGTH];
      CHAR_DATA   *victim;

      /* find target */
      argument = one_argument (argument, word);
      if ((victim = get_char_room (ch, word)) == NULL)
	 send_to_char ("They aren't here.\n\r", ch);

      /* more stupidity checks */
      else if (ch == victim)
	 send_to_char ("Talking to yourself is the first sign of insanity.\n\r", ch);

      /* yet another stupidity check */
      else if (victim->position <= POS_SLEEPING)
	 send_to_char ("Perhaps now is not the most opportune time, they're not awake.\n\r", ch);

      /* finally! */
      else
      {
	 char         buf[MAX_INPUT_LENGTH], message[MAX_STRING_LENGTH],
	              muffled[MAX_STRING_LENGTH], *unmuffled;
	 bool         lastMufd = TRUE;

	 /* we need to save original message */
	 unmuffled = argument;
	 muffled[0] = '\0';
	 while (*argument != '\0')
	 {
	    int          chance = number_range (1, 100);

	    /* there has got to be a better way.. */
	    /* argument = one_argument (argument, word); */
	    argument = first_arg (argument, word, FALSE);

	    /* chance of word being unheard */
	    if (chance > 25)
	    {
	       if (chance > 80)
		  strcat (muffled, "...");
	       else if (chance > 50)
		  strcat (muffled, "..");
	       else
		  strcat (muffled, ".");
	       lastMufd = TRUE;
	    }
	    else
	    {
	       sprintf (buf, "%s%s", lastMufd ? "" : " ", word);
	       strcat (muffled, buf);
	       lastMufd = FALSE;
	    }
	 }

	 /* send it out as appropriate */
	 sprintf (message, "You mutter to $N, '`r%s`8'", unmuffled);
	 act (message, ch, NULL, victim, TO_CHAR, POS_RESTING);
	 sprintf (message, "$n mutters to you, '`r%s`8'", unmuffled);
	 act (message, ch, NULL, victim, TO_VICT, POS_RESTING);
	 sprintf (message, "$n mutters to $N, '`r%s`8'", muffled);
	 act (message, ch, NULL, victim, TO_NOTVICT, POS_RESTING);
	 sprintf (message, "Those around you hear, '`r%s`8'", muffled);
	 act (message, ch, NULL, NULL, TO_CHAR, POS_RESTING);
	 act (message, victim, NULL, NULL, TO_CHAR, POS_RESTING);
      }
   }
   return;
}
