Jump to content

Diffrence between player and mob


Recommended Posts

Hello, I need your help guys with something.. I want to make a statement if the player's level is bigger than the monster level with 10 levels then he does something..

 

for example: If the player is level 13 and the monster is level 1 . When he kills that monster the statement won't work, but if he kills a lv 3 monster the statement work because the difference is 10 level or less between them ..

 

Regards.

Link to comment
Share on other sites

bool CHARACTER::CheckLevelDifference(LPCHARACTER pkAttacker,LPCHARACTER pkVictim){//(optional namespace CHARACTER you can include this function everywhere as long as LPCHARACTER objects are declared aka #include "char.h")
if (pkAttacker->IsPC() && !pkVictim->IsPC())

	if (pkAttacker->GetLevel() - pkVictim->GetLevel() <= 10)
		return true;
return false;
}

remeber declaration inside header file if you plan to call it outside of said class
  bool			CheckLevelDifference(LPCHARACTER pkAttacker, LPCHARACTER pkVictim);

Moreover if you do decide to implement it inside char.cpp/char.h you can use this variation which accepts only one argument.
  
bool CHARACTER::CheckLevelDifference(LPCHARACTER ch){
if (IsPC() && !ch->IsPC())
	if (GetLevel() - ch->GetLevel() <= 10)
		return true;
return false;
}
bool CheckLevelDifference(LPCHARACTER ch);

And call it like this
  .....
	LPCHARACTER pc;
	LPCHARACTER mob;
	if (pc->CheckLevelDifference(mob))
	//else if you chose the first approach and for instance you declared and defined it inside CHARACTER_MANAGER
	if (CHARACTER_MANAGER::Instance().CheckLevelDifference(pc, mob);

 

Link to comment
Share on other sites

6 hours ago, OtherChoice said:

bool CHARACTER::CheckLevelDifference(LPCHARACTER pkAttacker,LPCHARACTER pkVictim){//(optional namespace CHARACTER you can include this function everywhere as long as LPCHARACTER objects are declared aka #include "char.h")
if (pkAttacker->IsPC() && !pkVictim->IsPC())

	if (pkAttacker->GetLevel() - pkVictim->GetLevel() <= 10)
		return true;
return false;
}

remeber declaration inside header file if you plan to call it outside of said class
  bool			CheckLevelDifference(LPCHARACTER pkAttacker, LPCHARACTER pkVictim);

Moreover if you do decide to implement it inside char.cpp/char.h you can use this variation which accepts only one argument.
  
bool CHARACTER::CheckLevelDifference(LPCHARACTER ch){
if (IsPC() && !ch->IsPC())
	if (GetLevel() - ch->GetLevel() <= 10)
		return true;
return false;
}
bool CheckLevelDifference(LPCHARACTER ch);

And call it like this
  .....
	LPCHARACTER pc;
	LPCHARACTER mob;
	if (pc->CheckLevelDifference(mob))
	//else if you chose the first approach and for instance you declared and defined it inside CHARACTER_MANAGER
	if (CHARACTER_MANAGER::Instance().CheckLevelDifference(pc, mob);

 

I want it as a quest :D please ,, how can I define the mob in a quest ? 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.