I have looked at several of similar topics and compared them with my code, but I don't see any of the same problems. Can someone else tell me if they see something wrong?
Dev-C++ says "expected primary-expression before 'int'" and "expected ';' before 'int'" and that they are on line 557.
I doubt anyone would look through tis whole thing, but any help woulb be tremendously appreciated.
#include <iostream>
#include "fstream"
#include <stdio.h>
/******************************************************************************/
using namespace std;
string name; // Username
string job; // Job
string save1 = "Save1.txt"; // Load File #1
string save2 = "Save2.txt"; // Load File #2
string save3 = "Save3.txt"; // Save File #3
char hometown [99]; // Hometown
int new_old; // New or old game
int save; // Determines which saved game it is
int choice; // Make choice w/ 1 - 15
int yes_or_no; // 1=Yes or 2=No
int escape; // Whether or not you fleed from the battle
int lvl = 1; // Level
int xp; // Eperience
int xp_lvl = xp + lvl*100; // Total experience needed for level
int xp_req; // Experience still needed for next level
int stat_points = 1; // Points to increase stats
int money = 100; // Money
int potion = 1; // Number of potions
int hp; // Health
int max_hp; // Max Health
int mp; // Magic/Mana Points
int max_mp; // Max Magic/Mana Points
int attack; // Attack stat
int defense; // Defense stat
int magic; // Magic stat
int speed; // Speed stat
int intellegence; // Intellegence stat
int mnst_hp; // Monster Health
int mnst_max_hp; // Monster Max Health
int mnst_attack; // Monster Attack stat
int mnst_defense; // Monster Defense stat
int mnst_speed; // Monster Speed stat
long experience (int& xp, int& lvl)
{
if (xp >= xp_lvl)
{
++lvl;
attack = attack + 2;
defense = defense + 2;
magic = magic + 2;
speed = speed + 2;
intellegence = intellegence + 2;
stat_points++;
cout << "Level Up!\nYou are now level " << lvl << "!\n\n" << endl;
cout << "Stats:" << endl
<< "\tAttack- " << attack << endl
<< "\tDefense- " << defense << endl
<< "\tMagic- " << magic << endl
<< "\tSpeed- " << speed << endl
<< "\tIntellegence- " << intellegence << endl;
xp_lvl = xp + lvl*100;
system ("pause");
system ("cls");
/****************************** SAVE GAME **********************************/
if (save == 1)
{
ofstream savefile1;
savefile1.open ("save1.txt");
savefile1 << __DATE__ << "\t" << __TIME__ << endl
<< "Username: " << name << endl
<< "Hometown: " << hometown << endl
<< "Class: " << job << endl
<< "Money: " << money << endl
<< "Level: " << lvl << endl
<< "Experience: " << xp << endl
<< "Stats: " << " ATK- " << attack << endl
<< "\tDEF- " << defense << endl
<< "\tMGC- " << magic << endl
<< "\tSPD- " << speed << endl
<< "\tINT- " << intellegence << endl;
}
else if (save == 2)
{
ofstream savefile2;
savefile2.open ("save2.txt");
savefile2 << __DATE__ << "\t" << __TIME__ << endl
<< "Username: " << name << endl
<< "Hometown: " << hometown << endl
<< "Class: " << job << endl
<< "Money: " << money << endl
<< "Level: " << lvl << endl
<< "Experience: " << xp << endl
<< "Stats: " << " ATK- " << attack << endl
<< "\tDEF- " << defense << endl
<< "\tMGC- " << magic << endl
<< "\tSPD- " << speed << endl
<< "\tINT- " << intellegence << endl;
}
else if (save == 3)
{
ofstream savefile3;
savefile3.open ("save3.txt");
savefile3 << __DATE__ << "\t" << __TIME__ << endl
<< "Username: " << name << endl
<< "Hometown: " << hometown << endl
<< "Class: " << job << endl
<< "Money: " << money << endl
<< "Level: " << lvl << endl
<< "Experience: " << xp << endl
<< "Stats: " << " ATK- " << attack << endl
<< "\tDEF- " << defense << endl
<< "\tMGC- " << magic << endl
<< "\tSPD- " << speed << endl
<< "\tINT- " << intellegence << endl;
}
ofstream autosave;
autosave.open ("autosave.txt");
autosave << __DATE__ << "\t" << __TIME__ << endl
<< "Username: " << name << endl
<< "Hometown: " << hometown << endl
<< "Class: " << job << endl
<< "Money: " << money << endl
<< "Level: " << lvl << endl
<< "Experience: " << xp << endl
<< "Stats: " << " ATK- " << attack << endl
<< "\tDEF- " << defense << endl
<< "\tMGC- " << magic << endl
<< "\tSPD- " << speed << endl
<< "\tINT- " << intellegence << endl;
/**************************************************************************/
}
else if (xp < xp_lvl)
{
int xp_req = xp_lvl - xp;
cout << "You need " << xp_req << " to gain a level.\n" << endl;
system ("pause");
system ("cls");
}
return 0;
}
long battle (int& xp, int attack, int defense, int magic, int speed, int intellegence, int& hp, int max_hp, int& mp, int& potion, int mnst_attack, int mnst_defense, int mnst_speed, int mnst_hp, int mnst_max_hp)
{
cout << "What action would you like to take?\n" << endl
<< "(1) Attack\n(2) Magic\n(3) Heal(Uses 1 potion)\n(4) Flee" << endl;
while (mnst_hp >= 1)
{
if (hp >=1)
{
int choice = 0;
cin >> choice;
if(choice == 1)
{
double damage = 1.5*attack-mnst_defense;
double mstr_hp = mnst_hp-damage;
cout << "You delt " << damage << " damage!" << endl
<< "The monster has " << mnst_hp << "/" << mnst_max_hp << "!" << endl;
}
else if(choice == 2)
{
}
else if(choice == 3)
{
}
else if(choice == 4)
{
int flee = rand() % 20 + 1;
if(flee <= 10)
{
int flee = rand() % 20 + 1;
if (flee <= 10)
{
cout << "Fled successfully!\n" << endl;
system ("pause");
system ("cls");
int escape = 1;
break;
}
else
{
cout << "Failed to escape!\n" << endl;
}
}
}
}
if(escape == 1)
{
}
else if(escape == 0)
{
int xp = xp + 50;
experience (xp, lvl);
}
return 0;
}
long armory (int& money);
{
system ("cls");
cout << "Money: $" << money << endl;
cout << "\n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(1) Wooden Sword $300 ****|" << endl;
cout << "|**** Attack + 2 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(2) Steel Sword $500 ****|" << endl;
cout << "|**** Attack + 4 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(3) Poison Blade $700 ****|" << endl;
cout << "|**** Attack + 6 & Poision Effect ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(4) Plasma Blade $1000 ****|" << endl;
cout << "|**** Attack + 10 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(5) Wooden Shield $300 ****|" << endl;
cout << "|**** Defense + 2 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(6) Cracked Shield $500 ****|" << endl;
cout << "|**** Defense + 4 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(7) Mirror Shield $700 ****|" << endl;
cout << "|**** Defense + 6 & Mirror Effect ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(8) Blazing Shield $1000 ****|" << endl;
cout << "|**** Defense + 10 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(9) Leather Armor $300 ****|" << endl;
cout << "|**** Defense + 2 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(10) Chain Mail $500 ****|" << endl;
cout << "|**** Defense + 4 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(11) Steel Armor $700 ****|" << endl;
cout << "|**** Defense + 6 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(12) Flame Armor $1000 ****|" << endl;
cout << "|**** Defense + 10 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(13) Magic Wand $300 ****|" << endl;
cout << "|**** Magic + 2 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(14) Spell Book $500 ****|" << endl;
cout << "|**** Magic + 5 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(15) Scroll of Wisdom $300 ****|" << endl;
cout << "|**** Intellegence + 2 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(16) Ancient Relic $500 ****|" << endl;
cout << "|**** Intellegence + 5 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(17) Running Shoes $300 ****|" << endl;
cout << "|**** Speed + 2 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(18) Wings of Icarus $500 ****|" << endl;
cout << "|**** Speed + 5 ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(19) Potion $150 ****|" << endl;
cout << "|**** Heals 25 H ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
cout << " ========================================== " << endl;
cout << "|******************************************|" << endl;
cout << "|****(20) Exit ****|" << endl;
cout << "|**** ****|" << endl;
cout << "|******************************************|" << endl;
cout << " ========================================== \n\n" << endl;
int choice = 0;
cin >> choice;
if(choice == 1)
{
if (money >= 300)
{
attack = attack + 2;
}
}
else if(choice == 2)
{
}
else if(choice == 3)
{
}
else if(choice == 4)
{
}
else if(choice == 5)
{
}
else if(choice == 6)
{
}
else if(choice == 7)
{
}
else if(choice == 8)
{
}
else if(choice == 9)
{
}
else if(choice == 10)
{
}
else if(choice == 11)
{
}
else if(choice == 12)
{
}
else if(choice == 13)
{
}
else if(choice == 14)
{
}
else if(choice == 15)
{
}
else if(choice == 16)
{
}
else if(choice == 17)
{
}
else if(choice == 18)
{
}
else if(choice == 19)
{
}
else if(choice == 20)
{
}
return 0;
}
long arena(int lvl);
{
cout << "Who would you like to battle?\n" << endl
<< "(1) Rat\n" << endl;
cin >> choice;
if(choice == 0)
{
}
else if(choice == 1)
{
cout << "A wild rat appears!\n" << endl;
battle (xp, attack, defense, magic, speed, intellegence, hp, max_hp, mp, potion, mnst_attack, mnst_defense, mnst_speed, mnst_hp, mnst_max_hp );
}
if(lvl>=1)
{
cout << "*********************************" << endl;
cout << "*** (1) Rat ***" << endl;
cout << "*********************************" << endl;
}
else if(lvl>=2)
{
}
else if(lvl>=4)
{
}
else if(lvl>=6)
{
}
else if(lvl>=8)
{
}
else if(lvl>=10)
{
}
else if(lvl>=12)
{
}
else if(lvl>=14)
{
}
else if(lvl>=16)
{
}
else if(lvl>=18)
{
}
else if(lvl>=20)
{
}
else if(lvl>=22)
{
}
else if(lvl>=24)
{
}
else if(lvl>=26)
{
}
else if(lvl>=28)
{
}
else if(lvl>=30)
{
}
else if(lvl>=32)
{
}
else if(lvl>=34)
{
}
else if(lvl>=36)
{
}
else if(lvl>=38)
{
}
else if(lvl>=40)
{
}
else if(lvl>=42)
{
}
else if(lvl>=44)
{
}
else if(lvl>=46)
{
}
else if(lvl>=48)
{
}
else if(lvl>=50)
{
}
return 0;
}
int main ()
{
title:
cout << " " << __DATE__ << " " << __TIME__ << "\n" << endl;
cout << " **************************************************************************\n";
cout << " ************************************ ******** **********&&*********\n";
cout << " ** *** **** ************ @ ***< ********%%%%&&&*****\n";
cout << " ** *** ** *** ** **** ******#*** *** ****** **** *** * %&&********\n";
cout << " ** *** ** *** ** **********#######***** **** ******** * ************\n";
cout << " ** *** *** ************####***** ****************\n";
cout << " ** *** ** ****** *** *******##****** ******************\n";
cout << " ** *** ** ****** *** ******#**#****** ******** *******************\n";
cout << " ** *** ** ******* ****************** *********** ********************\n";
cout << " *************************************** *********** ********************\n";
cout << " **************************************************************************\n";
cout << " ****** **** **** ***** ** ** **** ** *** ***** ** *** ***\n";
cout << " ***** *** *** *** ***** ** ***** **** **** ***** ***** ** *** ** ******\n";
cout << " ***** ** *** **** *** *** *** ***** *** **** ***** ***** ** *** ** ******\n";
cout << " **** ** ** **** *** *** *** ** * ** **** ***** ***** ** *** ***\n";
cout << " **** ** **** **** * **** ***** ** * **** ***** ***** ** *** ** ******\n";
cout << " **** **** ** *** ***** * **** ***** *** **** ****** *** *** *** ** ******\n";
cout << " **** **** ** ******* ***** ** **** **** ******* **** *** ** ***\n";
cout << " **************************************************************************\n";
cout << " **************************************************************************\n\n";
cout << " (1) New Game (2) Load Game " << endl;
cin >> new_old;
if (new_old == 1)
{
system ("pause");
system ("cls");
cout << "Which save file would you like to use?" << endl;
cin >> save;
system ("cls");
cout << "Hello, traveler, what is your name?" << endl;
cin >> name;
system ("cls");
cout << "Where are you from, " << name << "?" << endl;
cin >> hometown;
system ("cls");
cout << "Ahh, " << hometown << ", that is a beautiful town!\n" << endl;
system ("pause");
system ("cls");
job:
cout << "What would you like to be, " << name << " of " << hometown << "?\n" << endl;
cout << "(1) Knight" << endl
<< "(2) Mage" << endl
<< "(3) Archer" << endl
<< "(4) Blacksmith" << "\n" << endl;
cin >> choice;
if (choice == 1)
{
cout << "\n\tYou are a Knight? (1=yes, 2=no)\n" << endl;
cin >> yes_or_no;
if (yes_or_no == 1)
{
job = "Knight";
attack = rand() % 12 + 6;
defense = rand() % 12 + 6;
magic = rand() % 5 + 3;
speed = rand() % 10 + 5;
intellegence = rand() % 7 + 4;
cout << "Great!\n" << endl;
system ("pause");
system ("cls");
}
else if (yes_or_no == 2)
{
cout << "Ok, then.\n" << endl;
system ("pause");
goto job;
}
}
else if (choice == 2)
{
cout << "\n\tYou are a Mage? (1=yes, 2=no)\n" << endl;
cin >> yes_or_no;
if (yes_or_no == 1)
{
job = "Mage";
attack = rand() % 7 + 4;
defense = rand() % 5 + 3;
magic = rand() % 12 + 6;
speed = rand() % 10 + 5;
intellegence = rand() % 12 + 6;
cout << "Great!\n" << endl;
system ("pause");
system ("cls");
}
else if (yes_or_no == 2)
{
cout << "Ok, then.\n" << endl;
system ("pause");
goto job;
}
}
else if (choice == 3)
{
cout << "\n\tYou are an Archer? (1=yes, 2=no)\n" << endl;
cin >> yes_or_no;
if (yes_or_no == 1)
{
job = "Archer";
attack = rand() % 12 + 6;
defense = rand() % 10 + 5;
magic = rand() % 5 + 3;
speed = rand() % 7 + 4;
intellegence = rand() % 12 + 6;
cout << "Great!\n" << endl;
system ("pause");
system ("cls");
}
else if (yes_or_no == 2)
{
cout << "Ok, then.\n" << endl;
system ("pause");
goto job;
}
}
else if (choice == 4)
{
cout << "\n\tYou are a Blacksmith? (1=yes, 2=no)\n" << endl;
cin >> yes_or_no;
if (yes_or_no == 1)
{
job = "Blacksmith";
attack = rand() % 12 + 6;
defense = rand() % 12 + 6;
magic = rand() % 7 + 4;
speed = rand() % 5 + 3;
intellegence = rand() % 10 + 5;
cout << "Great!\n" << endl;
system ("pause");
system ("cls");
}
else if (yes_or_no == 2)
{
cout << "Ok, then.\n" << endl;
system ("pause");
goto job;
}
}
else if (choice == 5)
{
cout << "\n\tYou are an Assassin? (1=yes, 2=no)\n" << endl;
cin >> yes_or_no;
if (yes_or_no == 1)
{
job = "Assassin";
attack = rand() % 12 + 6;
defense = rand() % 7 + 4;
magic = rand() % 5 + 3;
speed = rand() % 12 + 6;
intellegence = rand() % 10 + 5;
cout << "\tWelcome to the Brotherhood...\n" << endl;
system ("pause");
system ("cls");
}
else if (yes_or_no == 2)
{
cout << "Ok, then.\n" << endl;
system ("pause");
goto job;
}
}
else if (choice >= 6)
{
system ("cls");
cout << "Enter an integer between 1 and 4! ;)\n" << endl;
system ("pause");
system ("cls");
goto job;
}
/****************************** SAVE GAME **********************************/
if (save == 1)
{
ofstream savefile1;
savefile1.open ("save1.txt");
savefile1 << __DATE__ << "\t" << __TIME__ << endl
<< "Username: " << name << endl
<< "Hometown: " << hometown << endl
<< "Class: " << job << endl
<< "Money: " << money << endl
<< "Level: " << lvl << endl
<< "Experience: " << xp << endl
<< "Stats: " << " ATK- " << attack << endl
<< "\tDEF- " << defense << endl
<< "\tMGC- " << magic << endl
<< "\tSPD- " << speed << endl
<< "\tINT- " << intellegence << endl;
}
else if (save == 2)
{
ofstream savefile2;
savefile2.open ("save2.txt");
savefile2 << __DATE__ << "\t" << __TIME__ << endl
<< "Username: " << name << endl
<< "Hometown: " << hometown << endl
<< "Class: " << job << endl
<< "Money: " << money << endl
<< "Level: " << lvl << endl
<< "Experience: " << xp << endl
<< "Stats: " << " ATK- " << attack << endl
<< "\tDEF- " << defense << endl
<< "\tMGC- " << magic << endl
<< "\tSPD- " << speed << endl
<< "\tINT- " << intellegence << endl;
}
else if (save == 3)
{
ofstream savefile3;
savefile3.open ("save3.txt");
savefile3 << __DATE__ << "\t" << __TIME__ << endl
<< "Username: " << name << endl
<< "Hometown: " << hometown << endl
<< "Class: " << job << endl
<< "Money: " << money << endl
<< "Level: " << lvl << endl
<< "Experience: " << xp << endl
<< "Stats: " << " ATK- " << attack << endl
<< "\tDEF- " << defense << endl
<< "\tMGC- " << magic << endl
<< "\tSPD- " << speed << endl
<< "\tINT- " << intellegence << endl;
}
ofstream autosave;
autosave.open ("autosave.txt");
autosave << __DATE__ << "\t" << __TIME__ << endl
<< "Username: " << name << endl
<< "Hometown: " << hometown << endl
<< "Class: " << job << endl
<< "Money: " << money << endl
<< "Level: " << lvl << endl
<< "Experience: " << xp << endl
<< "Stats: " << " ATK- " << attack << endl
<< "\tDEF- " << defense << endl
<< "\tMGC- " << magic << endl
<< "\tSPD- " << speed << endl
<< "\tINT- " << intellegence << endl;
/**************************************************************************/
}
else if (new_old == 2)
{
load:
system ("cls");
cout << "Which save file would you like to load?" << endl;
cin >> save;
if (save == 1)
{
int yes_or_no = 0;
cout << "Load Save File 1? (1=yes, 2=no, anything else goes back to menu)" << endl;
cin >> yes_or_no;
if (yes_or_no == 1)
{
ifstream savefile1;
savefile1.open ("Save1.cpp", ios::in);
getline(cin, name);
goto lobby;
}
else if (yes_or_no == 2)
{
cout << "O.K., then." << endl;
goto load;
}
else
{
system ("cls");
goto title;
}
}
if (save == 1)
{
int yes_or_no = 0;
cout << "Load Save File 2? (1=yes, 2=no, anything else goes back to menu)" << endl;
cin >> yes_or_no;
if (yes_or_no == 1)
{
ifstream savefile2; ("Save2.cpp");
while ( savefile2.good() )
{
getline(cin, name);
}
goto lobby;
}
else if (yes_or_no == 2)
{
cout << "O.K., then." << endl;
goto load;
}
else
{
system ("cls");
goto title;
}
}
if (save == 3)
{
int yes_or_no = 0;
cout << "Load Save File 3? (1=yes, 2=no, anything else goes back to menu)" << endl;
cin >> yes_or_no;
if (yes_or_no == 1)
{
ifstream savefile3; ("Save3.cpp");
while ( savefile3.good() )
{
getline(cin, name);
}
goto lobby;
}
else if (yes_or_no == 2)
{
cout << "O.K., then." << endl;
goto load;
}
else
{
system ("cls");
goto title;
}
}
}
lobby:
cout << "Hello, " << name << ", what would you like to do?\n\n" << endl;
cout << " ============================== " << endl;
cout << "|******************************|" << endl;
cout << "|****(1) Explore ****|" << endl;
cout << "|******************************|" << endl;
cout << " ============================== \n\n" << endl;
cout << " ============================== " << endl;
cout << "|******************************|" << endl;
cout << "|****(2) Armory ****|" << endl;
cout << "|******************************|" << endl;
cout << " ============================== \n\n" << endl;
cout << " ============================== " << endl;
cout << "|******************************|" << endl;
cout << "|****(3) Quit ****|" << endl;
cout << "|******************************|" << endl;
cout << " ============================== \n\n" << endl;
int choice = 0;
cin >> choice;
if (choice == 1)
{
battle (xp, attack, defense, magic, speed, intellegence, hp, max_hp, mp, potion, mnst_attack, mnst_defense, mnst_speed, mnst_hp, mnst_max_hp);
}
else if (choice == 2)
{
armory (money);
}
else if (choice == 3)
{
goto end;
}
goto lobby;
end:
system ("pause");
return 0;
}
}