Code:
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
void levelup (int level, int spec, int Select, int Dexterity=0, int Strength=0, int Wisdom=0, int Charisma=0, int Intelligence=0,int Constitution=0, int lvlselect=0, int magic=0, int sword=0, int bow=0, int reflex=0, int will=0);
void Fight (int btd, int estrike, int enemytd ,int tdr, int tdh, int tdl, int enemyhp,int hp,int attack,int ac,int enemyattack, int enemyac, int enemydmg, int dmg, int strike);
int main()
{
char name[256];
int btd, enemyhp, tdl, tdh, tdr, estrike, enemytd, hp, attack, ac , enemyattack, enemyac, enemydmg, dmg, Select=0, spec=1, strike=0, Dexterity=0, Strength=0, Wisdom=0, Charisma=0, Intelligence=0, Constitution=0, lvlselect=0, level=0, magic=0, sword=0, bow=0, reflex=0, will=0;
srand(time(NULL));
cout << "So, what's your name?" << endl;
cin.getline ( name,256, '\n' );
cout << "Your name is " << name << ", right?" << endl;
cout << "Awesome! " << name << ", now we can start!" << endl;
cout << "it is now time to choose your skills (to level-up press enter)" << endl;
cin.get();
level=0; lvlselect=1;
levelup ( level, Select, Dexterity, Strength, Wisdom, Charisma, Intelligence, Constitution,
lvlselect, magic, sword, bow, reflex, will, spec); cin.get();
btd=1; enemytd=4; tdl=1; tdh=10; tdr=(tdh-tdl)+1; enemyhp=70; hp=70; attack=200; ac=10; enemyattack=2; enemyac=10;
Fight ( btd, estrike, enemytd, tdr, tdl, tdh, enemyhp, hp, attack, ac, enemyattack, enemyac, enemydmg , dmg, strike);
return 0;
}
void levelup (int level, int Select, int Dexterity, int Strength,
int Wisdom, int Charisma, int Intelligence, int Constitution,
int lvlselect,int magic,int sword,int bow,int reflex,int will, int spec)
{
cout << endl <<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
cout << "Level Up!" << endl;
cout << "Welcome to the level up screen! You are now level: "<< level << endl;
cout << "As you have just leveled up, you are able to increase one basic skill, and gain training in one specific skill.\n";
cout << lvlselect << " point(s) remaining in basic skills:" << endl;
cout << "1. Increase your Strength."<< endl;
cout << "2. Increase your Dexterity." <<endl;
cout << "3. Increase your Constitution.\n";
cout << "4. Increase your Intelligence.\n";
cout << "5. Increase your Wisdom.\n";
cout << "6. Increase your Charisma.\n";
cin>>Select;
switch ( Select ) {
case 1:
cout << "You have improved your strength"; Strength++;
--lvlselect;
if (lvlselect>0)
levelup ( level, Select, Dexterity, Strength, Wisdom, Charisma, Intelligence, Constitution, lvlselect, magic, sword, bow, reflex, will);
break;
case 2:
cout << "you have improved your dexterity"; Dexterity++;
--lvlselect;
if (lvlselect>0)
levelup ( level, Select, Dexterity, Strength, Wisdom, Charisma, Intelligence, Constitution, lvlselect,magic,sword,bow,reflex,will);
break;
case 3:
cout << "You have improved your constitution"; Constitution++;
--lvlselect;
if (lvlselect>0)
levelup ( level, Select, Dexterity, Strength, Wisdom, Charisma, Intelligence, Constitution, lvlselect,magic,sword,bow,reflex,will);
break;
case 4:
cout << "You have improved your intelligence"; Intelligence++;
--lvlselect;
if (lvlselect>0)
levelup ( level, Select, Dexterity, Strength, Wisdom, Charisma, Intelligence, Constitution, lvlselect,magic,sword,bow,reflex,will);
break;
case 5:
cout << "You have improved your wisdom"; Wisdom++;
--lvlselect;
if (lvlselect>0)
levelup ( level, Select, Dexterity, Strength, Wisdom, Charisma, Intelligence, Constitution, lvlselect,magic,sword,bow,reflex,will);
break;
case 6:
cout << "you have improved your charisma"; Charisma++;
break;
default:
cout<<"Haha, very witty, no skills for you lameo";
--lvlselect;
if (lvlselect>0)
levelup ( level, Select, Dexterity, Strength, Wisdom, Charisma, Intelligence, Constitution, lvlselect,magic,sword,bow,reflex,will);
break;
}
cout << "\nYou are now allowed to train in 1 specific skill:\n";
cout << "1. Train in Magic\n";
cout << "2. Train in Swords\n";
cout << "3. Train in Bows\n";
if (level>0)
cout << "4. Train in Will\n";
if (level>0)
cout << "5. Train in Reflex\n";
cin >> spec;
switch ( spec )
{
case 1:
cout << " You practice with magic and get better at it"; magic++;
break;
case 2:
cout << "You train in swords\n"; sword++;
break;
case 3:
cout << "Your skill with bows has gotten better\n"; bow++;
break;
case 4:
cout << "Your mental willpower has increased\n"; will++;
break;
case 5:
cout << "Your instant reflexes have been improved\n"; reflex++;
break;
default:
cout << "No skills for you now, real funny!";
break;
}
cout << "\nYour skills are currently as follows:\n";
cout << "Strength: " << Strength << "\n";
cout << "Dexterity: " << Dexterity << "\n";
cout << "Constitution: " << Constitution << "\n";
cout << "Intelligence: " << Intelligence << "\n";
cout << "Wisdom: " << Wisdom << "\n";
cout << "Charisma: " << Charisma << "\n";
cout << "Magic: " << magic << "\n";
cout << "Swordsmanship: " << sword << "\n";
cout << "Bowmanship: " << bow << "\n";
cout << "Will: " << will << "\n";
cout << "Reflexes: " << reflex << "\n";
}
void Fight (int estrike, int btd, int enemyhp,int hp,int attack,int ac,int enemyattack, int enemyac, int enemydmg, int dmg, int strike, int tdr, int tdl, int tdh, int enemytd)
{
cout << "You engage in a fight against the enemy!\n";
while (enemyhp>0 && hp>0)
{
cout << "You attack your enemy: ";
const int N = 21;
strike=rand()%N + attack;
cout << strike << endl;
cin.get();
if (strike>enemyac)
{
dmg= tdl+int(tdr*rand()/(RAND_MAX+btd));
cout << "A hit!\n";
cout << "you do " << dmg << "damage.\n";
enemyhp=enemyhp - dmg;
cout << enemyhp << hp;
cin.get();
}
if (strike<enemyac)
cout << "you attempt to strike the opposition, but fail to damage your enemy." << endl;
cout << "Your enemy attacks you: ";
strike=rand()*21/ (RAND_MAX + 200);
cout << estrike << endl;
cin.get();
if (estrike>ac)
{
enemydmg = (int) enemytd * rand()/(RAND_MAX +1.0);
cout << "A hit!\n";
cout << "your enemy does " << enemydmg << "damage.\n";
hp=hp-enemydmg;
cin.get();
}
else
cout << "Your enemy misses you." << endl;
}
if (enemyhp==0)
cout << "You strike down your enemy!" << endl;
if (hp==0)
{
cout << "Your enemy strikes at you, and you fall to the ground and die. Sorry! Nice try!" << endl;
}
}
There it is,