Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstdlib>
- #include <ctime>
- #include <chrono>
- #include <thread>
- using namespace std;
- float exp, pdmg, mdmg, nmdmg;
- int decision, mhp, php, itm, gmvr;
- int pot, clns, tp, usg;
- void attack(),defend(),item(),dn(),run(),spell();
- void delay(int millisecond), crit();
- int main() {
- srand (time(NULL));
- pdmg = rand() % 25 + 5;
- mdmg = rand() % 20 + 15;
- nmdmg = rand() % 10 + 5;
- mhp = rand() % 35 + 65;
- php = 100;
- exp = rand() % 15 + 35;
- pot = rand() % 15 + 35;
- cout << "You encounter an orc, in the middle of the dungeon.\n";
- delay(1000);
- cout << "What do you do?\n";
- delay(1000);
- cout << "HEALTH: " << php << " MONSTER HEALTH: " << mhp;
- delay(500);
- bool condition = true;
- while (condition) {
- cout << "\n\n Attack (1)\n Defend (2)\n Item (3)\n Spell (4)\n Do nothing (5)\n Run away (6)\n";
- cin >> decision;
- switch (decision) {
- case 1:
- attack();
- break;
- case 2:
- defend();
- break;
- case 3:
- item();
- break;
- case 4:
- spell();
- break;
- case 5:
- dn();
- break;
- case 6:
- run();
- break;
- }
- if (mhp <= 0) {
- cout << "\n Orc has been defeated! gained " << exp << " xp.";
- return 0;
- }
- if (php <= 0) {
- cout << "\n Game Over. Would you like to try again?\n";
- string gmvr;
- cin >> gmvr;
- }
- if (mdmg > 35) {
- crit();
- break;
- }
- }
- }
- void attack() {
- cout << "You attack the orc, dealing " << pdmg << " damage.\n";
- mhp = mhp - pdmg;
- php = php - mdmg;
- delay(500);
- cout << "HEALTH: " << php << " MONSTER HEALTH: " << mhp;
- }
- void defend() {
- cout << "You defend the orc's attack. You take " << nmdmg << " damage.\n";
- php = php - nmdmg;
- delay(500);
- cout << "HEALTH: " << php << " MONSTER HEALTH: " << mhp;
- }
- void item() {
- cout << "What item would you like to use?\n";
- cout << "Potions (1)\n Cleansers (2)\n Teleport Scroll (3)\n";
- cin >> itm;
- switch (itm) {
- case 1:
- if (php == 100) {
- cout << "You are at full health.\n";
- break;
- }
- else if (php >= 75) {
- cout << "You drank a potion, healing " << pot << " health.\n";
- php = php + pot;
- delay(500);
- cout << "The orc attacks you while you were drinking the potion, dealing " << mdmg << " damage.\n";
- delay(500);
- php = php - mdmg;
- cout << "HEALTH: " << php << " MONSTER HEALTH: " << mhp;
- break;
- }
- else if (php <= 75) {
- cout << "You drank a potion, healing " << pot << " health.\n";
- php = php + pot;
- delay(500);
- cout << "HEALTH: " << php << " MONSTER HEALTH: " << mhp;
- break;
- }
- case 2:
- cout << "You cant use that right now.\n";
- delay(500);
- break;
- case 3:
- cout << "You cant use that right now.\n";
- delay(500);
- break;
- }
- }
- void spell() {
- }
- void dn() {
- }
- void run() {
- }
- void crit() {
- }
- void delay(int millisecond)
- {
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement