06 Sep, 2012, Hades_Kane wrote in the 1st comment:
Votes: 0
It's not a "have to have" kinda thing, and certainly not something I really have any interest in coding myself, but I was curious if anyone has run across or knew where a C based random name generator snippet (prefer an emphasis on fantasy) might be?

Long shot I figure, but it would be a neat tool for players to have without having to go to an external source like a website.
06 Sep, 2012, arholly wrote in the 2nd comment:
Votes: 0
This is the code my mud uses (ROM2.4)
/*
* Randomised name creation.
*/
void name_replacer(char *format, char *first, char *last, char *out)
{
char buf[MSL]={'\0'};
char *str;
char *i;
char *point;

if(format == NULL)
return;

point = buf;
str = str_dup(format);

// we should never reach this if format is null.
if(str == NULL)
return;

/* replace $f with first and $l with last. */
while ( *str != '\0' )
{
if ( *str != '$' )
{
*point++ = *str++;
continue;
}
++str;

switch ( *str )
{
default: bug( "[*****] BUG: Rand_name: bad code %d.", *str );
i = " Dave "; break;
case 'f': i = first;
break;
case 'l': i = last;
break;
case ' ': i = "$";
break;
case '$': i = "$";
break;
}

++str;
while ( ( *point = *i ) != '\0' )
++point, ++i;
}
*point++ = '\0';

/* Removed to try to fix name changing bug.
return str_dup(buf);
*/
strcpy(out, buf);

return;
}

#define MAX_NAMES 103

char* male_names [MAX_NAMES] =
{
"Michael", "Matthew", "Nicholas", "Christopher", "Joshua", "Austin", "Tyler", "Brandon",
"Joseph", "Andrew", "Daniel", "Ryan", "Zachary", "Anthony", "Dylan", "David", "Jonathan",
"William", "James", "John", "Alexander", "Justin", "Jordan", "Noah", "Robert", "Brian",
"Jose", "Steven", "Kyle", "Kevin", "Christian", "Samuel", "Eric", "Benjamin", "Thomas",
"Hunter", "Ethan", "Sean", "Devin", "Cameron", "Nathan", "Aaron", "Caleb", "Connor", "Cody",
"Jason", "Luis", "Timothy", "Isaac", "Adam", "Jared", "Charles", "Richard", "Gabriel",
"Mark", "Jack", "Isaiah", "Juan", "Logan", "Alex", "Antonio", "Carlos", "Elijah", "Jesse",
"Brendan", "Patrick", "Luke", "Angel", "Dakota", "Lucas", "Chase", "Cole", "Seth",
"Nathaniel", "Jeremy", "Alejandro", "Ian", "Tristan", "Jeffrey", "Jake", "Garrett",
"Victor", "Jackson", "Marcus", "Trevor", "Bradley", "Brett", "Bryce", "Adrian", "Evan",
"Gavin", "Paul", "Tanner", "Colton", "Dalton", "Kenneth", "Spencer", "Xavier", "Peter",
"Dave", "Mick", "Matt", "Bernard"
};

char* female_names [MAX_NAMES] =
{
"Emily", "Sarah", "Brianna", "Samantha", "Hailey", "Ashley", "Kaitlyn", "Madison", "Hannah",
"Alexis", "Jessica", "Alyssa", "Abigail", "Kayla", "Megan", "Katherine", "Taylor",
"Elizabeth", "Makayla", "Rachel", "Jasmine", "Olivia", "Victoria", "Emma", "Anna",
"Rebecca", "Natalie", "Courtney", "Lauren", "Sydney", "Amanda", "Nicole", "Destiny", "Stephanie", "Morgan", "Julia", "Sierra", "Brittany", "Grace", "Danielle", "Jennifer",
"Kaylee", "Mackenzie", "Alexandra", "Savannah", "Amber", "Jordan", "Kylie", "Shelby",
"Christina", "Jacqueline", "Gabriella", "Maria", "Erica", "Gabrielle", "Madeline", "Erin",
"Mary", "Marissa", "Andrea", "Vanessa", "Kimberly", "Michelle", "Riley", "Brooke", "Bailey",
"Kiara", "Cassandra", "Chloe", "Sophia", "Alexandria", "Cassidy", "Kelly", "Melissa",
"Kelsey", "Laura", "Miranda", "Jade", "Paige", "Sabrina", "Casey", "Molly", "Katie",
"Alicia", "Isabel", "Leslie", "Lily", "Alexa", "Caroline", "Mariah", "Jenna", "Angela",
"Veronica", "Chelsea", "Autumn", "Diana", "Faith", "Shannon", "Bethany", "Bianca",
"Stacey", "Magrat", "Sarah"
};

