Jump to content

Use BeltInventory slots without Belt


Recommended Posts

Hi guys. I have a mount inventory system which is using the belt inventory. I have a button for it, and I had to have a Belt on to use it(like official) but I wanted to use it without Belt
If you want to do this follow this tutorial, I'm not good at coding, so maybe there's better solution, but I did this that way. Sorry for my English.
Open char_item.cpp and search:

bool CHARACTER::IsEmptyItemGrid(TItemPos Cell, BYTE bSize, int iExceptionCell) const


Search this in IsEmptyItemGrid (Item disappear fix by: Pisti95)

if (Cell.IsBeltInventoryPosition())
{
	LPITEM beltItem = GetWear(WEAR_BELT);

	if (NULL == beltItem)
		return false;
  
	if (false == CBeltInventoryHelper::IsAvailableCell(bCell - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))
		return false;

Comment it, make it look like this:
 

if (Cell.IsBeltInventoryPosition())
{
	//LPITEM beltItem = GetWear(WEAR_BELT);
		
	//if (NULL == beltItem)
	//	return true;
		
	//if (false == CBeltInventoryHelper::IsAvailableCell(bCell - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))
	//	return false;

 

Open belt_inventory_helper.h

Search for:

static bool IsExistItemInBeltInventory(LPCHARACTER pc)

Make it look like this:

	static bool IsExistItemInBeltInventory(LPCHARACTER pc)
	{
		//for (WORD i = BELT_INVENTORY_SLOT_START; i < BELT_INVENTORY_SLOT_END; ++i)
		//{
		//	LPITEM beltInventoryItem = pc->GetInventoryItem(i);
		//
		//	if (NULL != beltInventoryItem)
		//		return true;
		//}

		return true;
	}

You can compile game.

Python part to ,,turn off" disabled slots, and make it look like you have a Belt on
Open uiinventory.py

 

Search this in class BeltInventoryWindow

def RefreshSlot(self):

Change this:
 

self.wndBeltInventorySlot.SetAlwaysRenderCoverButton(slotNumber, True)

To this:
 

self.wndBeltInventorySlot.SetAlwaysRenderCoverButton(slotNumber, False)

Then change this:
 

self.wndBeltInventorySlot.DisableCoverButton(slotNumber)

To this:
 

self.wndBeltInventorySlot.EnableCoverButton(slotNumber)

And I dont know if its necessary, but I did these thing too

Search for this in class BeltInventoryWindow

def __LoadWindow(self):

In this search for:

for i in xrange(item.BELT_INVENTORY_SLOT_COUNT):
	slotNumber = item.BELT_INVENTORY_SLOT_START + i
	wndBeltInventorySlot.SetCoverButton(slotNumber,	"d:/ymir work/ui/game/quest/slot_button_01.sub",\
										"d:/ymir work/ui/game/quest/slot_button_01.sub",\
										"d:/ymir work/ui/game/quest/slot_button_01.sub")
										"d:/ymir work/ui/game/belt_inventory/slot_disabled.tga", False, False)

And comment the last line, make it look like this:

#"d:/ymir work/ui/game/belt_inventory/slot_disabled.tga", False, False)

Client source (Still don't know, if it's necessary or not)
Open Userinterface/PythonPlayerModule.cpp

Search for:

#ifdef ENABLE_NEW_EQUIPMENT_SYSTEM
PyObject * playerIsEquippingBelt(PyObject* poSelf, PyObject* poArgs)
{

Make it look like this: (Change PyObject * playerIsAvailableBeltInventoryCell(PyObject* poSelf, PyObject* poArgs) too! )
 

#ifdef ENABLE_NEW_EQUIPMENT_SYSTEM
PyObject * playerIsEquippingBelt(PyObject* poSelf, PyObject* poArgs)
{
	const CPythonPlayer* player = CPythonPlayer::InstancePtr();
	bool bEquipping = false;

//	const TItemData* data = player->GetItemData(TItemPos(EQUIPMENT, c_Equipment_Belt));
//
//	if (NULL != data)
//		bEquipping = 0 < data->count;

	return Py_BuildValue("b", bEquipping);
	
}

PyObject * playerIsAvailableBeltInventoryCell(PyObject* poSelf, PyObject* poArgs)
{
	const CPythonPlayer* player = CPythonPlayer::InstancePtr();
//	const TItemData* pData = player->GetItemData(TItemPos(EQUIPMENT, c_Equipment_Belt));
//
//	if (NULL == pData || 0 == pData->count)
//		return Py_BuildValue("b", true);
//
//	CItemManager::Instance().SelectItemData(pData->vnum);
	CItemData * pItem = CItemManager::Instance().GetSelectedItemDataPointer();

	long beltGrade = pItem->GetValue(0);

	int pos = 0;
	if (!PyTuple_GetInteger(poArgs, 0, &pos))
		return Py_BadArgument();

	//return Py_BuildValue("b", CBeltInventoryHelper::IsAvailableCell(pos - c_Belt_Inventory_Slot_Start, GetItemGrade(pItem->GetName())));
	return Py_BuildValue("b", CBeltInventoryHelper::IsAvailableCell(pos - c_Belt_Inventory_Slot_Start, beltGrade));
}
#endif


And we're done. Have a good day!

Edited by redscoutyt2
  • Good 2
  • Love 1
Link to comment
Share on other sites

It has one bug I can't solve. The problem is: When I drag an item(first item) to another item(second item), the second item disappears and the first item goes to the second item slot, and the second item just disappears. If i log out, or restart the client nothing will happen only when I restart the server. When I restart the server the second item which is disappers, will appear again.

 

Solved, i'll update the post.

Edited by redscoutyt2
Link to comment
Share on other sites

  • 2 months later...

if use char_item.cpp from martysama :

Plus additional:

Search for:

	// @fixme141 BEGIN
	if (TItemPos(item->GetWindow(), item->GetCell()).IsBeltInventoryPosition())
	{
		LPITEM beltItem = GetWear(WEAR_BELT);

		if (NULL == beltItem)
		{
			ChatPacket(CHAT_TYPE_INFO, "<Belt> You can't use this item if you have no equipped belt.");
			return false;
		}

		if (false == CBeltInventoryHelper::IsAvailableCell(item->GetCell() - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))
		{
			ChatPacket(CHAT_TYPE_INFO, "<Belt> You can't use this item if you don't upgrade your belt.");
			return false;
		}
	}
	// @fixme141 END

 

Make it look like this:

	// @fixme141 BEGIN
	if (TItemPos(item->GetWindow(), item->GetCell()).IsBeltInventoryPosition())
	{
		/*LPITEM beltItem = GetWear(WEAR_BELT);

		if (NULL == beltItem)
		{
			ChatPacket(CHAT_TYPE_INFO, "<Belt> You can't use this item if you have no equipped belt.");
			return false;
		}

		if (false == CBeltInventoryHelper::IsAvailableCell(item->GetCell() - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))
		{
			ChatPacket(CHAT_TYPE_INFO, "<Belt> You can't use this item if you don't upgrade your belt.");
			return false;
		}*/
		
		return true;
	}
	// @fixme141 END

 

Good luck! 😄

 

  • Metin2 Dev 1
  • Good 1
  • Love 1
Link to comment
Share on other sites

  • 10 months later...

Hello, i did all from post but it work just in belt_inventory_helper.h with return false; after that i did4 inventory,  i cant find anywhere(Dev,Hub,PvPelit.) solution for this bug ( log nothing, syserr nothing ) https://metin2.download/picture/Xby4tW5pRJf9mkD1I75NhJPNgExiDX8S/.gif I know, its server side, but can anyone give me some advice please? Problem is you can put items from safebox to belt inventory.

Code: char_item: 

if (Cell.IsBeltInventoryPosition())

            {

                //LPITEM beltItem = GetWear(WEAR_BELT);

 

                //if (NULL == beltItem)

                    //return false;

 

                //if (false == CBeltInventoryHelper::IsAvailableCell(bCell - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))

                    //return false;

 

                if (m_pointsInstant.bItemGrid[bCell])

                {

                    if (m_pointsInstant.bItemGrid[bCell] == iExceptionCell)

                        return true;

 

                    return false;

                }

 

                if (bSize == 1)

                    return true;

 

            }

 

belt_inv_helper:

    static bool IsExistItemInBeltInventory(LPCHARACTER pc)

    {

        //for (WORD i = BELT_INVENTORY_SLOT_START; i < BELT_INVENTORY_SLOT_END; ++i)

        //{

            //LPITEM beltInventoryItem = pc->GetInventoryItem(i);

 

            //if (NULL != beltInventoryItem)

                //return true;

        //}

 

        return false;

    }

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

19 hours ago, 2DsSDKMN said:

Hello, i did all from post but it work just in belt_inventory_helper.h with return false; after that i did4 inventory,  i cant find anywhere(Dev,Hub,PvPelit.) solution for this bug ( log nothing, syserr nothing ) https://metin2.download/picture/Xby4tW5pRJf9mkD1I75NhJPNgExiDX8S/.gif I know, its server side, but can anyone give me some advice please? Problem is you can put items from safebox to belt inventory.

Code: char_item: 

if (Cell.IsBeltInventoryPosition())

            {

                //LPITEM beltItem = GetWear(WEAR_BELT);

 

                //if (NULL == beltItem)

                    //return false;

 

                //if (false == CBeltInventoryHelper::IsAvailableCell(bCell - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))

                    //return false;

 

                if (m_pointsInstant.bItemGrid[bCell])

                {

                    if (m_pointsInstant.bItemGrid[bCell] == iExceptionCell)

                        return true;

 

                    return false;

                }

 

                if (bSize == 1)

                    return true;

 

            }

 

belt_inv_helper:

    static bool IsExistItemInBeltInventory(LPCHARACTER pc)

    {

        //for (WORD i = BELT_INVENTORY_SLOT_START; i < BELT_INVENTORY_SLOT_END; ++i)

        //{

            //LPITEM beltInventoryItem = pc->GetInventoryItem(i);

 

            //if (NULL != beltInventoryItem)

                //return true;

        //}

 

        return false;

    }

# edit solved

Link to comment
Share on other sites

  • 11 months later...

@Many

my cmd_general.cpp:

Detail:

		if (ch->GetHorse() != NULL)
		{
			sys_log(1, "[DO_RIDE] start riding");
			ch->StartRiding();
			return;
		}

		for (UINT i=0; i<INVENTORY_AND_EQUIP_SLOT_MAX; ++i) //INVENTORY_MAX_NUM
		{
			LPITEM item = ch->GetInventoryItem(i);
			if (NULL == item)
				continue;

			if (item->IsRideItem())
			{
				if (
					NULL==ch->GetWear(WEAR_UNIQUE1)
					|| NULL==ch->GetWear(WEAR_UNIQUE2)
	#ifdef ENABLE_MOUNT_COSTUME_SYSTEM
					|| NULL==ch->GetWear(WEAR_COSTUME_MOUNT)
	#endif
				)

 

Edited by Pisti95
  • Lmao 1
Link to comment
Share on other sites

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.