///// main.cpp///////
#include <iostream>
#include <time.h>
#include "fight.h"
#include "player.h"
#include "zombie.h"
usingnamespace std;
int direction;
player R; //instance of player class
combat B; //instance of combat class
zombie E; //instance of zombie class
int main ()
{
cout << " Welcome to Z.E.T.A" << endl;
cout << " “ Zombie Elimination Training Academy ”" << endl;
cout << " You have been selected to attempt to " << endl;
cout << " enter this elite group. Your first" << endl;
cout << " task is to reach our training facility " << endl;
cout << " located at the old airport. You can" << endl;
cout << " take one weapon from those provided " << endl;
cout << " in the room. Good luck." << endl;
cout << " " << endl;
cout << " You see set out on a table." << endl;
cout << " a shotgun with 12 shells," << endl;
cout << " a 9mm pistol with 30 rounds, " << endl;
cout << " a chainsaw," << endl;
cout << " a M16 with 60 rounds " << endl;
cout << " and a hatchet. " << endl;
cout << " " << endl;
cout << " Choose your weapon. " << endl;
cout << " To choose your weapon," << endl;
cout << " enter 1 for the Shotgun, " << endl;
cout << " 9 for the 9mm, " << endl;
cout << " 2 for the chainsaw, " << endl;
cout << " 16 for the M16 and " << endl;
cout << " 3 for the Hatchet. " << endl;
cout << endl;
cin >> R.weapon; //weapon selection
switch (R.weapon)// iniatilize weapon variables
{
case 1: //shotgun selected
R.prime = 4; //primary attack
R.ammo = 12; //ammo tracking
R.second = 1; //secondary or hand to hand attack
R.hitchance = 0; //player base hit number
break;
case 9: //9MM pistol selected
R.prime = 1; //primary attack
R.ammo = 30; //ammo tracking
R.second = 1; //secondary or hand to hand attack
R.hitchance = 2; //player base hit number
break;
case 2: //Chainsaw selected
R.prime = 3; //primary attack
R.ammo = 1000; //ammo tracking
R.second = 1; //secondary or hand to hand attack
R.hitchance = 4; //player base hit number
break;
case 16: //M16 selected
R.prime = 2; //primary attack
R.ammo = 60; //ammo tracking
R.second = 1; //secondary or hand to hand attack
R.hitchance = 3; //player base hit number
break;
case 3: //Hatchet selected
R.prime = 2; //primary attack
R.ammo = 1000; //ammo tracking
R.second = 2; //secondary or hand to hand attack
R.hitchance = 4; //player base hit number
break;
}
cout << " Now that you have chosen your weapon it is" << endl;
cout << " now time to get to the airport." << endl;
cout << " Looking out the window you see a few zombies walking the streets. " <<endl;
cout << " This is not going to be as easy as it sounds." << endl;
cout << " You head out down the stairs to get to the facility." << endl;
cout << " As you near the bottom floor you hear a faint shuffling sound." << endl;
cout << " Sounds like it is time to kill your first zombie." << endl;
cout << " " << endl;
B.fight_combat(); //combat function call
cout << "After taking out that zombie you take a moment to collect yourself." << endl;
cout << "Walking out the door you see the main road to the airport " << endl;
cout << "and the back streets and alleys. The main road has zombies all over it and who knows what you may find taking the alleys. " << endl;
cout << "Enter 1 to take the road or 2 to go the back way." << endl;
cin >> direction;
if (direction == 1)//the hard way
{
cout << "You start making you way down the road listening carefully for signs of zombies. " << endl;
cout << "After passing a few abandoned cars you see a zombie shuffling out from behind a car up ahead." << endl;
B.fight_combat(); //call combat function
if (E.zombiehealth == 0) //zombie dead move on
cout << "Well hopefully all that noise doesn’t attract too much attention." <<endl;
cout << "Heading down the road a bit faster now more and more zombies are coming out behind you." << endl;
cout << "As you near the entrance of the airport you see 3 zombies chewing on a corpse in the road." << endl;
cout << "Looks like you have one more big fight ahead of you." << endl;
B.fight_combat(); // call combat function
if (E.zombiehealth == 0)// zombie dead move on
B.fight_combat(); //call combat function
if (E.zombiehealth == 0) // zombie dead move on
B.fight_combat(); // call combat function
if (E.zombiehealth == 0) //zombie dead move on
cout << "Well you somehow managed to beat those zombies. Dragging yourself through the gate you feel somehow relived." << endl;
cout << "A man in a military uniform walks up to you. " << endl;
cout << "Well done looks like you have what it takes to help us rid the world of this zombie menace." << endl;
cout << "Welcome to Z.E.T.A." << endl;
cin.get();
cin.get();
return 0;
}
//End the hard way
if (direction == 2) //The easy way
{
cout << "Twisting through the side streets you can hear the zombies everywhere but so far have yet to see any." << endl;
cout << "Suddenly one stumbles out form a dark corner." << endl;
B.fight_combat(); //call the combat function
if (E.zombiehealth == 0) // zombie dead move on
cout << "Thankfully you know your way around town. " << endl;
cout << endl;
cout << "Taking a few more turns you see a zombie crawling out of a house." << endl;
B.fight_combat(); //call the combat function
if (E.zombiehealth == 0) // zombie dead move on
cout << "Just when you think you might have been better off taking the main road you spot the airport employee parking garage. " << endl;
cout << "Thinking to yourself, wasn’t there a tunnel leading in to the airport in there." <<endl;
cout << "Making your way through the garage you manage to find the tunnel with little difficulty. " << endl;
cout << "As you approach the tunnel entrance you see a zombie, who looks like a pilot scratching at the door. " << endl;
B.fight_combat(); //call the combat function
if (E.zombiehealth == 0) //zombie dead move on
cout << "After dispatching the zombie pilot you try to open the door only to find it takes a special key. " << endl;
cout << "Searching around you notice a key card on the pilots belt. Using it to open the door you run through the tunnel to the airport." << endl;
cout << "When you come out you almost run in to a man in a military uniform. He looks at you and smiles. " << endl;
cout << "Well done you will do well here. We have needed someone like you for some time now. " << endl;
cout << "Let’s get you cleaned up and start you training. " << endl;
cin.get();
cin.get();
return 0;
//end the easy way
}
return 0;//end of the intro more story in the works
}
////Player.cpp///////
#include <iostream>
#include "player.h"
#include "fight.h"
#include "zombie.h"
usingnamespace std;
player::player(void)
{
playerhealth = 10; //Player Health declared
}
player::~player()
{
}
player P; //instance of player clas
zombie G; //instance of zombie class
combat Z; //instance of combat class
int playerAttack() //player Attack function
{
cout << " Choose your attack. " << endl;
cout << " Enter 1 to shoot or 2 of Hand to Hand" << endl;
cout << " " << endl;
//cout << " prime is" << this -> prime << endl;
//cout << "ammo is "<< this -> ammo << endl;
//cout << "second is " << this -> second << endl;
//cout << "hitchance is " << this -> hitchance << endl;
//cout << " player health is " << P.playerhealth << endl;
//cout << " zombie health is " << G.zombiehealth << endl;
//cout << "randhit mod is" << randhitmod << endl;
cin >> P.attack; //player chooses primary or secondary or hand to hand attack
switch (P.attack)//if (A.attack == 1)
{
case 1: //pirmary attack
if (Z.randhitmod + P.hitchance >= Z.hit, P.ammo --)
{
cout << "You hit the zombie" << endl; //Player hit zombie
G.zombiehealth = G.zombiehealth - P.prime;
}
else;//if (randhitmod + this -> hitchance < A.hit, this -> ammo --)
{
P.ammo--;
cout << "You missed the zombie" << endl; // player misses zombie
}
if (P.ammo == 0) //ammo check
{
cout << "Click, click you are out of ammo." << endl;
P.hitchance = -9999;
}
//if ( A.attack == 2)
case 2: //secondary attack
if (Z.randhitmod + P.hitchance >= Z.hit)
{
cout << "You hit the zombie" << endl;
G.zombiehealth = G.zombiehealth - P.second;
}
if (Z.randhitmod + P.hitchance < Z.hit)
{
cout << "You missed the zombie" << endl;
}
default:
cout << "Please enter either 1 or 2." << endl;
break;
}
return 0;
}
/////fight.cpp//////
#include <iostream>
#include "fight.h"
#include <time.h>
#include "player.h"
#include "stdlib.h"
#include "zombie.h"
usingnamespace std;
combat A; //instance of combat class
zombie D; //instance of zombie class
player Q; // instance of player class
combat::combat(void)
{
hit = 10; //int hit declared
}
combat::~combat()
{
}
int combat::fight_combat() //combat function
{
srand(time(NULL)); // random number generator
int randhitmod = rand() % 10 +1; //random number range
Q.playerAttack(); // call playerAttack function
D.deadAttack(); // call zombieAttack function
if (Q.playerhealth <= 0) //game over
{
cout << "The zombie pulls you to the ground and starts to devour your flesh. Hopefully you will not feel this too long. " << endl;
cout << "Game over" << endl;
cin.get();
cin.get();
return 0;
}
else (D.zombiehealth <= 0); //move on
{
cout << "That was close hopefully there will not be too many of those." << endl;
}
while (Q.playerhealth >= 0, D.zombiehealth >= 0) //Loop until one or the other is dead
cin.get();
cin.get();
return D.zombiehealth;
}
/////zombie.cpp//////
#include <iostream>
#include "zombie.h"
#include "player.h"
#include "fight.h"
usingnamespace std;
player C; //instance of player class
zombie F; //instance of zombie class
combat Y; //instance of copmbat class
zombie::zombie(void)
{
zombiehitmod = 1; //zombies modifier to hit a target declared
zombiechop = 1; //zombie damage declared
zombiehitchance = 1; //zombie base chance to hit declared
zombiehealth = 3; // zombie health declared
}
zombie::~zombie()
{
}
int deadAttack()
//zombie attacks
{
if (F.zombiehitmod + Y.randhitmod >= Y.hit) //zombie hits player
{
cout << "The zombie hits you" << endl;
C.playerhealth = C.playerhealth - F.zombiechop;
}
if (F.zombiehitmod + Y.randhitmod <= Y.hit) //zombie deals damage
{
cout << "The zombie missed you" << endl;
}
return 0;
}
////fight.h///////
#include <iostream>
#ifndef fight_h
#define fight_h
usingnamespace std;
class combat
{
public:
combat(void);
~combat(void);
int randhitmod; //random number generator
int hit; //number needed to hit a target currently is 10
int fight_combat(); // combat function
};
#endif
//////player.h//////
#include <iostream>
#ifndef player_h
#define player_h
usingnamespace std;
class player
{
public:
player(void);
~player(void);
int weapon; //weapon selection variable
int playerhealth; //Player health variable
int prime; //primary attack variable
int second; //secondary attack variable
int ammo; //Ammo chack variable
int hitchance; //Weapon modifier to hit a target
int attack; //Attack selection variable
int playerAttack(); //playerAttack function
};
#endif
///zombie.h///////
#include <iostream>
#ifndef zombie_h
#define zombie_h
usingnamespace std;
class zombie
{
public:
zombie(void);
~zombie(void);
int zombiehealth; //zombies health variable
int deadAttack(); //zombie attack function
int zombiehitmod ; //zombie modifier to hit a target
int zombiechop ; //zombie damage
int zombiehitchance ; // zombie base to hit a target
};
#endif
class zombie
{
public:
zombie(void);
~zombie(void);
int zombiehealth; //zombies health variable
int deadAttack(); //zombie attack function
int zombiehitmod ; //zombie modifier to hit a target
int zombiechop ; //zombie damage
int zombiehitchance ; // zombie base to hit a target
} //<<<< here
#endif