Jump to content
  • Advertisement
Sign in to follow this  
Nikita21

Unresolved?

This topic is 4231 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

S_Skills.cpp



#define GetSkillData(SkillIndex) ((Skills*)(&SkillTable[SkillIndex]))

void Skills::DeathMessageType(int Magic)
{
	if(MagicType(FIRE)) { printf("was burned by "); }
}


void Skills::TypeOfDamage(int type) {
	srand(time(0));
	type = rand()%MAX_TYPES;
	switch(type) {
		case FIRE:
			{ DeathMessageType(GetSkillData(0)->MagicType(FIRE)); }
		break;
		case FROST:
			{ Skill_Damage += 3; printf("+6 Froest damage given"); }
		break;
	case NATURE:
		{Skill_Damage += 3; printf("+6 Nature damage given"); }
		break;
	case LIGHTNING:
		{ Skill_Damage +=7; printf("+7 Lightning damage given");}
		break;
	case MAGIC:
		{ Skill_Damage +=7; printf("+7 Magic damage given");}
		break;
	case PHYSICAL:
		{ Skill_Damage +=7; printf("+7 Physical damage given");}
		break;
	case NONE:
		{ Skill_Damage; printf("None damage given");}
		break;
	default:
		{ Skill_Damage +=4; printf("+7 Physical damage given"); }
		break;
		}
};


S_Skills.h
enum ELEMENTS {FIRE, FROST, NATURE, LIGHTNING, MAGIC, PHYSICAL, NONE, MAX_TYPES} E_Elements;

struct Skills { 
	char s_Skill_Name[SKILL_NAME]; // 0
	bool CanCast;				   // 1
	int Skill_Damage;			   // 2
	int Mana_Cost;				   // 3
	int TimeCast;				   // 4
	int MagicMod;				   // 5
	int ELEMENT;				   // 6
	int MagicType(int Element);	   // 7
	void TypeOfDamage(int type);    void.
	void DeathMessageType(int Magic);  void.
private:
	static const int OK = 0;	   // 0
	static const int FAIL = 1;         // 1
};

Errors
s_skills.obj : error LNK2019: unresolved external symbol "public: int __thiscall Skills::MagicType(int)" (?MagicType@Skills@@QAEHH@Z) referenced in function "public: void __thiscall Skills::DeathMessageType(int)" (?DeathMessageType@Skills@@QAEXH@Z)
C:\Documents and Settings\Illasera Moo\My Documents\CPP Projects\IllaConsoleRPG\Debug\IllaConsoleRPG.exe : fatal error LNK1120: 1 unresolved externals

Note : These are bits of the relevant code

Share this post


Link to post
Share on other sites
Advertisement
Where's your definition of the function "MagicType"? All you have is the declaration:

int MagicType(int Element);

Share this post


Link to post
Share on other sites
I am not sure if it is just a typo in your posting but you did not include the header file in the .cpp file. Also I did not see the MagicType function defined anywhere. Maybe that will fix the unresolved error.

Share this post


Link to post
Share on other sites
You declare a function in your class:
int MagicType(int Element);	   // 7

which you don't define.

PS The macro GetSkillData() should be an inlined function instead. There is no reason for it to be a macro and lose the type safety.

Share this post


Link to post
Share on other sites
Thanks for everyone`s help,

This is what i wanted :)

Skills.h



struct Skills {
char s_Skill_Name[SKILL_NAME]; // 0
bool CanCast; // 1
int Skill_Damage; // 2
int Mana_Cost; // 3
int TimeCast; // 4
int EleType; // 5
int SkillMod; // 6
private:
static const int OK = 0; // 0
static const int FAIL = 1; // 1
};

struct SkillTypes : public Skills
{
void TypeOfDamage(int type); // Extrenel void.
void DeathMessageType(int Magic); // Exeterenl void.
void MagicType(int Element); // void
private:
int Element;
};




Skills.cpp



void SkillTypes::MagicType(int Element) {
int x = Element;
if(x == FIRE) { printf("was burned by "); }
else if(x == FROST) { printf("was Frozen by "); }
}

void SkillTypes::TypeOfDamage(int type) {
srand(time(0));
type = rand()%MAX_TYPES;
switch(type) {
case FIRE:
{ MagicType(FIRE); }
break;
case FROST:
{ MagicType(FROST); }
break;

// ... And so on...


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!