Would you like to make this site your homepage? It's fast and easy...
Yes, Please make this my home page!
Return to Home Page
//****************************************
//* Dragon Warrior Battler V 0.95 *
//* Created By MaxKnight *
//* Special Thanks to Surgo *
//****************************************
/////////////////////////////////////////
#include // Input/Output Stream
#include // Basic String
#include // Exit Function
#include // String Assignment
using namespace std;
#include // Random Numbers
#include "Player.h" // Player Class
#include "Monster.h" // Monster Class
#include "macros.h" // Surgo's Macro (Thanks Surgo!!!)
#include "Utility.h" // Pause Function
int main()
{
srand((unsigned int) time(NULL)); // Allows for Random Numbers
string PlayerName; // Player Name
string FileName; // Saved File Name
int BattleCount = 0; // # of battles to fight
int CountBattle = 0; // Total # of battles
int Damage = 0; // Damage variable
int Accuracy = 0; // Accuracy variable
int Option = 0; // Option variable
int Ruin = 0; // Ru(i)n variable
int Choose = 1; // Variable variable (You gotta check this out!)
int Healamt = 0; // Healing variable
int StatusAcc = 0; // Accuracy of status magic
char FightMore = 'n'; // Fight more battles?
cout << "//****************************************" << endl;
cout << "//* Dragon Warrior Battler V 0.95 *" << endl;
cout << "//* Created By MaxKnight *" << endl;
cout << "//* Special Thanks to Surgo *" << endl;
cout << "//****************************************" << endl;
cout << "/////////////////////////////////////////" << endl;
cout << "Please enter your name: "; // Kinda obvious
cin >> PlayerName;
FileName = PlayerName + ".dat"; // Transform into File Name
CPlayer Hero; // Create Player
Hero.InitStats(PlayerName); // Initialize Statistics
cout << "Please purchase a weapon." << endl;
Hero.PlayerShop(); // Purchase Weapon
cout << "Please purchase armor." << endl;
Hero.PlayerShop(); // Purchase Armor
Hero.ShowStats(); // Show thy stats!
Pause(); // Gimme a key!
do
{
cout << endl << "How many battles do you wish to fight? ";
cin >> BattleCount; // Fight this many
cout << endl;
while(BattleCount > 0)
{
CMonster Enemy; // Create Monster
Enemy.GetEnemy(Hero.level); // Get Monster, duh!
cout << endl << "A " << Enemy.Name << " draws near!" << endl;
do
{
do
{
if ((Hero.Status == 1) || (Hero.Status == 3)) // Player sleep
{
StatusAcc = (RANDOM(100) + 1);
if (StatusAcc < 20)
{
cout << Hero.Name << " is no longer asleep!" << endl;
if (Hero.Status == 3)
Hero.Status = 2;
else
Hero.Status = 0;
}
else
cout << Hero.Name << " is asleep!" << endl;
Choose = 1;
}
else // Player stopspell
{
if (Hero.Status == 2)
{
StatusAcc = (RANDOM(100) + 1);
if (StatusAcc < 10)
{
cout << Hero.Name << " is no longer under the influence of Stopspell!" << endl;
Hero.Status = 0;
}
}
cout << "Command?" << endl; // Enter your command
cout << "1. Attack 2. Magic" << endl;
cout << "3. Item\t 4. Run" << endl;
cin >> Option;
if (Option == 2) // Magic first
{
if (Hero.Status == 2) // Silence
{
cout << Hero.Name << "'s spells are stopped!" << endl;
Choose = 0;
}
else
{
if (Hero.maglev == 0)
cout << endl << Hero.Name << " has no magic to cast." << endl;
else if (Hero.maglev == 1)
cout << endl << "1. Heal" << endl;
else if (Hero.maglev == 2)
cout << endl << "1. Heal 2. Hurt" << endl;
else if (Hero.maglev == 3)
{
cout << endl << "1. Heal 2. Hurt" << endl;
cout << "3. Sleep" << endl;
}
else if (Hero.maglev == 4)
{
cout << endl << "1. Heal 2. Hurt" << endl;
cout << "3. Sleep 4. Stopspell" << endl;
}
else if (Hero.maglev == 5)
{
cout << endl << "1. Heal 2. Hurt" << endl;
cout << "3. Sleep 4. Stopspell" << endl;
cout << "5. Healmore" << endl;
}
else if (Hero.maglev == 6)
{
cout << endl << "1. Heal 2. Hurt" << endl;
cout << "3. Sleep 4. Stopspell" << endl;
cout << "5. Healmore 6. Hurtmore" << endl;
}
cin >> Choose;
Choose = Hero.PlayerCastMagic(Choose);
if(Choose == 1) // Player heal
{
Healamt = RANDOM(Hero.HPMax / 4);
cout << Hero.Name << " casts Heal on self!" << endl;
cout << Hero.Name << " heals " << Healamt << " HP!" << endl;
Hero.HP += Healamt;
if (Hero.HP > Hero.HPMax)
Hero.HP = Hero.HPMax;
Hero.MP -= 4;
}
else if(Choose == 2) // Player Hurt
{
Damage = (RANDOM(Enemy.HPMax / 4) + 1);
cout << Hero.Name << " casts Hurt on " << Enemy.Name << "!" << endl;
cout << Enemy.Name << " takes " << Damage << " damage!" << endl;
Enemy.HP -= Damage;
if (Enemy.HP < 0)
Enemy.HP = 0;
Hero.MP -= 2;
}
else if(Choose == 3) // Player Sleep
{
StatusAcc = (RANDOM(100) + 1);
cout << Hero.Name << " casts Sleep on " << Enemy.Name << "!" << endl;
if ((StatusAcc < 30) || ((Enemy.Status == 1) || (Enemy.Status == 3)))
{
cout << "Spell had no effect!" << endl;
Hero.MP -= 3;
}
else
{
cout << Enemy.Name << " was put to sleep!" << endl;
if (Enemy.Status == 2)
Enemy.Status = 3;
else
Enemy.Status = 1;
Hero.MP -= 3;
}
}
else if(Choose == 4) // Player Stopspell
{
StatusAcc = (RANDOM(100) + 1);
cout << Hero.Name << " casts Stopspell on " << Enemy.Name << "!" << endl;
if ((StatusAcc <30) || ((Enemy.Status == 2) || (Enemy.Status == 3)))
{
cout << "Spell had no effect!" << endl;
Hero.MP -= 4;
}
else
{
cout << Enemy.Name << "'s spells were silenced!" << endl;
if (Enemy.Status == 1)
Enemy.Status = 3;
else
Enemy.Status = 2;
Hero.MP -= 4;
}
}
else if(Choose == 5) // Player Healmore
{
Healamt = (RANDOM(Hero.HPMax / 2) + (Hero.HPMax / 4));
cout << Hero.Name << " casts Healmore on self!" << endl;
cout << Hero.Name << " resores " << Healamt << " HP!" << endl;
Hero.HP += Healamt;
if (Hero.HP > Hero.HPMax)
Hero.HP = Hero.HPMax;
Hero.MP -= 10;
}
else if(Choose == 6) // Player Hurtmore
{
Damage = (RANDOM(Enemy.HPMax / 2) + (Hero.HPMax / 4));
cout << Hero.Name << " casts Hurtmore on " << Enemy.Name << "!" << endl;
cout << Enemy.Name << " takes " << Damage << " damage!" << endl;
Enemy.HP -= Damage;
if (Enemy.HP < 0)
Enemy.HP = 0;
Hero.MP -=5;
}
else if(Choose == 0) // Reset Choose
Choose = 1;
}
}
}
}while(Choose == 0);
if (Option == 1) // Attack second
{
Accuracy = RANDOM(100);
if (Accuracy < Enemy.Evade) // Accuracy Check
cout << Hero.Name << " missed!" << endl;
else
{
Damage = Hero.PlayerAttack(Enemy.HP, Enemy.Defense); // Deal damage
if (Damage <= 0)
Damage = 1;
else if (Enemy.HP < 0)
Enemy.HP = 0;
cout << Hero.Name << " deals " << Damage << " damage to " << Enemy.Name << "." << endl;
}
}
else if (Option == 3) // Herb Heal third
{
Hero.PlayerUseItem();
}
else if (Option == 4) // Grab yer asses and run!
{
Ruin = 0;
Ruin = Hero.PlayerRun(Enemy.Name, Enemy.Evade);
if (Ruin == 0)
{
cout << Hero.Name << " tries to run..." << endl;
cout << "But " << Enemy.Name << " was in the way!" << endl;
}
else if (Ruin == 1)
{
cout << Hero.Name << " ran away!" << endl;
break;
}
}
if (Enemy.HP == 0) // Didja win...?
{
cout << Hero.Name << " has killed " << Enemy.Name << endl;
Hero.WinBattle(Enemy.Name, Enemy.Exp, Enemy.Gold);
}
else // I suppose not...
{
if ((Enemy.Status == 1) || (Enemy.Status == 3)) // Enemy sleep
{
StatusAcc = (RANDOM(100) + 1);
if (StatusAcc <= 20)
{
cout << Enemy.Name << " woke up!" << endl;
if (Enemy.Status == 3)
Enemy.Status = 2;
else
Enemy.Status = 0;
}
else
cout << Enemy.Name << " is asleep!" << endl;
}
else // Enemy options
{
do
{
Option = (RANDOM(1) + 1);
if (Option == 1) // Enemy attack
{
Accuracy = RANDOM(100);
if (Accuracy < 5) // Accuracy Check
cout << Enemy.Name << " missed!" << endl;
else
{
Damage = Enemy.MonsterAttack(Hero.HP, Hero.Defense);
if (Damage <= 0) // Attack!
Damage = 1;
else if (Hero.HP < 0)
Hero.HP = 0;
cout << Enemy.Name << " inflicts " << Damage << " damage to " << Hero.Name << "." << endl;
}
}
else if (Option == 2) // Attempt to cast magic
{
if (Enemy.Status == 2) // Enemy stopspell
{
StatusAcc = (RANDOM(100) + 1);
if (StatusAcc <= 10)
{
cout << Enemy.Name << " is no longer under the influence of Stopspell!" << endl;
Enemy.Status = 0;
}
else
cout << Enemy.Name << " cannot cast spells due to Stopspell!" << endl;
}
else if (Enemy.Magic1 == 0) // No Magic at all
Option = 0;
else
{
Enemy.EMagic = (RANDOM(100) + 1);
if(Enemy.EMagic <=50)
{
if(Enemy.Magic1 == 1) // Enemy Heal
{
cout << Enemy.Name << " casts Heal on self!" << endl;
if (Enemy.MP < 4)
{
cout << Enemy.Name << " doesn't have enough MP to cast Heal!" << endl;
break;
}
else
{
Healamt = RANDOM(Enemy.HPMax / 4);
cout << Enemy.Name << " is healed of " << Healamt << " damage!" << endl;
Enemy.HP += Healamt;
if (Enemy.HP > Enemy.HPMax)
Enemy.HP = Enemy.HPMax;
Enemy.MP -= 4;
}
}
else if (Enemy.Magic1 == 2) // Enemy Hurt
{
cout << Enemy.Name << " casts Hurt on " << Hero.Name << "!" << endl;
if (Enemy.MP < 2)
{
cout << Enemy.Name << " doesn't have enough MP to cast Hurt!" << endl;
break;
}
else
{
Damage = (RANDOM(Enemy.HPMax / 4) + 1);
cout << Enemy.Name << " inflicts " << Damage << " damage to " << Hero.Name << endl;
Hero.HP -= Damage;
if (Hero.HP < 0)
Hero.HP = 0;
Enemy.MP -= 2;
}
}
else if (Enemy.Magic1 == 3) // Enemy Sleep
{
cout << Enemy.Name << " casts Sleep on " << Hero.Name << "!" << endl;
if (Enemy.MP < 3)
{
cout << Enemy.Name << " doesn't have enough MP to cast Sleep!" << endl;
break;
}
else
{
StatusAcc = (RANDOM(100) + 1);
if ((StatusAcc < 30) || (Hero.Status == 1) || (Hero.Status == 3))
{
cout << "Spell had no effect!" << endl;
Enemy.MP -= 3;
}
else
{
cout << Hero.Name << " has fallen asleep!" << endl;
if (Hero.Status = 2)
Hero.Status = 3;
else
Hero.Status = 1;
Enemy.MP -=3;
}
}
}
else if (Enemy.Magic1 == 4) // Enemy Stopspell
{
cout << Enemy.Name << " casts Stopspell on " << Hero.Name << "!" << endl;
if (Enemy.MP < 4)
{
cout << Enemy.Name << " doesn't have enough MP to cast Stopspell!" << endl;
break;
}
else
{
StatusAcc = (RANDOM(100) + 1);
if ((StatusAcc < 30) || (Hero.Status == 2) || (Hero.Status == 3))
{
cout << "Spell had no effect!" << endl;
Enemy.MP -= 4;
}
else
{
cout << Hero.Name << "'s spells were silenced!" << endl;
if (Hero.Status = 1)
Hero.Status = 3;
else
Hero.Status = 2;
Enemy.MP -= 4;
}
}
}
else if (Enemy.Magic1 == 5) // Enemy Healmore
{
cout << Enemy.Name << " casts Healmore on self!" << endl;
if (Enemy.MP < 10)
{
cout << Enemy.Name << " doesn't have enough MP to cast Healmore!" << endl;
break;
}
else
{
Healamt = (RANDOM(Enemy.HPMax / 2) + (Enemy.HPMax / 4));
cout << Enemy.Name << " is healed of " << Healamt << " damage!" << endl;
Enemy.HP += Healamt;
if (Enemy.HP > Enemy.HPMax)
Enemy.HP = Enemy.HPMax;
Enemy.MP -= 10;
}
}
else if (Enemy.Magic1 == 6) // Enemy Hurtmore
{
cout << Enemy.Name << " casts Hurtmore on " << Hero.Name << "!" << endl;
if (Enemy.MP < 5)
{
cout << Enemy.Name << " doesn't have enough MP to cast Hurtmore!" << endl;
break;
}
else
{
Damage = (RANDOM(Enemy.HPMax / 2) + (Enemy.HPMax / 4));
cout << Enemy.Name << " inflicts " << Damage << " damage to " << Hero.Name << "!" << endl;
Hero.HP -= Damage;
if (Hero.HP < 0)
Hero.HP = 0;
Enemy.MP -= 5;
}
}
else if (Enemy.Magic1 == 7) // Dragon's Breath
{
cout << Enemy.Name << " uses Dragon's Breath on " << Hero.Name << "!" << endl;
Damage = RANDOM((Hero.HPMax * 3) /4);
cout << Enemy.Name << " inflicts " << Damage << " damage to " << Hero.Name << "!" << endl;
Hero.HP -= Damage;
if (Hero.HP < 0)
Hero. HP = 0;
}
}
else
{
if(Enemy.Magic2 == 1) // Enemy Heal (2)
{
cout << Enemy.Name << " casts Heal on self!" << endl;
if (Enemy.MP < 4)
{
cout << Enemy.Name << " doesn't have enough MP to cast Heal!" << endl;
break;
}
else
{
Healamt = RANDOM(Enemy.HPMax / 4);
cout << Enemy.Name << " is healed of " << Healamt << " damage!" << endl;
Enemy.HP += Healamt;
if (Enemy.HP > Enemy.HPMax)
Enemy.HP = Enemy.HPMax;
Enemy.MP -= 4;
}
}
else if (Enemy.Magic2 == 2) // Enemy Hurt (2)
{
cout << Enemy.Name << " casts Hurt on " << Hero.Name << "!" << endl;
if (Enemy.MP < 2)
{
cout << Enemy.Name << " doesn't have enough MP to cast Hurt!" << endl;
break;
}
else
{
Damage = (RANDOM(Enemy.HPMax / 4) + 1);
cout << Enemy.Name << " inflicts " << Damage << " damage to " << Hero.Name << endl;
Hero.HP -= Damage;
if (Hero.HP < 0)
Hero.HP = 0;
Enemy.MP -= 2;
}
}
else if (Enemy.Magic2 == 3) // Enemy Sleep (2)
{
cout << Enemy.Name << " casts Sleep on " << Hero.Name << "!" << endl;
if (Enemy.MP < 3)
{
cout << Enemy.Name << " doesn't have enough MP to cast Sleep!" << endl;
break;
}
else
{
StatusAcc = (RANDOM(100) + 1);
if ((StatusAcc < 30) || (Hero.Status == 1) || (Hero.Status == 3))
{
cout << "Spell had no effect!" << endl;
Enemy.MP -= 3;
}
else
{
cout << Hero.Name << " has fallen asleep!" << endl;
if (Hero.Status = 2)
Hero.Status = 3;
else
Hero.Status = 1;
Enemy.MP -=3;
}
}
}
else if (Enemy.Magic2 == 4) // Enemy Stopspell (2)
{
cout << Enemy.Name << " casts Stopspell on " << Hero.Name << "!" << endl;
if (Enemy.MP < 4)
{
cout << Enemy.Name << " doesn't have enough MP to cast Stopspell!" << endl;
break;
}
else
{
StatusAcc = (RANDOM(100) + 1);
if ((StatusAcc < 30) || (Hero.Status == 2) || (Hero.Status == 3))
{
cout << "Spell had no effect!" << endl;
Enemy.MP -= 4;
}
else
{
cout << Hero.Name << "'s spells were silenced!" << endl;
if (Hero.Status = 1)
Hero.Status = 3;
else
Hero.Status = 2;
Enemy.MP -= 4;
}
}
}
else if (Enemy.Magic2 == 5) // Enemy Healmore (2)
{
cout << Enemy.Name << " casts Healmore on self!" << endl;
if (Enemy.MP < 10)
{
cout << Enemy.Name << " doesn't have enough MP to cast Healmore!" << endl;
break;
}
else
{
Healamt = (RANDOM(Enemy.HPMax / 2) + (Enemy.HPMax / 4));
cout << Enemy.Name << " is healed of " << Healamt << " damage!" << endl;
Enemy.HP += Healamt;
if (Enemy.HP > Enemy.HPMax)
Enemy.HP = Enemy.HPMax;
Enemy.MP -= 10;
}
}
else if (Enemy.Magic2 == 6) // Enemy Hurtmore (2)
{
cout << Enemy.Name << " casts Hurtmore on " << Hero.Name << "!" << endl;
if (Enemy.MP < 5)
{
cout << Enemy.Name << " doesn't have enough MP to cast Hurtmore!" << endl;
break;
}
else
{
Damage = (RANDOM(Enemy.HPMax / 2) + (Enemy.HPMax / 4));
cout << Enemy.Name << " inflicts " << Damage << " damage to " << Hero.Name << endl;
Hero.HP -= Damage;
if (Hero.HP < 0)
Hero.HP = 0;
Enemy.MP -= 5;
}
}
}
}
}
}while(Option == 0); // End enemy option
}
if(Hero.HP == 0) // Player dies
{
cout << "I'm sorry, " << Hero.Name << ", but you have died at the hands of a " << Enemy.Name << "." << endl;
Pause();
Hero.~CPlayer();
Enemy.~CMonster();
exit(1);
}
}
}while(Enemy.HP != 0); // End battle block
cout << endl << "Battle Count = " << BattleCount << endl;
Pause();
--BattleCount;
++CountBattle;
Enemy.~CMonster();
}
FightMore = Hero.BattleRest(FileName);
}while(FightMore == 'y'); // Keep fighting?
cout << endl << "Count of Battles = " << CountBattle << endl; // Count of battles
return 0; // End of program
}