Jump to content
×
×
  • Create New...

Cannot attack mob if my level is too hight


Recommended Posts

  • Sun

This little code let you not attack mob if difference between you level and mob lever is over 15

 

//Battle.cpp

//in bool battle_is_attackable(LPCHARACTER ch, LPCHARACTER victim) search:



    if (victim->IsDead())

        return false;

   

//Add Under:



    if (!(victim->IsPC()))

    {

        if (ch->GetLevel() - victim->GetLevel() > 15)

        {

            return false;

        }
      
    }

 

This is the hidden content, please

Edited by TokiSan
  • Metin2 Dev 4
  • Love 2
  • Good 1
Link to comment
Share on other sites

  • Moderator
On 1/17/2021 at 1:17 AM, TokiSan said:

 

 

    if (!(victim->IsPC()))
    {

        if (ch->GetLevel() - victim->GetLevel() > 15)
        {
            return false;

        }
        else
        {
            return true;

        }
    }

 

 

Thanks for release, but there's something wrong.

First, you've to put the condition after it's checking the safe zone and others, you made a return true without checking those as well. (things will going wrong)

Second, you'll get a negative number if:

int player = 50;
int victim = 80;
int diff = player - victim;
cout << (diff > 15) << endl;
// -30 > 15 ? = false

You've to use std::abs for getting the absolute value.

The code should look like:

This is the hidden content, please

Basically you can't attack a mob if:

  • playerLevel = 50
  • monsterLevel = 66

or:

  • playerLevel = 66
  • monsterLevel = 50
Edited by VegaS™
  • Good 3
Link to comment
Share on other sites

  • Sun
28 minutes ago, VegaS™ said:

 

Thanks for release, but there's something wrong.

First, you've to put the condition after it's checking the safe zone and others, you made a return true without checking those as well. (things will going wrong)

Second, you'll get a negative number if:


int player = 50;
int victim = 80;
int diff = player - victim;
cout << (diff > 15) << endl;
// -30 > 15 ? = false

You've to use std::abs for getting the absolute value.

The code should look like:


if (ch && victim && !victim->IsPC())
{
	static const BYTE DIFFERENCE_LEVEL_ATTACK = 15;
	if (std::abs(ch->GetLevel() - victim->GetLevel()) > DIFFERENCE_LEVEL_ATTACK)
		return false;
}

 

Basically you can't attack a mob if:

  • playerLevel = 50
  • monsterLevel = 66

or:

  • playerLevel = 66
  • monsterLevel = 50

Umh I thank you for the answer, but what interested me was just the case where a player's level was higher than that of a monster. In fact, when you do a boss event, several bosses of different levels are spawned. That way I just wanted to prevent larger levels from take bosses to the smallest levels. About the opposite, who care. If you want attack op boss your problem. 

 

Btw it's a code that I wrote fast, I don't know if you need to Insert the trigg for ATTR_BANPK. Tomorrow I'll watch it better. 

Edited by TokiSan
Link to comment
Share on other sites

  • Moderator

I didn't said that you've to insert something, I mean that structure of your condition, it's non-sense, if (condition) retun false else return true;

Because there're other checks which has to be checked, before you return that true, was enough just to return false if the condition was fulfilled, that's all.

 

Quote

but what interested me was just the case where a player's level was higher than that of a monster.

 

Quote

difference between you level and mob lever is over 15

Difference means (x-y).

Your code is bugged, please try to run it.

This is the hidden content, please

I'm talking about the conditions and math itself, they're totally wrong.

If you really want to check just if the player level is higher than monster then you've to do this:

if ((ch->GetLevel() > victim->GetLevel()) && (ch->GetLevel() - victim->GetLevel()) > 15)

 

So, in that way you're not comparing a negative number with a positive one, you'll be fine.

But yeah.. who cares about math rules in metin2? 🤨

 

Btw, if someone uses your code how it's right now, and there's a guy who knows some basics of reverse engineering, can modify the function IsInSafe in someone's client and make it return false all of the time, he can start a party...

He can kill everybody from every place, even in the safe zone since you made a return true at the beginning of the function.

Edited by VegaS™
  • Good 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.


  • Activity

    1. 36

      Destroy Item System

    2. 1

      Brillances

    3. 0

      Fusion.org is Looking for Staff Members

    4. 1

      Brillances

    5. 3

      ELONIA2 | PVM-MEDIUM | 11 LANGUAGES | INTERNATIONAL | A NEW STORY

    6. 4

      Spider Queen not spawining in spider dungeon v1

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.