Re: [coding] [newbie] languages [long]

From: Invincibill (bill@longboys.net)
Date: 01/25/99


Dan Egli wrote:
>
> I recently downloaded the language patch for circle, but it's not quite
> what I'm looking for. I wonder if someone out there could help?
>
> The problem is this: Unless everyone in the room is fluent in that
> language, and they are set to speak in that language, then the system
> garbels the text. I could see that if they were not fluent in the
> language, but really... If someone actually knows a language, should it
> really matter if they are speaking in it? Just because I'm speaking englih
> doesn't mean I couldn't understand another language I knew if I heard
> someone speak it. How would you accompilsh that? Here's the do_say routine
> as I have hacked it to work:

-->snip

here is my lang stuff..i use the lang snippet but its just slightly
modified...
you should be able to make sense of it no prob tho.


#define SPEAKING(ch)            ((ch)->player_specials->saved.speaking)
#define GET_LANG(ch, i)          ((ch)->player_specials->saved.langs[i])
//for stock circle i think you would want something like..
#define GET_LANG(ch, i)         ((ch)->player_specials->saved.spells[i +
lang_offset])
//or something like that.

 PCOMM(do_lang_say)
 {

   extern char *pc_lang_types[];
   char ibuf[MAX_INPUT_LENGTH];
   char obuf[MAX_INPUT_LENGTH];
   int dir;
   CHAR *tch, *lch, *lch_next;

   if(!CAN_PERFORM_CMD(ch, cmd_number, PRIV_MORTAL)) {
     send_to_char("Sorry, you do not have permission to use this
command.\n\r", ch);
     return; }

   skip_spaces(&argument);
   MOBTrigger = FALSE;

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

   if(IS_NPC(ch) || (IS_IMMORTAL(ch))) {
     sprintf(buf, "$n says, '%s'", argument);
     act(buf, FALSE, ch, 0, 0, TO_ROOM);
     if(BIT_FLAGGED(ch, BIT_NOREPEAT))
        send_to_char(OK, ch);
     else {
        sprintf(buf, "You say, \"%s\"\n\r", argument);
        delete_doubledollar(buf);
        send_to_char(buf, ch);
     }
     MOBTrigger = TRUE;
     mprog_speech_trigger(argument, ch);
   } else {
     strcpy(ibuf, argument);
     garble_text(ibuf, GET_LANG(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);
           garble_text(obuf, GET_LANG(tch, SPEAKING(ch)));
           //we garble it twice for more confusion. :)
           if (IS_NPC(tch) || IS_IMMORTAL(tch))
             sprintf(buf, "$n says, '%s'\n\r", argument);
           else if ((GET_LANG(tch, SPEAKING(ch)) <= 33) || //33 is an
arbitrary number which
              (GET_LANG(ch, SPEAKING(ch)) <= 33))          //seemed to
make the most sense
             sprintf(buf, "$n says, '%s'\n\r", obuf);
           else
             sprintf(buf, "$n says in %s, '%s'\n\r",
                pc_lang_types[(SPEAKING(ch))], ibuf);  //ibuf is less
garbled than obuf
           act(buf, TRUE, ch, 0, tch, TO_VICT);
         }
       }
       if (BIT_FLAGGED(ch, BIT_NOREPEAT))
        send_to_char(OK, ch);
       else {
        sprintf(buf, "You %ssay in %s, '%s'\n\r",
                GET_LANG(ch, SPEAKING(ch) > 33) ? "" : "attempt to ",
                pc_lang_types[(SPEAKING(ch))],
                ibuf);
        delete_doubledollar(buf);
        send_to_char(buf, ch);}

     MOBTrigger = TRUE;
     mprog_speech_trigger(argument, ch);
  }
  // let people in other rooms hear voices from this room
  // if the room is small enough.
  if(ROOM_SIZE(ch->in_room) <= RSIZE_SMALL) {
    for(dir=0;dir <NUM_OF_DIRS; dir++)
      if(CAN_GO(ch,dir) || CAN_HEAR(ch,dir))
        for(lch=world[EXIT(ch, dir)->to_room].people; lch;
lch=lch_next){
          lch_next = lch->next_in_room;
          send_to_charf(lch, "You hear voices coming from %s%s.\n\r",
                  ((dir==8) ? "above" :
                   (dir==9) ? "below" : "the "),
                  ((dir==8 || dir==9) ? "" : dir_types[dir].l_dir));
        }
  }
 }

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

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




--
Weather forecast for today: Sunny & Mild
Weather forecast for tomorrow : Sunny & Mild
www.giftsgalore.com : www.longboys.net
telnet://undying.longboys.net:4000 http://undying.longboys.net


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



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