Ok, so you want a fight function. What does the function do? Break it down. Do you pass it to creatures who are going to fight? Do you pass it the weapons to be used in fighting? It really depends on how complex you want to make it.
Do you know what structures and classes are? If not, I'd suggest at least reading on the very basics of both. In short, they're a way to bundle variables (and functions, but ignore that for now) together. Like a suit case.
Then you could do something like this:
Code:
struct weapon
{
char name[20];
int mindam, maxdam;
char damagestring[40];
};
Then you could make an array of these items...
Code:
struct weapon theWeapons[] =
{
{ "sword", 1, 10, "***slashes***" },
{ "club", 2, 6, "**bludgeons**" },
{ "Schildt Book", 10000, 10000, ">>>TEACHES WRONG THINGS<<<" }
};
You could then do something like:
Code:
void fightitout( struct weapon *attacker, struct weapon *victim )
{
...do stuff with the weapons we pass...
}
...stuff...
/* Have a Schildt Book fight a club... */
fightitout( theWeapons[2], theWeapons[1] );
Now that's a crude example, and not just because I mention Schildt, but because I wouldn't really make a fight function take weapons as parameters. I'd make it take creatures instead...
But you get the idea.
Quzah.