Language Addition [by Frollo]
Snippet Posted Wednesday, August 12th @ 11:29:48 PM, by George Greer in the Utils dept.


From: Frollo 
Subject: Another Language Snippet

This is just a language function, incorporates language and stuff into the
normal say, toggle-able and all that stuff.

You may have to change around the colors (&c, &r, etc) -- didn't
feel like taking them out :)
---act.comm.c---

char *languages[] =
{
  "common",
  "elven",
  "gnomish",
  "dwarven",
  "\n"
};

void list_languages(struct char_data *ch)
{

int a = 0, i;

sprintf(buf, "Languages:\r\n");

for (i = MIN_LANGUAGES; i < MAX_SKILLS; i++) {


if (GET_SKILL(ch, i) > 60)



sprintf(buf, "%s%s%s%s", buf, a++ != 0 ? "&c, " : "&w[&c ", SPEAKING(ch) == i ?
 CCRED(ch, C_NRM) : "", languages[a-1]);

}

sprintf(buf, "%s &w]&n\r\n", buf);

send_to_char(buf, ch);

}

ACMD(do_languages)
{

int i, found = FALSE;

one_argument(argument, arg);


if (!*arg)


list_languages(ch);

else {


for (i = MIN_LANGUAGES; i < MAX_SKILLS; i++) {



if (is_abbrev(arg, languages[i-MIN_LANGUAGES]) && GET_SKILL(ch, i) > 60) {




SPEAKING(ch) = i;




sprintf(buf, "You now speak %s.\r\n", languages[i-MIN_LANGUAGES]);




send_to_char(buf, ch);




found = TRUE;




break;



}


}


if (!found)



list_languages(ch);

}
}

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_say)
{
  char ibuf[MAX_INPUT_LENGTH];
  char obuf[MAX_INPUT_LENGTH];
  struct char_data *tch;

  skip_spaces(&argument);

  if(!*argument) {
    send_to_char("Yes, but WHAT do you want to say?\r\n", ch);
    return;
  }

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

  if (!IS_NPC(ch))

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 */


  if (!IS_NPC(ch) && !IS_NPC(tch))


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

      send_to_char("&c",tch);

  sprintf(buf, "$n says, '%s&c'&n",  obuf);

  CAP(buf);
      act(buf, TRUE, ch, 0, tch, TO_VICT);
    }
  }

  sprintf(buf, "&cYou say, '%s&c'&n", argument);
  act(buf, TRUE, ch, 0, 0, TO_CHAR);

}

---spells.h---
#define LANG_COMMON




196
#define LANG_ELVEN




197
#define LANG_GNOME




198
#define LANG_DWARVEN




199
#define MIN_LANGUAGES




196

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



<< Language Addition [by ?] | Reply | View as text | Threaded | Liblist Commands: Rlist, Mlist, Olist Commands [by Myrddin] >>

 


Related Links
  Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.