Basically what I'm trying to do is simple.

My main problem is the random numbers, but in the comments i have some other issues...
if you know how to fix them that would be great the other two main ones im having trouble with are:

the do loop until the monsters health is 0,
and once the code ran, having the user press any key to go back to the starting fight menu.


back to the main problem:

based on the "monsters" level it will do a random amount of damage..
for example:

the monsters level is 3.

void fightd () {
     
            dwarf = 500;
     
              // do loop here, until the monsters health is <= 0
              system ("cls");
                  
                    if (health <= 0){
                    cout << "You have died." << endl; 
                    cout << "Returning to Main menu." << endl;
                    mainmenu();
                    }
                    else {
                         cout << "Your health is: " << health << endl << endl;
                         cout << "The Dwarf's heath is: " << dwarf << endl << endl << endl;
                         cout << "Do you want to: " << endl;
                         cout << "1. Fight." << endl;
                         cout << "2. Heal." << endl;
                         cout << "3. Go to Main menu." << endl;
                         cin >> choice;
                           if (choice == 1){
                              system ("cls");
                               cout <<  "You hit your enemy for: " <<  endl;
                               // will put random numbers between 1 and 20
                               // multiply this random number Strength
                               cout <<  "Your enemy hit you for:" <<  endl;
                               // will do random between 1 and 10
                               // multiply this by the monsters level
                               cout << "To continue fighing press any key." << endl;
                               // press any key code to go back to the main fighting menu.
                                 }
                           else if (choice == 2){
                                   system ("cls") ;
                                   cout << "You have chosen to heal." << endl;
                                   // random healing between 1 and 10
                                   // mana devided by 10
                                   // random healing multiplied by the 1/10th mana
                                   // add that number to health
                                   
                                    cout <<  "Your enemy hit you for:" <<  endl;
                                   // will do random between 1 and 10
                                   // multiply this by the monsters level
                                   // minus this from the health
                                   cout << "Your health is now: " << health << endl;
                                   cout << endl << endl;
                                   
                                   cout << "To continue fighing press any key." << endl;
                                   // press any key code to go back to the main fighting menu.
                                }
                           else if (choice == 3) mainmenu ();
                           else {
                                cout << "That is not a choice. please try again." << endl;
                                // will go back to the start of the loop again.
                                }
                             
                                 }
               
               }

it would be the same thing for the players damage against the monster.

Edited 6 Years Ago by skorm909: n/a

So turn your comments into code. We aren't a coding service, we help you fix your code that's wrong. Your code isn't wrong, it's non-existant.

Also, explain the problem you're having. All you say is your problem is with random numbers. I see nothing about random numbers in your code, just in comments.

sorry, well ignore the first code then.

what this was supposed to be about was, i couldn't find anything on how to make random numbers,
Ive heard that i need to use rand and srand but i don't know where i can learn to do these things.

Edited 6 Years Ago by skorm909: n/a

Try Googling those terms. It's been a while since you've posted, but I remember you were going through similar things before. Find the simplest example that does what you want and emulate it in a short test program (3-5 lines) and then integrate it into your work.

This article has been dead for over six months. Start a new discussion instead.