Jump to content
metin2dev
Metin2International
Sign in to follow this  
Root

[HowTo*]Anti-Elixir in duel

Recommended Posts

Hi there,

I did this long time ago and i was thinking to share it, is not something wow but im still new in c++ and i dont really understand evrything so if u find any bugs in this system you are free to say.Search in server/game/pvp.cpp for :

Spoiler



		if (pkPVP->Agree(pkChr->GetPlayerID()))
		{


 

Add under :

Spoiler



for(int i = 0; i < INVENTORY_MAX_NUM; i++)
                        {
                            if(pkChr->GetInventoryItem(i)> 0 && pkChr->GetInventoryItem(i)->GetSocket(0) == 1 && pkChr->GetInventoryItem(i)->GetVnum() == 72723){
                                pkChr->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkChr->GetName());
                                pkChr->GetInventoryItem(i)->SetSocket(0, false);
                                pkChr->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkChr->GetInventoryItem(i)> 0 && pkChr->GetInventoryItem(i)->GetSocket(0) == 1 && pkChr->GetInventoryItem(i)->GetVnum() == 72724){
                                pkChr->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkChr->GetName());
                                pkChr->GetInventoryItem(i)->SetSocket(0, false);
                                pkChr->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkChr->GetInventoryItem(i)> 0 && pkChr->GetInventoryItem(i)->GetSocket(0) == 1 && pkChr->GetInventoryItem(i)->GetVnum() == 72725){
                                pkChr->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkChr->GetName());
                                pkChr->GetInventoryItem(i)->SetSocket(0, false);
                                pkChr->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkChr->GetInventoryItem(i)> 0 && pkChr->GetInventoryItem(i)->GetSocket(0) == 1 && pkChr->GetInventoryItem(i)->GetVnum() == 72726){
                                pkChr->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkChr->GetName());
                                pkChr->GetInventoryItem(i)->SetSocket(0, false);
                                pkChr->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkVictim->GetInventoryItem(i)> 0 && pkVictim->GetInventoryItem(i)->GetSocket(0) == 1 && pkVictim->GetInventoryItem(i)->GetVnum() == 72723)
                            {
                                pkVictim->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkVictim->GetName());
                                pkVictim->GetInventoryItem(i)->SetSocket(0, false);
                                pkVictim->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkVictim->GetInventoryItem(i)> 0 && pkVictim->GetInventoryItem(i)->GetSocket(0) == 1 && pkVictim->GetInventoryItem(i)->GetVnum() == 72724)
                            {
                                pkVictim->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkVictim->GetName());
                                pkVictim->GetInventoryItem(i)->SetSocket(0, false);
                                pkVictim->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkVictim->GetInventoryItem(i)> 0 && pkVictim->GetInventoryItem(i)->GetSocket(0) == 1 && pkVictim->GetInventoryItem(i)->GetVnum() == 72725)
                            {
                                pkVictim->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkVictim->GetName());
                                pkVictim->GetInventoryItem(i)->SetSocket(0, false);
                                pkVictim->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkVictim->GetInventoryItem(i)> 0 && pkVictim->GetInventoryItem(i)->GetSocket(0) == 1 && pkVictim->GetInventoryItem(i)->GetVnum() == 72726)
                            {
                                pkVictim->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkVictim->GetName());
                                pkVictim->GetInventoryItem(i)->SetSocket(0, false);
                                pkVictim->GetInventoryItem(i)->Lock(false);
                                    
                            }


 

Ok now we implement a function im not the author of it , the author is 


So in pvp.cpp we search for:

Spoiler



CPVPManager::~CPVPManager()
{
}
//And we add under this @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bool CPVPManager::HasDuel(LPCHARACTER pkChar) { 
    CPVPSetMap::iterator it = m_map_pkPVPSetByID.find(pkChar->GetPlayerID()); 
     
    if (it != m_map_pkPVPSetByID.end()) { 
        itertype(it->second) it2 = it->second.begin(); 
         
        while (it2 != it->second.end()) { 
            CPVP * pvp = *it2++; 
            if (pvp->IsFight()) 
                return true; 
        } 
    } 
    return false; 
} 


 

 

In pvp.h we search this:

Spoiler

