Jump to content

Pet Attacking Bug


Recommended Posts

I added pet attacking system and I have next bug: pet can drop item from mobs

 

df880a684b0b78040266dddf0f5d0312.png

 

How can I solve this? Items have the pet owner's name or owner can pickup the items if pet is his. I tried something but doesn't work.

 

 

Thanks in advance.

 

Pet attacking: 

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

In char_battle.cpp you have sth like this 

void CHARACTER::Reward(bool bItemDrop)

there you have

if (CBattleArena::instance().IsBattleArenaMap(pkAttacker->GetMapIndex()) == false)
 {
   item->SetOwnership(pkAttacker);
 }

And you can use method to take id or e.g create a new method bool isPet()

Edited by Deucalion
  • Love 1
Link to comment
Share on other sites

 

a8f629c3c5a3219c032e78c496fc0a1b.pngi dont try it, in a few minutes , i go to try it, but i think this will work.

 

Pet's last hit = 0 drop.

Great solution bro,

Next time use brain.

 

the best soultion = pet drop can get the owner.

 

ok, when 2 players attack a metin, 2 players get rewards right?

if the pet dont do the last hit, but the pet attack, both can have drops.

Great solution bro,

Next time use brain.

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
Link to comment
Share on other sites

            if (CBattleArena::instance().IsBattleArenaMap(pkAttacker->GetMapIndex()) == false)
            {
                if (pkAttacker->IsPC())
                {
                    item->SetOwnership(pkAttacker);
                }
                else if (pkAttacker->IsPet())
                {
                    for (CPetSystem::TPetActorMap::iterator go = pkAttacker->GetPetSystem()->m_petActorMap.begin();go != pkAttacker->GetPetSystem()->m_petActorMap.end(); ++go)
                    {
                        CPetActor* petActor = go->second;
                        if (NULL != petActor)
                        {
                            LPCHARACTER own = petActor->GetOwner();
                            if (own)
                            {
                                item->SetOwnership(own);
                            }
                        }
                    }
                }
            }

I'm not using pet attack system so I can't test it.

I'm 50% sure it works.

 

Include must be added:

 

#include "PetSystem.h"

Regards,

newja

 

 

 

#Edit

 

M5UBlCl.png

 

BSzKIB1.png

 

dtL4U25.gif

 

Works.

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 4
Link to comment
Share on other sites

            if (CBattleArena::instance().IsBattleArenaMap(pkAttacker->GetMapIndex()) == false)
            {
                if (pkAttacker->IsPC())
                {
                    item->SetOwnership(pkAttacker);
                }
                else if (pkAttacker->IsPet())
                {
                    for (CPetSystem::TPetActorMap::iterator go = pkAttacker->GetPetSystem()->m_petActorMap.begin();go != pkAttacker->GetPetSystem()->m_petActorMap.end(); ++go)
                    {
                        CPetActor* petActor = go->second;
                        if (NULL != petActor)
                        {
                            LPCHARACTER own = petActor->GetOwner();
                            if (own)
                            {
                                item->SetOwnership(own);
                            }
                        }
                    }
                }
            }

I'm not using pet attack system so I can't test it.

I'm 50% sure it works.

 

Include must be added:

 

#include "PetSystem.h"

Regards,

newja

 

I tested but not works , I put the TPetActorMap m_petActorMap; public and not work.

Link to comment
Share on other sites

Problem is with SetOwnership yes? So maybe  only need to add sth like this:

	if (ch->IsPet())
	{
		for (CPetSystem::TPetActorMap::iterator iter = to->GetPetSystem()->m_petActorMap.begin(); iter != to->GetPetSystem()->m_petActorMap.end(); ++iter){
			if (CPetActor* petActor = iter->second){
				ch = petActor->GetOwner();
			}
		}
	}

in item.cpp in method

void CItem::SetOwnership(LPCHARACTER ch, int iSec)

above

m_dwOwnershipPID = ch->GetPlayerID();

So the pice of code should look like this:

if (true == LC_IsEurope())
	{
		if (iSec <= 10)
			iSec = 30;
	}


	if (ch->IsPet())
	{
		for (CPetSystem::TPetActorMap::iterator iter = to->GetPetSystem()->m_petActorMap.begin(); iter != to->GetPetSystem()->m_petActorMap.end(); ++iter){
			if (CPetActor* petActor = iter->second){
				ch = petActor->GetOwner();
			}
		}
	}
		
	m_dwOwnershipPID = ch->GetPlayerID();

	item_event_info* info = AllocEventInfo<item_event_info>();

It's untested!

 

Efit: of course you need to add include 

"PetSystem.h"

 on the top of the file

  • Love 1
Link to comment
Share on other sites

Are you sure this work 100%?

Because we already tried this and sometimes it works and sometimes not.

 

There's such a mess in the code, I can't really tell if it's everything now but..

go to char_battle.cpp and find:

item->SetOwnership(ch);

replace with this

                   if (CBattleArena::instance().IsBattleArenaMap(ch->GetMapIndex()) == false)
                        if (ch->IsPC())
                        {
                            item->SetOwnership(ch);
                        }
                        else if (ch->IsPet())
                        {
                            for (CPetSystem::TPetActorMap::iterator go = ch->GetPetSystem()->m_petActorMap.begin();go != ch->GetPetSystem()->m_petActorMap.end(); ++go)
                            {
                                CPetActor* petActor = go->second;
                                if (NULL != petActor)
                                {
                                    LPCHARACTER own = petActor->GetOwner();
                                    if (own)
                                    {
                                        item->SetOwnership(own);
                                    }
                                }
                            }
                        }

or do as @Deucalion says, however its problem lies deeper than that.

 

Regards,

newja

  • Love 1
Link to comment
Share on other sites

  • 8 years later...

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.