Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- //* do a complete rebuild each time you run it
- int main()
- {
- string startGame;
- string name;
- string nameTrue;
- string shipClass;
- float health;
- float missle;
- float gun;
- float dodge;
- int sectorChoice = 0;
- int attackChoice;
- int bossCleared = 0;
- float crHealth;
- float dmgDone = 0;
- float bossGun = 20;
- float bossMissle = 20;
- float bossDmgDone = 0;
- float crBossHealth;
- float bossHealth = 250;
- float enemyGun = 15;
- float enemyMissle = 15;
- float crEnemyHealth;
- float enemyHealth = 150;
- float enemyDmgDone;
- cout << "IMPORTANT: It is recommended to perform a complete rebuild before running the game each time or else it might not work." << endl << endl;
- cout << "#### ##### ### #### " << endl;
- cout << "# # # # # #" << endl;
- cout << "# # # # # #" << endl;
- cout << "#### # ##### #### " << endl;
- cout << " # # # # ## " << endl;
- cout << " # # # # # # " << endl;
- cout << "#### # # # # # " << endl << endl;
- cout << " ### ## ## ## ## ## ## ## # ### " << endl;
- cout << "# # # # # # # # # # # # # # # # # #" << endl;
- cout << "# # # # # # # # # # # # # # # # # #" << endl;
- cout << "# # # # # # # # # # # ## # # # # # #" << endl;
- cout << "# # # # # # # # # # # # ## # #" << endl;
- cout << "# # # # # # # # # # # # ## # #" << endl;
- cout << " ### ## # # # # # # # # # ## ### " << endl << endl;
- cout << "Welcome to Star Command!" << endl << "Would you like to play? Enter yes or no." << endl;
- cin >> startGame;
- if(startGame == "yes")
- {
- cout << "Here we go!" << endl;
- } else {
- cout << "That's too bad.";
- return 0;
- }
- cout << "Welcome aboard captain! What is your name?" << endl;
- cin >> name;
- cout << "Is this your name? " << name << endl << "Enter yes or no." << endl;
- cin >> nameTrue;
- if(nameTrue == "no")
- {
- cout << "How would you like to correct it?" << endl;
- cin >> name;
- cout << "Is this correct now? " << name << endl;
- cout << "Enter yes or no." << endl;
- cin >> nameTrue;
- } else {
- cout << "Let's get started on our mission!" << endl << endl;
- }
- cout << "A few days ago we recieved a distress beacon, signaling unknown engine faliure. We sent out a scout ship to investigate, but lost contact shortly after arriving in the sector. Before the scout was destroyed, they signaled a heavy enemy presence in the area. We believe the ship has been trying to skirt our defenses in secret, and attack our main battle fleet from its flank. With out nearest fleet tied besieged in the defense of mining operations, you must take a fast ship to eliminate this threat. Be careful, for we believe this ship is carring a new weapon system, and it is unkown how effective it is. " << endl << endl;
- cout << "What class of ship will you take? " << endl;
- cout << "Cruisers are the heaviest we can spare at the moment, they can take hits and dish them out, but arn't as manuverable as thier lighter counterparts. Frigates offer a good tradeoff between manuverability, survivability, and damage output. It is a ship suited for many roles. Corvettes are nimble little ships with a very high damage potential. All of this comes with a great cost to survivability. " << endl;
- cout << "Enter cruiser, frigate, or corvette. The default choice is corvette." << endl;
- cin >> shipClass;
- if(shipClass == "cruiser")
- {
- health = 475;
- missle = 20;
- gun = 24;
- dodge = 0.1;
- cout << "You have chosen a crusier!" << endl;
- }
- else if(shipClass == "frigate")
- {
- health = 350;
- missle = 20;
- gun = 20;
- dodge = 0.4;
- cout << "You have chosen a frigate!" << endl;
- }
- else
- {
- health = 271;
- missle = 28;
- gun = 12;
- dodge = 0.6;
- cout << "You have chosen a corvette!" << endl;
- };
- cout << endl;
- cout << "Your health, missle damage, gun damage, and dodge sats are:" << endl;
- health++;
- cout << health << endl;
- cout << missle << endl;
- cout << gun << endl;
- cout << dodge << endl <<endl;
- cout << "You begin your journey by jumping to the last known coordinates of the enemy ship." << endl << endl;
- while(health > 0 && bossCleared != 1)
- {
- health++;
- cout << " SECTOR MAP " << endl;
- cout << "#################" << endl;
- cout << "# <1> #" << endl;
- cout << "# %% | %% #" << endl;
- cout << "# <2>---|---<3> #" << endl;
- cout << "# %% | %% #" << endl;
- cout << "# <CURRENT> #" << endl;
- cout << "#################" << endl << endl;
- cout << "Where should we investigate?" << endl;
- cout << "Choose sector 1 , 2 , or 3 ." << endl;
- cin >> sectorChoice;
- switch(sectorChoice)
- {
- case 1:
- cout << "You jump into the friendly sector and are immediatley attacked!" << endl;
- cout << "Its rebel scout gaurding the warp beacon, and he is preparing to warp away!" << endl;
- cout << "You must destroy him before he can reach the main fleet!" << endl;
- health++;
- while(health > 0 && enemyHealth >= 0)
- {
- health++;
- cout << "What do you want do?" << endl;
- cout << "Select 1 to fire the main guns, or select 2 to fire missiles." << endl;
- cin >> attackChoice;
- cout << crHealth << health << endl;
- srand(time(0));
- float dmgMult = ((rand()%4)* .1) + 0.8;
- //*Player's attack loop:
- if(attackChoice == 1)
- {
- cout << "You fire the main guns and score a hit!" << endl;
- dmgDone = gun * dmgMult;
- crEnemyHealth = enemyHealth - dmgDone;
- cout << "You deal " << dmgDone << " points of damage to the enemy!" << endl;
- }
- else if(attackChoice == 2)
- {
- cout << "You fire a salvo of missiles that hit their mark!" << endl;
- dmgDone = missle * dmgMult;
- crEnemyHealth = enemyHealth - dmgDone;
- cout << "You deal " << dmgDone << " points of damage to the enemy!" << endl;
- }
- else
- {
- cout << "The enemy acts before you could fire off a shot!" << endl;
- }
- //* Begin enemy's attack loop:
- cout << crHealth << health << endl;
- float enemyChoice = (rand()%3);
- float missChance = ((rand()%10) * .1);
- if(enemyChoice == 1)
- {
- cout << "The enemy fires off a salvo of missiles!" << endl;
- if(missChance + dodge >= 1)
- {
- cout << "You successfully dodge the salvo!" << endl;
- }
- else
- {
- cout << "A direct hit is scored on you, and fireballs blossom along your hull." << endl;
- enemyDmgDone = enemyMissle * dmgMult;
- cout << "You sustain " << enemyDmgDone << "points of damage." << endl;
- crHealth = health - enemyDmgDone;
- };
- }
- else if(enemyChoice == 2)
- {
- cout << "The enmy fires it's battery of guns!" << endl;
- if(missChance + dodge >= 1)
- {
- cout << "The shells barely miss your ship!" << endl;
- }
- else
- {
- cout << "Their shells rip punch through your ship causing significant damage." << endl;
- enemyDmgDone = enemyGun * dmgMult;
- cout << "You sustain " << enemyDmgDone << "points of damage." << endl;
- crHealth = health - enemyDmgDone;
- }
- }
- else
- {
- cout << "The enemy fails to act, and it's time for you to strike!" << endl;
- }
- cout << crHealth << health << endl;
- health = crHealth;
- enemyHealth = crEnemyHealth;
- cout << crHealth << health << endl;
- cout << endl;
- cout << "Your currenth ship health is " << health << " an your enemies health is " << enemyHealth << "." << endl << endl;
- }
- cout << "You have destroyed the enemy scout! Your mission remains secret to the enemy." << endl;
- break;
- case 2:
- cout << "You arrive in this sector to find debris from a once great battle. You fly among the burnt out hulls of ships before finding nothing of value." << endl;
- health++;
- break;
- case 3:
- cout << "You arrive in this sector and pick up an unusual signal." << endl;
- cout << "You communication officers identify it as the secret rebel ship!" << endl;
- cout << "You fire up your weapon systems and move in on the source of the signal." << endl;
- //** BOSS FIGHT BEGINS HERE:
- cout << health << endl;
- health++;
- while(health > 0 && bossHealth >=0)
- {
- cout << "What do you want do?" << endl;
- cout << "Select 1 to fire the main guns, or select 2 to fire missiles." << endl;
- cout << health << endl;
- cin >> attackChoice;
- float dmgMult = ((rand()%4)* .1) + 0.8;
- //*Player's attack loop:
- if(attackChoice == 1)
- {
- cout << "You fire the main guns and score a hit!" << endl;
- dmgDone = gun * dmgMult;
- crBossHealth = bossHealth - dmgDone;
- cout << "You deal " << dmgDone << " points of damage to the enemy!" << endl;
- }
- else if(attackChoice == 2)
- {
- cout << "You fire a salvo of missiles that hit their mark!" << endl;
- dmgDone = missle * dmgMult;
- crBossHealth = bossHealth - dmgDone;
- cout << "You deal " << dmgDone << " points of damage to the enemy!" << endl;
- }
- else
- {
- cout << "The enemy acts before you could fire off a shot!" << endl;
- };
- //* Begin enemy's attack loop:
- cout << crHealth << health << endl;
- srand(time(0));
- float enemyChoice = (rand()%3);
- float missChance = ((rand()%10) * .1);
- if(enemyChoice == 1)
- {
- cout << "The enemy fires off a salvo of missiles!" << endl;
- if(missChance + dodge >= 1)
- {
- cout << "You successfully dodge the salvo!" << endl;
- }
- else
- {
- cout << "A direct hit is scored on you, and fireballs blossom along your hull." << endl;
- bossDmgDone = bossMissle * dmgMult;
- cout << "You sustain " << enemyDmgDone << "points of damage." << endl;
- crHealth = health - bossDmgDone;
- }
- }
- else if(enemyChoice == 2)
- {
- cout << "The enmy fires it's battery of guns!" << endl;
- if(missChance + dodge >= 1)
- {
- cout << "The shells barely miss your ship!" << endl;
- }
- else
- {
- cout << "Their shells rip punch through your ship causing significant damage." << endl;
- bossDmgDone = bossGun * dmgMult;
- cout << "You sustain " << enemyDmgDone << "points of damage." << endl;
- crHealth = health - bossDmgDone;
- }
- }
- else
- {
- cout << "The enemy fails to act, and it's time for you to strike!" << endl;
- }
- cout << crHealth << health << endl;
- health = crHealth;
- bossHealth = crBossHealth;
- cout << crHealth << health << endl;
- cout << endl;
- cout << "Your current ship health is " << health << " an your enemies health is " << bossHealth << "." << endl << endl;
- }
- if(bossHealth <= 0)
- {
- cout << "You have destroyed the rebel ship, and prevented their secret weapon from being used!" << endl;
- bossCleared = 1;
- }
- else
- {
- cout << "Your mission has failed, and you will never live too see the destruction of the fleet." << endl;
- }
- break;
- default:
- {
- cout << "You arrive in this sector to nothing but empty space. You turn back to the sector you came from." << endl;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment