hey, i'm writing a piece of code and i got an error that i really don't understand. The code is below, but i had to post it all because i can't even understand the error, so i posted it all.
The Error:
1>main.obj : error LNK2019: unresolved external symbol "int __cdecl combat(void)" (?combat@@YAHXZ) referenced in function "void __cdecl North1(void)" (?North1@@YAXXZ)
1>C:\Users\Matthew\documents\visual studio 2010\Projects\Text_Game\Debug\Text_Game.exe : fatal error LNK1120: 1 unresolved externals
The Code:
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <ctime>
#include <Windows.h>
using namespace std;
string Plrname;
int choiceint;
int choose (string);
bool dragonkilled;
bool plrhasgear;
bool plrkilled;
string Path1;
int combat();
void North1 ();
void South1 ();
void East1 ();
void West1 ();
int main () {
system("title The Game");
dragonkilled = 0;
plrkilled = 0;
cout << "Welcome to the game." << endl;
cout << " " << endl;
cout << "What is your name?" << endl;
getline(cin,Plrname);
cout << "Now " << Plrname << ", we shall begin." << endl;
cin.ignore();
cin.get();
system("cls");
cout << "You wake in a strange forest, with no memories of how you got here, but" << endl;
cout << "you are in the middle of a crossroads, what path shall you take?" << endl;
cout << "(North, South, East or West)" << endl;
getline(cin,Path1);
choose(Path1);
if (choiceint == 1) {
North1();
} else if (choiceint == 2) {
South1();
} else if (choiceint == 3) {
East1();
} else if (choiceint == 4) {
West1();
} else {
choose(Path1);
}
do {
choose(Path1);
} while (dragonkilled == 0, plrkilled == 0);
if (plrkilled == 1) {
system("cls");
cout << "You lose!" << endl;
} else if (dragonkilled == 1) {
system("cls");
cout << "You win!" << endl;
}
system("pause");
return 0;
}
int choose (string choice) {
if (choice == "north", "North") {
choiceint = 1;
} else if (choice == "south", "South") {
choiceint = 2;
} else if (choice == "east", "East") {
choiceint = 3;
} else if (choice == "west", "West") {
choiceint = 4;
} else {
choiceint = 5;
}
return (choiceint);
}
void North1 () {
if (plrhasgear == 1) {
cout << "You decide to travel north, and come across a monster!" << endl;
combat();
system("cls");
cout << "Where do you want to go now?" << endl;
getline(cin,Path1);
} else {
cout << "You found some gear!" << endl;
plrhasgear = 1;
cin.ignore();
cin.get();
cout << "Where do you want to go now?" << endl;
getline(cin,Path1);
}
}
void South1 () {
cout << "You decide to travel south, and come across a monster!" << endl;
combat();
system("cls");
cout << "Where do you want to go now?" << endl;
getline(cin,Path1);
}
void East1 () {
cout << "You decide to travel south, and come across a monster!" << endl;
combat();
system("cls");
cout << "Where do you want to go now?" << endl;
getline(cin,Path1);
}
void West1 () {
cout << "You decide to travel west, and come across a monster!" << endl;
combat();
system("cls");
cout << "Where do you want to go now?" << endl;
getline(cin,Path1);
}
int Combat () {
system ("cls");
int monsterno;
int monsterlvl;
double monsterhp;
double monsterdmg;
int monstercrit;
double plrhp;
double plrdmg;
plrhp = 10;
plrdmg = 5;
if (plrhasgear == 1) {
plrhp = plrhp*2.5;
plrdmg = plrdmg*2;
}
srand( int( time( NULL ) ) );
monsterno = rand() % 4;
monstercrit = rand() % 5;
if (monsterno == 0) {
cout << "You have encountered a panther!" << endl;
monsterhp = 20;
monsterlvl = 1;
monsterdmg = 2;
if (monstercrit == 0) {
monsterdmg = monsterdmg * 1.5;
}
} else if (monsterno == 1) {
cout << "You have encountered a troll!" << endl;
monsterhp = 25;
monsterlvl = 2;
monsterdmg = 3;
if (monstercrit == 0) {
monsterdmg = monsterdmg * 1.5;
}
} else if (monsterno == 2) {
cout << "You have encountered a necromancer!" << endl;
monsterhp = 30;
monsterlvl = 3;
monsterdmg = 5;
if (monstercrit == 0,1) {
monsterdmg = monsterdmg * 1.5;
}
} else if (monsterno == 3) {
cout << "You have encountered the dragon, good luck!" << endl;
monsterhp = 40;
monsterlvl = 5;
monsterdmg = 10;
if (monstercrit == 0,1,2) {
monsterdmg = monsterdmg * 2;
}
if (monsterhp == 0) {
dragonkilled = 1;
}
}
do {
cout << "You have " << plrhp << " health remaining." << endl;
cout << "The monster has " << monsterhp << " health remaining." << endl;
cin.ignore();
cin.get();
system("cls");
cout << "Monster hits you for " << monsterdmg << " damage!" << endl;
plrhp = plrhp-monsterdmg;
cin.ignore();
cin.get();
cout << Plrname << " hits the monster for " << plrdmg << "damage!" << endl;
cin.ignore();
cin.get();
} while (plrhp != 0, monsterhp != 0);
if (plrhp == 0) {
plrkilled = 1;
}
return (plrkilled);
}
sorry that the code is so long, as i said, i'm not sure were i've gone wrong so i posted it all.