Re: Languages

From: Chris Herringshaw (xxviper@umich.edu)
Date: 09/05/95


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.

---
Christopher Herringshaw       | University of Michigan Medical Center
Special Projects Development  | 1500 East Medical Center Dr. B1-240TC
xxviper@umich.edu             |        Ann Arbor, Michigan 48109-0704
http://www.umich.edu/~xxviper |                  +0101 (313) 747-2778      

On Sat, 26 Aug 1995, system operator wrote:

> How many people out there have implemented languages?  I just put them
> in today, and was wondering if anyone has any suggestions for my code.
> I'm a little shakey on text manipulation, so if anyone notices some real
> gaffs I made here, I'd apprectiate being set straight.
> 
> I'll include everything you need to "make it go" in case anyone wants
> to test it, or actually use it... it does work, I'm just not sure if
> I've gone about it in the most efficient way, thus I'm posting it here
> to see what others have to say...
> 
> 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"
> 
> 
> 
> --snip--
> 
> /* spells.h */
> #define LANG_COMMON     190
> #define LANG_ELVEN      191
> #define LANG_DWARVEN    192
> #define LANG_TROLLISH   193
> #define LANG_HALFLING   194
> 
> 
> /* this would fit best in utils.h */
> #define SPEAKING(ch)     ((ch)->player_specials->saved.speaking)
> 
> 
> /* this would fit best in constants.c */
> const char *languages[] =
> {
>   "common",
>   "elven",
>   "dwarven",
>   "trollish",
>   "halfling",
>   "\n"
> };
> 
> 
> /* the rest would fit best in act.comm.c i guess */
> 
> 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)];
> }
> 
> 
> ACMD(do_lang_say)
> {
> 
>   char ibuf[MAX_INPUT_LENGTH];
>   char obuf[MAX_INPUT_LENGTH];
>   int ofs = 190;              /* offset - should be first language */
>   struct char_data *tch;      
> 
>   skip_spaces(&argument);
> 
>   if(!*argument) {
>     send_to_char("Say what?\r\n", ch);
>     return;
>   }
> 
>   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);
>       else
>         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);
> 
> }
> 
> 
> --snip--
> 
> 



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