CPVP *			Find(DWORD dwCRC);
//And we add under @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bool                    HasDuel(LPCHARACTER pkChar);

 

Now we finished with this function that helps us to check if a player is in a duel.

We open char_item.cpp and we search and add under:

Spoiler

if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
									{
										ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장에서 사용하실 수 없습니다."));
										return false;
									}
//Add under this @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                                                                        LPCHARACTER ch = quest::CQuestManager::instance().GetCurrentCharacterPtr();
                                                                        if(CPVPManager::Instance().HasDuel(ch) && item->GetVnum() == 72723 || 	 CPVPManager::Instance().HasDuel(ch) && item->GetVnum() == 72724 || CPVPManager::Instance().HasDuel(ch) && item->GetVnum() == 72725 || CPVPManager::Instance().HasDuel(ch) && item->GetVnum() == 72726)
                                                                        {
                                                                        	ChatPacket(CHAT_TYPE_INFO, "%s you cannot use auto potions while you are in a duel.", ch->GetName());
										return false;    
                                                                        }

 

I think thats it,I will come later with extra code for banning other potions like normal red or blessing.

Have a nice day.

Best regards Root.

  • Like 1
  • Confused 1

Share this post


Link to post
Share on other sites

i think thats is better:

 

int blocked_items[] = {72723,  72724, 72725, 72726};

for(size_t i = 0; i < INVENTORY_MAX_NUM; i++) {
	for (size_t id = 0; id < 4; id++) {
		if(pkChr->GetInventoryItem(i)> 0 && pkChr->GetInventoryItem(i)->GetSocket(0) == 1 && pkChr->GetInventoryItem(i)->GetVnum() == blocked_items[id]) {
			pkChr->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkChr->GetName());
			pkChr->GetInventoryItem(i)->SetSocket(0, false);
			pkChr->GetInventoryItem(i)->Lock(false);
		} else if(pkVictim->GetInventoryItem(i)> 0 && pkVictim->GetInventoryItem(i)->GetSocket(0) == 1 && pkVictim->GetInventoryItem(i)->GetVnum() == blocked_items[id]) {
			pkVictim->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkVictim->GetName());
			pkVictim->GetInventoryItem(i)->SetSocket(0, false);
			pkVictim->GetInventoryItem(i)->Lock(false);
		}
	}
}

but dont tested

 

 

looks like:

