Jump to content

xP3NG3Rx

Honorable Member
  • Posts

    839
  • Joined

  • Days Won

    393
  • Feedback

    100%

Posts posted by xP3NG3Rx

  1. Here is the code for old compilers:

    struct s_sort {
    	bool operator() (LPITEM src, LPITEM dst) { return (src->GetVnum()<dst->GetVnum()); }
    } _sort;
    
    ACMD(do_sort_inventory)
    {
    	std::vector<LPITEM> collectItems;
    	std::vector<WORD> oldCells;
    	int totalSize = 0;
    	for (WORD i = 0; i < INVENTORY_MAX_NUM; ++i)
    	{
    		LPITEM item = ch->GetInventoryItem(i);
    		if (item)
    		{
    			totalSize += item->GetSize();
    			oldCells.push_back(item->GetCell());
    			collectItems.push_back(item);
    		}
    	}
    	if (totalSize - 3 >= INVENTORY_MAX_NUM)
    	{
    		ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("INVENTORY_FULL_CANNOT_SORT"));
    		return;
    	}
    
    	std::vector<LPITEM>::iterator it = collectItems.begin(), end = collectItems.end();
    	for (; it != end; ++it)
    		((LPITEM)*it)->RemoveFromCharacter();
    
    	std::sort(collectItems.begin(), collectItems.end(), _sort);
    
    	std::vector<LPITEM>::iterator it1 = collectItems.begin(), end1 = collectItems.end();
    	for (; it1 != end1; ++it1)
    	{
    		WORD cell = ch->GetEmptyInventory(((LPITEM)*it1)->GetSize());
    		((LPITEM)*it1)->AddToCharacter(ch, TItemPos(INVENTORY, cell)/*, isNew=false*/);
    	}
    }

     

    • Love 2
  2. M2 Download Center

    This is the hidden content, please
    ( Internal )

    Hello.

    I saw this stuff on this and on another board also with bugs or it was incomplete, and I made it to myself.
    Feel free to use it with your brain.

    Good to know about this:

    • The name of those items which have attributes will be golden.
    • The skillbook and skillforget items will show the name of skill also.
    • If the item isn't yours than the ownership color will be red instead of yellow.

    * Készségkönyv = Skillbook(id:50300)
    * Feledés könyve = Skillforget book(id:70037)

    PS.: If you have problems with the implementation: start to upgrade your programming knowledges and don't disturb me in private message, I won't answer.
    Thank you for understanding.

    This is the hidden content, please

    • Metin2 Dev 106
    • kekw 1
    • Eyes 1
    • Think 1
    • Confused 1
    • Scream 1
    • Good 22
    • Love 3
    • Love 79
  3. Hello,

    Today I'm gonna share with you a little fix from the official server.

     

    Spoiler
    // PythonPlayerModule.cpp
    PyObject * playerPartyMemberVIDToPID(PyObject* poSelf, PyObject* poArgs)
    {
        DWORD dwVID;
        if (!PyTuple_GetUnsignedLong(poArgs, 0, &dwVID))
            return Py_BadArgument();
     
        DWORD dwPID;
        if (CPythonPlayer::Instance().PartyMemberVIDToPID(dwVID, &dwPID))
            return Py_BuildValue("i", dwPID);
     
        return Py_BuildValue("i", 0);
    }
    //
            { "PartyMemberVIDToPID",                    playerPartyMemberVIDToPID,                  METH_VARARGS },
     
    After if you want to remove a member by VID just use like this:
    (m2)net(m2g).SendPartyRemovePacket(player.PartyMemberVIDToPID(self.vid))

     

     

    https://pastebin.com/15aqnrif

    .png

    • Metin2 Dev 2
    • Love 8
  4. M2 Download Center

    This is the hidden content, please
    ( Internal )

    Hello.

     

    The most people here and on every board in this section don't have any clue about programming and they cannot do even nothing with the open source library codes, so here are the cryptlib(5.6.3 and 5.6.5) and libjpeg(9a) libraries what built with vc141 by me on the latest(I think) SDK on Windows10 10.0.16299.0.

    Sorry for my raw style but this is the truth.

    This is the hidden content, please

    This is the hidden content, please

    Aaaand I don't wanna talk about the services, that is another story...

    Spoiler

    How dare they ask money from the people for their ugly codes... JESUS.
     

    Spoiler

    I'm sorry, I'm just f>cked up right now.

     

     

    Peace.

    • Metin2 Dev 40
    • kekw 2
    • Dislove 2
    • Angry 1
    • Sad 2
    • Think 1
    • Good 9
    • Love 1
    • Love 32
  5. Of course it isn't problem.

    But let me to inform you; on the official, they are using a new part value stores the vnum of pendant, and than querying the values from it.

    int *__cdecl playerGetElementByVID(int a1, int a2)
    {
    	int *result; // eax
    	int iPendantVnum; // eax
    	signed int iN; // [esp+8h] [ebp-1Ch]
    	char tItemApply; // [esp+Ch] [ebp-18h]
    	char *pPendantItemData; // [esp+14h] [ebp-10h]
    	int iVID; // [esp+18h] [ebp-Ch]
    	_DWORD *pDestInstance; // [esp+1Ch] [ebp-8h]
    	int _dummy; // [esp+20h] [ebp-4h]
    
    	if ( !PyTuple_GetLong(a2, 0, &iVID) )
    		return (int *)Py_BadArgument();
    	_dummy = 0;
    	pDestInstance = (_DWORD *)(*(int (__thiscall **)(signed int, int))(MEMORY[4] + 8))(4, iVID);// CPythonCharacterManager::Instance().GetInstancePtr(iVID);
    	if ( !pDestInstance )
    		return python27_Py_BuildValue((int)"i", 0);
    	iPendantVnum = CInstanceBase::GetPart(pDestInstance, 6);// New PART_PENDANT to querying the equipped item of the target
    	if ( !CItemManager::GetItemDataPointer(0, iPendantVnum, &pPendantItemData) )
    		return python27_Py_BuildValue((int)"i", 0);
    	iN = 0;
    	while ( 2 )
    	{
    		if ( iN >= 3 )
    			return python27_Py_BuildValue((int)"i", 0);
    		CItemData::GetApply(pPendantItemData, iN, (int)&tItemApply);
    		switch ( tItemApply.bType )
    		{
    			case 99:	// APPLY_ENCHANT_ELECT
    				result = python27_Py_BuildValue((int)"i", 2048);
    				break;
    			case 100:	// APPLY_ENCHANT_FIRE
    				result = python27_Py_BuildValue((int)"i", 4096);
    				break;
    			case 101:	// APPLY_ENCHANT_ICE
    				result = python27_Py_BuildValue((int)"i", 8192);
    				break;
    			case 102:	// APPLY_ENCHANT_WIND
    				result = python27_Py_BuildValue((int)"i", 16384);
    				break;
    			case 103:	// APPLY_ENCHANT_EARTH
    				result = python27_Py_BuildValue((int)"i", 32768);
    				break;
    			case 104:	// APPLY_ENCHANT_DARK
    				result = python27_Py_BuildValue((int)"i", 65536);
    				break;
    			default:
    				++iN;
    				continue;
    		}
    		break;
    	}
    	return result;
    }

     

    • Love 4
  6. Me neither see the server side codes why :unsure:.

    Also the official version is client side only.

    Anyway thanks.

    Spoiler
    
                        {'name': 'ELEMENT_IMG_PATH',
                         'type': 'dict',
                         'value': {2048: 'd:/ymir work/ui/game/12zi/element/elect.sub',
                                   4096: 'd:/ymir work/ui/game/12zi/element/fire.sub',
                                   8192: 'd:/ymir work/ui/game/12zi/element/ice.sub',
                                   16384: 'd:/ymir work/ui/game/12zi/element/wind.sub',
                                   32768: 'd:/ymir work/ui/game/12zi/element/earth.sub',
                                   65536: 'd:/ymir work/ui/game/12zi/element/dark.sub'}},
    
    int __cdecl nonplayerGetAttElementFlagByVID(int a1, int a2)
    {
    	int iVID; // [esp+1Ch] [ebp-Ch]
    	int dwVnum; // [esp+20h] [ebp-8h]
    	_DWORD *pCInstanceBase; // [esp+24h] [ebp-4h]
    
    	if ( !PyTuple_GetULong(a2, 0, &dwVnum) )
    		return Py_BuildException(0);
    	pCInstanceBase = (_DWORD *)(*(int (__thiscall **)(signed int, int))(MEMORY[4] + 8))(4, dwVnum);
    	if ( !pCInstanceBase )
    		return python27_Py_BuildValue("i", 0);
    	iVID = CInstanceBase::GetVirtualNumber(pCInstanceBase);
    	if ( CPythonNonPlayer::IsRaceFlagByVnum(0, iVID, 2048) )
    		return python27_Py_BuildValue("i", 2048);
    	if ( CPythonNonPlayer::IsRaceFlagByVnum(0, iVID, 4096) )
    		return python27_Py_BuildValue("i", 4096);
    	if ( CPythonNonPlayer::IsRaceFlagByVnum(0, iVID, 8192) )
    		return python27_Py_BuildValue("i", 8192);
    	if ( CPythonNonPlayer::IsRaceFlagByVnum(0, iVID, 16384) )
    		return python27_Py_BuildValue("i", 16384);
    	if ( CPythonNonPlayer::IsRaceFlagByVnum(0, iVID, 32768) )
    		return python27_Py_BuildValue("i", 32768);
    	if ( CPythonNonPlayer::IsRaceFlagByVnum(0, iVID, 65536) )
    		return python27_Py_BuildValue("i", 65536);
    	return python27_Py_BuildValue("i", 0);
    }
    
    bool __thiscall CPythonNonPlayer::IsRaceFlagByVnum(char *this, int a2, int a3)
    {
    	int v4; // [esp+4h] [ebp-8h]
    	bool v5; // [esp+Bh] [ebp-1h]
    
    	v4 = CPythonNonPlayer::GetTable(this, a2);
    	if ( v4 )
    		v5 = (a3 & *(_DWORD *)(v4 + 84)) != 0;
    	else
    		v5 = 0;
    	return v5;
    }
    
    /*
    Why I'm sure in that the +84 is the race flag?
    	fprintf(f, "vnum = %d\n", (*(DWORD*)buf));
    	buf += 4;
    	fprintf(f, "name = %s\n", buf);
    	buf += 25;
    	fprintf(f, "localized_name = %s\n", buf);
    	buf += 25;
    	fprintf(f, "type = %d\n", (*(BYTE*)buf));
    	buf += 1;
    	fprintf(f, "rank = %d\n", (*(BYTE*)buf));
    	buf += 1;
    	fprintf(f, "battle_type = %d\n", (*(BYTE*)buf));
    	buf += 1;
    	fprintf(f, "level = %d\n", (*(BYTE*)buf));
    	buf += 1;
    	fprintf(f, "scale = %d\n", (*(BYTE*)buf));
    	buf += 1;
    	fprintf(f, "size = %d\n", (*(BYTE*)buf));
    	buf += 1;
    	fprintf(f, "gold_min = %d\n", (*(DWORD*)buf));
    	buf += 4;
    	fprintf(f, "gold_max = %d\n", (*(DWORD*)buf));
    	buf += 4;
    	fprintf(f, "exp = %d\n", (*(DWORD*)buf));
    	buf += 4;
    	fprintf(f, "max_hp = %d\n", (*(DWORD*)buf));
    	buf += 4;
    	fprintf(f, "regen_cycle = %d\n", (*(BYTE*)buf));
    	buf += 1;
    	fprintf(f, "regen_pct = %d\n", (*(BYTE*)buf));
    	buf += 1;
    	fprintf(f, "def = %d\n", (*(WORD*)buf));
    	buf += 2;
    	fprintf(f, "aiflag = %d\n", (*(DWORD*)buf));
    	buf += 4;
    	fprintf(f, "raceflag = %d\n", (*(DWORD*)buf));
    
    	4+25+25+1+1+1+1+1+1+4+4+4+4+1+1+2+4 = 84 :)
    */

     

     

    • Love 1
×
×
  • 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.