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

Swap item problem


Zerial

Question

  • Premium

Hi everybody! I have got a problem with my item swap system. Almost everything is good except one thing.:

Sihzf.gif

My char_item.cpp:

if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell)){
				
	if (INVENTORY == Cell.window_type && INVENTORY == DestCell.window_type && !Cell.IsEquipPosition()){
			
		LPITEM item3 = NULL;
		item3 = GetItem(DestCell);
		
		if (!GetItem(DestCell))
			return false;
					
		if (item3->IsExchanging())
			return false;
					
		if (true == item3->isLocked())
			return false;
		
		// if equal size
		if (item->GetSize() == item3->GetSize()){
						
			item->RemoveFromCharacter();
			item3->RemoveFromCharacter();
						
			SetItem(DestCell, item);
			SetItem(Cell, item3);
							
			return true;
		}
					
		//replace with yours inventory page count
		int page_count = 3;
				
		//when swaping items have diferent size
		if(item->GetSize() > 1 ){
					
			int j = 0;
						
			int destination_size = 0;
			LPITEM check_item = NULL;
					
			do
			{
				BYTE slot = DestCell.cell + (5 * j);
							
				//if slot is empty
				if (!(check_item = GetItem(TItemPos(INVENTORY, slot)))){
					if((item->GetSize() -1) == j){
						if((DestCell.cell / (INVENTORY_MAX_NUM / page_count)) != ((DestCell.cell + (5 * j)) / (INVENTORY_MAX_NUM / page_count)))    
							return false;
					}
				}
				else{
					check_item = GetItem(TItemPos(INVENTORY, slot));
					destination_size += check_item->GetSize();
							
					if((item->GetSize() -1) == j){
						//last item must have size 1 to swap
						if(check_item->GetSize() > 1)
							return false;
								
						if((DestCell.cell / (INVENTORY_MAX_NUM / page_count)) != ((DestCell.cell + (5 * j)) / (INVENTORY_MAX_NUM / page_count)))    
							return false;
					}                            
				}                
			}
			while (++j < item->GetSize());
					
					
			if((Cell.cell + 5) == DestCell.cell)
				return false;
					
			if(item->GetSize() < destination_size)
				return false;
						
			item->RemoveFromCharacter();    
					
			int k = 0;
			check_item = NULL;
					
			do
			{
				BYTE slot = DestCell.cell + (5 * k);
				BYTE slot2 = Cell.cell + (5 * k);
									
				if (!(check_item = GetItem(TItemPos(INVENTORY, slot))))
					continue;
				else{
					check_item->RemoveFromCharacter();
					SetItem(TItemPos(INVENTORY, slot2), check_item);
				}    
						
			}
			while (++k < item->GetSize());
						
					SetItem(DestCell, item);
		}
		else
					return false;
	}
	else
		return false;
}

I hope somebody can help me. Thank you in advance.

Regards

Link to comment
  • Answers 1
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

1 answer to this question

Recommended Posts

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

Announcements

  • -15% Discount in Metin2 Dev Store (01/10/2021 => 31/12/2021) => Code => 15_PCT_OCT_TO_DEC_2021


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.