//////main cpp///////
#include <iostream>
#include <time.h>
#include "fight.h"
#include "player.h"
usingnamespace std;
int direction;
int main ()
{
player currPlayer;
combat currCombat;
cout << "Welcome to Z.E.T.A" << endl;
cout << "“Zombie Elimination Training Academy”" << endl;
cout << "You have been selected to attempt to enter this elite group." << endl;
cout << "Your first task is to reach our training facility located at the old airport. " << endl;
cout << "You can take one weapon from those provided in the room. Good luck." << endl;
cout << "You see set out on a table. There is a shotgun with 12 shells, a 9mm pistol with 30 rounds, a chainsaw," << endl;
cout << "a M16 with 60 rounds and a hatchet. " << endl;
cout << "Choose your weapon. To choose your weapon enter 1 for the Shotgun, 9 for the 9mm, 2 for the chainsaw, " << endl;
cout << "16 for the M16 and 3 for the Hatchet. " << endl;
cout << endl;
cin >> currPlayer.weapon;
switch (currPlayer.weapon)
{
case 1:
currCombat.prime = 4;
currCombat.ammo = 12;
currCombat.second = 1;
currCombat.hitchance = 0;
break;
case 9:
currCombat.prime = 1;
currCombat.ammo = 30;
currCombat.second = 1;
currCombat.hitchance = 2;
break;
case 2:
currCombat.prime = 3;
currCombat.ammo = 1000;
currCombat.second = 1;
currCombat.hitchance = 4;
break;
case 16:
currCombat.prime = 2;
currCombat.ammo = 60;
currCombat.second = 1;
currCombat.hitchance = 3;
break;
case 3:
currCombat.prime = 2;
currCombat.ammo = 1000;
currCombat.second = 2;
currCombat.hitchance = 4;
break;
}
cout << "Now that you have chosen your weapon it’s 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’s time to kill your first zombie." << endl;
combat::fight_combat;
if (currCombat.playerhealth == 0)
{
cout << "You have died!! Guess you weren’t good enough for Z.E.T.A." << endl;
cout << "Game over";
return 0;
}
if (currCombat.zombiehealth == 0)
cout << "That was close hopefully there won’t be too many of those." << endl;
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;
////fight.h //////
#include <iostream>
#ifndef fight_h
#define fight_h
usingnamespace std;
class combat
{
public:
int playerhealth;
int prime;
int second;
int ammo;
int hit;
int zombiehealth;
int randhitmod;
int hitmod;
int zombiehitmod;
int zombiechop;
int hitchance;
int zombiehitchance;
char attack;
void fight_combat();
};
#endif
//////fight.cpp///////
#include <iostream>
#include "fight.h"
#include "time.h"
#include "player.h"
#include "stdlib.h"
usingnamespace std;
void fight_combat(combat com)
{
com.playerhealth = 10;
com.zombiehealth = 3;
int hitmod = 10;
srand(time(NULL));
int randhitmod = rand() % 10 +1;
cout << "Choose your attack. ";
cout << "Enter 1 to shoot or 2 of Hand to Hand";
cin >> com.attack;
if (com.attack == 1)
{
if (randhitmod + hitmod >= com.hit)
cout << "You hit the zombie";
com.zombiehealth = com.zombiehealth - com.prime, com.ammo --;
while (com.ammo = 0)
cout << "Click, click you are out of ammo.";
com.hitchance = -9999;
if (randhitmod + hitmod < com.hit)
cout << "You missed the zombie";
}
if ( com.attack == 2)
{
if (randhitmod + hitmod >= com.hit)
cout << "You hit the zombie";
com.zombiehealth = com.zombiehealth - com.second;
if (randhitmod + hitmod < com.hit)
cout << "You missed the zombie";
if (randhitmod + hitmod < com.hit)
cout << "You missed the zombie";
if (com.zombiehitmod + randhitmod >= com.hit)
cout << "The zombie hits you";
com.playerhealth = com.playerhealth - 1;
if (com.zombiehitmod + randhitmod < com.hit)
cout << "The zombie missed you";
}
while (com.playerhealth >= 0);
while (com.zombiehealth >= 0);
return;
}
This is only the most revelant part of the program and needs to function and call the function in the fight.cpp but it doesn't.
What am I doing wrong here?