All pastes #885212 Raw Edit

chris

public text v1 · immutable
#885212 ·published 2008-01-30 20:29 UTC
rendered paste body
void (entity owner, entity item) Put_Item_Into_Inventory =
{
	local float x, y, i, YIncrement, max_2d;
	local entity index, slot;
	
	index = Inv_Check_Fit (owner, item);

	if (index == owner)
	{
	print ("Item does not fit into player's inventory\n");
	return;
	}
	
	//	index is the succesfully fitted item's top left slot..
	//	this contains all the data, all other slots are simply
	//	pointers back to the top left data container.

	Inv_Copy (item, index);
	
	max_2d = floor(sqrt(INV_SLOTS));
	x = item.inv_item_size_x;
	y = item.inv_item_size_y;
	YIncrement = 0;
	
	
	
	while (YIncrement <= y)
	{
		for (i = index.slotnumber + (YIncrement*max_2d); i <= (x + index.slotnumber); i++)
		{
			slot = owner.(inventory[i]);
		
			slot.pointsto = index;	
			slot.itemtype = index.itemtype;
			
				print ("Slotnumber: ", ftos(i), " is a pointer of: ");
				print (ftos(index.slotnumber), "\n");
			
		}	
	
	i -= x;
	YIncrement += 1;
	

	}

};