Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <random>
- #include <chrono>
- #include <cmath>
- #include <stdio.h>
- struct Move {
- std::string move; // move name
- int base_dam; // base damage
- };
- struct Monster {
- std::string name;
- int lvl;
- int hp;
- int attack;
- int defence;
- int speed;
- Move moveset[4];
- };
- Monster rat{ "rat", 1 ,40 , 7 , 8 , 10, {{"Bite", 5}, {"Tail whip", 6}, {"Pounce", 9}} };
- Monster bat{ "bat", 1 ,50 , 6 , 4 , 13, {{"Wing attack", 7}, {"Sonic scream", 5}, {"Leech Life", 9}} };
- Monster imp{ "imp", 1 ,60 , 7 , 7 , 10, {{"Ember", 7}, {"Magic attack", 5}, {"Fire spin", 9}} };
- Monster kobold{ "kobold", 1 ,80, 18 , 15 , 18 , {{"Shortsword Slash", 10}, {"Sneak Attack", 15}, {"Quick Strike", 12}, {"Poison Dart", 14}} };
- Monster Goblin{ "Goblin" , 1, 60 , 10 , 13, 15, {{"Club Attack", 6 }, {"Heavy Attack", 9}, {"Head smash", 10}, {"slam", 7}} };
- Monster Skeleton{ "skeleton", 1 ,50 , 18 , 8 , 10, {{"Piercing arrow", 10 }, {"Poison arrow",10}, {"Bone arrow", 12}, {"Multi_shot" , 15}} };
- Monster Spider{ "spider", 1 ,80 , 8 , 15 , 18, { {"String shot", 9}, {"Poison Bite", 10}, {"Sharp Claw", 8}, {"Scratch", 6}} };
- Monster Slime{ "Slime" , 1 ,100 , 8 , 18 , 5, {{"Spikes", 6}, {"Gunk shout", 10}, {"Poison gas" , 8}, {"Toxic", 7}} };
- Monster* Mon_info;
- void print(std::string statement, int index) { // print(narrator , 0);
- std::cout << statement << std::fflush;
- // std::this_thread::sleep_for(std::chrono::microseconds(100000));
- }
- void battle(Monster* mon1, Monster& mon2)
- {
- int input, dmg_taken, dmg_taken2;
- while (mon1->hp > 0 && mon2.hp > 0) {
- std::cout << "Your lvl : " << mon1->lvl << "\t " << mon2.lvl << " lvl : " << mon2.lvl << std::endl;
- std::cout << "Your HP : " << mon1->hp << "\t" << mon2.name << " HP : " << mon2.hp << std::endl;
- std::cout << "What do you want to do?? \t" << " 1. Attack 2. Info\n";
- std::cin >> input;
- switch (input) {
- case 1:
- std::cout << "Choose your attack" << "\n";
- for (int i{ 0 }; i < 4; i++) {
- std::cout << i + 1 << "." << mon1->moveset[i].move << "[" << mon1->moveset[i].base_dam << "]" << std::endl;
- }
- std::cin >> input;
- std::cout << "You used " << mon1->moveset[input - 1].move << "\n";
- dmg_taken = static_cast<int>(1.5 * (mon1->moveset[input - 1]).base_dam * static_cast<double>(mon1->attack) / mon2.defence);
- std::cout << "You did " << dmg_taken << std::endl;
- mon2.hp = mon2.hp - dmg_taken;
- if (mon2.hp > 0) {
- std::mt19937 rn{ static_cast<unsigned int>(
- std::chrono::high_resolution_clock::now().time_since_epoch().count()
- ) };
- std::uniform_int_distribution<int> die4{ 1 , 3 };
- std::cout << "Monster" << " used " << mon2.moveset[die4(rn)].move << std::endl;
- dmg_taken2 = static_cast<int>(1.5 * mon1->moveset[input - 1].base_dam * static_cast<double>(mon2.attack) / mon1->defence);
- std::cout << "You lost " << dmg_taken2 << " hp" << std::endl;
- mon1->hp = mon1->hp - dmg_taken2;
- }
- if (mon1->hp == 0) {
- std::cout << "you lost lmao\n";
- }
- break;
- case 2:
- std::cout << "Stats" << std::endl;
- std::cout << "HP : " << mon1->hp << "\n";
- std::cout << "Attack : " << mon1->attack << "\n";
- std::cout << "Defence : " << mon1->defence << "\n";
- std::cout << "Speed : " << mon1->speed << "\n";
- }
- }
- }
- int main() {
- Monster Mon_info;
- int input;
- std::string narrator;
- char input2;
- std::string m_race, P_name; // monster race and player name
- narrator = "Welcome Traveler!!";
- std::cout << narrator << std::endl;
- start:
- narrator = "Please choose your monster race";
- print(narrator, 0);
- std::cout << std::endl;
- narrator = "1. Goblin 2. Slime 3.Spider 4.Skeleton";
- print(narrator, 0);
- std::cout << "\n";
- std::cin >> input;
- switch (input) {
- case 1:
- std::cout << "Would you like to know more about Goblin??" << "\n";
- std::cin >> input2;
- if ((input2 != 'Y') && (input2 != 'y')) {
- goto start;
- }
- else {
- narrator = "Goblins are a common fantasy creature often depicted as small,"
- "green-skinned humanoids with pointy ears, sharp teeth, and a mischievous or malevolent nature. "
- "They are typically portrayed as being weak and cowardly in combat, but make up for it with their"
- "intelligence and cunning.";
- print(narrator, 0);
- std::cout << std::endl;
- std::cout << "Would you like to be a Goblin??" << "\n";
- std::cin >> input2;
- if ((input2 != 'Y') && (input2 != 'y')) {
- goto start;
- }
- else {
- m_race = "goblin";
- Monster* Mon_info{ &Goblin };
- }
- }
- break;
- case 2:
- std::cout << "Would you like to know more about the slime??" << "\n";
- std::cin >> input2;
- if ((input2 != 'Y') && (input2 != 'y')) {
- goto start;
- }
- else {
- narrator = "Slimes are often depicted as gelatinous creatures with a simple, blob-like shape."
- "They are typically very weak and slow, but may have some unique abilities such as splitting into smaller slimes or leaving a trail of acid behind them.";
- print(narrator, 0);
- std::cout << std::endl;
- std::cout << "Would you like to be a slime??" << "\n";
- std::cin >> input2;
- if ((input2 != 'Y') && (input2 != 'y')) {
- goto start;
- }
- else {
- m_race = "slime";
- Monster* Mon_info{ &Slime };
- }
- }
- break;
- case 3:
- std::cout << "Would you like to know more about the spider??" << "\n";
- std::cin >> input2;
- if ((input2 != 'Y') && (input2 != 'y')) {
- goto start;
- }
- else {
- narrator = "Spiders are arachnids with eight legs and two body segments, typically depicted in games as large, aggressive creatures with venomous bites."
- "They may be able to climb walls or shoot webs to immobilize the player."
- "Different types of spiders may have different abilities or weaknesses, such as resistance to poison or vulnerability to fire.";
- print(narrator, 0);
- std::cout << std::endl;
- std::cout << "Would you like to be a spider??" << "\n";
- std::cin >> input2;
- if ((input2 != 'Y') && (input2 != 'y')) {
- goto start;
- }
- else {
- m_race = "spider";
- Monster* Mon_info{ &Spider };
- }
- }
- break;
- case 4:
- std::cout << "Would you like to know more about the skeleton??" << "\n";
- std::cin >> input2;
- if ((input2 != 'Y') && (input2 != 'y')) {
- goto start;
- }
- else {
- narrator = "Skeletons are undead creatures typically depicted as animated skeletons, either armed with weapons or using their own bones as weapons."
- "They are often weak to blunt damage but resistant to piercing and slashing attacks.";
- print(narrator, 0);
- std::cout << std::endl;
- std::cout << "Would you like to be a Skeleton??" << "\n";
- std::cin >> input2;
- if ((input2 != 'Y') && (input2 != 'y')) {
- goto start;
- }
- else {
- m_race = "skeleton";
- Monster* Mon_info{ &Skeleton };
- } std::cout << "You are a " << m_race << " now";
- std::cout << "Your states are :";
- std::cout << "Hp " << Mon_info.attack << std::endl;
- break;
- }
- }
- std::string M_encounter;
- std::cout << "Traveler, Please enter your name\n";
- std::cin >> P_name;
- std::cout << "All set, Entering the world..........." << "\n";
- start2:
- std::cout << "B-Town" << "\n";
- std::cout << "Gorgon :- Hurry!! The village is under attack, please do something" << "\n";
- std::cout << "Harpy :- Hurry, we have to fight, The village leader is fighting to save the village " << "\n";
- std::cout << "narrator :- While having conversation, one enters your house\n";
- std::mt19937 mt{ static_cast<unsigned int>(
- std::chrono::high_resolution_clock::now().time_since_epoch().count()
- ) };
- std::uniform_int_distribution<int> MonNum{ 1 , 4 };
- int Num = MonNum(mt);
- if (Num == 1) {
- M_encounter = "Rat";
- battle(Mon_info, rat);
- }
- else if (Num == 2) {
- M_encounter = "Bat";
- battle(Mon_info, bat);
- }
- else if (Num == 3) {
- M_encounter = "Imp";
- battle(Mon_info, imp);
- }
- else {
- M_encounter = "Kobold";
- battle(Mon_info, kobold);
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement