Advertisement
asqapro

RPG Big Update

Jul 15th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 40.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <time.h>
  6. #include <vector>
  7. #include <windows.h>
  8. #include <algorithm>
  9.  
  10. using namespace std;
  11.  
  12. void char_create();
  13. void alive();
  14. void dead();
  15. void rest_explore();
  16. void battle();
  17. void explore();
  18.  
  19. struct monster{
  20.     int mon_health;
  21.     int mon_max_health;
  22.     int speed;
  23.     int exp_drop;
  24.     int mon_dmg;
  25.     int mon_level;
  26.     string rand_item;
  27.     string mon_name;
  28.     vector<string> item_drop_list;
  29.  
  30.     void rep_dmg(){
  31.         mon_dmg = rand() % 15 + 3;
  32.         mon_dmg += mon_level * 2;
  33.     }
  34.     void bi_dmg(){
  35.         mon_dmg = rand() % 7 + 1;
  36.         mon_dmg += mon_level * 2;
  37.     }
  38.     void hum_dmg(){
  39.         mon_dmg = rand() % 10 + 2;
  40.         mon_dmg += mon_level * 2;
  41.     }
  42.     void hy_dmg(){
  43.         mon_dmg = rand() % 20 + 10;
  44.         mon_dmg += mon_level * 2;
  45.     }
  46.  
  47.     void mon_level_up(){
  48.         mon_level += 1;
  49.     }
  50.  
  51.     void item_drop(){
  52.         int drop_rate1 = rand() % 5 + 1;
  53.         int drop_rate2 = rand() % 5 + 1;
  54.         int drop_rate_hy1 = rand() % 10 + 1;
  55.         int drop_rate_hy2 = rand() % 10 + 1;
  56.         int get_rand_item = rand() % 3 + 1;
  57.         if(mon_name=="hybrid"){
  58.             if(drop_rate_hy1==drop_rate_hy2){
  59.                 rand_item = item_drop_list[get_rand_item];
  60.             }
  61.             else{
  62.                 rand_item = "nothing";
  63.             }
  64.         }
  65.         if(drop_rate1==drop_rate2){
  66.             rand_item = item_drop_list[get_rand_item];
  67.         }
  68.         else{
  69.             rand_item = "nothing";
  70.         }
  71.     }
  72.  
  73.     void reptile(){
  74.         mon_health = 25 + mon_level * 5;
  75.         speed = 2;
  76.         exp_drop = 35;
  77.         mon_name = "reptile";
  78.         item_drop_list.push_back("health potion");
  79.         item_drop_list.push_back("battle axe");
  80.         item_drop_list.push_back("heavy chestplate");
  81.         //frequency = 30
  82.     }
  83.     void bird(){
  84.         mon_health = 15 + mon_level * 5;
  85.         speed = 15;
  86.         exp_drop = 15;
  87.         mon_name = "bird";
  88.         item_drop_list.push_back("health potion");
  89.         item_drop_list.push_back("dagger");
  90.         item_drop_list.push_back("light chestplate");
  91.         //frequency = 45
  92.     }
  93.     void humanoid(){
  94.         mon_health = 20 + mon_level * 5;
  95.         speed = 10;
  96.         exp_drop = 20;
  97.         mon_name = "humanoid";
  98.         item_drop_list.push_back("health potion");
  99.         item_drop_list.push_back("wooden staff");
  100.         item_drop_list.push_back("arcane chestplate"); //to be made more arcaney
  101.         //frequency = 20
  102.     }
  103.     void hybrid(){
  104.         mon_health = 35 + mon_level * 5;
  105.         speed = 7;
  106.         exp_drop = 55;
  107.         mon_name = "hybrid";
  108.         item_drop_list.push_back("health potion");
  109.         item_drop_list.push_back("health potionx2");
  110.         item_drop_list.push_back("health potionx3");
  111.         //frequency = 5
  112.     }
  113. }mob;
  114.  
  115. struct player{
  116.     string race_class;
  117.     int health;
  118.     int max_health;
  119.     int exp;
  120.     int level;
  121.     int dmg;
  122.     string head;
  123.     string arms;
  124.     string hands;
  125.     string chest;
  126.     string legs;
  127.     string feet;
  128.     string player_class;
  129.     vector<string> inventory;
  130.  
  131.     void level_up(){
  132.         max_health += 10;
  133.         health = max_health;
  134.         level ++;
  135.     }
  136.  
  137.     void warrior_dmg(){
  138.         dmg = rand() % 10 + 5;
  139.         dmg += level * 4;
  140.     }
  141.     void rouge_dmg(){
  142.         int base = rand() % 5 + 1;
  143.         int second_base = rand() % 5 + 1;
  144.         int crit = 15;
  145.         if (base == second_base){
  146.             dmg = crit;
  147.         }
  148.         else{
  149.             dmg = base;
  150.         dmg += level * 4;
  151.         }
  152.     }
  153.     void mage_dmg(){
  154.         dmg = rand() % 7 + 1;
  155.         dmg += level * 6;
  156.     }
  157.  
  158.     void human_rouge(){
  159.         string special_race_abil = "run if low health";
  160.         string special_proff_abil = "avoid battles";
  161.         health = 35;
  162.         max_health = health;
  163.         player_class = "rouge";
  164.         race_class = "human_rouge";
  165.     }
  166.     void human_warrior(){
  167.         string special_race_abil = "run if low health";
  168.         string special_proff_abil = "heavy items";
  169.         health = 55;
  170.         max_health = health;
  171.         player_class = "warrior";
  172.         race_class = "human_warrior";
  173.     }
  174.     void human_mage(){
  175.         string special_race_abil = "run if low health";
  176.         string special_proff_abil = "magic";
  177.         health = 40;
  178.         max_health = health;
  179.         player_class = "mage";
  180.         race_class = "human_mage";
  181.     }
  182.  
  183.     void orc_rouge(){
  184.         string special_race_abil = "extra dmg";
  185.         string special_proff_abil = "avoid battles";
  186.         health = 35;
  187.         max_health = health;
  188.         player_class = "rouge";
  189.         race_class = "orc_rouge";
  190.     }
  191.  
  192.     void orc_warrior(){
  193.         string special_race_abil = "extra dmg";
  194.         string special_proff_abil = "heavy items";
  195.         health = 55;
  196.         max_health = health;
  197.         player_class = "warrior";
  198.         race_class = "orc_warrior";
  199.     }
  200.     void orc_mage(){
  201.         string special_race_abil = "extra dmg";
  202.         string special_proff_abil = "magic";
  203.         health = 40;
  204.         max_health = health;
  205.         player_class = "mage";
  206.         race_class = "orc_mage";
  207.     }
  208.  
  209.     void elf_rouge(){
  210.         string extra_combo_abil = "always escape battles";
  211.         string special_race_abil = "first attack";
  212.         string special_proff_abil = "avoid battles";
  213.         health = 35;
  214.         max_health = health;
  215.         player_class = "rouge";
  216.         race_class = "elf_rouge";
  217.     }
  218.     void elf_warrior(){
  219.         string extra_combo_abil = "always escape battles";
  220.         string special_proff_abil = "heavy items";
  221.         health = 55;
  222.         max_health = health;
  223.         player_class = "warrior";
  224.         race_class = "elf_warrior";
  225.     }
  226.     void elf_mage(){
  227.         string extra_combo_abil = "always escape battles";
  228.         string special_proff_abil = "magic";
  229.         health = 40;
  230.         max_health = health;
  231.         player_class = "mage";
  232.         race_class = "elf_mage";
  233.  
  234.     }
  235. }character;
  236.  
  237. struct equips{
  238.     vector<string> h_head;
  239.     vector<string> h_chest;
  240.     vector<string> h_arm;
  241.     vector<string> h_hand;
  242.     vector<string> h_leg;
  243.     vector<string> h_feet;
  244.     vector<string> l_head;
  245.     vector<string> l_chest;
  246.     vector<string> l_arm;
  247.     vector<string> l_hand;
  248.     vector<string> l_leg;
  249.     vector<string> l_feet;
  250.     vector<string> a_head;
  251.     vector<string> a_chest;
  252.     vector<string> a_arm;
  253.     vector<string> a_hand;
  254.     vector<string> a_leg;
  255.     vector<string> a_feet;
  256.  
  257.     void heavy(){
  258.         //h_head.push_back(/*head gear */);
  259.         h_chest.push_back("heavy chestplate");
  260.         //h_arm.push_back(/*arm stuff */);
  261.         h_hand.push_back("battle axe");
  262.         h_leg.push_back("heavy leggings");
  263.         //h_feet.push_back(/*feet stuff */);
  264.     }
  265.  
  266.     void light(){
  267.         //l_head.push_back(/*head gear */);
  268.         l_chest.push_back("light chestplate");
  269.         //l_arm.push_back(/*arm stuff */);
  270.         l_hand.push_back("dagger");
  271.         l_leg.push_back("light leggings");
  272.         //l_feet.push_back(/*feet stuff */);
  273.     }
  274.  
  275.     void arcane(){
  276.         //a_head.push_back(/*head gear */);
  277.         a_chest.push_back("arcane chestplate");
  278.         //a_arm.push_back(/*arm stuff */);
  279.         a_hand.push_back("staff");
  280.         a_leg.push_back("arcane leggings");
  281.         //a_feet.push_back(/*feet stuff */);
  282.     }
  283.     void equip_heavy_items(){
  284.         vector<string> inven_copy(character.inventory);
  285.         if(!character.inventory.empty()){
  286.             for (vector<string>::iterator i=inven_copy.begin(); i != inven_copy.end(); ++i){
  287.                 if(find(h_head.begin(), h_head.end(), *i) != h_head.end()){
  288.                     if(character.head.empty()){
  289.                         cout << "You equipped: " << *i << endl;
  290.                         character.head+=*i;
  291.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  292.                         if (position != character.inventory.end())
  293.                         character.inventory.erase(position);
  294.                     }
  295.                     else{
  296.                         cout << "Headgear already equipped." << endl;
  297.                     }
  298.                 }
  299.                 else if(find(h_chest.begin(), h_chest.end(), *i) != h_chest.end()){
  300.                     if(character.chest.empty()){
  301.                         cout << "You equipped: " << *i << endl;
  302.                         character.chest+=*i;
  303.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  304.                         if (position != character.inventory.end())
  305.                         character.inventory.erase(position);
  306.                     }
  307.                     else{
  308.                         cout << "Chestplate already equipped." << endl;
  309.                     }
  310.                 }
  311.                 else if(find(h_arm.begin(), h_arm.end(), *i) != h_arm.end()){
  312.                     if(character.arms.empty()){
  313.                         cout << "You equipped: " << *i << endl;
  314.                         character.arms+=*i;
  315.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  316.                         if (position != character.inventory.end())
  317.                         character.inventory.erase(position);
  318.                     }
  319.                     else{
  320.                         cout << "Arm guards already equipped." << endl;
  321.                     }
  322.                 }
  323.                 else if(find(h_hand.begin(), h_hand.end(), *i) != h_hand.end()){
  324.                     if(character.hands.empty()){
  325.                         cout << "You equipped: " << *i << endl;
  326.                         character.hands+=*i;
  327.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  328.                         if (position != character.inventory.end())
  329.                         character.inventory.erase(position);
  330.                     }
  331.                     else{
  332.                         cout << "Weapon already equipped." << endl;
  333.                     }
  334.                 }
  335.                 else if(find(h_leg.begin(), h_leg.end(), *i) != h_leg.end()){
  336.                     if(character.legs.empty()){
  337.                         cout << "You equipped: " << *i << endl;
  338.                         character.legs+=*i;
  339.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  340.                         if (position != character.inventory.end())
  341.                         character.inventory.erase(position);
  342.                     }
  343.                     else{
  344.                         cout << "Leggings already equipped." << endl;
  345.                     }
  346.                 }
  347.                 else if(find(h_feet.begin(), h_feet.end(), *i) != h_feet.end()){
  348.                     if(character.feet.empty()){
  349.                         cout << "You equipped: " << *i << endl;
  350.                         character.feet+=*i;
  351.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  352.                         if (position != character.inventory.end())
  353.                         character.inventory.erase(position);
  354.                     }
  355.                     else{
  356.                         cout << "Boots already equipped." << endl;
  357.                     }
  358.                 }
  359.                 else{
  360.                     cout << "Nothing to equip." << endl;
  361.                     break;
  362.                 }
  363.             }
  364.         }
  365.         else{
  366.             cout << "No items to equip." << endl;
  367.         }
  368.     }
  369.     void equip_light_items(){
  370.         vector<string> inven_copy(character.inventory);
  371.         if(!character.inventory.empty()){
  372.             for (vector<string>::iterator i=inven_copy.begin(); i != inven_copy.end(); ++i){
  373.                 if(find(l_head.begin(), l_head.end(), *i) != l_head.end()){
  374.                     if(character.head.empty()){
  375.                         cout << "You equipped: " << *i << endl;
  376.                         character.head+=*i;
  377.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  378.                         if (position != character.inventory.end())
  379.                         character.inventory.erase(position);
  380.                     }
  381.                     else{
  382.                         cout << "Headgear already equipped." << endl;
  383.                     }
  384.                 }
  385.                 else if(find(l_chest.begin(), l_chest.end(), *i) != l_chest.end()){
  386.                     if(character.chest.empty()){
  387.                         cout << "You equipped: " << *i << endl;
  388.                         character.chest+=*i;
  389.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  390.                         if (position != character.inventory.end())
  391.                         character.inventory.erase(position);
  392.                     }
  393.                     else{
  394.                         cout << "Chestplate already equipped." << endl;
  395.                     }
  396.                 }
  397.                 else if(find(l_arm.begin(), l_arm.end(), *i) != l_arm.end()){
  398.                     if(character.arms.empty()){
  399.                         cout << "You equipped: " << *i << endl;
  400.                         character.arms+=*i;
  401.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  402.                         if (position != character.inventory.end())
  403.                         character.inventory.erase(position);
  404.                     }
  405.                     else{
  406.                         cout << "Arm guards already equipped." << endl;
  407.                     }
  408.                 }
  409.                 else if(find(l_hand.begin(), l_hand.end(), *i) != l_hand.end()){
  410.                     if(character.hands.empty()){
  411.                         cout << "You equipped: " << *i << endl;
  412.                         character.hands+=*i;
  413.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  414.                         if (position != character.inventory.end())
  415.                         character.inventory.erase(position);
  416.                     }
  417.                     else{
  418.                         cout << "Weapon already equipped." << endl;
  419.                     }
  420.                 }
  421.                 else if(find(l_leg.begin(), l_leg.end(), *i) != l_leg.end()){
  422.                     if(character.legs.empty()){
  423.                         cout << "You equipped: " << *i << endl;
  424.                         character.legs+=*i;
  425.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  426.                         if (position != character.inventory.end())
  427.                         character.inventory.erase(position);
  428.                     }
  429.                     else{
  430.                         cout << "Leggings already equipped." << endl;
  431.                     }
  432.                 }
  433.                 else if(find(l_feet.begin(), l_feet.end(), *i) != l_feet.end()){
  434.                     if(character.feet.empty()){
  435.                         cout << "You equipped: " << *i << endl;
  436.                         character.feet+=*i;
  437.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  438.                         if (position != character.inventory.end())
  439.                         character.inventory.erase(position);
  440.                     }
  441.                     else{
  442.                         cout << "Boots already equipped." << endl;
  443.                     }
  444.                 }
  445.                 else{
  446.                     cout << "Nothing to equip." << endl;
  447.                     break;
  448.                 }
  449.             }
  450.         }
  451.         else{
  452.             cout << "No items to equip." << endl;
  453.         }
  454.     }
  455.     void equip_arcane_items(){
  456.         vector<string> inven_copy(character.inventory);
  457.         if(!character.inventory.empty()){
  458.             for (vector<string>::iterator i=inven_copy.begin(); i != inven_copy.end(); ++i){
  459.                 if(find(a_head.begin(), a_head.end(), *i) != a_head.end()){
  460.                     if(character.head.empty()){
  461.                         cout << "You equipped: " << *i << endl;
  462.                         character.head+=*i;
  463.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  464.                         if (position != character.inventory.end())
  465.                         character.inventory.erase(position);
  466.                     }
  467.                     else{
  468.                         cout << "Headgear already equipped." << endl;
  469.                     }
  470.                 }
  471.                 else if(find(a_chest.begin(), a_chest.end(), *i) != a_chest.end()){
  472.                     if(character.chest.empty()){
  473.                         cout << "You equipped: " << *i << endl;
  474.                         character.chest+=*i;
  475.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  476.                         if (position != character.inventory.end())
  477.                         character.inventory.erase(position);
  478.                     }
  479.                     else{
  480.                         cout << "Chestplate already equipped." << endl;
  481.                     }
  482.                 }
  483.                 else if(find(a_arm.begin(), a_arm.end(), *i) != a_arm.end()){
  484.                     if(character.arms.empty()){
  485.                         cout << "You equipped: " << *i << endl;
  486.                         character.arms+=*i;
  487.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  488.                         if (position != character.inventory.end())
  489.                         character.inventory.erase(position);
  490.                     }
  491.                     else{
  492.                         cout << "Arm guards already equipped." << endl;
  493.                     }
  494.                 }
  495.                 else if(find(a_hand.begin(), a_hand.end(), *i) != a_hand.end()){
  496.                     if(character.hands.empty()){
  497.                         cout << "You equipped: " << *i << endl;
  498.                         character.hands+=*i;
  499.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  500.                         if (position != character.inventory.end())
  501.                         character.inventory.erase(position);
  502.                     }
  503.                     else{
  504.                         cout << "Weapon already equipped." << endl;
  505.                     }
  506.                 }
  507.                 else if(find(a_leg.begin(), a_leg.end(), *i) != a_leg.end()){
  508.                     if(character.legs.empty()){
  509.                         cout << "You equipped: " << *i << endl;
  510.                         character.legs+=*i;
  511.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  512.                         if (position != character.inventory.end())
  513.                         character.inventory.erase(position);
  514.                     }
  515.                     else{
  516.                         cout << "Leggings already equipped." << endl;
  517.                     }
  518.                 }
  519.                 else if(find(a_feet.begin(), a_feet.end(), *i) != a_feet.end()){
  520.                     if(character.feet.empty()){
  521.                         cout << "You equipped: " << *i << endl;
  522.                         character.feet+=*i;
  523.                         vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
  524.                         if (position != character.inventory.end())
  525.                         character.inventory.erase(position);
  526.                     }
  527.                     else{
  528.                         cout << "Boots already equipped." << endl;
  529.                     }
  530.                 }
  531.                 else{
  532.                     cout << "Nothing to equip." << endl;
  533.                     break;
  534.                 }
  535.             }
  536.         }
  537.         else{
  538.             cout << "No items to equip." << endl;
  539.         }
  540.     }
  541.  
  542. }equipment;
  543.  
  544.  
  545. struct locations{
  546.     bool first_time_abon;
  547.     bool first_time_mon;
  548.     bool first_time_farm;
  549.     bool first_time_boat;
  550.     string rand_house_item;
  551.     int dot_count;
  552.     int dot_stop;
  553.  
  554.     void create_first_time(){
  555.         first_time_abon = true;
  556.         first_time_boat = true;
  557.         first_time_farm = true;
  558.         first_time_mon = true;
  559.     }
  560.  
  561.     void fish(){
  562.         vector<string> fish;
  563.         fish.push_back("bass");
  564.         fish.push_back("trout");
  565.         fish.push_back("rainbow fish");
  566.         fish.push_back("a sickly grey fish");
  567.         cout << "You sit by the edge of the lake and throw out your line";
  568.         for(dot_count = 1; dot_count <= dot_stop; dot_count++){
  569.                 cout <<  ". ";
  570.                 Sleep(1200);
  571.             }
  572.         int rand_try = rand() % 3 + 1;
  573.         int rand_try2 = rand() % 3 + 1;
  574.         if(rand_try==rand_try2){
  575.             int rand_caught = rand() % 4 + 1;
  576.             string caught = fish[rand_caught];
  577.             cout << "You caught a " << caught << "." << endl;
  578.             character.inventory.push_back(caught);
  579.         }
  580.         else{
  581.             cout << "Nothing bites and you give up." << endl;
  582.         }
  583.     }
  584.  
  585.     void abandoned_house(){
  586.         vector<string> house_items;
  587.         string location = "on the side of the path.";
  588.         string inhabitants = "no one.";
  589.         house_items.push_back("health potion");
  590.         house_items.push_back("dagger");
  591.         house_items.push_back("light leggings");
  592.         string special_events = "You find a journal. Entries to be added. You put the journal in your bag.";
  593.  
  594.         if(first_time_abon==true){
  595.             cout << "You discovered an abandoned house." << endl;
  596.             Sleep(800);
  597.             cout << "It is " << location << endl;
  598.             Sleep(800);
  599.             cout << "There is no one home";
  600.             dot_stop = 3;
  601.             for (dot_count = 1; dot_count <= dot_stop; dot_count++){
  602.                 cout <<  ". ";
  603.                 Sleep(1200);
  604.             }
  605.             cout << "Wait! You found some dead bodies..." << endl;
  606.             Sleep(800);
  607.             int house_item_get = rand() % house_items.size();
  608.             rand_house_item = house_items[house_item_get];
  609.             cout << "You search the house and find " << rand_house_item << "." << endl;
  610.             character.inventory.push_back(rand_house_item);
  611.             Sleep(800);
  612.             cout << special_events << endl;
  613.             character.inventory.push_back("journal");
  614.             first_time_abon = false;
  615.         }
  616.         else{
  617.             cout << "You happen upon the abandoned house again." << endl;
  618.         }
  619.     }
  620.     void monster_house(){
  621.         vector<string> house_items;
  622.         string location = "deep in the dark woods.";
  623.         string inhabitants = "no one.";
  624.         string special_events = "The house comes alive and tries to eat you! You manage to escape, but lose a little health.";
  625.         if(first_time_mon==true){
  626.             cout << "You find a large house..." << endl;
  627.             Sleep(800);
  628.             cout << "It is " << location << endl;
  629.             Sleep(800);
  630.             cout << "There is no one home." << endl;
  631.             Sleep(800);
  632.             cout << "You begin to search for any useful items";
  633.             dot_stop = 3;
  634.             for (dot_count = 1; dot_count <= dot_stop; dot_count++){
  635.                 cout <<  ". ";
  636.                 Sleep(1200);
  637.             }
  638.             cout << endl;
  639.             cout << special_events << endl;
  640.             character.health -= 10;
  641.             first_time_mon = false;
  642.         }
  643.         else{
  644.             cout << "You see the monster house, but avoid it." << endl;
  645.         }
  646.     }
  647.     void farm(){
  648.         vector<string> house_items;
  649.         string location = "in a grassy field. You can see an orchard in the distance.";
  650.         string inhabitants = "a kind woman by the name of Mary.";
  651.         house_items.push_back("apple x4");
  652.         string special_events = "Mary allows you to take as many apples as you can carry. They will each heal a small amount of health.";
  653.         if(first_time_farm==true){
  654.             cout << "You discover a farm " << location << endl;
  655.             Sleep(800);
  656.             cout << "You meet " << inhabitants << endl;
  657.             Sleep(800);
  658.             cout << special_events << endl;
  659.             Sleep(800);
  660.             cout << "You take 4." << endl;
  661.             character.inventory.push_back(house_items[0]);
  662.             first_time_farm = false;
  663.         }
  664.         else{
  665.             cout << "You find the farm again, and take an apple." << endl;
  666.             character.inventory.push_back("apple");
  667.         }
  668.     }
  669.     void boathouse(){
  670.         vector<string> house_items;
  671.         string location = "on the edge of a large lake.";
  672.         string inhabitants = "no one.";
  673.         house_items.push_back("wooden staff");
  674.         house_items.push_back("fishing bait x1");
  675.         string special_events = "You can fish if you want. Do you want to?(y/n) ";
  676.         if(first_time_boat==true){
  677.             cout << "You find a boathouse " << location << endl;
  678.             Sleep(800);
  679.             cout << "There is no one here." << endl;
  680.             Sleep(800);
  681.             int house_item_get = rand() % house_items.size();
  682.             rand_house_item = house_items[house_item_get];
  683.             cout << "You search the place and find " << rand_house_item << "." << endl;
  684.             character.inventory.push_back(rand_house_item);
  685.             Sleep(800);
  686.             cout << special_events;
  687.             string f_o_no;
  688.             cin >> f_o_no;
  689.             while(true){
  690.                 if(f_o_no=="y"){
  691.                     fish();
  692.                     break;
  693.                 }
  694.                 else if(f_o_no=="n"){
  695.                     break;
  696.                 }
  697.                 else{
  698.                     cout << "Type 'y' or 'n'." << endl;
  699.                 }
  700.             }
  701.             first_time_boat = false;
  702.         }
  703.         else{
  704.             string fish_or_no;
  705.             cout << "You find the boathouse." << endl;
  706.             Sleep(800);
  707.             cout << "You see the fishing rod again. Do you want to fish?(y/n) ";
  708.             cin >> fish_or_no;
  709.             while(true){
  710.                 if(fish_or_no=="y"){
  711.                     fish();
  712.                 }
  713.                 else if(fish_or_no!="n"){
  714.                     cout << "Choose 'y' or 'n'." << endl;
  715.                 }
  716.             }
  717.         }
  718.     }
  719. }locs;
  720.  
  721.  
  722. int main(){
  723.     equipment.heavy();
  724.     equipment.light();
  725.     equipment.arcane();
  726.     locs.create_first_time();
  727.     string reload;
  728.     srand(time(NULL));
  729.     char_create();
  730.     alive();
  731.     cout << "Something crashed.";
  732.     return 0;
  733. }
  734.  
  735.  
  736. void char_create(){
  737.     character.level = 1;
  738.     string pick_race = "";
  739.     string pick_class = "";
  740.     while(true){
  741.         cout << "Pick your race(human, orc, or elf): ";
  742.         cin >> pick_race;
  743.         if(pick_race!="human"){
  744.                 if(pick_race!="orc"){
  745.                     if(pick_race!="elf"){
  746.                         cout << "Choose 'human', 'orc', or 'elf'." << endl;
  747.                     }
  748.                     else{
  749.                         break;
  750.                     }
  751.                 }
  752.                 else{
  753.                     break;
  754.                 }
  755.         }
  756.         else{
  757.             break;
  758.         }
  759.     }
  760.     while(true){
  761.         cout << "Pick your class(warrior, mage, or rouge): ";
  762.         cin >> pick_class;
  763.         if(pick_class!="warrior"){
  764.                 if(pick_class!="mage"){
  765.                     if(pick_class!="rouge"){
  766.                         cout << "Choose 'warrior', 'mage', or 'rouge'." << endl;
  767.                     }
  768.                     else{
  769.                         break;
  770.                     }
  771.                 }
  772.                 else{
  773.                     break;
  774.                 }
  775.         }
  776.         else{
  777.             break;
  778.         }
  779.     }
  780.     string picked = pick_race+"_"+pick_class;
  781.     if (picked == "human_rouge"){
  782.         character.human_rouge();
  783.     }
  784.     else if (picked == "human_warrior"){
  785.         character.human_warrior();
  786.     }
  787.     else if (picked == "human_mage"){
  788.         character.human_mage();
  789.     }
  790.  
  791.     else if (picked == "orc_rouge"){
  792.         character.orc_rouge();
  793.     }
  794.     else if (picked == "orc_warrior"){
  795.         character.orc_warrior();
  796.     }
  797.     else if (picked == "orc_mage"){
  798.         character.orc_mage();
  799.     }
  800.  
  801.     else if (picked == "elf_rouge"){
  802.         character.elf_rouge();
  803.     }
  804.     else if (picked == "elf_warrior"){
  805.         character.elf_warrior();
  806.     }
  807.     else if (picked == "elf_mage"){
  808.         character.elf_mage();
  809.     }
  810.     else{
  811.         cout << "Character creation failed. Try again please." << endl;
  812.         main();
  813.     }
  814. };
  815.  
  816. void battle(){
  817.     int freq = rand() % 100 + 1;
  818.     if(freq < 46){
  819.         mob.bird();
  820.     }
  821.     else if(freq > 45 && freq < 76){
  822.         mob.reptile();
  823.     }
  824.     else if(freq > 75 && freq < 96){
  825.         mob.humanoid();
  826.     }
  827.     else{
  828.         mob.hybrid();
  829.     }
  830.     cout << "You encountered a " << mob.mon_name << "!" << endl;
  831.     Sleep(800);
  832.     cout << "Prepare for battle." << endl;
  833.     Sleep(800);
  834.     if(character.player_class == "rouge"){
  835.         string avoid;
  836.         cout << "Do you want to avoid the battle?(y/n) ";
  837.         cin >> avoid;
  838.         if(avoid == "y"){
  839.             cout << "You sneak back to your camp." << endl;
  840.             rest_explore();
  841.         }
  842.     }
  843.     int speed2 = rand() % mob.speed + 1;
  844.     if(mob.speed == speed2){
  845.         if(mob.mon_name=="reptile"){
  846.             mob.rep_dmg();
  847.         }
  848.         else if(mob.mon_name=="bird"){
  849.             mob.bi_dmg();
  850.         }
  851.         else if(mob.mon_name=="humanoid"){
  852.             mob.hum_dmg();
  853.         }
  854.         else{
  855.             mob.hy_dmg();
  856.         }
  857.         cout << "The monster attacks first, dealing " << mob.mon_dmg << " damage." << endl;
  858.         character.health -= mob.mon_dmg;
  859.         cout << "Your health drops to " << character.health << "." << endl;
  860.         Sleep(800);
  861.     }
  862.     else{
  863.         if(character.player_class=="warrior"){
  864.             character.warrior_dmg();
  865.         }
  866.         else if(character.player_class=="rouge"){
  867.             character.rouge_dmg();
  868.         }
  869.         else{
  870.             character.mage_dmg();
  871.         }
  872.         cout << "You attack first, dealing " << character.dmg << " damage." << endl;
  873.         mob.mon_health -= character.dmg;
  874.         cout << "The monster's health drops to " << mob.mon_health << "." << endl;
  875.         Sleep(800);
  876.     }
  877.     while(true){
  878.         if(mob.mon_name=="reptile"){
  879.             mob.rep_dmg();
  880.         }
  881.         else if(mob.mon_name=="bird"){
  882.             mob.bi_dmg();
  883.         }
  884.         else if(mob.mon_name=="humanoid"){
  885.             mob.hum_dmg();
  886.         }
  887.         else{
  888.             mob.hy_dmg();
  889.         }
  890.  
  891.         if(character.player_class=="warrior"){
  892.             character.warrior_dmg();
  893.         }
  894.         else if(character.player_class=="rouge"){
  895.             character.rouge_dmg();
  896.         }
  897.         else{
  898.             character.mage_dmg();
  899.         }
  900.         cout << "You attack, dealing " << character.dmg << " damage." << endl;
  901.         Sleep(800);
  902.         mob.mon_health -= character.dmg;
  903.         if(mob.mon_health <= 0){
  904.             cout << "You defeated the monster! You earn " << mob.exp_drop << " experience." << endl;
  905.             character.exp += mob.exp_drop;
  906.             Sleep(800);
  907.             if(character.exp>=100){
  908.                 cout << "Congratulations, you went up a level! " << endl;
  909.                 Sleep(800);
  910.                 cout << "Your health increases by 10. Dmg to be added." << endl;
  911.                 Sleep(800);
  912.                 cout << "But as you increase in strength, so do the monsters." << endl;
  913.                 Sleep(800);
  914.                 character.level_up();
  915.                 mob.mon_level_up();
  916.                 character.exp -= 100;
  917.             }
  918.             mob.item_drop();
  919.             cout << "The monster dropped " << mob.rand_item << "." << endl;
  920.             if(mob.rand_item=="nothing"){
  921.                 rest_explore();
  922.             }
  923.             string pick_up;
  924.             while(true){
  925.                 cout << "Do you want to put it in your inventory?(y/n) ";
  926.                 cin >> pick_up;
  927.                 if(pick_up=="y"){
  928.                     cout << "You picked up the item. You have limited inventory." << endl; //Specify inventory spaces left
  929.                     character.inventory.push_back(mob.rand_item);
  930.                     rest_explore();
  931.                 }
  932.                 else if(pick_up=="n"){
  933.                     rest_explore();
  934.                 }
  935.                 else{
  936.                     cout << "Pick \'y\' or \'n\'." << endl;
  937.                 }
  938.             }
  939.             Sleep(800);
  940.             rest_explore();
  941.         }
  942.         cout << "The monster's health drops to " << mob.mon_health << "." << endl;
  943.         Sleep(800);
  944.         cout << "The monster attacks, dealing " << mob.mon_dmg << " damage." << endl;
  945.         Sleep(800);
  946.         character.health -= mob.mon_dmg;
  947.         if(character.health <= 0){
  948.             cout << "You have died." << endl;
  949.             dead();
  950.         }
  951.         cout << "Your health drops to " << character.health << "." << endl;
  952.         Sleep(800);
  953.         while(true){
  954.             string run;
  955.             cout << "Do you want to try to run?(y/n) ";
  956.             cin >> run;
  957.             if(run=="y"){
  958.                 if(character.race_class=="elf_rouge"){
  959.                     cout << "You managed to escape!" << endl;
  960.                     rest_explore();
  961.                 }
  962.                 else{
  963.                     if(mob.speed == speed2){
  964.                         cout << "You managed to escape!" << endl;
  965.                         rest_explore();
  966.                     }
  967.                     else{
  968.                         if(mob.mon_name=="reptile"){
  969.                             mob.rep_dmg();
  970.                         }
  971.                         else if(mob.mon_name=="bird"){
  972.                             mob.bi_dmg();
  973.                         }
  974.                         else if(mob.mon_name=="humanoid"){
  975.                             mob.hum_dmg();
  976.                         }
  977.                         else{
  978.                             mob.hy_dmg();
  979.                         }
  980.                         cout << "You try to escape, but trip." << endl;
  981.                         Sleep(800);
  982.                         cout << "The " << mob.mon_name << " uses your blunder to attack again." << endl;
  983.                         Sleep(800);
  984.                         cout << "It attacks, dealing " << mob.mon_dmg << " damage." << endl;
  985.                         Sleep(800);
  986.                         character.health -= mob.mon_dmg;
  987.                         if(character.health<=0){
  988.                             cout << "You have died." << endl;
  989.                             dead();
  990.                         }
  991.                         cout << "Your health drops to " << character.health << "." << endl;
  992.                         Sleep(800);
  993.                     }
  994.                 }
  995.             }
  996.             else if(run=="n"){
  997.                 Sleep(800);
  998.                 break;
  999.             }
  1000.             else{
  1001.                 cout << "Please type \'n\' or \'y\'." << endl;
  1002.             }
  1003.         }
  1004.     }
  1005. }
  1006.  
  1007. void explore(){
  1008.     vector<string> poss_locs;
  1009.     int dot_count = 1;
  1010.     int dot_stop = 3;
  1011.     cout << "You leave your camp, looking for anything interesting." << endl;
  1012.     cout << "You find a long path and walk along it." << endl;
  1013.     for (dot_count = 1; dot_count <= dot_stop; dot_count++){
  1014.             cout <<  ". ";
  1015.              Sleep(800);
  1016.         }
  1017.     poss_locs.push_back("abon_house");
  1018.     poss_locs.push_back("mon_house");
  1019.     poss_locs.push_back("f_house");
  1020.     poss_locs.push_back("b_house");
  1021.     poss_locs.push_back("None");
  1022.     int found_index = rand() % poss_locs.size();
  1023.     string found = poss_locs[found_index];
  1024.     if(found=="abon_house"){
  1025.         locs.abandoned_house();
  1026.     }
  1027.     else if(found=="mon_house"){
  1028.         locs.monster_house();
  1029.     }
  1030.     else if(found=="f_house"){
  1031.         locs.farm();
  1032.     }
  1033.     else if(found=="b_house"){
  1034.         locs.boathouse();
  1035.     }
  1036.     else{
  1037.         cout << "You find nothing interesting." << endl;
  1038.     }
  1039.     Sleep(800);
  1040.     rest_explore();
  1041. }
  1042.  
  1043.  
  1044. void rest_explore(){
  1045.     string action;
  1046.     int dot_count = 1;
  1047.     int dot_stop = 3;
  1048.     cout << "What do you want to do? ";
  1049.     cin >> action;
  1050.     if (action == "rest"){
  1051.         for (dot_count = 1; dot_count <= dot_stop; dot_count++){
  1052.             cout <<  ". ";
  1053.              Sleep(800);
  1054.         }
  1055.         cout <<  "You awake feeling rested." << endl;
  1056.         character.health += (character.max_health - character.health);
  1057.         rest_explore();
  1058.     }
  1059.     else if(action == "explore"){
  1060.         int fequ = rand() % 100 + 1;
  1061.         if(fequ < 11){
  1062.             battle();
  1063.         }
  1064.         else{
  1065.             explore();
  1066.         }
  1067.     }
  1068.     else if(action == "battle"){
  1069.         battle();
  1070.     }
  1071.     else if(action == "status"){
  1072.         cout << "Your health is " << character.health << "." << endl;
  1073.         Sleep(800);
  1074.         if(character.inventory.empty()){
  1075.             cout << "Your inventory is empty." << endl;
  1076.         }
  1077.         else{
  1078.             cout << "Your inventory consists of: ";
  1079.             for (vector<string>::iterator i = character.inventory.begin(); i != character.inventory.end(); ++i){
  1080.                 vector<string>::iterator x = i;
  1081.                 cout << *i;
  1082.                 if(++x!=character.inventory.end()){
  1083.                     cout << ", ";
  1084.                 }
  1085.                 else{
  1086.                     cout << "." << endl;
  1087.                 }
  1088.             }
  1089.         }
  1090.         Sleep(800);
  1091.         cout << "You have " << character.exp << " experience points." << endl;
  1092.         Sleep(800);
  1093.         cout << "You need " << 100 - character.exp << " more point(s) to level." << endl;
  1094.         Sleep(800);
  1095.         cout << "You are level " << character.level << "." << endl;
  1096.         Sleep(800);
  1097.         cout << "Headgear: " << character.head << endl;
  1098.         cout << "Chestplate: " << character.chest << endl;
  1099.         cout << "Arms: " << character.arms << endl;
  1100.         cout << "Weapon: " << character.hands << endl;
  1101.         cout << "Leggings: " << character.legs << endl;
  1102.         cout << "Boots: " << character.feet << endl;
  1103.         rest_explore();
  1104.     }
  1105.     else if(action == "save"){
  1106.         //cout << "Your game is saved. Only one saved game is possible at a time." << endl;
  1107.         //save();
  1108.         cout << "Working on it." << endl;
  1109.         rest_explore();
  1110.     }
  1111.     else if(action == "equip"){
  1112.         if(character.player_class=="warrior"){
  1113.             equipment.equip_heavy_items();
  1114.         }
  1115.         else if(character.player_class=="rouge"){
  1116.             equipment.equip_light_items();
  1117.         }
  1118.         else if(character.player_class=="mage"){
  1119.             equipment.equip_arcane_items();
  1120.         }
  1121.         rest_explore();
  1122.     }
  1123.     else if(action=="help"){
  1124.         cout << "Type 'rest' to regain your health, 'explore' if you're feeling adventerous, " << endl;
  1125.         cout << "'save' to save your character status, 'equip' to equip items in your inventory, ";
  1126.         cout << "or 'battle' to fight monsters for experience and special items." << endl;
  1127.         rest_explore();
  1128.     }
  1129.     else{
  1130.         cout << "Choose 'rest', 'status', 'explore', 'save', 'equip', or 'battle'." << endl;
  1131.         rest_explore();
  1132.     }
  1133. }
  1134.  
  1135.  
  1136. void alive(){
  1137.     cout << "This is your home base." << endl;
  1138.     Sleep(800);
  1139.     cout << "You can view character stats here, rest to regain health, and many other things.";
  1140.     cout << "For a list, type 'help'." << endl;
  1141.     rest_explore();
  1142. }
  1143.  
  1144. void dead(){
  1145.     cout << "Working on dead function." << endl;
  1146.     cout << "For now, game is reset." << endl;
  1147.     main();
  1148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement