Jump to content

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
https://metin2.dev/topic/21228-diffrence-between-player-and-mob/
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);

 

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 ? 

  • Premium

ON KILL YOU HAVE:

pc -> the char

npc->the entity victim.

 

You can do like official:

Spoiler

when kill with not npc.is_pc() and pc.get_level()-npc.get_level() < 10 begin
       --DO THINGS
end

 

10 is the level diff.

 

  • Love 1
10 hours ago, WeedHex said:

ON KILL YOU HAVE:

pc -> the char

npc->the entity victim.

 

You can do like official:

  Hide contents

when kill with not npc.is_pc() and pc.get_level()-npc.get_level() < 10 begin
       --DO THINGS
end

 

10 is the level diff.

 

Finally I found the function :P thanks dude 

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.