- Joined
- Jun 10, 2008
- Messages
- 117
- Reaction score
- 0
Hello, i am currently making a text RPG but for specific monsters i want their damage to be withing a certain range of number and then choose them randomly. Please help
what if i want it between like 13 and 20?
rand(min, max);
#include <iostream>
#include <cstdlib>
int main()
{
unsigned int max = 500, min = 100;
if ((max - min) > RAND_MAX)
{
std::cerr << "Range overflows the maximum of rand();\n";
}
while (1)
{
unsigned int random = (rand() % ((max - min) + 1))) + min;
std::cout << random << '\n';
}
//return 0;
}
case 1:
cout << "The walking Mushroom attacks!\n";
unsigned int UHP - (rand() * (8 - 2 - 1)) + 2;
cout << "You now have " << UHP << " Health Points left!\n";
system("pause");