Important Thoughts on text rpg

Hello various people of this site. This is my first program/project and I was hoping for any and all comments (good or bad) to give thoughts on this. Also I
wanted to go about improving and becoming more detailed in the battles including number generator, interaction between, and HP/MP ; but not sure how to go about it or at least a tutorial. It is INCOMPLETE but is far enough done to have it work but not so far to not be able to change it.

PS/ I learn better looking at source code.
PSS/ Done in two days.

#include <iostream>

using namespace std;

int main(void)

{
int choice;
int choice1;
int choice2;

cout << "welcome to your first quest!\n" << endl;
cout << "In this game we will experience a number of situations." << endl;
cout << "As of right now all the situations will follow the same pattern." << endl;
cout << "1. A situation will be presented." << endl;
cout << "2. Your choices will be given." << endl;
cout << "3. You will be asked to make a choice." << endl;
cout << "4. The result of your choice will be shown." << endl;
cout << "As the story progresses we will add things such as quests." << endl;
cout << "begin!\n" << endl;

cout << "We open this tale on a path between a forest and field." << endl;
cout << "You are riding a carriage with a tradesman down a dirt road." << endl;
cout << "You are an up and coming adventurer on your first journey." << endl;
cout << "Currently you are on your way to terrorvale to become a bounty hunter." << endl;
cout << "You reach down to grab something from your bag." << endl;
cout << "Suddenly, an arrow is imbedded into the carriage " << endl;
cout << "where you were just sitting. You quickly look around for the attacker." << endl;
cout << "You see a goblin archer in the field to your left.\n" << endl;

cout << "What will you do?" << endl;
cout << "1. Take up your sword and rush the goblin?" << endl;
cout << "2. Pull out your bow and arrow and launch an arrow?" << endl;
cout << "3. Cast a Spell to destroy him?\n" << endl;

cout << "Your choice: " << endl;
cin >> choice;

if( choice == 1)
{
cout << "\nYou charge the goblin archer cutting off his arm " << endl;
cout << "and slashing across his chest. The Goblin falls " << endl;
cout << "to the ground, but before you can finish him you hear " << endl;
cout << "the tradesman scream. You turn to see a goblin jumping " << endl;
cout << "from the carriage and running into the forest.\n" << endl;
}

else if( choice == 2)
{
cout << "\nYou shoot an arrow into the goblins chest." << endl;
cout << "You go to retrieve your arrow but before you can you hear a scream behind you." << endl;
cout << "You turn to see a goblin running from the carriage into the woods\n" <<endl;
}

else if( choice == 3)
{
cout << "\nYou begin chanting. A fireball launches through the air " << endl;
cout << "into the goblin. You go to finish him off but hear a scream " << endl;
cout << "from the tradesmen. you turn to see a goblin run from the " << endl;
cout << "carriage into the woods.\n" << endl;
}

else
{
cout << "\nThats not a choice! YOU FAIL!" << endl;
cout << "you are now dead. start over\n" <<endl;
}

cout << "You go to check on the tradesman. He's injured but not badly." << endl;
cout << "The tradesmen asks you to help retrieve a box the goblin has stolen" << endl;
cout << "It apperently it contains something important and you should not open it\n" << endl;

cout << "What will you do?" <<endl;
cout << "1. Help him because it is right." << endl;
cout << "2. Help him but ask for a reward." << endl;
cout << "3. Ask whats in it for you." << endl;

cout << "Your Choice: " << endl;
cin >> choice1;

if( choice1 == 1)
{
cout << "\nYou offered to help him out of kindness." << endl;
cout << "He hands you 10 gold pieces and offers 10 more when you return with the box" << endl;
cout << "You decide to loot the goblin before heading off on your mission.\n" << endl;
}

else if( choice1 == 2)
{
cout << "\nYou accept the tradesman request but ask for a reward in return" << endl;
cout << "The Tradesman agrees reluctantly and hands you 5 gold" << endl;
cout << "You decide to search the goblin before heading after the goblin.\n" <<endl;
}

else if( choice1 == 3)
{
cout << "\nYou immediatly request payment for your services." << endl;
cout << "The Tradesman stomps about in anger clearly displeased." << endl;
cout << "After a minutes of pacing the Tradesmen reluctantly agrees and pays 5 gold" << endl;
cout << "You thank him for his services and decide to go loot your earlier kill.\n" << endl;
}

else
{
cout << "\nThats not a choice! YOU FAIL!" << endl;
cout << "you are now dead. start over\n" <<endl;
}

cout << "Walking towards the goblin you notice it is still alive. You question it." << endl;
cout << "After a few minutes of interrogation the goblin tells you of a cave hideout" << endl;
cout << "The hideout is located in a valley just within the forest. You kill the goblin." << endl;
cout << "You search the goblins body and find rope, a dagger, and bow and arrows." << endl;
cout << "You head into the forest. You notice the tracks of the goblin and follow them." << endl;
cout << "As you near the cave you notice two goblin standing guard in front of a " << endl;
cout << "crudely built wooden door." <<endl;
cout << "How will you handle this situation?\n" << endl;

cout << "Choices: " << endl;
cout << "1. Rush the goblins." << endl;
cout << "2. Climb to top of cave and drop onto them." << endl;
cout << "3. Cast a spell to destroy them." << endl;

cout << "Your choice: " << endl;
cin >> choice2;

if( choice2 == 1)
{
cout << "\nYou rush the goblin guards." << endl;
cout << "The goblins attack you parry one goblin but hit by the other." << endl;
cout << "You manage to defeat the goblins with minor injury.\n" << endl;
cout << "You quickly use healing magic to heal your wounds." << endl;
}

else if( choice2 == 2)
{
cout << "\nYou climb to the top of the cave and drop down onto the goblins head." << endl;
cout << "You slit the first goblins throat and tackled the other." << endl;
cout << "You are able to choke out the goblin but recieve a gash across the face." <<endl;
cout << "You quickly apply salve and bandage the gash.\n" << endl;
}

else if( choice2 == 3)
{
cout << "\nYou begin chanting in foreign togues causing the air to shimmer." << endl;
cout << "Suddenly the ground below the goblins opened its jaws and devoured them." << endl;
cout << "Feeling weak you drink a potion to regain your strength and stamina." << endl;
}

else
{
cout << "\nThats not a choice! YOU FAIL!" << endl;
cout << "you are now dead. start over\n" <<endl;
}

system ("pause");
return 0;

}
Last edited on
I don't like the fact that it has such a linear path, you should try to do some type of chance system and health system. Health system would be easy, but the chance system you could do something simple as a random number generated and work with it. For example if the number generated was odd or even you could perform from it.

Also about system functions, from what I have heard it has very bad performance for programs. Try to use getchar(); .

But any program you make its pure practice, practice makes perfect so continue the project no matter what anyone says.
Last edited on
You can wrap these story strings around array which would make main function clean.

In advanced way you can also follow up on hashmap.
Last edited on
Firstly: Use [code]Code goes here[/code] tags. That makes the code easier to read.

As for the program, It is too unclear without indenting, so I can just give one comment, You can use switch rather than If-else statements. That would make it considerably cleaner!
Best of luck with the games!

P.S. Yes, using system is not a good habit. Just have a look at this:
http://www.cplusplus.com/forum/beginner/1988/

You can use
1
2
3
cout << "Press enter to exit . . .";
cin.get();
return 0;
Last edited on
Topic archived. No new replies allowed.