having trouble with a class function call

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//////main cpp///////
#include <iostream>
#include <time.h>
#include "fight.h"
#include "player.h"

using namespace 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
using namespace 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"

using namespace 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?
Topic archived. No new replies allowed.