char* last_names [MAX_NAMES] =
{
"Smith", "Johnson", "Williams", "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor",
"Morrison", "Black", "White", "Grossman", "Thall", "Finklestein", "Bevill", "McGuinn",
"Olson", "Wiater", "Convey", "Sabaitis", "Brothers", "Kotiw", "Carraway", "Jennings",
"Major", "Watts", "Bendig", "Abbott", "Abene", "Zurek", "Zarov", "Yurchak", "Vogt", "Ulum",
"Tzanetopoulos", "Turner", "Swanson", "Strong", "Stoffer", "Rozen", "Roy", "Rosenthal",
"RoonieQuinn", "Qazi", "Putman", "Pulman", "Pruitt", "Overstreet", "Owen", "Nutile",
"Norman", "Noelle", "Musso", "Mulvihill", "Morgan", "Mitchels", "Lynn", "Luber", "Liva",
"Krueger", "Kozlowski", "Koffmann", "June", "Jones", "Jensen", "Isztok", "Hutchins",
"Hughes", "Howard", "Griffin", "Green", "Greenan", "Gould", "Giles", "Froemel", "Flynn",
"Fishman", "Esposito", "Emerson", "Edgeson", "Drozd", "Downs", "Dohra", "Curley", "Crosby",
"Coote", "Collins", "Burger", "Bruns", "Blunt", "Blackmond", "Barnett", "Fitzgerald",
"Wood", "Smyth", "Stryker", "Sweet", "Sutherland", "Cohen",
"Dredd", "O'Reily", "Kilborn"
};

