Jump to content
×
×
  • Create New...

How To Make Pet Name Like Official with Level


Recommended Posts

Hey guys, i think not many people know how to put the pet name like oficial so im making a tutorial on how to do it.

 

  • First, go to game->PetSystem.cpp and search for:
Spoiler

 void CPetActor::SetName(const char* name)

 

  •  Under that function add this:           
Spoiler

 

void CPetActor::SetLevel(BYTE level)
{
    BYTE petLevel = level;
    if (0 > level)
    {
        petLevel = 0;
    }

    if (true == IsSummoned())
        m_pkChar->SetLevel(petLevel);

    m_level = petLevel;
}

 

 

  • Search for:
Spoiler

DWORD CPetActor::Summon(const char* petName, LPITEM pSummonItem, bool bSpawnFar)

 

  • Replace with:
Spoiler

DWORD CPetActor::Summon(const char* petName, BYTE petLevel, LPITEM pSummonItem, bool bSpawnFar)

 

  • In that same function (Summon), you will find this:
Spoiler

this->SetName(petName);

 

  • Add under:
Spoiler

this->SetLevel(petLevel);

 

  • Search for:
Spoiler

CPetActor* CPetSystem::Summon(DWORD mobVnum, LPITEM pSummonItem, const char* petName, bool bSpawnFar, DWORD options)

 

  • Replace with:
Spoiler

CPetActor* CPetSystem::Summon(DWORD mobVnum, LPITEM pSummonItem, const char* petName, BYTE petLevel, bool bSpawnFar, DWORD options)

 

  • In the same function you will find:
Spoiler

DWORD petVID = petActor->Summon(petName, pSummonItem, bSpawnFar);

 

  • Replace with:
Spoiler

DWORD petVID = petActor->Summon(petName, petLevel, pSummonItem, bSpawnFar);

  • Save the file.

 

  • Open game->PetSystem.h.
  • Search for:
Spoiler

std::string        m_name; 

 

  • Add under:
Spoiler

BYTE            m_level;

 

  • Search for:
Spoiler

void            SetName(const char* petName);

 

  • Add under:
Spoiler

void            SetLevel(BYTE petLevel);

 

  • A little bit under you will find:
Spoiler

DWORD            Summon(const char* petName, LPITEM pSummonItem, bool bSpawnFar = false);

 

  • Replace with:
Spoiler

DWORD            Summon(const char* petName, BYTE petLevel, LPITEM pSummonItem, bool bSpawnFar = false);

 

  • Search for:
Spoiler

CPetActor*    Summon(DWORD mobVnum, LPITEM pSummonItem, const char* petName, bool bSpawnFar, DWORD options = CPetActor::EPetOption_Followable | CPetActor::EPetOption_Summonable);

 

  • Add Under;
Spoiler

CPetActor*    Summon(DWORD mobVnum, LPITEM pSummonItem, const char* petName, BYTE petLevel, bool bSpawnFar, DWORD options = CPetActor::EPetOption_Followable | CPetActor::EPetOption_Summonable);

 

  • Save the file. 

 

Lastly we will change the quest function pet.summon(mobVnum, petName, bFromFar) to pet.summon(mobVnum, petName, petLevel, bFromFar)

 

  • Open game->questlua_pet.cpp and search for :
Spoiler

int pet_summon(lua_State* L)

 

  • Replace the function with:
Spoiler

 

int pet_summon(lua_State* L)
    {
        LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
        CPetSystem* petSystem = ch->GetPetSystem();
        LPITEM pItem = CQuestManager::instance().GetCurrentItem();
        if (!ch || !petSystem || !pItem)
        {
            lua_pushnumber (L, 0);
            return 1;
        }

        if (0 == petSystem)
        {
            lua_pushnumber (L, 0);
            return 1;
        }

        // ¼Òȯ¼öÀÇ vnum
        DWORD mobVnum= lua_isnumber(L, 1) ? lua_tonumber(L, 1) : 0;

        // ¼Òȯ¼öÀÇ À̸§
        const char* petName = lua_isstring(L, 2) ? lua_tostring(L, 2) : 0;

        BYTE petLevel = lua_isnumber(L, 3) ? lua_tonumber(L, 3) : 0;

        // ¼ÒȯÇÏ¸é ¸Ö¸®¼­ºÎÅÍ ´Þ·Á¿À´ÂÁö ¿©ºÎ
        bool bFromFar = lua_isboolean(L, 4) ? lua_toboolean(L, 4) : false;

        CPetActor* pet = petSystem->Summon(mobVnum, pItem, petName, petLevel, bFromFar);

        if (pet != NULL)
            lua_pushnumber (L, pet->GetVID());
        else
            lua_pushnumber (L, 0);

        return 1;
    }

 

  • Save the file.
  • Compile It.

Done :)

Now just change your pet quest function to pet.summon(mobVnum, petName, petLevel, bFromFar).

To make the clientside changes check out .Avenue topic: https://metin2dev.org/board/index.php?/topic/8276-how-to-pet-level-in-other-color-like-official/
PS: In .Avenue topic dont forget to check also the second post he done is a important step to make you see the pet level.

