Hello im trying to make a simple text rpg game and so far i have a problem that couldnt find an alternative solution. The result of a subtraction is not correct and its just random big numbers.
Sorry i have to copy the whole program im a noob and i dont know what is wrong
i point where is the problem with //
#include <cstdlib>
#include <iostream>
#include <ctime>
usingnamespace std;
int strength=1;
int dexterity=1;
int perception=1;
int intelligence=1;
int charisma=1;
int stamina=1;
int health;
int melle=strength+dexterity;
int ranged=strength+perception;
int force=strength+intelligence;
int intmidate=strength+charisma;
int heavy=strength+stamina;
int mobility=dexterity+perception;
int disarm=dexterity+intelligence;
int bluff=dexterity+charisma;
int light=dexterity+stamina;
int senses=perception+intelligence;
int haggle=perception+charisma;
int instinct=perception+stamina;
int persuasion=intelligence+charisma;
int survival=intelligence+stamina;
int leadership=charisma+stamina;
int start=0;
string name;
void stats()
{
int st=strength;
int de=dexterity;
int pe=perception;
int in=intelligence;
int ch=charisma;
int sa=stamina;
int total2=st+de+pe+in+ch+sa;
int total1;
total1-=total2; //This is the subtraction
if (start==0)
{
char x;
do{
cout<<"What is your name?"<<endl;
cin>>name;
cout<<"Are you sure that "<<name<<" is your name? (Press Y to confirm)"<<endl;
cin>>x;
system("cls");
}while (x!='Y');
int v=0;
do{
string y;
cout<<name<<" you have "<<total1<<" remaining stat points to put at your atribbutes."<<endl; //Here is the bug i get random numbers instead of the actual result of the Subtraction
cout<<"Remember it's skills that matter most not atributes."<<endl;
cout<<"(Type the atribute you want to increase (Min 1 - Max 10)"<<endl;
cout<<"-----------------------------------------------"<<endl;
cout<<"strength= "<<strength<<" ('str' for description)"<<endl;
cout<<"dexterity= "<<dexterity<<" ('dex' for description)"<<endl;
cout<<"perception= "<<perception<<" ('per' for description)"<<endl;
cout<<"intelligence= "<<intelligence<<" ('int' for description)"<<endl;
cout<<"charisma= "<<charisma<<" ('cha' for description)"<<endl;
cout<<"stamina= "<<stamina<<" ('int' for description)"<<endl;
cin>>y;
if (y=="strength")
{
do{
system("cls");
cout<<"Choose how much strength you will have"<<endl;
cin>>strength;
st=strength;
}while (strength<1 or strength>10);
}
if (y=="dexterity")
{
do{
system("cls");
cout<<"Choose how much dexterity you will have"<<endl;
cin>>dexterity;
de=dexterity;
}while (dexterity<1 or dexterity>10);
}
if (y=="perception")
{
do{
system("cls");
cout<<"Choose how much perception you will have"<<endl;
cin>>perception;
pe=perception;
}while (perception<1 or perception>10);
}
if (y=="intelligence")
do{
system("cls");
cout<<"Choose how much intelligence you will have"<<endl;
cin>>intelligence;
in=intelligence;
}while (intelligence<1 or intelligence>10);
if (y=="charisma")
{
do{
system("cls");
cout<<"Choose how much charisma you will have"<<endl;
cin>>charisma;
ch=charisma;
}while (charisma<1 or charisma>10);
}
if (y=="stamina")
{
do{
system("cls");
cout<<"Choose how much stamina you will have"<<endl;
cin>>stamina;
sa=stamina;
}while (stamina<1 or stamina>10);
}
if (total1==0)
{
cout<<"END"<<endl;
if (y=="END")
{
v=1;
}
}
total2=st+de+pe+in+ch+sa;
total1-=total2; //same subtraction
system("cls");
}while (v<1);
}
}
int main()
{
stats();
}