I'm trying to make a text RPG and I want weapons to do a range of damage. For example, a short sword would do 2-6 damage. To do this, I want to use 2 variables, W & WV. W is for weapon and WV is for weapon variance (or variability, or some other word starting with v...). This is my basic damage formula for a weapon dealing 2-6 damage:
code:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
int damage();
int w,wv;
w=2
wv=4;
int damage()
{
int dam;
dam=srand(wv)+w;//this is the line I'm not sure of
return dam;
}
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Thats how I want to do it, generate a number from 0-4, then add 2 to it, thus dealing 2-6 damage. I've gotten something like that to work, its just that the number won't change each time it is called. I want to do a similar thing for thac0, but I'll do that once I know how to make random numbers that change each time they are called.
Thanks,
napKIN