char *name_select(char *table[MAX_NAMES])
{
int i;
char *a;

i = number_range(0, MAX_NAMES - 1);

/* Removed to try to fix name changing bug.
a = str_dup(table[i]);
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/
a = table[i];
return a;
}

void rand_name(CHAR_DATA *ch)
{
char *first;
char *last;
char out[4*MSL]={'\0'};

if(ch->sex == SEX_FEMALE)
{
first = name_select(female_names);
last = name_select(last_names);
}
else
{
first = name_select(male_names);
last = name_select(last_names);
}

PURGE_DATA(ch->name);
name_replacer(ch->pIndexData->player_name, first, last, out);
ch->name = str_dup(out);
PURGE_DATA(ch->short_descr);
name_replacer(ch->pIndexData->short_descr, first, last, out);
ch->short_descr = str_dup(out);
PURGE_DATA(ch->long_descr);
name_replacer(ch->pIndexData->long_descr, first, last, out);
ch->long_descr = str_dup(out);
PURGE_DATA(ch->description);
name_replacer(ch->pIndexData->description, first, last, out);
ch->description = str_dup(out);
}
06 Sep, 2012, arholly wrote in the 3rd comment:
Votes: 0
So then in the short, long, name, or description, all we do is put $f or $l and it goes to town.
06 Sep, 2012, Hades_Kane wrote in the 4th comment:
Votes: 0
I appreciate it, arholly.

For reference, though, this is more what I am looking for:

http://www.rinkworks.com/namegen/

Something to generate a unique, fantasy type name from a series of prefixes, suffixes, or logical consonant/vowel placement, rather than placement of predefined names to generate a combination of first/last names.
06 Sep, 2012, arholly wrote in the 5th comment:
Votes: 0
Ahh…Gotcha. If you figure it out, let me know.
06 Sep, 2012, Hades_Kane wrote in the 6th comment:
Votes: 0
Will do!
07 Sep, 2012, Lyanic wrote in the 7th comment:
Votes: 0
There's one posted on lpmuds.net (just search for it), but it's in LPC. You could convert it to C easily enough.
07 Sep, 2012, Oliver wrote in the 8th comment:
Votes: 0
The easiest thing here to do would probably be to use an existing interface. You linked to the Rinkworks generator; why not pull a page from that (assuming it's allowed by the website creator, I'm not sure on that) and use those?
07 Sep, 2012, Idealiad wrote in the 9th comment:
Votes: 0
Here's a nice one:

https://bitbucket.org/jice/libtcod/src/0...

and

https://bitbucket.org/jice/libtcod/src/0...

There might be libtcod library parsing functions in namegen_c.c you'll have to reimplement/copy, but most of the work is done for you and it's quite flexible.
07 Sep, 2012, plamzi wrote in the 10th comment:
Votes: 0
I like rolling my own because I can fine-tune the sound of the resulting name. I'm using several versions of a syllable-based function to make sure that mercenary names have a different flavor from pet names, etc.

In the function I'm sharing, the variations are intentionally somewhat limited–that way if someone likes a mercenary name they've generated, they can re-generate it in 3-400 rolls :) But more combinations can be added.

There are a few assumptions below that are different from stock DIKU. The most important is that the strings being modified don't point to the prototype (template). In order to use this in codebases that use mob prototypes, you'd have to add a few lines to modify those strings safely.

int size_of(char *arr[]) {
int size = 0;
while (arr[size] != NULL) size++;
return size;
}

char *one_of(char *arr[]) {
return arr[number(0, size_of(arr)-2)];
}

/* Bedlam mercenary random personal names */

void name_the_mercenaries(int merc_room) {

static char *merc_syl_closed[] = { "gob", "gup", "gad", "got", "dan", "sil", "ban", "vig", "zom", "rak", "dob", "mag", "tog", "vat", "gam",
"bok", "jok", "rok", "mek", "dim", "ris", "tok", "tan", "tor", "mar", "mor", "vig", "rem",
"sal", "sel", "les", "rit", "vel", "vir", "lin", "don", "dar", "dir", "mir", "lir",
"ties", "mael", "fein", "man", "fin", "dyr", "lyr", "nyr", "vyr", NULL };

static char *merc_syl_open[] = { "ara", "arca", "anka", "eva", "ena", "ega", "oma", "ik", "era", "ida",
"oda", "ami", "oka", "ipa", "ina", "osa", "abi", "ea", "ai", "amai",
"ata", "isa", "ira", "ara", "ala", "ela", "ula", "asa", "esa", "eta", NULL };

static char *merc_syl_edge[] = { "p", "n", "m", "k", "s", "t", "u", "z", "r", "b", "g", "l", "t", "f", "x", NULL };
static char *merc_syl_opening[] = { "sa", "mi", "fa", "li", "fe", "si", "bri", "ty", "ly", NULL };
static char *merc_syl_closing[] = { "af", "ip", "es", "il", "am", "in", "an", "ir", "el", "et", "yl", NULL };

struct char_data *merc;
char *name;

for (merc = world[merc_room].people; merc; merc = merc->next_in_room) {

name = strdup("");

if (GET_SEX(merc) == SEX_MALE) {
if (!number(0, 2)) {
strcat(name, one_of(merc_syl_open));
strcat(name, one_of(merc_syl_edge));
strcat(name, one_of(merc_syl_closing));
}
else if (!number(0, 1)) {
strcat(name, one_of(merc_syl_closing));
strcat(name, one_of(merc_syl_open));
strcat(name, one_of(merc_syl_edge));
}
else {
if (number(0, 1)) strcat(name, one_of(merc_syl_edge));
strcat(name, one_of(merc_syl_open));
if (number(0, 3))
strcat(name, one_of(merc_syl_closed));
else
strcat(name, one_of(merc_syl_edge));
}
}
else {
if (!number(0, 3)) {
strcat(name, one_of(number(0, 1)?merc_syl_closed:merc_syl_edge));
strcat(name, one_of(merc_syl_open));
}
else if (!number(0, 2)) {
strcat(name, one_of(merc_syl_opening));
strcat(name, one_of(merc_syl_edge));
strcat(name, one_of(merc_syl_open));
}
else if (!number(0, 1)) {
strcat(name, one_of(merc_syl_edge));
strcat(name, one_of(merc_syl_closing));
strcat(name, one_of(merc_syl_open));
}
else {
strcat(name, one_of(merc_syl_opening));
strcat(name, one_of(merc_syl_open));
}
}

free(GET_MNAME(merc));
free(GET_MSHORT(merc));
free(GET_MLONG(merc));

sprintf(buf, "mercenary %s", name);
GET_MNAME(merc) = strdup(buf);
sprintf(buf, "%s the Mercenary", CAP(name));
GET_MSHORT(merc) = strdup(buf);
sprintf(buf, "%s is here.\r\n", GET_MSHORT(merc));
GET_MLONG(merc) = strdup(buf);

free(name);
}

}
07 Sep, 2012, Hades_Kane wrote in the 11th comment:
Votes: 0
Idealiad said:
Here's a nice one:

https://bitbucket.org/jice/libtcod/src/0...

and

https://bitbucket.org/jice/libtcod/src/0...

There might be libtcod library parsing functions in namegen_c.c you'll have to reimplement/copy, but most of the work is done for you and it's quite flexible.


It looks like it'd be nice, but there are so many errors kicking up from this thing and many of them things I can't understand why they are kicking up errors.

How's it going to tell me there's no semi colon at the end of a line I'm looking at… that ends in a semi colon?

I'm hitting with a blunt hammer best I can, but this appears to be far beyond my capability to make any sense out of.

I appreciate the suggestions, still seeing if I can do much with any of them.
07 Sep, 2012, Hades_Kane wrote in the 12th comment:
Votes: 0
plamzi said:
I like rolling my own because I can fine-tune the sound of the resulting name. I'm using several versions of a syllable-based function to make sure that mercenary names have a different flavor from pet names, etc.

In the function I'm sharing, the variations are intentionally somewhat limited–that way if someone likes a mercenary name they've generated, they can re-generate it in 3-400 rolls :) But more combinations can be added.