void CPVPManager::Insert(LPCHARACTER pkChr, LPCHARACTER pkVictim)
{
	if (pkChr->IsDead() || pkVictim->IsDead())
		return;
	int blocked_items[] = {72723,  72724, 72725, 72726};

	CPVP kPVP(pkChr->GetPlayerID(), pkVictim->GetPlayerID());

	CPVP * pkPVP;

	if ((pkPVP = Find(kPVP.m_dwCRC)))
	{
		// º¹¼öÇÒ ¼ö ÀÖÀ¸¸é ¹Ù·Î ½Î¿ò!
		if (pkPVP->Agree(pkChr->GetPlayerID()))
		{
			pkVictim->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s´Ô°úÀÇ ´ë°á ½ÃÀÛ!"), pkChr->GetName());
			pkChr->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s´Ô°úÀÇ ´ë°á ½ÃÀÛ!"), pkVictim->GetName());
			for(size_t i = 0; i < INVENTORY_MAX_NUM; i++) {
				for (size_t id = 0; id < 4; id++) {
					if(pkChr->GetInventoryItem(i)> 0 && pkChr->GetInventoryItem(i)->GetSocket(0) == 1 && pkChr->GetInventoryItem(i)->GetVnum() == blocked_items[id]) {
						pkChr->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkChr->GetName());
						pkChr->GetInventoryItem(i)->SetSocket(0, false);
						pkChr->GetInventoryItem(i)->Lock(false);
					} else if(pkVictim->GetInventoryItem(i)> 0 && pkVictim->GetInventoryItem(i)->GetSocket(0) == 1 && pkVictim->GetInventoryItem(i)->GetVnum() == blocked_items[id]) {
						pkVictim->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkVictim->GetName());
						pkVictim->GetInventoryItem(i)->SetSocket(0, false);
						pkVictim->GetInventoryItem(i)->Lock(false);
					}
				}
			}

		}
		return;
	}

	pkPVP = M2_NEW CPVP(kPVP);

	pkPVP->SetVID(pkChr->GetPlayerID(), pkChr->GetVID());
	pkPVP->SetVID(pkVictim->GetPlayerID(), pkVictim->GetVID());

	m_map_pkPVP.insert(map<DWORD, CPVP *>::value_type(pkPVP->m_dwCRC, pkPVP));

	m_map_pkPVPSetByID[pkChr->GetPlayerID()].insert(pkPVP);
	m_map_pkPVPSetByID[pkVictim->GetPlayerID()].insert(pkPVP);

	pkPVP->Packet();

	char msg[CHAT_MAX_LEN + 1];
	snprintf(msg, sizeof(msg), LC_TEXT("%s´ÔÀÌ ´ë°á½ÅûÀ» Çß½À´Ï´Ù. ½Â³«ÇÏ·Á¸é ´ë°áµ¿ÀǸ¦ Çϼ¼¿ä."), pkChr->GetName());

	pkVictim->ChatPacket(CHAT_TYPE_INFO, msg);
	pkChr->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%s¿¡°Ô ´ë°á½ÅûÀ» Çß½À´Ï´Ù."), pkVictim->GetName());

	// NOTIFY_PVP_MESSAGE
	LPDESC pkVictimDesc = pkVictim->GetDesc();
	if (pkVictimDesc)
	{
		TPacketGCWhisper pack;

		int len = MIN(CHAT_MAX_LEN, strlen(msg) + 1);

		pack.bHeader = HEADER_GC_WHISPER;
		pack.wSize = sizeof(TPacketGCWhisper) + len;
		pack.bType = WHISPER_TYPE_SYSTEM;
		strlcpy(pack.szNameFrom, pkChr->GetName(), sizeof(pack.szNameFrom));

		TEMP_BUFFER buf;

		buf.write(&pack, sizeof(TPacketGCWhisper));
		buf.write(msg, len);

		pkVictimDesc->Packet(buf.read_peek(), buf.size());
	}	
	// END_OF_NOTIFY_PVP_MESSAGE
}

 

 

NOTE

make top of this file

#include "char_battle.cpp"

 

and all error fixxed

Share this post


Link to post
Share on other sites
Am 1.2.2017 um 14:39 schrieb Root:

Hi there,

I did this long time ago and i was thinking to share it, is not something wow but im still new in c++ and i dont really understand evrything so if u find any bugs in this system you are free to say.Search in server/game/pvp.cpp for :

  Unsichtbaren Inhalt anzeigen

 



		if (pkPVP->Agree(pkChr->GetPlayerID()))
		{

 

 

 

 

Add under :

  Unsichtbaren Inhalt anzeigen

 



for(int i = 0; i < INVENTORY_MAX_NUM; i++)
                        {
                            if(pkChr->GetInventoryItem(i)> 0 && pkChr->GetInventoryItem(i)->GetSocket(0) == 1 && pkChr->GetInventoryItem(i)->GetVnum() == 72723){
                                pkChr->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkChr->GetName());
                                pkChr->GetInventoryItem(i)->SetSocket(0, false);
                                pkChr->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkChr->GetInventoryItem(i)> 0 && pkChr->GetInventoryItem(i)->GetSocket(0) == 1 && pkChr->GetInventoryItem(i)->GetVnum() == 72724){
                                pkChr->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkChr->GetName());
                                pkChr->GetInventoryItem(i)->SetSocket(0, false);
                                pkChr->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkChr->GetInventoryItem(i)> 0 && pkChr->GetInventoryItem(i)->GetSocket(0) == 1 && pkChr->GetInventoryItem(i)->GetVnum() == 72725){
                                pkChr->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkChr->GetName());
                                pkChr->GetInventoryItem(i)->SetSocket(0, false);
                                pkChr->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkChr->GetInventoryItem(i)> 0 && pkChr->GetInventoryItem(i)->GetSocket(0) == 1 && pkChr->GetInventoryItem(i)->GetVnum() == 72726){
                                pkChr->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkChr->GetName());
                                pkChr->GetInventoryItem(i)->SetSocket(0, false);
                                pkChr->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkVictim->GetInventoryItem(i)> 0 && pkVictim->GetInventoryItem(i)->GetSocket(0) == 1 && pkVictim->GetInventoryItem(i)->GetVnum() == 72723)
                            {
                                pkVictim->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkVictim->GetName());
                                pkVictim->GetInventoryItem(i)->SetSocket(0, false);
                                pkVictim->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkVictim->GetInventoryItem(i)> 0 && pkVictim->GetInventoryItem(i)->GetSocket(0) == 1 && pkVictim->GetInventoryItem(i)->GetVnum() == 72724)
                            {
                                pkVictim->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkVictim->GetName());
                                pkVictim->GetInventoryItem(i)->SetSocket(0, false);
                                pkVictim->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkVictim->GetInventoryItem(i)> 0 && pkVictim->GetInventoryItem(i)->GetSocket(0) == 1 && pkVictim->GetInventoryItem(i)->GetVnum() == 72725)
                            {
                                pkVictim->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkVictim->GetName());
                                pkVictim->GetInventoryItem(i)->SetSocket(0, false);
                                pkVictim->GetInventoryItem(i)->Lock(false);
                                    
                            }
                            else if(pkVictim->GetInventoryItem(i)> 0 && pkVictim->GetInventoryItem(i)->GetSocket(0) == 1 && pkVictim->GetInventoryItem(i)->GetVnum() == 72726)
                            {
                                pkVictim->ChatPacket(CHAT_TYPE_INFO, "%s potions are banned in duel" , pkVictim->GetName());
                                pkVictim->GetInventoryItem(i)->SetSocket(0, false);
                                pkVictim->GetInventoryItem(i)->Lock(false);
                                    
                            }

 

 

 

 

