[Newbie] [Code] Language code errors

From: Patrick Yokley (hawke@excalibur.net)
Date: 09/25/96


I'm trying to imp a language code I found and I am receiving some errors
and cannot pinpoint my problem.  Couls you take a look at the errors and
see if you all could help me pinpoint the problem for me?  Would be
appretiated :)  I'm also including an attachment of the Language Code that
I'm using to help.  If anyone has a different code that you are using,
could you please post it?  Thanks again.


act.comm.c: In function `do_lang_say':
act.comm.c:58: structure has no member named `speaking'
act.comm.c:65: structure has no member named `speaking'
act.comm.c:67: structure has no member named `speaking'
act.comm.c:70: structure has no member named `speaking'
act.comm.c:75: structure has no member named `speaking'
*** Error code 1


Language Code

Some notes: I use skill slots to hold language ability, this coincides very
nicely with my learn_by_use code (stripped out of this example). If you try
to use this, you'll need to make the appropriate entries in spells.h (I use
190+ for langs), also, you'll need to change one of the spares in the player
structure to be "speaking".

Oh, you'll also need some way to toggle what language you're speaking, you
could use a simple do_speak command or something, I'm not finished putting
this all in yet, so I just made an entry in do_set to toggle the person's
current lang like: SPEAKING(vict) = value

Take note that it might also be a good idea to set the characters' native
language to 100% when they begin.


#define LANG_COMMON     190
#define LANG_ELVEN      191
#define LANG_DWARVEN    192
#define LANG_TROLLISH   193
#define LANG_HALFLING   194


#define SPEAKING(ch)     ((ch)->player_specials->saved.speaking)


const char *languages[] =


void garble_text(char *string, int percent)
  char letters[] = "aeiousthpwxyz";
  int i;

  for (i = 0; i < strlen(string); ++i)
    if (isalpha(string[i]) && number(0, 1) && number(0, 100) > percent)  
      string[i] = letters[number(0, 12)];

  extern char *languages[];
  char ibuf[MAX_INPUT_LENGTH];
  char obuf[MAX_INPUT_LENGTH];
  int ofs = 190;              /* offset - should be first language */
  struct char_data *tch;      


  if(!*argument) {
    send_to_char("Say what?\r\n", ch);

  strcpy(ibuf, argument);     /* preserve original text */

  garble_text(ibuf, GET_SKILL(ch, SPEAKING(ch)));

  for (tch = world[ch->in_room].people; tch; tch = tch->next_in_room) {
    if (tch != ch && AWAKE(tch) && tch->desc) {

      strcpy(obuf, ibuf);     /* preserve the first garble */

      garble_text(obuf, GET_SKILL(tch, SPEAKING(ch)));

      if (GET_SKILL(tch, SPEAKING(ch)) < 1)
        sprintf(buf, "$n says, in an unfamiliar tongue,\r\n     '%s'",  obuf);
        sprintf(buf, "$n says, in the %s tongue,\r\n     '%s'", languages[(SPEAKING(ch) - ofs)], obuf);
      act(buf, TRUE, ch, 0, tch, TO_VICT);

  sprintf(buf, "You say, in the %s tongue,\r\n     '%s'", languages[(SPEAKING(ch)- ofs)], argument);
  act(buf, TRUE, ch, 0, 0, TO_CHAR);


One funky thing I see here, is that it appears that the garbled text changes
each time. For example, if I say the words "Hello there Sparky, you're a dead
man!" six times, anyone not speaking my language should see the same string
six times, not 6 different ones. I got around this by assigning each language
an index (Say like 5 10 15 20), and in the garble text routine, I adjust the
ascii value of the character by the index. If I overrun the range of printable
characters, I just wrap around. The result is that the exact same string
appears each time the speaker says the same phrase. One major benefit of
this is that it allows a player to "learn" and recognize certain phrases
in foreign tongues, just as in real life. Therefore players of different
races can have at least minimal verbal interaction. Of course you can also
do an:

> emote says: Hi There!

... But that's not my problem to solve.

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