There are a few assumptions below that are different from stock DIKU. The most important is that the strings being modified don't point to the prototype (template). In order to use this in codebases that use mob prototypes, you'd have to add a few lines to modify those strings safely.


This definitely looks like something I can manage to work with…. gonna play around with it a bit and see if I can get it to do what I'm trying. Thanks :D

edit to add:
If I get this working the way I want to, I'm going to attempt to add in different "types" of names similar to what Idealiad linked… I'll report back with my progress.
07 Sep, 2012, Hades_Kane wrote in the 13th comment:
Votes: 0
It could probably be better written, and I'm sure there's some redundancy in some of the code here, but this is what I did with the code plamzi shared:

I use tab in my code editor, so the formatting is a bit funky…

int size_of(char *arr[])
{
int size = 0;
while (arr[size] != NULL) size++;
return size;
}

char *one_of(char *arr[])
{
return arr[number_range(0, size_of(arr)-2)];
}

/* Code derived from Bedlam's mercenary random personal names by Diablos of/for End of Time (eotmud.com:4000) */
char *generate_name(int gender, int type)
{
static char *standard_syl_closed[] = { "gob", "gup", "gad", "got", "dan", "sil", "ban", "vig", "zom", "rak", "dob", "mag", "tog", "vat", "gam",
"bok", "jok", "rok", "mek", "dim", "ris", "tok", "tan", "tor", "mar", "mor", "vig", "rem",
"sal", "sel", "les", "rit", "vel", "vir", "lin", "don", "dar", "dir", "mir", "lir",
"ties", "mael", "fein", "man", "fin", "dyr", "lyr", "nyr", "vyr", NULL };
static char *standard_syl_open[] = { "ara", "arca", "anka", "eva", "ena", "ega", "oma", "ik", "era", "ida",
"oda", "ami", "oka", "ipa", "ina", "osa", "abi", "ea", "ai", "amai",
"ata", "isa", "ira", "ara", "ala", "ela", "ula", "asa", "esa", "eta", NULL };
static char *standard_syl_edge[] = { "p", "n", "m", "k", "s", "t", "u", "z", "r", "b", "g", "l", "t", "f", "x", NULL };
static char *standard_syl_opening[] = { "sa", "mi", "fa", "li", "fe", "si", "bri", "ty", "ly", NULL };
static char *standard_syl_closing[] = { "af", "ip", "es", "il", "am", "in", "an", "ir", "el", "et", "yl", NULL };

static char *fantasy_syl_closed[] = { "ban", "bar", "cut", "dan", "dar", "del", "der", "fin", "jed", "kan", "kar", "ker", "mar", "mer", "van", "var", "tyr",
"bet", "cut", "tor", "ris", "tok", "vel", "lin", "lyr", "vyr", "beth", "bett", "dell", "kurr", "tsal", "tser", "tsir", NULL };
static char *fantasy_syl_open[] = { "ina", "ala", "aelle", "oro", "ara", "ona", "ola", "asa", "ora", "aera", "ana", NULL };
static char *fantasy_syl_edge[] = { "l", "n", "r", "s", "m", "w", "x", "d", NULL };
static char *fantasy_syl_opening[] = { "ly", "we", "la", "fa", "ja", "jo", "mo", "lo", "de", "da", NULL };
static char *fantasy_syl_closing[] = { "an", "ar", "or", "al", "en", "eo", "el", "ol", "ess", "in", "il", NULL };

static char *norse_syl_closed[] = { "nid", "heim", "far", "mir", "nar", "nir", "rir", "sil", "sir", "ttir", "gud", "hag", "jot", "jut", "tun", "var", "tys", "vol", "ygg",
"nar", "din", "tal", "gar", NULL };
static char *norse_syl_open[] = { "ala", "ae", "ali", "iva", "aea", "ana", "oda", "odi", "olu", NULL };
static char *norse_syl_edge[] = { "h", "g", "v", "t", "r", "d", "n", "s", "n", NULL };
static char *norse_syl_opening[] = { "bi", "fe", "ha", "jo", "ma", "mu", "nu", "ta", "va", "vo", "da", NULL };
static char *norse_syl_closing[] = { "ad", "ald", "agr", "ar", "ard", "eyr", "far", "heim", "ar", "ir", "urd", "an", "yr", "al", "in", "agg", NULL };

static char *celtic_syl_closed[] = { "dan", "del", "mor", "nem", "rig", "ren", "fig", "nan", "lun", "leg", "fyn", "lyn", "myn", "tal", "wyn", "del", "ker", "wyr",
"kyn", "kel", "kyl", "cil", "cal", NULL };
static char *celtic_syl_open[] = { "ae", "ela", "ora", "io", "ama", "eka", "oka", "ala", "ola", NULL };
static char *celtic_syl_edge[] = { "r", "g", "k", "l", "w", "y", "f", NULL };
static char *celtic_syl_opening[] = { "ra", "ka", "la", "fi", "so", "re", "do", "li", "io", "nae", "fae", "mae", "tae", NULL };
static char *celtic_syl_closing[] = { "ig", "ach", "eth", "ed", "em", "og", "or", "orn", "yn", "gus", "aid", "ain", "an", NULL };

static char *dwarven_syl_closed[] = { "bom", "dar", "gar", "gim", "jor", "kil", "mar", "nal", "ras", "ren", "tar", "tel", "wer", "von", "wer", "yur",
"rok", "nok", "lok", "fon", "fin", "nik", "rit", "tin", "vad", "fun", "tal", "vad", NULL };
static char *dwarven_syl_open[] = { "aka", "ara", "ono", "efa", "uga", "uri", "uda", NULL };
static char *dwarven_syl_edge[] = { "k", "r", "t", "n", "y", "s", NULL };
static char *dwarven_syl_opening[] = { "ga", "da", "ra", "ka", "ty", "ry", "gu", NULL };
static char *dwarven_syl_closing[] = { "et", "ur", "ek", "al", "as", "ar", NULL };


char *name;
int number = 0;

number = number_range(1,3);

name = strdup("");

if (gender == 1)
{
if (number == 3)
{
if(type == 1) // standard
{
strcat(name, one_of(standard_syl_open));
strcat(name, one_of(standard_syl_edge));
strcat(name, one_of(standard_syl_closing));
}
else if(type == 2) // fantasy
{
strcat(name, one_of(fantasy_syl_open));
strcat(name, one_of(fantasy_syl_edge));
strcat(name, one_of(fantasy_syl_closing));
}
else if(type == 3) // norse
{
strcat(name, one_of(norse_syl_open));
strcat(name, one_of(norse_syl_edge));
strcat(name, one_of(norse_syl_closing));
}
else if(type == 4) // celtic
{
strcat(name, one_of(celtic_syl_open));
strcat(name, one_of(celtic_syl_edge));
strcat(name, one_of(celtic_syl_closing));
}
else if(type == 5) // dwarven
{
strcat(name, one_of(dwarven_syl_open));
strcat(name, one_of(dwarven_syl_edge));
strcat(name, one_of(dwarven_syl_closing));
}
}
else if (number == 2)
{
if(type == 1) // standard
{
strcat(name, one_of(standard_syl_closing));
strcat(name, one_of(standard_syl_open));
strcat(name, one_of(standard_syl_edge));
}
else if(type == 2) // fantasy
{
strcat(name, one_of(fantasy_syl_closing));
strcat(name, one_of(fantasy_syl_open));
strcat(name, one_of(fantasy_syl_edge));
}
else if(type == 3) // norse
{
strcat(name, one_of(norse_syl_closing));
strcat(name, one_of(norse_syl_open));
strcat(name, one_of(norse_syl_edge));
}
else if(type == 4) // celtic
{
strcat(name, one_of(celtic_syl_closing));
strcat(name, one_of(celtic_syl_open));
strcat(name, one_of(celtic_syl_edge));
}
else if(type == 5) // dwarven
{
strcat(name, one_of(dwarven_syl_closing));
strcat(name, one_of(dwarven_syl_open));
strcat(name, one_of(dwarven_syl_edge));
}
}
else
{
if(type == 1) // standard
{
if (number == 1) strcat(name, one_of(standard_syl_edge));
strcat(name, one_of(standard_syl_open));
if (number == 3)
strcat(name, one_of(standard_syl_closed));
else
strcat(name, one_of(standard_syl_edge));
}
else if(type == 2) // fantasy
{
if (number == 1) strcat(name, one_of(fantasy_syl_edge));
strcat(name, one_of(fantasy_syl_open));
if (number == 3)
strcat(name, one_of(fantasy_syl_closed));
else
strcat(name, one_of(fantasy_syl_edge));

}
else if(type == 3) // norse
{
if (number == 1) strcat(name, one_of(norse_syl_edge));
strcat(name, one_of(norse_syl_open));
if (number == 3)
strcat(name, one_of(norse_syl_closed));
else
strcat(name, one_of(norse_syl_edge));

}
else if(type == 4) // celtic
{
if (number == 1) strcat(name, one_of(celtic_syl_edge));
strcat(name, one_of(celtic_syl_open));
if (number == 3)
strcat(name, one_of(celtic_syl_closed));
else
strcat(name, one_of(celtic_syl_edge));

}
else if(type == 5) // dwarven
{
if (number == 1) strcat(name, one_of(dwarven_syl_edge));
strcat(name, one_of(dwarven_syl_open));
if (number == 3)
strcat(name, one_of(dwarven_syl_closed));
else
strcat(name, one_of(dwarven_syl_edge));

}
}
}
else
{
if (number == 3)
{
if(type == 1) // standard
{
strcat(name, one_of(number == 1?standard_syl_closed:standard_syl_edge));
strcat(name, one_of(standard_syl_open));
}
else if(type == 2) // fantasy
{
strcat(name, one_of(number == 1?fantasy_syl_closed:fantasy_syl_edge));
strcat(name, one_of(fantasy_syl_open));
}
else if(type == 3) // norse
{
strcat(name, one_of(number == 1?norse_syl_closed:norse_syl_edge));
strcat(name, one_of(norse_syl_open));
}
else if(type == 4) // celtic
{
strcat(name, one_of(number == 1?celtic_syl_closed:celtic_syl_edge));
strcat(name, one_of(celtic_syl_open));
}
else if(type == 5) // dwarven
{
strcat(name, one_of(number == 1?dwarven_syl_closed:dwarven_syl_edge));
strcat(name, one_of(dwarven_syl_open));
}
}
else if (number == 2)
{
if(type == 1) // standard
{
strcat(name, one_of(standard_syl_opening));
strcat(name, one_of(standard_syl_edge));
strcat(name, one_of(standard_syl_open));
}
else if(type == 2) // fantasy
{
strcat(name, one_of(fantasy_syl_opening));
strcat(name, one_of(fantasy_syl_edge));
strcat(name, one_of(fantasy_syl_open));
}
else if(type == 3) // norse
{
strcat(name, one_of(norse_syl_opening));
strcat(name, one_of(norse_syl_edge));
strcat(name, one_of(norse_syl_open));
}
else if(type == 4) // celtic
{
strcat(name, one_of(celtic_syl_opening));
strcat(name, one_of(celtic_syl_edge));
strcat(name, one_of(celtic_syl_open));
}
else if(type == 5) // dwarven
{
strcat(name, one_of(dwarven_syl_opening));
strcat(name, one_of(dwarven_syl_edge));
strcat(name, one_of(dwarven_syl_open));
}
}
else if (number == 1)
{
if(type == 1) // standard
{
strcat(name, one_of(standard_syl_edge));
strcat(name, one_of(standard_syl_closing));
strcat(name, one_of(standard_syl_open));
}
else if(type == 2) // fantasy
{
strcat(name, one_of(fantasy_syl_edge));
strcat(name, one_of(fantasy_syl_closing));
strcat(name, one_of(fantasy_syl_open));
}
else if(type == 3) // norse
{
strcat(name, one_of(norse_syl_edge));
strcat(name, one_of(norse_syl_closing));
strcat(name, one_of(norse_syl_open));
}
else if(type == 4) // celtic
{
strcat(name, one_of(celtic_syl_edge));
strcat(name, one_of(celtic_syl_closing));
strcat(name, one_of(celtic_syl_open));
}
else if(type == 5) // dwarven
{
strcat(name, one_of(dwarven_syl_edge));
strcat(name, one_of(dwarven_syl_closing));
strcat(name, one_of(dwarven_syl_open));
}
}
else
{
if(type == 1) // standard
{
strcat(name, one_of(standard_syl_opening));
strcat(name, one_of(standard_syl_open));
}
else if(type == 2) // fantasy
{
strcat(name, one_of(fantasy_syl_opening));
strcat(name, one_of(fantasy_syl_open));
}
else if(type == 3) // norse
{
strcat(name, one_of(norse_syl_opening));
strcat(name, one_of(norse_syl_open));
}
else if(type == 4) // celtic
{
strcat(name, one_of(celtic_syl_opening));
strcat(name, one_of(celtic_syl_open));
}
else if(type == 5) // dwarven
{
strcat(name, one_of(dwarven_syl_opening));
strcat(name, one_of(dwarven_syl_open));
}
}
}
return capitalize(name);
}

