Advertisement
Guest User

DOS RPG Test

a guest
Apr 20th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #include <chrono>
  6. #include <thread>
  7. using namespace std;
  8. float exp, pdmg, mdmg, nmdmg;
  9. int decision, mhp, php, itm, gmvr;
  10. int pot, clns, tp, usg;
  11. void attack(),defend(),item(),dn(),run(),spell();
  12. void delay(int millisecond), crit();
  13. int main() {
  14.    
  15.     srand (time(NULL));
  16.     pdmg = rand() % 25 + 5;
  17.     mdmg = rand() % 20 + 15;
  18.     nmdmg = rand() % 10 + 5;
  19.     mhp = rand() % 35 + 65;
  20.     php = 100;
  21.     exp = rand() % 15 + 35;
  22.     pot = rand() % 15 + 35;
  23.    
  24.     cout << "You encounter an orc, in the middle of the dungeon.\n";
  25.     delay(1000);
  26.     cout << "What do you do?\n";
  27.     delay(1000);
  28.     cout << "HEALTH: " << php << " MONSTER HEALTH: " << mhp;
  29.     delay(500);
  30.         bool condition = true;
  31.     while (condition) {
  32.     cout << "\n\n Attack (1)\n Defend (2)\n Item (3)\n Spell (4)\n Do nothing (5)\n Run away (6)\n";
  33.     cin >> decision;
  34.     switch (decision) {
  35.         case 1:
  36.             attack();
  37.             break;
  38.            
  39.         case 2:
  40.             defend();
  41.             break;
  42.            
  43.         case 3:
  44.             item();
  45.             break;
  46.            
  47.         case 4:
  48.             spell();
  49.             break;
  50.         case 5:
  51.             dn();
  52.             break;
  53.        
  54.         case 6:
  55.             run();
  56.             break;
  57.             }
  58.         if (mhp <= 0) {
  59.         cout << "\n Orc has been defeated! gained " << exp << " xp.";
  60.         return 0;
  61.         }
  62.     if (php <= 0) {
  63.         cout << "\n Game Over. Would you like to try again?\n";
  64.         string gmvr;
  65.         cin >> gmvr;
  66.         }  
  67.     if (mdmg > 35) {
  68.         crit();
  69.         break;
  70.     }
  71.     }
  72. }
  73. void attack() {
  74.                 cout << "You attack the orc, dealing " << pdmg << " damage.\n";
  75.             mhp = mhp - pdmg;
  76.             php = php - mdmg;
  77.             delay(500);
  78.             cout << "HEALTH:  " << php << " MONSTER HEALTH:  " << mhp;
  79.             }
  80. void defend() {
  81.                 cout << "You defend the orc's attack. You take " << nmdmg << " damage.\n";
  82.                 php = php - nmdmg;
  83.                 delay(500);
  84.                 cout << "HEALTH:  " << php << " MONSTER HEALTH:  " << mhp;
  85.     }
  86. void item() {
  87.     cout << "What item would you like to use?\n";
  88.     cout << "Potions (1)\n Cleansers (2)\n Teleport Scroll (3)\n";
  89.     cin >> itm;
  90.     switch (itm) {
  91.         case 1:
  92.             if (php == 100) {
  93.                 cout << "You are at full health.\n";
  94.                 break;
  95.             }
  96.             else if (php >= 75) {
  97.                 cout << "You drank a potion, healing " << pot << " health.\n";
  98.                 php = php + pot;
  99.                 delay(500);
  100.                 cout << "The orc attacks you while you were drinking the potion, dealing " << mdmg << " damage.\n";
  101.                 delay(500);
  102.                 php = php - mdmg;
  103.                 cout << "HEALTH: " << php << " MONSTER HEALTH: " << mhp;
  104.                 break;
  105.             }
  106.             else if (php <= 75) {
  107.                 cout << "You drank a potion, healing " << pot << " health.\n";
  108.                 php = php + pot;
  109.                 delay(500);
  110.                     cout << "HEALTH: " << php << " MONSTER HEALTH: " << mhp;
  111.                     break;
  112.                
  113.             }
  114.         case 2:
  115.             cout << "You cant use that right now.\n";
  116.             delay(500);
  117.             break;
  118.            
  119.         case 3:
  120.             cout << "You cant use that right now.\n";
  121.             delay(500);
  122.             break;
  123.            
  124.     }
  125. }
  126. void spell() {
  127.    
  128. }
  129. void dn() {
  130. }
  131. void run() {
  132. }
  133. void crit() {
  134.    
  135. }
  136. void delay(int millisecond)
  137. {
  138.         std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement