#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
inline int Cls()
{
system("cls");
return 0;
}
struct Character
{
int maxmana, maxhp, strength, defence, magic, agility;
int mana, hp;
int experience;
int damage;
int damageestimate[2];
float battleinterval;
char name[20];
char race[7];
char characterclass[15];
};
Character player;
Character enemy;
char CharacterResults()
{
char yn;
bool done = 0;
do
{
Cls();
cout << "Name: " << player.name;
cout << "\nRace: " << player.race;
cout << "\nClass: " << player.characterclass;
cout << "\n\nStrength: " << player.strength;
cout << "\nDefence: " << player.defence;
cout << "\nMagic: " << player.magic;
cout << "\nAgility: " << player.agility;
cout << "\n\nMaximum Mana: " << player.maxmana;
cout << "\nMaximum HP: " << player.maxhp;
cout << "\n\nBattle Interval: " << player.battleinterval;
cout << "\n\nWould you like to keep these stats and continue?(y/n)";
cout << flush;
yn = getch();
if (yn != ''y'' && yn != ''Y'' && yn != ''n'' && yn != ''N'')
{
cout << "\n\nNot a valid choice.\n\n";
cout << "Press any key to continue...";
cout << flush;
getch();
}
else
done = 1;
} while (done = 0);
return yn;
}
int CharacterMenu()
{
bool done;
bool done2;
char result;
char choice;
do
{
done = 1;
Cls();
cout << "What is your name?\n";
cin.getline (player.name,21);
do
{
done2 = 1;
Cls();
cout << "Please choose a race for your character:\n\n";
cout << "1. Human: A strong physical race, in offence and defence.\n\n";
cout << "2. Goblin: Another physical race, with a powerful attack, but little grasp of"
<< "\n magic.\n\n";
cout << "3. Elf: A less physical race, with its roots in magic.\n\n";
cout << "4. Faerie: A very agile race.\n\n";
cout << "5. Dragon: The most well-rounded of all races.\n\n";
cout << flush;
choice = getch();
switch(choice)
{
case ''1'':
strcpy(player.race,"Human\0");
player.strength = 30;
player.defence = 30;
player.magic = 10;
player.agility = 15;
break;
case ''2'':
strcpy(player.race,"Goblin\0");
player.strength = 40;
player.defence = 30;
player.magic = 5;
player.agility = 10;
break;
case ''3'':
strcpy(player.race,"Elf\0");
player.strength = 15;
player.defence = 10;
player.magic = 45;
player.agility = 15;
break;
case ''4'':
strcpy(player.race,"Faerie\0");
player.strength = 5;
player.defence = 20;
player.magic = 25;
player.agility = 35;
break;
case ''5'':
strcpy(player.race,"Dragon\0");
player.strength = 20;
player.defence = 25;
player.magic = 20;
player.agility = 20;
break;
default:
cout << "Not a valid choice.\n\n";
cout << "Press any key to continue...";
cout << flush;
getch();
done = 0;
break;
}
Cls();
cout << "Please choose a class for your character:\n\n";
cout << "1. Blood Mage: A sorceror class with powerful but sometimes suicidal spells.\n\n";
cout << "2. Thief: A nimble class that attacks with agility, and steals various things.\n\n";
cout << "3. Elemental Mage: A sorceror class that can control the elements.\n\n";
cout << "4. Ninja: A strong and agile physical class that uses martial arts spells.\n\n";
cout << "5. Gladiator: Another strong physical class that uses close-range weapons.\n\n";
cout << "6. Warlord: An agile class that uses long-range weapons.\n\n";
cout << flush;
choice = getch();
switch(choice)
{
case ''1'':
strcpy(player.characterclass,"Blood Mage\0");
player.strength += 20;
player.defence += 20;
player.magic += 20;
player.agility += 20;
break;
case ''2'':
strcpy(player.characterclass,"Thief\0");
player.strength += 15;
player.defence += 15;
player.magic += 20;
player.agility += 30;
break;
case ''3'':
strcpy(player.characterclass,"Elemental Mage\0");
player.strength += 10;
player.defence += 15;
player.magic += 35;
player.agility += 20;
break;
case ''4'':
strcpy(player.characterclass,"Ninja\0");
player.strength += 30;
player.defence += 10;
player.magic += 15;
player.agility += 25;
break;
case ''5'':
strcpy(player.characterclass,"Gladiator\0");
player.strength += 30;
player.defence += 30;
player.magic += 10;
player.agility += 10;
break;
case ''6'':
strcpy(player.characterclass,"Warlord\0");
player.strength += 20;
player.defence += 20;
player.magic += 10;
player.agility += 30;
break;
default:
cout << "Not a valid choice.\n\n";
cout << "Press any key to continue...";
cout << flush;
getch();
done2 = 0;
break;
}
player.maxmana = 2 * player.magic;
player.mana = player.maxmana;
player.maxhp = 2 * player.defence;
player.hp = player.maxhp;
player.battleinterval = 1000.0f / (float)player.agility;
result = CharacterResults();
if (result == ''n'' || result == ''N'')
{
Cls();
cout << "You may now choose again, press any key...";
cout << flush;
getch();
done2 = 0;
}
} while (done2 = 0);
return 0;
}
int Story()
{
Cls();
cout << "Story:\n\n"
<< "Welcome to the land of Relourin, young warrior. You have been selected by the\n"
<< "King himself for this mission.\n\n"
<< "This land is in grave danger. Something has emerged into the depths of the\n"
<< "Great Volcano. Many strange things have been happening. Strange unfriendly\n"
<< "creatures have been roaming the countryside, looking for a fight. The local\n"
<< "villages have been sabotaged. There are far too many of them for us to ward\n"
<< "off without you. You are our only hope.\n\n"
<< "Leave with haste, and rid this land of evil before it''s too late.\n\n"
<< "Press any key to continue...";
cout << flush;
getch();
CharacterMenu();
Cls();
cout << "Press any key to exit..." << flush;
getch();
return 0;
}
int main()
{
char choice;
Start:
Cls();
cout << "RPG\n\n" << "What would you like to do?\n\n";
cout << "1. New Game\n" << "2. Resume Game\n" << "3. Exit\n\n";
cout << flush;
choice = getch();
switch(choice)
{
case ''1'':
Story();
break;
case ''2'':
Cls();
cout << "Not yet available\n\n\n";
cout << "Press any key to reset...";
cout << flush;
getch();
goto Start;
case ''3'':
Cls();
cout << "Press any key to exit..." << flush;
getch();
return 0;
default:
cout << "Not a valid choice.\n\n";
cout << "Press any key to continue...";
cout << flush;
getch();
goto Start;
}
return 0;
}
--------------------Configuration: RPG - Win32 Debug--------------------
Compiling...
RPG.cpp
C:\Windows\Desktop\Web Site\XtremeSoftware RPG\Rpg\RPG.cpp(211) : error C2062: type ''int'' unexpected (Line of Int Story)
C:\Windows\Desktop\Web Site\XtremeSoftware RPG\Rpg\RPG.cpp(212) : error C2143: syntax error : missing '';'' before ''{'' ({ after Int Story)
C:\Windows\Desktop\Web Site\XtremeSoftware RPG\Rpg\RPG.cpp(234) : error C2601: ''main'' : local function definitions are illegal ({ after Int Main)
C:\Windows\Desktop\Web Site\XtremeSoftware RPG\Rpg\RPG.cpp(269) : fatal error C1004: unexpected end of file found
Error executing cl.exe. (End of File)
RPG.exe - 4 error(s), 0 warning(s)