Jump to content

Swap item problem


Recommended Posts

  • 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

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

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

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.