I hope this was usefull,
Kind Regards,
Frozen

 

  • Love 5
Link to comment
Share on other sites

Have you done this part?

Server-Source, char.cpp

Search for:

if (IsPC() == true && (LC_IsEurope() == true || LC_IsCanada() == true || LC_IsSingapore() == true))

Replace the complete if-statement with: 

		if ((IsPC() || IsMonster() || IsPet()) == true)
		{
			addPacket.dwLevel = GetLevel();
		}
		else
		{
			addPacket.dwLevel = 0;
		}

Credits: .Avenue

 

Link to comment
Share on other sites

12 hours ago, Frozen said:

Have you done this part?

Server-Source, char.cpp

Search for:

if (IsPC() == true && (LC_IsEurope() == true || LC_IsCanada() == true || LC_IsSingapore() == true))

Replace the complete if-statement with: 

		if ((IsPC() || IsMonster() || IsPet()) == true)
		{
			addPacket.dwLevel = GetLevel();
		}
		else
		{
			addPacket.dwLevel = 0;
		}

Credits: .Avenue

 

yes  you can show my part

Spoiler

        if ((IsPC()|| IsPet()) == true)
        {
            addPacket.dwLevel = GetLevel();
        }
        else
        {
            addPacket.dwLevel = 0;
        }

 

Link to comment
Share on other sites

  • Moon

At first, you don't have to follow a long way for that. The second one is about CPetActor::SetLevel. You don't have to follow a long way for that too. The default will be one all the time if the level is less than zero. 

addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel() : 0;
void CPetActor::SetLevel(BYTE level)
{
	if (!IsSummoned())
		return;
	
	if (level < 0)
		level = 1; // Default will be 1 all the time if the level is less than zero.
	
	m_pkChar->SetLevel(level);
	m_level = level;
}

Do not be sorry, be better.

Link to comment
Share on other sites

  • Moon
Just now, ImBacK said:
what the difference

We're calling that code style. You don't have to use if condition all the time. You're just assign the variable with the condition. You can do this with "?" too.

Kind Regards ~ Ken

Do not be sorry, be better.

Link to comment
Share on other sites

13 hours ago, Ken said:

At first, you don't have to follow a long way for that. The second one is about CPetActor::SetLevel. You don't have to follow a long way for that too. The default will be one all the time if the level is less than zero. 

addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel() : 0;
void CPetActor::SetLevel(BYTE level)
{
	if (!IsSummoned())
		return;
	
	if (level < 0)
		level = 1; // Default will be 1 all the time if the level is less than zero.
	
	m_pkChar->SetLevel(level);
	m_level = level;
}

ken i test your edit but level dont show [email protected]

Link to comment
Share on other sites

11 hours ago, Ken said:

At first, you don't have to follow a long way for that. The second one is about CPetActor::SetLevel. You don't have to follow a long way for that too. The default will be one all the time if the level is less than zero. 

addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel() : 0;
void CPetActor::SetLevel(BYTE level)
{
	if (!IsSummoned())
		return;
	
	if (level < 0)
		level = 1; // Default will be 1 all the time if the level is less than zero.
	
	m_pkChar->SetLevel(level);
	m_level = level;
}

That's totally correct, thanks for the optimization.

Kind Regards.

Link to comment
Share on other sites

On 21/12/2015 at 2:23 PM, Ken said:

At first, you don't have to follow a long way for that. The second one is about CPetActor::SetLevel. You don't have to follow a long way for that too. The default will be one all the time if the level is less than zero. 

addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel() : 0;
void CPetActor::SetLevel(BYTE level)
{
	if (!IsSummoned())
		return;
	
	if (level < 0)
		level = 1; // Default will be 1 all the time if the level is less than zero.
	
	m_pkChar->SetLevel(level);
	m_level = level;
}

like this?  cause i am noob...

Spoiler

if (IsPC() == true && (LC_IsEurope() == true || LC_IsCanada() == true || LC_IsSingapore() == true))
        {
            addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel();
        }
        else
        {
            addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel() : 0;
        }

 

Link to comment
Share on other sites

15 minutes ago, BackPlayer said:

like this?  cause i am noob...

  Hide contents

if (IsPC() == true && (LC_IsEurope() == true || LC_IsCanada() == true || LC_IsSingapore() == true))
        {
            addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel();
        }
        else
        {
            addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel() : 0;
        }

 

No instead of the if statement just put this: What this is doing is the same as the if statement: (the checks) ? (what is equal case true) : (what is equal case false);

addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel() : 0;
Link to comment
Share on other sites

if (IsPC() == true && (LC_IsEurope() == true || LC_IsCanada() == true || LC_IsSingapore() == true))
        {
            addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel();
        }
        else
        {
            addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel() : 0;
        }addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel() : 0;

Delete this /\ and put this V:

addPacket.dwLevel = IsPC() || IsMonster() || IsPet() ? GetLevel() : 0;

But you dont need to make the code like this, this is just a way to optimize the code, you can put like is in avenue topic.

  • Love 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


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.