Jump to content
metin2dev
  • 0
Sign in to follow this  
LISA

open pc.give_item2(vnum) - Stacking in Inventory?

Question

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

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

Hi,

I see similiar requests (also on other boards), but none of them are solved.
If there is an expert who can help me out it would be super kind.

Thanks in advance

 

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

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

 

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

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);

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×