Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <vector>
- #include <windows.h>
- #include <algorithm>
- using namespace std;
- void char_create();
- void alive();
- void dead();
- void base();
- void battle();
- void explore();
- struct monster{
- int rep_count;
- int bi_count;
- int hum_count;
- int hy_count;
- int mon_count;
- int mon_health;
- int mon_max_health;
- int speed;
- int exp_drop;
- int mon_dmg;
- int mon_level;
- string rand_item;
- string mon_name;
- vector<string> item_drop_list;
- void rep_dmg(){
- mon_dmg = rand() % 15 + 3;
- mon_dmg += mon_level * 2;
- }
- void bi_dmg(){
- mon_dmg = rand() % 7 + 1;
- mon_dmg += mon_level * 2;
- }
- void hum_dmg(){
- mon_dmg = rand() % 10 + 2;
- mon_dmg += mon_level * 2;
- }
- void hy_dmg(){
- mon_dmg = rand() % 20 + 10;
- mon_dmg += mon_level * 2;
- }
- void mon_level_up(){
- mon_level += 1;
- }
- void item_drop(){
- int drop_rate1 = rand() % 5 + 1;
- int drop_rate2 = rand() % 5 + 1;
- int drop_rate_hy1 = rand() % 10 + 1;
- int drop_rate_hy2 = rand() % 10 + 1;
- int get_rand_item = rand() % 3 + 1;
- if(mon_name=="hybrid"){
- if(drop_rate_hy1==drop_rate_hy2){
- rand_item = item_drop_list[get_rand_item];
- }
- else{
- rand_item = "nothing";
- }
- }
- if(drop_rate1==drop_rate2){
- rand_item = item_drop_list[get_rand_item];
- }
- else{
- rand_item = "nothing";
- }
- }
- void reptile(){
- mon_health = 25 + mon_level * 5;
- speed = 2;
- exp_drop = 35;
- mon_name = "reptile";
- item_drop_list.push_back("health potion");
- item_drop_list.push_back("battle axe");
- item_drop_list.push_back("heavy chestplate");
- //frequency = 30
- }
- void bird(){
- mon_health = 15 + mon_level * 5;
- speed = 15;
- exp_drop = 15;
- mon_name = "bird";
- item_drop_list.push_back("health potion");
- item_drop_list.push_back("dagger");
- item_drop_list.push_back("light chestplate");
- //frequency = 45
- }
- void humanoid(){
- mon_health = 20 + mon_level * 5;
- speed = 10;
- exp_drop = 20;
- mon_name = "humanoid";
- item_drop_list.push_back("health potion");
- item_drop_list.push_back("wooden staff");
- item_drop_list.push_back("arcane chestplate"); //to be made more arcaney
- //frequency = 20
- }
- void hybrid(){
- mon_health = 35 + mon_level * 5;
- speed = 7;
- exp_drop = 55;
- mon_name = "hybrid";
- item_drop_list.push_back("health potion");
- item_drop_list.push_back("health potionx2");
- item_drop_list.push_back("health potionx3");
- //frequency = 5
- }
- }mob;
- struct player{
- string race_class;
- int health;
- int max_health;
- int exp;
- int level;
- int dmg;
- string head;
- string arms;
- string hands;
- string chest;
- string legs;
- string feet;
- string player_class;
- vector<string> inventory;
- void level_up(){
- max_health += 10;
- health = max_health;
- level ++;
- }
- void warrior_dmg(){
- dmg = rand() % 10 + 5;
- dmg += level * 4;
- }
- void rouge_dmg(){
- int base = rand() % 5 + 1;
- int second_base = rand() % 5 + 1;
- int crit = 15;
- if (base == second_base){
- dmg = crit;
- }
- else{
- dmg = base;
- dmg += level * 4;
- }
- }
- void mage_dmg(){
- dmg = rand() % 7 + 1;
- dmg += level * 6;
- }
- void human_rouge(){
- string special_race_abil = "run if low health";
- string special_proff_abil = "avoid battles";
- health = 35;
- max_health = health;
- player_class = "rouge";
- race_class = "human_rouge";
- }
- void human_warrior(){
- string special_race_abil = "run if low health";
- string special_proff_abil = "heavy items";
- health = 55;
- max_health = health;
- player_class = "warrior";
- race_class = "human_warrior";
- }
- void human_mage(){
- string special_race_abil = "run if low health";
- string special_proff_abil = "magic";
- health = 40;
- max_health = health;
- player_class = "mage";
- race_class = "human_mage";
- }
- void orc_rouge(){
- string special_race_abil = "extra dmg";
- string special_proff_abil = "avoid battles";
- health = 35;
- max_health = health;
- player_class = "rouge";
- race_class = "orc_rouge";
- }
- void orc_warrior(){
- string special_race_abil = "extra dmg";
- string special_proff_abil = "heavy items";
- health = 55;
- max_health = health;
- player_class = "warrior";
- race_class = "orc_warrior";
- }
- void orc_mage(){
- string special_race_abil = "extra dmg";
- string special_proff_abil = "magic";
- health = 40;
- max_health = health;
- player_class = "mage";
- race_class = "orc_mage";
- }
- void elf_rouge(){
- string extra_combo_abil = "always escape battles";
- string special_race_abil = "first attack";
- string special_proff_abil = "avoid battles";
- health = 35;
- max_health = health;
- player_class = "rouge";
- race_class = "elf_rouge";
- }
- void elf_warrior(){
- string extra_combo_abil = "always escape battles";
- string special_proff_abil = "heavy items";
- health = 55;
- max_health = health;
- player_class = "warrior";
- race_class = "elf_warrior";
- }
- void elf_mage(){
- string extra_combo_abil = "always escape battles";
- string special_proff_abil = "magic";
- health = 40;
- max_health = health;
- player_class = "mage";
- race_class = "elf_mage";
- }
- }character;
- struct equips{
- vector<string> h_head;
- vector<string> h_chest;
- vector<string> h_arm;
- vector<string> h_hand;
- vector<string> h_leg;
- vector<string> h_feet;
- vector<string> l_head;
- vector<string> l_chest;
- vector<string> l_arm;
- vector<string> l_hand;
- vector<string> l_leg;
- vector<string> l_feet;
- vector<string> a_head;
- vector<string> a_chest;
- vector<string> a_arm;
- vector<string> a_hand;
- vector<string> a_leg;
- vector<string> a_feet;
- void heavy(){
- //h_head.push_back(/*head gear */);
- h_chest.push_back("heavy chestplate");
- //h_arm.push_back(/*arm stuff */);
- h_hand.push_back("battle axe");
- h_leg.push_back("heavy leggings");
- //h_feet.push_back(/*feet stuff */);
- }
- void light(){
- //l_head.push_back(/*head gear */);
- l_chest.push_back("light chestplate");
- //l_arm.push_back(/*arm stuff */);
- l_hand.push_back("dagger");
- l_leg.push_back("light leggings");
- //l_feet.push_back(/*feet stuff */);
- }
- void arcane(){
- //a_head.push_back(/*head gear */);
- a_chest.push_back("arcane chestplate");
- //a_arm.push_back(/*arm stuff */);
- a_hand.push_back("staff");
- a_leg.push_back("arcane leggings");
- //a_feet.push_back(/*feet stuff */);
- }
- void equip_heavy_items(){
- vector<string> inven_copy(character.inventory);
- if(!character.inventory.empty()){
- for (vector<string>::iterator i=inven_copy.begin(); i != inven_copy.end(); ++i){
- if(find(h_head.begin(), h_head.end(), *i) != h_head.end()){
- if(character.head.empty()){
- cout << "You equipped: " << *i << endl;
- character.head+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Headgear already equipped." << endl;
- }
- }
- else if(find(h_chest.begin(), h_chest.end(), *i) != h_chest.end()){
- if(character.chest.empty()){
- cout << "You equipped: " << *i << endl;
- character.chest+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Chestplate already equipped." << endl;
- }
- }
- else if(find(h_arm.begin(), h_arm.end(), *i) != h_arm.end()){
- if(character.arms.empty()){
- cout << "You equipped: " << *i << endl;
- character.arms+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Arm guards already equipped." << endl;
- }
- }
- else if(find(h_hand.begin(), h_hand.end(), *i) != h_hand.end()){
- if(character.hands.empty()){
- cout << "You equipped: " << *i << endl;
- character.hands+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Weapon already equipped." << endl;
- }
- }
- else if(find(h_leg.begin(), h_leg.end(), *i) != h_leg.end()){
- if(character.legs.empty()){
- cout << "You equipped: " << *i << endl;
- character.legs+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Leggings already equipped." << endl;
- }
- }
- else if(find(h_feet.begin(), h_feet.end(), *i) != h_feet.end()){
- if(character.feet.empty()){
- cout << "You equipped: " << *i << endl;
- character.feet+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Boots already equipped." << endl;
- }
- }
- else{
- cout << "Nothing to equip." << endl;
- break;
- }
- }
- }
- else{
- cout << "No items to equip." << endl;
- }
- }
- void equip_light_items(){
- vector<string> inven_copy(character.inventory);
- if(!character.inventory.empty()){
- for (vector<string>::iterator i=inven_copy.begin(); i != inven_copy.end(); ++i){
- if(find(l_head.begin(), l_head.end(), *i) != l_head.end()){
- if(character.head.empty()){
- cout << "You equipped: " << *i << endl;
- character.head+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Headgear already equipped." << endl;
- }
- }
- else if(find(l_chest.begin(), l_chest.end(), *i) != l_chest.end()){
- if(character.chest.empty()){
- cout << "You equipped: " << *i << endl;
- character.chest+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Chestplate already equipped." << endl;
- }
- }
- else if(find(l_arm.begin(), l_arm.end(), *i) != l_arm.end()){
- if(character.arms.empty()){
- cout << "You equipped: " << *i << endl;
- character.arms+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Arm guards already equipped." << endl;
- }
- }
- else if(find(l_hand.begin(), l_hand.end(), *i) != l_hand.end()){
- if(character.hands.empty()){
- cout << "You equipped: " << *i << endl;
- character.hands+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Weapon already equipped." << endl;
- }
- }
- else if(find(l_leg.begin(), l_leg.end(), *i) != l_leg.end()){
- if(character.legs.empty()){
- cout << "You equipped: " << *i << endl;
- character.legs+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Leggings already equipped." << endl;
- }
- }
- else if(find(l_feet.begin(), l_feet.end(), *i) != l_feet.end()){
- if(character.feet.empty()){
- cout << "You equipped: " << *i << endl;
- character.feet+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Boots already equipped." << endl;
- }
- }
- else{
- cout << "Nothing to equip." << endl;
- break;
- }
- }
- }
- else{
- cout << "No items to equip." << endl;
- }
- }
- void equip_arcane_items(){
- vector<string> inven_copy(character.inventory);
- if(!character.inventory.empty()){
- for (vector<string>::iterator i=inven_copy.begin(); i != inven_copy.end(); ++i){
- if(find(a_head.begin(), a_head.end(), *i) != a_head.end()){
- if(character.head.empty()){
- cout << "You equipped: " << *i << endl;
- character.head+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Headgear already equipped." << endl;
- }
- }
- else if(find(a_chest.begin(), a_chest.end(), *i) != a_chest.end()){
- if(character.chest.empty()){
- cout << "You equipped: " << *i << endl;
- character.chest+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Chestplate already equipped." << endl;
- }
- }
- else if(find(a_arm.begin(), a_arm.end(), *i) != a_arm.end()){
- if(character.arms.empty()){
- cout << "You equipped: " << *i << endl;
- character.arms+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Arm guards already equipped." << endl;
- }
- }
- else if(find(a_hand.begin(), a_hand.end(), *i) != a_hand.end()){
- if(character.hands.empty()){
- cout << "You equipped: " << *i << endl;
- character.hands+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Weapon already equipped." << endl;
- }
- }
- else if(find(a_leg.begin(), a_leg.end(), *i) != a_leg.end()){
- if(character.legs.empty()){
- cout << "You equipped: " << *i << endl;
- character.legs+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Leggings already equipped." << endl;
- }
- }
- else if(find(a_feet.begin(), a_feet.end(), *i) != a_feet.end()){
- if(character.feet.empty()){
- cout << "You equipped: " << *i << endl;
- character.feet+=*i;
- vector<string>::iterator position = find(character.inventory.begin(), character.inventory.end(), *i);
- if (position != character.inventory.end())
- character.inventory.erase(position);
- }
- else{
- cout << "Boots already equipped." << endl;
- }
- }
- else{
- cout << "Nothing to equip." << endl;
- break;
- }
- }
- }
- else{
- cout << "No items to equip." << endl;
- }
- }
- }equipment;
- struct locations{
- bool first_time_abon;
- bool first_time_mon;
- bool first_time_farm;
- bool first_time_boat;
- string rand_house_item;
- int dot_count;
- int dot_stop;
- void create_first_time(){
- first_time_abon = true;
- first_time_boat = true;
- first_time_farm = true;
- first_time_mon = true;
- }
- void fish(){
- vector<string> fish;
- fish.push_back("bass");
- fish.push_back("trout");
- fish.push_back("rainbow fish");
- fish.push_back("a sickly grey fish");
- cout << "You sit by the edge of the lake and throw out your line";
- for(dot_count = 1; dot_count <= dot_stop; dot_count++){
- cout << ". ";
- Sleep(1200);
- }
- int rand_try = rand() % 3 + 1;
- int rand_try2 = rand() % 3 + 1;
- if(rand_try==rand_try2){
- int rand_caught = rand() % 4 + 1;
- string caught = fish[rand_caught];
- cout << "You caught a " << caught << "." << endl;
- character.inventory.push_back(caught);
- }
- else{
- cout << "Nothing bites and you give up." << endl;
- }
- }
- void abandoned_house(){
- vector<string> house_items;
- string location = "on the side of the path.";
- string inhabitants = "no one.";
- house_items.push_back("health potion");
- house_items.push_back("dagger");
- house_items.push_back("light leggings");
- string special_events = "You find a journal. Entries to be added. You put the journal in your bag.";
- if(first_time_abon==true){
- cout << "You discovered an abandoned house." << endl;
- Sleep(800);
- cout << "It is " << location << endl;
- Sleep(800);
- cout << "There is no one home";
- dot_stop = 3;
- for (dot_count = 1; dot_count <= dot_stop; dot_count++){
- cout << ". ";
- Sleep(1200);
- }
- cout << "Wait! You found some dead bodies..." << endl;
- Sleep(800);
- int house_item_get = rand() % house_items.size();
- rand_house_item = house_items[house_item_get];
- cout << "You search the house and find " << rand_house_item << "." << endl;
- character.inventory.push_back(rand_house_item);
- Sleep(800);
- cout << special_events << endl;
- character.inventory.push_back("journal");
- first_time_abon = false;
- }
- else{
- cout << "You happen upon the abandoned house again." << endl;
- }
- }
- void monster_house(){
- vector<string> house_items;
- string location = "deep in the dark woods.";
- string inhabitants = "no one.";
- string special_events = "The house comes alive and tries to eat you! You manage to escape, but lose a little health.";
- if(first_time_mon==true){
- cout << "You find a large house..." << endl;
- Sleep(800);
- cout << "It is " << location << endl;
- Sleep(800);
- cout << "There is no one home." << endl;
- Sleep(800);
- cout << "You begin to search for any useful items";
- dot_stop = 3;
- for (dot_count = 1; dot_count <= dot_stop; dot_count++){
- cout << ". ";
- Sleep(1200);
- }
- cout << endl;
- cout << special_events << endl;
- character.health -= 10;
- first_time_mon = false;
- }
- else{
- cout << "You see the monster house, but avoid it." << endl;
- }
- }
- void farm(){
- vector<string> house_items;
- string location = "in a grassy field. You can see an orchard in the distance.";
- string inhabitants = "a kind woman by the name of Mary.";
- house_items.push_back("apple x4");
- string special_events = "Mary allows you to take as many apples as you can carry. They will each heal a small amount of health.";
- if(first_time_farm==true){
- cout << "You discover a farm " << location << endl;
- Sleep(800);
- cout << "You meet " << inhabitants << endl;
- Sleep(800);
- cout << special_events << endl;
- Sleep(800);
- cout << "You take 4." << endl;
- character.inventory.push_back(house_items[0]);
- first_time_farm = false;
- }
- else{
- cout << "You find the farm again, and take an apple." << endl;
- character.inventory.push_back("apple");
- }
- }
- void boathouse(){
- vector<string> house_items;
- string location = "on the edge of a large lake.";
- string inhabitants = "no one.";
- house_items.push_back("wooden staff");
- house_items.push_back("fishing bait x1");
- string special_events = "You can fish if you want. Do you want to?(y/n) ";
- if(first_time_boat==true){
- cout << "You find a boathouse " << location << endl;
- Sleep(800);
- cout << "There is no one here." << endl;
- Sleep(800);
- int house_item_get = rand() % house_items.size();
- rand_house_item = house_items[house_item_get];
- cout << "You search the place and find " << rand_house_item << "." << endl;
- character.inventory.push_back(rand_house_item);
- Sleep(800);
- cout << special_events;
- string f_o_no;
- cin >> f_o_no;
- while(true){
- if(f_o_no=="y"){
- fish();
- break;
- }
- else if(f_o_no=="n"){
- break;
- }
- else{
- cout << "Type 'y' or 'n'." << endl;
- }
- }
- first_time_boat = false;
- }
- else{
- string fish_or_no;
- cout << "You find the boathouse." << endl;
- Sleep(800);
- cout << "You see the fishing rod again. Do you want to fish?(y/n) ";
- cin >> fish_or_no;
- while(true){
- if(fish_or_no=="y"){
- fish();
- }
- else if(fish_or_no!="n"){
- cout << "Choose 'y' or 'n'." << endl;
- }
- }
- }
- }
- }locs;
- int main(){
- srand(time(NULL)); //Seed the random number generator
- int situation = rand() % 5 + 1;
- if(situation==1){
- cout << "You are an adventurer, ready to take on the world." << endl;
- cout << "You left your hometown at an early age, feeling like you didn't fit in." << endl;
- cout << "You find yourself in a strange land, filled with monsters." << endl;
- cout << "You must either fight your way out, or dispose of their leader." << endl;
- }
- else if(situation==2){
- cout << "You're a mercenary, roaming the world." << endl;
- cout << "Your family was killed when you were young by a monster of a man." << endl;
- cout << "You became a contract killer to support yourself." << endl;
- cout << "But you soon grew tired of killing your own kind, and set out killing monsters." << endl;
- cout << "You must kill enough monsters to satisfy your anger, or avenge your family." << endl;
- }
- else if(situation==3){
- cout << "You are a scientist, trying to reseach a potentially deadly virus." << endl;
- cout << "You traveled to this monster-infested land looking for 'samples'." << endl;
- cout << "You soon realized that you would have to fight for your research..." << endl;
- cout << "So you picked up your weapon and screamed to the skies \"FOR SCIENCE!!!\"" << endl;
- cout << "You need to collect many samples, or steal the virus from their leader." << endl;
- }
- else if(situation==4){
- cout << "You were a king in your old town - a powerful Lord. But make one mistake... " << endl;
- cout << "Your \"followers\" turned on you as soon as they sensed your weakness." << endl;
- cout << "But you will have your revenge. You will return a warroir and kill them all." << endl;
- cout << "You will clear this land of monsters or kill their king and take over." << endl;
- cout << "\"Born to rule\" is your destiny, and it shall be fulfilled." << endl;
- }
- else{
- cout << "You heard of this monster-filled land at a young age, and set out for it." << endl;
- cout << "There are many monsters to defeat, but you are unfaltering." << endl;
- cout << "You won't stop until they're dead, or their leader is defeated." << endl;
- cout << "Because you plan to be the best that ever was." << endl;
- }
- mob.rep_count = 50;
- mob.bi_count = 95;
- mob.hum_count = 50;
- mob.hy_count = 5;
- mob.mon_count = 200;
- equipment.heavy();
- equipment.light(); //Create the heavy, light, and arcane armor lists
- equipment.arcane();
- locs.create_first_time(); //Set a true bool value for dealing with locations later
- string reload;
- //cout << "Do you want to load a save?(y/n) "
- //cin >> reload;
- //if(reload=="y"){
- // load();
- //}
- char_create(); //Create the character
- alive(); //While this function runs, you are "alive", stays within itself
- cout << "Something crashed."; //More a note for more than anything, tells me if I forgot to call inside the alive function
- return 0; //Program ends (should not be reached
- }
- void char_create(){
- character.level = 1;
- string pick_race = "";
- string pick_class = "";
- while(true){
- cout << "Pick your race(human, orc, or elf): ";
- cin >> pick_race;
- if(pick_race!="human"){
- if(pick_race!="orc"){
- if(pick_race!="elf"){
- cout << "Choose 'human', 'orc', or 'elf'." << endl;
- }
- else{
- break;
- }
- }
- else{
- break;
- }
- }
- else{
- break;
- }
- }
- while(true){
- cout << "Pick your class(warrior, mage, or rouge): ";
- cin >> pick_class;
- if(pick_class!="warrior"){
- if(pick_class!="mage"){
- if(pick_class!="rouge"){
- cout << "Choose 'warrior', 'mage', or 'rouge'." << endl;
- }
- else{
- break;
- }
- }
- else{
- break;
- }
- }
- else{
- break;
- }
- }
- string picked = pick_race+"_"+pick_class;
- if (picked == "human_rouge"){
- character.human_rouge();
- }
- else if (picked == "human_warrior"){
- character.human_warrior();
- }
- else if (picked == "human_mage"){
- character.human_mage();
- }
- else if (picked == "orc_rouge"){
- character.orc_rouge();
- }
- else if (picked == "orc_warrior"){
- character.orc_warrior();
- }
- else if (picked == "orc_mage"){
- character.orc_mage();
- }
- else if (picked == "elf_rouge"){
- character.elf_rouge();
- }
- else if (picked == "elf_warrior"){
- character.elf_warrior();
- }
- else if (picked == "elf_mage"){
- character.elf_mage();
- }
- else{
- cout << "Character creation failed. Try again please." << endl;
- main();
- }
- };
- void battle(){
- int freq = rand() % 100 + 1; //Revise, more efficient algorithm
- if(freq > 55){
- if(!mob.bi_count){
- battle();
- }
- mob.bird();
- }
- else if(freq > 25 && freq < 56){
- if(!mob.rep_count){
- battle();
- }
- mob.reptile();
- }
- else if(freq > 5 && freq < 26){
- if(!mob.hum_count){
- battle();
- }
- mob.humanoid();
- }
- else if(freq > 0 && freq < 6){
- if(!mob.hy_count){
- battle();
- }
- mob.hybrid();
- }
- cout << "You encountered a " << mob.mon_name << "!" << endl;
- Sleep(800);
- cout << "Prepare for battle." << endl;
- Sleep(800);
- if(character.player_class == "rouge"){
- string avoid;
- cout << "Do you want to avoid the battle?(y/n) ";
- cin >> avoid;
- if(avoid == "y"){
- cout << "You sneak back to your camp." << endl;
- base();
- }
- }
- int speed2 = rand() % mob.speed + 1;
- if(mob.speed == speed2){
- if(mob.mon_name=="reptile"){
- mob.rep_dmg();
- }
- else if(mob.mon_name=="bird"){
- mob.bi_dmg();
- }
- else if(mob.mon_name=="humanoid"){
- mob.hum_dmg();
- }
- else{
- mob.hy_dmg();
- }
- cout << "The monster attacks first, dealing " << mob.mon_dmg << " damage." << endl;
- character.health -= mob.mon_dmg;
- cout << "Your health drops to " << character.health << "." << endl;
- Sleep(800);
- }
- else{
- if(character.player_class=="warrior"){
- character.warrior_dmg();
- }
- else if(character.player_class=="rouge"){
- character.rouge_dmg();
- }
- else{
- character.mage_dmg();
- }
- cout << "You attack first, dealing " << character.dmg << " damage." << endl;
- mob.mon_health -= character.dmg;
- cout << "The monster's health drops to " << mob.mon_health << "." << endl;
- Sleep(800);
- }
- while(true){
- if(mob.mon_name=="reptile"){
- mob.rep_dmg();
- }
- else if(mob.mon_name=="bird"){
- mob.bi_dmg();
- }
- else if(mob.mon_name=="humanoid"){
- mob.hum_dmg();
- }
- else{
- mob.hy_dmg();
- }
- if(character.player_class=="warrior"){
- character.warrior_dmg();
- }
- else if(character.player_class=="rouge"){
- character.rouge_dmg();
- }
- else{
- character.mage_dmg();
- }
- cout << "You attack, dealing " << character.dmg << " damage." << endl;
- Sleep(800);
- mob.mon_health -= character.dmg;
- if(mob.mon_health <= 0){
- if(mob.mon_name=="reptile"){
- mob.rep_count--;
- }
- else if(mob.mon_name=="bird"){
- mob.bi_count--;
- }
- else if(mob.mon_name=="humanoid"){
- mob.hum_count--;
- }
- else{
- mob.hy_count--;
- }
- mob.mon_count--;
- if(mob.mon_count==0){
- cout << "Won." << endl; //Revise
- main();
- }
- cout << "You defeated the monster! You earn " << mob.exp_drop << " experience." << endl;
- character.exp += mob.exp_drop;
- Sleep(800);
- if(character.exp>=100){
- cout << "Congratulations, you went up a level! " << endl;
- Sleep(800);
- cout << "Your health increases by 10. Dmg to be added." << endl;
- Sleep(800);
- cout << "But as you increase in strength, so do the monsters." << endl;
- Sleep(800);
- character.level_up();
- mob.mon_level_up();
- character.exp -= 100;
- }
- mob.item_drop();
- cout << "The monster dropped " << mob.rand_item << "." << endl;
- if(mob.rand_item=="nothing"){
- base();
- }
- string pick_up;
- while(true){
- cout << "Do you want to put it in your inventory?(y/n) ";
- cin >> pick_up;
- if(pick_up=="y"){
- cout << "You picked up the item. You have limited inventory." << endl; //Specify inventory spaces left
- character.inventory.push_back(mob.rand_item);
- base();
- }
- else if(pick_up=="n"){
- base();
- }
- else{
- cout << "Pick \'y\' or \'n\'." << endl;
- }
- }
- Sleep(800);
- base();
- }
- cout << "The monster's health drops to " << mob.mon_health << "." << endl;
- Sleep(800);
- cout << "The monster attacks, dealing " << mob.mon_dmg << " damage." << endl;
- Sleep(800);
- character.health -= mob.mon_dmg;
- if(character.health <= 0){
- cout << "You have died." << endl;
- dead();
- }
- cout << "Your health drops to " << character.health << "." << endl;
- Sleep(800);
- while(true){
- string run;
- cout << "Do you want to try to run?(y/n) ";
- cin >> run;
- if(run=="y"){
- if(character.race_class=="elf_rouge"){
- cout << "You managed to escape!" << endl;
- base();
- }
- else{
- if(mob.speed == speed2){
- cout << "You managed to escape!" << endl;
- base();
- }
- else{
- if(mob.mon_name=="reptile"){
- mob.rep_dmg();
- }
- else if(mob.mon_name=="bird"){
- mob.bi_dmg();
- }
- else if(mob.mon_name=="humanoid"){
- mob.hum_dmg();
- }
- else{
- mob.hy_dmg();
- }
- cout << "You try to escape, but trip." << endl;
- Sleep(800);
- cout << "The " << mob.mon_name << " uses your blunder to attack again." << endl;
- Sleep(800);
- cout << "It attacks, dealing " << mob.mon_dmg << " damage." << endl;
- Sleep(800);
- character.health -= mob.mon_dmg;
- if(character.health<=0){
- cout << "You have died." << endl;
- dead();
- }
- cout << "Your health drops to " << character.health << "." << endl;
- Sleep(800);
- }
- }
- }
- else if(run=="n"){
- Sleep(800);
- break;
- }
- else{
- cout << "Please type \'n\' or \'y\'." << endl;
- }
- }
- }
- }
- void explore(){
- vector<string> poss_locs;
- int dot_count = 1;
- int dot_stop = 3;
- cout << "You leave your camp, looking for anything interesting." << endl;
- cout << "You find a long path and walk along it." << endl;
- for (dot_count = 1; dot_count <= dot_stop; dot_count++){
- cout << ". ";
- Sleep(800);
- }
- poss_locs.push_back("abon_house");
- poss_locs.push_back("mon_house");
- poss_locs.push_back("f_house");
- poss_locs.push_back("b_house");
- poss_locs.push_back("None");
- int found_index = rand() % poss_locs.size();
- string found = poss_locs[found_index];
- if(found=="abon_house"){
- locs.abandoned_house();
- }
- else if(found=="mon_house"){
- locs.monster_house();
- }
- else if(found=="f_house"){
- locs.farm();
- }
- else if(found=="b_house"){
- locs.boathouse();
- }
- else{
- cout << "You find nothing interesting." << endl;
- }
- Sleep(800);
- base();
- }
- void base(){
- string action;
- int dot_count = 1;
- int dot_stop = 3;
- cout << "What do you want to do? ";
- cin >> action;
- if (action == "rest"){
- for (dot_count = 1; dot_count <= dot_stop; dot_count++){
- cout << ". ";
- Sleep(800);
- }
- cout << "You awake feeling rested." << endl;
- character.health += (character.max_health - character.health);
- base();
- }
- else if(action == "explore"){
- int fequ = rand() % 100 + 1;
- if(fequ < 11){
- battle();
- }
- else{
- explore();
- }
- }
- else if(action == "battle"){
- battle();
- }
- else if(action == "status"){
- cout << "Your health is " << character.health << "." << endl;
- Sleep(800);
- if(character.inventory.empty()){
- cout << "Your inventory is empty." << endl;
- }
- else{
- cout << "Your inventory consists of: ";
- for (vector<string>::iterator i = character.inventory.begin(); i != character.inventory.end(); ++i){
- vector<string>::iterator x = i;
- cout << *i;
- if(++x!=character.inventory.end()){
- cout << ", ";
- }
- else{
- cout << "." << endl;
- }
- }
- }
- Sleep(800);
- cout << "You have " << character.exp << " experience points." << endl;
- Sleep(800);
- cout << "You need " << 100 - character.exp << " more point(s) to level." << endl;
- Sleep(800);
- cout << "You are level " << character.level << "." << endl;
- Sleep(800);
- cout << "Headgear: " << character.head << endl;
- cout << "Chestplate: " << character.chest << endl;
- cout << "Arms: " << character.arms << endl;
- cout << "Weapon: " << character.hands << endl;
- cout << "Leggings: " << character.legs << endl;
- cout << "Boots: " << character.feet << endl;
- base();
- }
- else if(action == "save"){
- //cout << "Your game is saved. Only one saved game is possible at a time." << endl;
- //save();
- cout << "Working on it." << endl;
- base();
- }
- else if(action == "equip"){
- if(character.player_class=="warrior"){
- equipment.equip_heavy_items();
- }
- else if(character.player_class=="rouge"){
- equipment.equip_light_items();
- }
- else if(character.player_class=="mage"){
- equipment.equip_arcane_items();
- }
- base();
- }
- else if(action=="help"){
- cout << "Type 'rest' to regain your health, 'explore' if you're feeling adventerous, " << endl;
- cout << "'save' to save your character status, 'equip' to equip items in your inventory, ";
- cout << "or 'battle' to fight monsters for experience and special items." << endl;
- base();
- }
- else{
- cout << "Choose 'rest', 'status', 'explore', 'save', 'equip', or 'battle'." << endl;
- base();
- }
- }
- void alive(){
- cout << "This is your home base." << endl;
- Sleep(800);
- cout << "You can view character stats here, rest to regain health, and many other things.";
- cout << "For a list, type 'help'." << endl;
- base();
- }
- void dead(){
- cout << "Working on dead function." << endl;
- cout << "For now, game is reset." << endl;
- main();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement