Jump to content

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
https://metin2.dev/topic/9755-how-to-make-pet-name-like-official-with-level/
Share on other sites

2 hours ago, ImBacK said:

thanks for u

but what about level up & exp ?

You can do it with a quest.

Take a look of Denis topic: https://metin2dev.org/board/index.php?/topic/1322-pet-system-with-experience-and-level-effect/

 

14 hours ago, Frozen said:

i test  it but pet level dont show and i add petLeve in quest nd IsPet in char.cpp

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

 

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;
        }

 

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.

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.

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 !@

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.

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;
        }

 

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;
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

https://metin2.download/picture/BhJ6gY27s38m7GIugOZRyu1VjkeIQWB6/.png  wait i forgot to use new fuction

i try and  new pet.summon but nothing

Edited by Metin2 Dev
Core X - External 2 Internal
10 minutes ago, BackPlayer said:

https://metin2.download/picture/BhJ6gY27s38m7GIugOZRyu1VjkeIQWB6/.png  wait i forgot to use new fuction

i try and  new pet.summon but nothing

After  you put that nothing happened?

Edited by Metin2 Dev
Core X - External 2 Internal

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.