Jump to content
×
×
  • Create New...
  • 0

Swap system,i ask experts


emanuel

Question

5 answers to this question

Recommended Posts

  • 0

Here is for char_item.cpp :

 

//search
		if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell))
			return false;
//change with:
		if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell))
		{
			if (!SwapItemToItem(Cell, DestCell))
				return false;
			else
				return true;
		}

//after last bool you put this:
bool CHARACTER::SwapItemToItem(TItemPos srcCell, TItemPos destCell)
{
	if (!CanHandleItem())
		return false;
	BYTE bCell = srcCell.cell;
	BYTE bDestCell = destCell.cell;
	BYTE pages_count = 4;

	if (srcCell.IsDragonSoulEquipPosition() || destCell.IsDragonSoulEquipPosition())
		return false;

	if (bCell == bDestCell)
		return false;

	if (srcCell.IsEquipPosition() || destCell.IsEquipPosition())
		return false;
	if (srcCell.window_type != INVENTORY || destCell.window_type != INVENTORY || destCell.cell >= INVENTORY_MAX_NUM)
		return false;

	LPITEM item1, item2;

	item1 = GetInventoryItem(bCell);
	item2 = GetInventoryItem(bDestCell);

	if (!item1 || !item2)
		return false;
	
	if (item1 == item2)
	{
	    sys_log(0, "[WARNING][WARNING][HACK USER!] : %s %d %d", m_stName.c_str(), bCell, bDestCell);
	    return false;
	}
	if (item1->GetSize() == item2->GetSize())
	{
		BYTE bCell1 = item1->GetCell();
		BYTE bCell2 = item2->GetCell();
		
		item1->RemoveFromCharacter();
		item2->RemoveFromCharacter();

		item1->AddToCharacter(this, TItemPos(INVENTORY, bCell2));
		item2->AddToCharacter(this, TItemPos(INVENTORY, bCell1));
	}
	
	if (item1->GetSize() > item2->GetSize())
	{
		BYTE bCell1 = item1->GetCell();
		ChatPacket(CHAT_TYPE_INFO, "Slot %d", bDestCell);
		BYTE pPageDest = bDestCell / (INVENTORY_MAX_NUM / pages_count);
		BYTE pPageDest2 = (((item1->GetSize()-1) * 5) + bDestCell) / (INVENTORY_MAX_NUM / pages_count);
		if (bDestCell >= INVENTORY_MAX_NUM)
			return false;
		if (pPageDest != pPageDest2)
		{
			for (int ii = 1; ii < 4; ++ii)
			{
				pPageDest2 = (bDestCell + (5*(item1->GetSize()-1)) - (5 * ii)) / (INVENTORY_MAX_NUM / pages_count);
				if (pPageDest == pPageDest2)
				{
					bDestCell = bDestCell - (5 * ii);
					break;
				}
			}
		}
		if (pPageDest != pPageDest2)
			return false;
		item1->RemoveFromCharacter();
		for (int i = 0; i < item1->GetSize(); ++i)
		{
			BYTE bBusyCell = bDestCell + (5 * i);
			BYTE lpage = bBusyCell / (INVENTORY_MAX_NUM / pages_count);
			if (lpage != pPageDest)
				continue;
			TItemPos busyCell(INVENTORY, bBusyCell);
			LPITEM busy = GetItem(busyCell);
			if (busy)
			{
				busy->RemoveFromCharacter();
				busy->AddToCharacter(this, TItemPos(INVENTORY, bCell1 + (5 * i)));
			}
		}
		item1->AddToCharacter(this, TItemPos(INVENTORY, bDestCell));
	}

	return true;
}

 

Link to comment
  • 0
  • Moon

Does it happen only with you move an item that its size is 3 slots?(like the weapon you show).

If so, try the following:

look for 

if (busy)
			{
				busy->RemoveFromCharacter();
				busy->AddToCharacter(this, TItemPos(INVENTORY, bCell1 + (5 * i)));
			}
		}

add below

(if item1->GetSize() == 3)

    bDestCell -= 5;

  • Love 1
Link to comment

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


  • Read our Rules
  • Activity

    1. 2

      Fix CursorImage 'NoneType' object is not callable.

    2. 0

      [Land of Heroes] We are looking for Game / Game Economy Designers

    3. 177

      Render Target Remastered

    4. 1

      MySQL stop when start server

    5. 0

    6. 59

      Emoji in TextLine

  • Recently Browsing

    No registered users viewing this page.

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.