Ok now we implement a function im not the author of it , the author is 


So in pvp.cpp we search for:

  Unsichtbaren Inhalt anzeigen

 



CPVPManager::~CPVPManager()
{
}
//And we add under this @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bool CPVPManager::HasDuel(LPCHARACTER pkChar) { 
    CPVPSetMap::iterator it = m_map_pkPVPSetByID.find(pkChar->GetPlayerID()); 
     
    if (it != m_map_pkPVPSetByID.end()) { 
        itertype(it->second) it2 = it->second.begin(); 
         
        while (it2 != it->second.end()) { 
            CPVP * pvp = *it2++; 
            if (pvp->IsFight()) 
                return true; 
        } 
    } 
    return false; 
} 

 

 

 

In pvp.h we search this:

  Unsichtbaren Inhalt anzeigen


CPVP *			Find(DWORD dwCRC);
//And we add under @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
bool                    HasDuel(LPCHARACTER pkChar);

 

Now we finished with this function that helps us to check if a player is in a duel.

We open char_item.cpp and we search and add under:

  Unsichtbaren Inhalt anzeigen


if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
									{
										ChatPacket(CHAT_TYPE_INFO, LC_TEXT("대련장에서 사용하실 수 없습니다."));
										return false;
									}
//Add under this @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                                                                        LPCHARACTER ch = quest::CQuestManager::instance().GetCurrentCharacterPtr();
                                                                        if(CPVPManager::Instance().HasDuel(ch) && item->GetVnum() == 72723 || 	 CPVPManager::Instance().HasDuel(ch) && item->GetVnum() == 72724 || CPVPManager::Instance().HasDuel(ch) && item->GetVnum() == 72725 || CPVPManager::Instance().HasDuel(ch) && item->GetVnum() == 72726)
                                                                        {
                                                                        	ChatPacket(CHAT_TYPE_INFO, "%s you cannot use auto potions while you are in a duel.", ch->GetName());
										return false;    
                                                                        }

 

I think thats it,I will come later with extra code for banning other potions like normal red or blessing.

Have a nice day.

Best regards Root.

error:
char_item.cpp:3934: error: 'CPVPManager' has not been declared

Share this post


Link to post
Share on other sites
La 12/24/2017 la 22:51, Aliano a spus:

error:
char_item.cpp:3934: error: 'CPVPManager' has not been declared

In char_item.cpp add on top:

#include "pvp.h"

 

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×