So i want to create a storyline that goes different ways depending on your choices. I cant seem to get it quite right. When i script it to pick the second reaction it still goes for the first reaction.
cout <<"Please pick your past\n";
cout <<"1 - Poor\n";
cout <<"2 - Middle Class\n";
cout <<"3 - Rich\n";
int pickPast;
cout <<"Pick your past: ";
cin >>pickPast;
switch (pickPast)
{
case 1:
cout <<"You awaken in the slums of Labsung to find your house robbed and your family missing.\n";
break;
case 2:
cout <<"You awaken to the loud noises of commerce near the bazzar in your two story house, upon waking up someone knocks on your door.\n";
break;
case 3:
cout <<"You awaken in your velvet robe and you are greeted by your butler, he requests that you go downstairs immediately.\n";
break;
}
while(true)
{
cout <<"Re-enter your Past value (1,2,or 3)";
char userInput;
cin >> userInput;
if(userInput == 1);
cout <<"You quickly leave the house and discover that a riot is in progress inside the slums, you see a woman being attacked but you also hear your sister calling for help in the distance.\n\n";
cout <<"Do you...\n";
cout <<"1 - Help the damsel in distress.\n";
cout <<"2 - Run instantly towards your sisters screams.\n";
int pickReaction;
cout <<"Pick your Reaction: ";
cin >>pickReaction;
switch (pickReaction)
{
case 1:
cout <<"You swing a hammer down on the attacker and save the woman who thanks and joins you in the search for your sister\n";
break;
case 2:
cout <<"You abandon the woman being attacked and run down the street towards your sister to find her being dragged away by the police, you try to wrestle the police off but you fail and end up getting beaten by the police.\n";
break;
}
if(userInput == 2);
cout <<"You walk outside to help your mother at the family store and as soon as you arrive a thief runs off with merchandise from your shop\n\n";
cout <<"Do you...\n";
cout <<"1 - Chase the thief.\n";
cout <<"2 - Attack the thief.\n";
cout <<"3 - Ignore the thief.\n";
int pickReaction2;
cout <<"Pick your reaction: ";
cin >>pickReaction2;
switch (pickReaction2)
{
case 1:
cout <<"You run after the thief only to run into an ambush set up by the thiefs band of ruffians, they swiftly attack and rob you!\n";
break;
case 2:
cout <<"You shoot the thief down and reclaim your merchandise, you leave the thief on the floor and enter your family's store.\n";
break;
case 3:
cout <<"The thief makes off with the merchandise but dont worry, no one saw you ignore the robbery.\n";
break;
}
If i take the semi colons away it completely ignores the text right after.
These
cout <<"You quickly leave the house and discover that a riot is in progress inside the slums, you see a woman being attacked but you also hear your sister calling for help in the distance.\n\n";
cout <<"You walk outside to help your mother at the family store and as soon as you arrive a thief runs off with merchandise from your shop\n\n";
.
.
. // rest of ur code
.// line 32.......
if(userInput == 1)
{ //use this
cout <<"You quickly leave the house and discover that a riot is in progress inside the slums, you see a woman being attacked but you also hear your sister calling for help in the distance.\n\n";
cout <<"Do you...\n";
cout <<"1 - Help the damsel in distress.\n";
cout <<"2 - Run instantly towards your sisters screams.\n";
int pickReaction;
cout <<"Pick your Reaction: ";
cin >>pickReaction;
switch (pickReaction)
{
case 1:
cout <<"You swing a hammer down on the attacker and save the woman who thanks and joins you in the search for your sister\n";
break;
case 2:
cout <<"You abandon the woman being attacked and run down the street towards your sister to find her being dragged away by the police, you try to wrestle the police off but you fail and end up getting beaten by the police.\n";
break;
}
} // and dis....
.//do the same to all ur if/if-else statements
.
.
as Zhuge told u the if statement wont run.U will also have to enclose
if statement in a { } if it has more than one commands/statements inside
it HOPE THIS WILL HELP YOU
cheers,
cyberdude
cout <<"You walk outside to help your mother at the family store and as soon as you arrive a thief runs off with merchandise from your shop\n\n";
cout <<"Do you...\n";
cout <<"1 - Chase the thief.\n";
cout <<"2 - Attack the thief.\n";
cout <<"3 - Ignore the thief.\n";
int pickReaction2;
cout <<"Pick your reaction: ";
cin >>pickReaction2;
switch (pickReaction2)
{
case 1:
cout <<"You run after the thief only to run into an ambush set up by the thiefs band of ruffians, they swiftly attack and rob you!\n";
break;
case 2:
cout <<"You shoot the thief down and reclaim your merchandise, you leave the thief on the floor and enter your family's store.\n";
break;
case 3:
cout <<"The thief makes off with the merchandise but dont worry, no one saw you ignore the robbery.\n";
break;
}
The way you designed your code will make it hard for you do do stuff.
I have a recommendation.
You could put the actions that should be done based on the answers in diferent functions. If action 1 happens you call function1, if the other thing happends then you call the other function.
For exemple you could have a part of all of this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
cout <<"You quickly leave the house and discover that a riot is in progress inside the slums, you see a woman being attacked but you also hear your sister calling for help in the distance.\n\n";
cout <<"Do you...\n";
cout <<"1 - Help the damsel in distress.\n";
cout <<"2 - Run instantly towards your sisters screams.\n";
int pickReaction;
cout <<"Pick your Reaction: ";
cin >>pickReaction;
switch (pickReaction)
{
case 1:
cout <<"You swing a hammer down on the attacker and save the woman who thanks and joins you in the search for your sister\n";
break;
case 2:
cout <<"You abandon the woman being attacked and run down the street towards your sister to find her being dragged away by the police, you try to wrestle the police off but you fail and end up getting beaten by the police.\n";
break;
}
in a function and just call it there. Othetwise you should put the whole code for what is to be done inside the switch, there is no point in asking the user to enter the same answer 2 times, right?