4rl3fd

D3

Jul 23rd, 2021 (edited)
816
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <string>
  5. #include <unistd.h>
  6.  
  7. using namespace std;
  8.  
  9. int php = 5; //player health
  10. int location; //player location(must be between 1 and 100)
  11.  
  12. /*
  13. locations:
  14. key for chest can be found between 25 and 50
  15. chest can randomly appear anywhere between 80 and 95
  16. */
  17.  
  18. bool haskey = false;
  19. bool hastalisman = false;
  20. bool hasheal = false;
  21. int d1;
  22. int d2;
  23. int movement; //how many tiles will you move
  24. int dec1; //for decision making
  25. string name;
  26. int stage = 1;//stage 1: get to door, stage 2: find chest for talisman, stage 3: find key, stage 4: get talisman, stage 5: leave dungeon
  27. int chance;
  28. string dunname;
  29. int points = 0;
  30. int walks = 0;
  31. int heals = 0;
  32. int hits = 0;
  33. int picks = 0;
  34.  
  35. int main();
  36.  
  37. void lose()
  38. {
  39.     points = (walks - heals) -hits;
  40.     system("clear");
  41.     cout << "YOU LOST" << endl;
  42.     cout << "AND SO, " << name << " HAS DIED IN THE DUNGEON OF " << dunname << endl;
  43.     cout << name << " HAS WALKED A DISTANCE OF " << walks << " AND HAS HEALED " << heals <<  " TIMES AND" << endl;
  44.     cout << "GOT HIT BY TRAPS " << hits << " TIMES AND PICKED UP " << picks << " LOOT" << endl;
  45.     cout << "END SCORE >>> " << points << endl;
  46.     cout << "PRESS ANY NUMBER THEN ENTER TO CONTINUE" << endl;
  47.     cin >> dec1;
  48.     cout << "RESTARTING GAME..." << endl;
  49.     php =5;
  50.     stage =1;
  51.     haskey =false;
  52.     hasheal = false;
  53.     hastalisman =false;
  54.     sleep(3);
  55.     system("clear");
  56.     main();
  57. }
  58.  
  59.  
  60. void winner()
  61. {
  62.     points = (walks - heals) -hits;
  63.     system("clear");
  64.      cout << "YOU WON" << endl;
  65.      cout << "END SCORE >>> " << points << endl;
  66.      cout << "PRESS ANY NUMBER THEN ENTER TO CONTINUE" << endl;
  67.     cin >> dec1;
  68.     cout << "RESTARTING GAME..." << endl;
  69.     php =5;
  70.     stage =1;
  71.     haskey =false;
  72.     hasheal = false;
  73.     hastalisman =false;
  74.     sleep(3);
  75.     system("clear");
  76.     main();
  77. }
  78.  
  79. int main()
  80. {
  81.     cout << "DEADLY DUNGEON OF DEATH"<< endl;
  82.     cout << "PLEASE ENTER YOUR NAME >> ";
  83.     cin >> name;
  84.     cout << endl;
  85.     cout << "PLEASE ENTER NAME OF DUNGEON >> ";
  86.     cin >> dunname;
  87.     cout << endl;
  88.     cout << "LOADING GAME..." << endl;
  89.     sleep(1);
  90.     cout << "YOU FIND YOURSELF IN THE DUNGEON OF " << dunname << endl;
  91.     cout << "YOU SEE A DOOR IN THE DISTANCE" << endl;
  92.     sleep(2);
  93.     stage =1;
  94.     game:
  95.         points = walks+picks -heals -hits;
  96.         if(php <= 0)
  97.         {
  98.             lose();
  99.         }
  100.  
  101.         system("clear");
  102.     srand(time(NULL));
  103.     d1 = (rand()%5) +1;
  104.     d2 = (rand()%5) +1;
  105.     movement = d1+d2;
  106.     if(stage == 1)
  107.     {
  108.         cout << "CURRENT GOAL: GET TO DOOR(POSITION 100)" << endl;
  109.     }
  110.     if(stage ==2)
  111.     {
  112.         cout << "CURRENT GOAL: FIND THE CHEST FOR THE TALISMAN(POSITION 80-95)" << endl;
  113.     }
  114.     if(stage ==3)
  115.     {
  116.         cout << "CURRENT GOAL: FIND THE KEY FOR THE CHEST(POSITION 25-50) " << endl;
  117.     }
  118.     if(stage ==4)
  119.     {
  120.         cout << "CURRENT GOAL: FIND THE CHEST(POSITION 80-95)" << endl;
  121.     }
  122.     if(stage == 5)
  123.     {
  124.         cout << "CURRENT GOAL: LEAVE THROUGH THE DOOR (POSITION 100)" << endl;
  125.     }
  126.  
  127.     cout << "DISTANCE WALKED>> " << walks << endl;
  128.     cout << "ITEMS PICKED UP>> " << picks << endl;
  129.     cout << "NUMBER OF TIMES HEALED>> " << heals << endl;
  130.     cout << "NUMBER OF TIMES GOT HIT>> " << hits << endl;
  131.     cout << endl;
  132.     cout << name << ">> " << php << endl;
  133.     cout << "TOTAL POINTS>> " << points << endl;
  134.     cout << endl;
  135.     cout << "CURRENT POSITION>> " << location << endl;
  136.     cout << endl;
  137.  
  138.     if(php != 3){
  139.     switch(rand()%10)
  140.     {
  141.     case 1:
  142.         cout << "YOU GOT HIT BY A TRAP!" << endl;
  143.         hits +=1;
  144.         sleep(1);
  145.         php -=1;
  146.         if(php <= 0)
  147.         {
  148.             lose();
  149.         }
  150.         break;
  151.     default:
  152.         break;
  153.     }
  154.     }
  155.  
  156.     trap:
  157.     if(hasheal == false && php < 5)
  158.     {
  159.         if(rand()% 100 < 50)
  160.         {
  161.         cout << "YOU SEE A HEALING POTION. IT MIGHT BE A TRAP, BUT IT COULD ALSO BE A POTION" << endl;
  162.         cout << "1) GET THE POTION 2)LEAVE THE POTION" << endl;
  163.         cin >> dec1;
  164.  
  165.         switch(dec1)
  166.         {
  167.         case 1:
  168.  
  169.             switch(rand()%5)
  170.             {
  171.             case 1:
  172.             case 2:
  173.                 cout << "YOU GOT A POTION!" << endl;
  174.                 picks +=1;
  175.                 hasheal = true;
  176.                 break;
  177.             default:
  178.                 cout << "IT WAS A TRAP" << endl;
  179.                 cout << "YOU LOST 1 HP" << endl;
  180.                 hits +=1;
  181.                 php -=1;
  182.                 if(php <= 0)
  183.         {
  184.             lose();
  185.         }
  186.                 break;
  187.             }
  188.             break;
  189.         case 2:
  190.             cout << "YOU LEAVE THE POTION" << endl;
  191.             break;
  192.         default:
  193.             cout << "PICK ONLY ONE OR TWO" << endl;
  194.             goto trap;
  195.             break;
  196.  
  197.         }
  198.  
  199.         }
  200.     }
  201.  
  202.     if(location >25 && location < 50 && haskey == false && stage == 3)
  203.     {
  204.         key:
  205.         cout << "YOU SEE A KEY. IT MAY BE A TRAP, BUT IT COULD ALSO BE A KEY" << endl;
  206.         cout << "1) GET KEY, 2) LEAVE KEY" << endl;
  207.         cin >> dec1;
  208.  
  209.         switch(dec1)
  210.         {
  211.         case 1:
  212.  
  213.             switch(rand()%5)
  214.             {
  215.             case 1:
  216.             case 2:
  217.                 cout << "YOU GOT A KEY!" << endl;
  218.                 cout << "GOAL UPDATED: GET THE TALISMAN" << endl;
  219.                 picks +=1;
  220.                 stage = 4;
  221.                 haskey = true;
  222.                 break;
  223.             default:
  224.                 cout << "IT WAS A TRAP" << endl;
  225.                 cout << "YOU LOST 1 HP" << endl;
  226.                 hits +=1;
  227.                 php -=1;
  228.                 if(php <= 0)
  229.         {
  230.             lose();
  231.         }
  232.                 break;
  233.             }
  234.             break;
  235.         case 2:
  236.             cout << "YOU LEAVE THE KEY" << endl;
  237.             break;
  238.         default:
  239.             cout << "PICK ONLY ONE OR TWO" << endl;
  240.             goto key;
  241.             break;
  242.  
  243.         }
  244.     }
  245.  
  246.         if(location > 80 && location < 95 && haskey == false && hastalisman == false && stage == 2)
  247.         {
  248.             system("clear");
  249.             cout << "YOU SEE A CHEST. UNFORTUNATELY YOU NEED A KEY TO OPEN IT" << endl;
  250.             cout << "GOAL UPDATED: FIND A KEY" << endl;
  251.             sleep(2);
  252.             stage =3;
  253.         }
  254.  
  255.  
  256.         if(location > 80 && location < 95 && haskey == true && hastalisman == false && stage == 4)
  257.         {
  258.             talis:
  259.             cout << "YOU SEE A CHEST. IT MAY BE A TRAP, BUT IT MAY ALSO CONTAIN THE TALISMAN" <<endl;
  260.             cout << "1) OPEN CHEST, 2) LEAVE CHEST" << endl;
  261.             cin >> dec1;
  262.  
  263.             switch(dec1)
  264.         {
  265.         case 1:
  266.  
  267.             switch(rand()%5)
  268.             {
  269.             case 1:
  270.             case 2:
  271.                 cout << "YOU GOT THE TALISMAN!" << endl;
  272.                 cout << "GOAL UPDATED: ESCAPE THE DUNGEON" << endl;
  273.                 picks +=1;
  274.                 stage =5;
  275.                 hasheal = true;
  276.                 sleep(2);
  277.                 break;
  278.             default:
  279.                 cout << "IT WAS A TRAP" << endl;
  280.                 cout << "YOU LOST 1 HP" << endl;
  281.                 hits +=1;
  282.                 php -=1;
  283.                 if(php <= 0)
  284.         {
  285.             lose();
  286.         }
  287.                 break;
  288.             }
  289.             break;
  290.         case 2:
  291.             cout << "YOU LEAVE THE CHEST" << endl;
  292.             break;
  293.         default:
  294.             cout << "PICK ONLY ONE OR TWO" << endl;
  295.             goto talis;
  296.             break;
  297.  
  298.         }
  299.  
  300.         }
  301.  
  302.         if (location == 100 && stage == 2&&stage ==3&& stage ==4)
  303.         {
  304.             cout << "YOU STILL DON'T HAVE THE TALISMAN" << endl;
  305.             sleep(2);
  306.         }
  307.  
  308.  
  309.         if(location ==100 && stage == 1)
  310.         {
  311.             cout << "YOU FINALLY REACH THE DOOR. IT'S LOCKED. YOU SEEM TO NEED A TALISMAN TO OPEN IT" << endl;
  312.             cout << "GOAL UPDATED: FIND THE CHEST THAT CONTAINS A TALISMAN" << endl;
  313.             stage = 2;
  314.             sleep(2);
  315.         }
  316.  
  317.  
  318.  
  319.     if(location == 100 && hastalisman == true && stage == 5)
  320.     {
  321.         system("clear");
  322.         cout << "YOU CAN FINALLY ESCAPE!" << endl;
  323.         cout << "YOU HAVE ESCAPED! GAME END" << endl;
  324.         sleep(5);
  325.         winner();
  326.     }
  327.  
  328.     heal:
  329.     cout << "PRESS ANY NUMBER THEN ENTER TO ROLL A DICE" << endl;
  330.     if(hasheal == true)
  331.     {
  332.         cout << "PRESS 0 TO HEAL" << endl;
  333.     }
  334.     cin >> dec1;
  335.     if(hasheal == true && dec1 == 0)
  336.     {
  337.         cout << "YOU HEALED 1 HP" << endl;
  338.         heals +=1;
  339.         sleep(2);
  340.         php += 1;
  341.         hasheal = false;
  342.         goto heal;
  343.     }
  344.     cout << "ROLLING DICE..." << endl;
  345.     sleep(1);
  346.     cout << "DICE 1>> " << d1 << endl;
  347.     cout << "DICE 2>> " << d2 << endl;
  348.     cout << "MOVE BY>> " << d1+d2 << endl;
  349.     mov:
  350.     cout << "WHICH DIRECTION DO YOU WANT TO MOVE?" << endl;
  351.     cout << "1) FORWARD, 2) BACKWARD" << endl;
  352.     cin >>dec1;
  353.     walks += (d1+d2);
  354.     switch(dec1)
  355.     {
  356.     case 1:
  357.         cout << "MOVING FORWARD" << endl;
  358.         location += movement;
  359.         break;
  360.     case 2:
  361.         cout << "MOVING BACKWARD" << endl;
  362.         location -= movement;
  363.         break;
  364.     default:
  365.         cout << "ONLY PICK 1 OR 2" << endl;
  366.         goto mov;
  367.     }
  368.     if(location > 100)
  369.     {
  370.         cout << "YOUR DICE ROLL IS TOO HIGH. REDUCING BY 12" << endl;
  371.         location -=12;
  372.         sleep(2);
  373.     }
  374.     if(location <= 0)
  375.     {
  376.         cout << "YOUR DICE ROLL IS TOO LOW. INCREASING BY 12" << endl;
  377.         location += 12;
  378.         sleep(2);
  379.     }
  380.  
  381.  
  382.     goto game;
  383. }
  384.  
RAW Paste Data