void do_genname( CHAR_DATA *ch, char *argument )
{
char arg1[MAX_INPUT_LENGTH];
char arg2[MAX_INPUT_LENGTH];
char arg3[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char output[MAX_STRING_LENGTH];
int gender = 0;
int type = 0;
int count = 0;
int number = 0;

argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
argument = one_argument( argument, arg3 );

if ( arg1[0] == '\0')
{
gender = number_range(1,2);
}
else
{
if(!is_number(arg1))
{
if(!str_cmp(arg1,"male"))
gender = 1;
else if(!str_cmp(arg1,"female"))
gender = 2;
else
{
send_to_char("That is not a valid gender.\r\n1 = male, 2 = female\r\n",ch);
return;
}
}
else
gender = atoi(arg1);
if(gender < 1 || gender > 2)
{
send_to_char("That is not a valid gender.\r\n1 = male, 2 = female\r\n",ch);
return;
}
}
if ( arg2[0] == '\0')
{
type = number_range(1,5);
}
else
{
if(is_number(arg2))
type = atoi(arg2);
else
{
if(!str_prefix(arg2,"standard"))
type = 1;
else if(!str_prefix(arg2,"fantasy"))
type = 2;
else if(!str_prefix(arg2,"norse"))
type = 3;
else if(!str_prefix(arg2,"celtic"))
type = 4;
else if(!str_prefix(arg2,"dwarven") || !str_prefix(arg2,"dwarf") )
type = 5;
else
{
send_to_char("That is not a valid type.\r\n1 = standard, 2 = fantasy, 3 = norse, 4 = celtic, 5 = dwarven\r\n",ch);
return;
}
}
if(type < 1 || type > 5)
{
send_to_char("That is not a valid type.\r\n1 = standard, 2 = fantasy, 3 = norse, 4 = celtic, 5 = dwarven\r\n",ch);
return;
}
}

buf2[0] = '\0';
output[0] = '\0';
if ( arg3[0] != '\0' && is_number(arg3))
{
number = atoi(arg3);
if(number > 20)
{
send_to_char("That number is too high, defaulting to 20 names.\r\n",ch);
number = 20;
}
if(number < 1)
number = 1;
for (count = 0; count < number; count++)
{
sprintf(output,"%s%s",generate_name(gender, type), number > 1 ? " " : "");
strcat(buf2,output);
}
sprintf(buf,"Random %s Name%s: %s\r\n",gender == 1 ? "Male" : "Female",number > 1 ? "s" : "",buf2);
}
else
sprintf(buf,"Random %s Name: %s\r\n",gender == 1 ? "Male" : "Female",generate_name(gender, type));
send_to_char(buf,ch);
return;
}


Here are some of the results:

genname male standard 20

Random Male Names: Tevaf Amaiuil Fatal Ilalam Amairip Elarag Kelaz Tisap Ilalal Etodat Amairam Nokat Okasaf Afarat Irodar Sulaz Tipal Kodal Arcazir Enazin


genname female fantasy 20

Random Female Names: Delina Xora Xola Lasina Faxola Larara Wala Waraera Nalaera Mowala Salaelle Saelle Sasa Welaelle Roro Monina Wenala Wemora Mola Dewala


genname male norse 20

Random Male Names: Todid Ivaturd Odinard Rodig Alateyr Inalat Rodih Alival Anadard Tivag Saev Odaran Eyrodid Haes Ralit Aralan Ralih Ivaheyr Alavar Hivad


genname female celtic 20

Random Female Names: Fiwela Fiwama Yigio Kayama Yora Gala Regela Rekora Kora Lirela Weka Rachio Wemala Naeroka Liwala Gama Lemela Dorama Naelela Kala


genname male dwarven 20

Random Male Names: Ekefak Ronor Uriket Rakay Uganek Asugak Refat Ugakas Asugay Eturin Uritas Urinet Urugak Urirek Nefak Kurin Konot Urarar Urarak Akarur


I was rather amused at one point when "Aesir" popped up as a Nordic name. I'll likely continue to fine tune this, but it's a great start, and I really appreciate the help that was provided.

plamzi, any other additional "derived from Bedlam" notes or info you'd like me to keep with this code? Also, how would you feel about me releasing this as a snippet for ROM (and if you are okay with this, what information you would like me to include with it)?
07 Sep, 2012, plamzi wrote in the 14th comment:
Votes: 0
Hades_Kane said:
I was rather amused at one point when "Aesir" popped up as a Nordic name. I'll likely continue to fine tune this, but it's a great start, and I really appreciate the help that was provided.

plamzi, any other additional "derived from Bedlam" notes or info you'd like me to keep with this code? Also, how would you feel about me releasing this as a snippet for ROM (and if you are okay with this, what information you would like me to include with it)?


My favorite from what you posted has to be "Ivaturd". I've a turd. Get it?

I'm fine with releasing it as a snippet, sure. Would be nice to add a link to bedlam.gotdns.com:9000 in the credits.

I wouldn't spend too much time polishing this, either. It's "dumb" code, and it's in C. Future generations will surely forgive us.
07 Sep, 2012, Hades_Kane wrote in the 15th comment:
Votes: 0
plamzi said:
Hades_Kane said:
I was rather amused at one point when "Aesir" popped up as a Nordic name. I'll likely continue to fine tune this, but it's a great start, and I really appreciate the help that was provided.

plamzi, any other additional "derived from Bedlam" notes or info you'd like me to keep with this code? Also, how would you feel about me releasing this as a snippet for ROM (and if you are okay with this, what information you would like me to include with it)?


My favorite from what you posted has to be "Ivaturd". I've a turd. Get it?

I'm fine with releasing it as a snippet, sure. Would be nice to add a link to bedlam.gotdns.com:9000 in the credits.

I wouldn't spend too much time polishing this, either. It's "dumb" code, and it's in C. Future generations will surely forgive us.


Was the "polishing" comment intentional?

Ivaturd
I've a turd
polishing
polishing a turd
Get it :p

But yeah, I'll be sure to throw in a link to bedlam in the credits. I'll probably upload it later tonight.

Thanks!

It's a silly little tool, but something I always thought would be handy to have for building mobs and for players who have exhausted their creativity on new characters.
07 Sep, 2012, Hades_Kane wrote in the 16th comment:
Votes: 0
Snippet uploaded, and I also have it working in my login sequence too, now! :D
08 Sep, 2012, plamzi wrote in the 17th comment:
Votes: 0
Hades_Kane said:
Snippet uploaded, and I also have it working in my login sequence too, now! :D


Cool. Good job on the different flavors of syllables, by the way. The dwarven ones are especially nice.
08 Sep, 2012, Lyanic wrote in the 18th comment:
Votes: 0
I am contemplating stealing some of the syllables, but the code makes me cringe in terror. No offense.
11 Sep, 2012, KaVir wrote in the 19th comment:
Votes: 0
I usually look at this issue from the other direction - rather than generating new names based on specific criteria, I like to analyse existing names. In fact my first ever public snippet was an automated naming policy checker, designed to verify that names are pronouncable, avoid offensive terms, and are appropriate to the character's race. More recently I implemented a feature that guesses your gender based on your name.

In theory such a system could be used for random names as well, generating a huge number of names, filtering them, and then splitting them into appropriate categories. You wouldn't want to do this on the fly, but it could be used to generate extensive tables of default names. Whether this would actually be worthwhile or not is rather debatable, but I think it would be an interesting experiment.

But for just generating a random name, I'd probably keep things simple:

char *GenerateName( void )
{
static char Result[128];
static const char *StartTable[] = { "Ra", "Ka", "Ash", "Mys", "Vin", "Bre", "Pol", "Nys", "Cal", "Wi", "Zi", NULL };
static const char *MiddleTable[] = { "", "", "", "", "", "san", "der", "jar", "zen", "shan", "ston", "peth", NULL };
static const char *EndTable[] = { "nar", "ia", "ith", "ion", "eth", "oth", "un", "eon", NULL };
static int MaxStart = 0, MaxMiddle = 0, MaxEnd = 0;
if ( !MaxStart ) {
for ( MaxStart = 0; StartTable[MaxStart] != NULL; ++MaxStart );
for ( MaxMiddle = 0; MiddleTable[MaxMiddle] != NULL; ++MaxMiddle );
for ( MaxEnd = 0; EndTable[MaxEnd] != NULL; ++MaxEnd );
}
sprintf( Result, "%s%s%s", StartTable[NumberRange(0,MaxStart-1)],
MiddleTable[NumberRange(0,MaxMiddle-1)], EndTable[NumberRange(0,MaxEnd-1)]);
return Result;
}
Random Picks
0.0/19