Here's an example of my random name generator. So far it only
creates 30 names. When I finally release the beta for my game it
will create 100. You only get 5 troops from a choice of 15, so
there is a very good chance of getting a unique squad with each
new game (the game is designed to provide long gameplay, so
you'll not likely be starting a ton of new games anyway, but
advancing a saved game).

I'm using the same algorithms to generate random skills and
attributes for each trooper. So you and nine of your friends could
all start new games and get 10 original, unique sets of troops.

Let me know what you think.

04-10-2002

jdinger

1 Attachment(s)

OK, for some strange reason the attachment didn't work?

Attempt #2:

04-10-2002

blight2c

any chance i can see the code, i wouldn't understand the windows stuff, but just the funciton

it's cool though . . it does what it's suppose to. i'll be more impressed if i can see the code i mean

04-10-2002

ErionD

Hehe i got a guy named Mark Marks =)
Anyway, its really cool!

04-11-2002

jdinger

Quote:

any chance i can see the code, i wouldn't understand
the windows stuff, but just the funciton

Sure. Here's the code with added comments leaving out most of
the windows only stuff:

Code:

//in the global declares
//the cName struct, simply used to hold a name segment and
//has a flag to show if it's already been used.
struct cName
{
char cNameSeg[40];
bool bUsed;
};

//need 3 of these, 1 for list of first names, 1 for list of last names
//and 1 for the amalgamated full names
cName fName[30], lName[30], wName[30];

//fill the cNameSeg members with data
strcpy(fName[0].cNameSeg,"Jason");
strcpy(fName[1].cNameSeg,"Bill");
//etc. etc. etc.
//currently this is a long list of strcpy's. today I'm modifying it
//so that it writes the 200 structs (100 fName, 100 lName) to
//a file and then reads them back in at run-time.

//reset the whole name counter
iName=0;
//randomize based on time
srand((unsigned)time(NULL));