Re: An uncommon problem... from "George" at Sep 29, 97 01:43:25 pm

From: Andrew Helm (ashe@IGLOU.COM)
Date: 09/30/97


I found the following file in some ftp archive. It's been modified
by me from it's original form so bear in mind that although all
the credit goes to the original authors, I might have introduced
some bugs, etc. To use it just do a makedrunk(text, character)
where text is the text and character is the player speaking it.
It's useful to put the makedrunk() in act.comm.c right before
someone gossips, says, tells, etc.

------------language.c---------------
/*  File: language.c
 *  Usage: Various language/speech utilities.
 */

#include "conf.h"
#include "sysdep.h"

#include "structs.h"
#include "utils.h"
#include "comm.h"
#include "interpreter.h"
#include "handler.h"
#include "db.h"


/* How to make a string look drunk... by Apex (robink@htsa.hva.nl)
 * Modified and enhanced for envy(2) by the Maniac from Mythran
 * Ported to Stock Circle 3.0 by Haddixx (haddixx@megamed.com)
 */

void makedrunk (char **text, struct char_data * ch) {
  static struct {
    int     min_drunk_level;
    int     number_of_rep;
    char    *replacement[11];
  } drunk[] = {
    {3, 10, {"a", "a", "a", "A", "aa", "ah", "Ah", "ao", "aw", "oa", "ahhhh"}},
    {8, 5, {"b", "b", "b", "B", "B", "vb"}},
    {3, 5, {"c", "c", "C", "cj", "sj", "zj"}},
    {5, 2, {"d", "d", "D"}},
    {3, 3, {"e", "e", "eh", "E"}},
    {4, 5, {"f", "f", "ff", "fff", "fFf", "F"}},
    {8, 2, {"g", "g", "G"}},
    {9, 6, {"h", "h", "hh", "hhh", "Hhh", "HhH", "H"}},
    {7, 6, {"i", "i", "Iii", "ii", "iI", "Ii", "I"}},
    {9, 5, {"j", "j", "jj", "Jj", "jJ", "J"}},
    {7, 2, {"k", "k", "K"}},
    {3, 2, {"l", "l", "L"}},
    {5, 8, {"m", "m", "mm", "mmm", "mmmm", "mmmmm", "MmM", "mM", "M"}},
    {6, 6, {"n", "n", "nn", "Nn", "nnn", "nNn", "N"}},
    {3, 6, {"o", "o", "ooo", "ao", "aOoo", "Ooo", "ooOo"}},
    {3, 2, {"p", "p", "P"}},
    {5, 5, {"q", "q", "Q", "ku", "ququ", "kukeleku"}},
    {4, 2, {"r", "r", "R"}},
    {2, 5, {"s", "ss", "zzZzssZ", "ZSssS", "sSzzsss", "sSss"}},
    {5, 2, {"t", "t", "T"}},
    {3, 6, {"u", "u", "uh", "Uh", "Uhuhhuh", "uhU", "uhhu"}},
    {4, 2, {"v", "v", "V"}},
    {4, 2, {"w", "w", "W"}},
    {5, 6, {"x", "x", "X", "ks", "iks", "kz", "xz"}},
    {3, 2, {"y", "y", "Y"}},
    {2, 9, {"z", "z", "ZzzZz", "Zzz", "Zsszzsz", "szz", "sZZz", "ZSz", "zZ", "Z"}}
  };
  char temp;
  char buffer[MAX_STRING_LENGTH];
  int pos = 0;
  int randomnum;

  buffer[0] = '\0';
  for(temp = **text;temp;temp = **text, (*text)++) {
    if(isalpha(temp)) {
      if(GET_COND(ch, DRUNK) > drunk[(toupper(temp) - 'A')].min_drunk_level) {
        randomnum = number(0, (drunk[(toupper(temp) - 'A')].number_of_rep));
        strcpy(&buffer[pos], drunk[(toupper(temp) - 'A')].replacement[randomnum]);
        pos += strlen(drunk[(toupper(temp) - 'A')].replacement[randomnum]);
      } else
        buffer[pos++] = **text;
    } else {
      if (isdigit(temp)) {
        temp = '0' + number(0, 9);
        buffer[pos++] = temp;
      } else
        buffer[pos++] = **text;
    }
    buffer[pos+1] = '\0';
  }

  strcpy(*text, buffer);
}


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST