Jump to content

pc.give_item2(vnum) - Stacking in Inventory?


Recommended Posts

Hi,

im currently trying to create my own chest that can drop adders  (1-5) and attribute changers.
The drop is created into inventory, when  the specific chest is opened (via quest).

I Implemented support for stacking those adders and changers (c++ / python) . Now I can manually drag and drop them over each other and they will add.
But they do not stack when added directly to inventory.


My special_item_group.txt does not contain any of these vnums (its actually empty)
Antiflags are 0 (serverside and clientside)
Flags are 4 (serverside and clientside)

Is there a way to stack them automatically, when given from a chest via pc.give_item2(vnum) ?

 

chest.quest

quest chest begin
	state start begin
		when 50184.use begin
			if pc.get_empty_inventory_count() >= 1 then
				local rnd = number(1,10)
				if rnd >= 0 and rnd < 2 then
									
					pc.give_item2(39029, 2)
					pc.remove_item(50184,1)
					
				elseif rnd >= 2 and rnd <= 3 then
					pc.give_item2(39004,1)
					pc.remove_item(50184,1)
				else 
					pc.give_item2(39028,5)
					pc.remove_item(50184,1)
				end
			else
				chat("Not enough inventory space.")
			end
		end	
	end			
end		

 

Kind regards

LISA

Link to comment
Share on other sites

Thanks for your reply,

I tested this now with different vnums for example with 27004 (small blue potion).
This Item is automatically stacking when added with pc_give_item2 into inventory.

Is this the source used by pc_give_item2()?

Spoiler

char_item.cpp

 

 


void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
{
	if (NULL == item)
	{
		sys_err ("NULL point.");
		return;
	}
	if (item->GetOwner())
	{
		sys_err ("item %d 's owner exists!",item->GetID());
		return;
	}
	
	int cell;
	if (item->IsDragonSoul())
	{
		cell = GetEmptyDragonSoulInventory(item);
	}
	else
	{
		cell = GetEmptyInventory (item->GetSize());
	}

	if (cell != -1)
	{
		if (item->IsDragonSoul())
			item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, cell));
		else
			item->AddToCharacter(this, TItemPos(INVENTORY, cell));

		LogManager::instance().ItemLog(this, item, "SYSTEM", item->GetName());

		if (item->GetType() == ITEM_USE && item->GetSubType() == USE_POTION)
		{
			TQuickslot * pSlot;

			if (GetQuickslot(0, &pSlot) && pSlot->type == QUICKSLOT_TYPE_NONE)
			{
				TQuickslot slot;
				slot.type = QUICKSLOT_TYPE_ITEM;
				slot.pos = cell;
				SetQuickslot(0, slot);
			}
		}
	}
	else
	{
		item->AddToGround (GetMapIndex(), GetXYZ());
		item->StartDestroyEvent();

		if (longOwnerShip)
			item->SetOwnership (this, 300);
		else
			item->SetOwnership (this, 60);
		LogManager::instance().ItemLog(this, item, "SYSTEM_DROP", item->GetName());
	}
}

 

 

please correct me if I am wrong.

Kind regards

LISA

Link to comment
Share on other sites

Thanks, 

vor 9 Stunden schrieb WeedHex:

pc.give_item2() already stacks the items.

You must put flag 4 item_proto side.

@WeedHex Yes you are correct, it stacks ordinary items.

As you can see in my first post, the flags for the items I try to stack are already set correct.
The difference here is that the Items I try to add with pc.give_item2 are adders/attribute changers (itemshop items). They behave differently - this seems to be a source issue.

You can test this by yourself. just use the quest and change the flags.

 

vor 8 Stunden schrieb Chyu ^^:

I'm not sure but I guess that pc.give_item() is not stacking items like pc.give_item2() does and that's a difference between them.

@Chyu ^^The function pc.give_item is depricated, you wont use this any longer since the vnum lookup is incorrect.
pc.give_item2(vnum,count) is the correct function to use.


If anyone knows more about this please let me know.

Thanks in advance

 

 

  • Love 1
Link to comment
Share on other sites

  • Premium

1) pc.give_item2()    Uses:  void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)

 

2)AutoGiveItem   Uses:

item->AddToCharacter()

 

3) if there is not place to put the item  AddToCharacter will does:

item->AddToGround()

 

4) AddToCharacter() will does    ch->SetItem(TItemPos(window_type, pos), this);

  • Love 1
Link to comment
Share on other sites

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.