Advertisement
asqapro

RPG

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