LISA 2 Posted August 7, 2018 Share Posted August 7, 2018 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 More sharing options...
LISA 2 Posted August 8, 2018 Author Share Posted August 8, 2018 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 Link to comment Share on other sites More sharing options...
Premium tierrilopes 452 Posted August 8, 2018 Premium Share Posted August 8, 2018 Its all about the function used by pc_give_item that gives the item Link to comment Share on other sites More sharing options...
LISA 2 Posted August 9, 2018 Author Share Posted August 9, 2018 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 More sharing options...
Premium WeedHex 635 Posted August 9, 2018 Premium Share Posted August 9, 2018 pc.give_item2() already stacks the items. You must put flag 4 item_proto side. 1 Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4881 Posted August 9, 2018 Bot Share Posted August 9, 2018 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. Link to comment Share on other sites More sharing options...
LISA 2 Posted August 9, 2018 Author Share Posted August 9, 2018 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 1 Link to comment Share on other sites More sharing options...
LISA 2 Posted August 10, 2018 Author Share Posted August 10, 2018 Still working on a solution, If anyone knows more about my problem please let me know (PM or here) Thanks in advance LISA Link to comment Share on other sites More sharing options...
Premium WeedHex 635 Posted August 13, 2018 Premium Share Posted August 13, 2018 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); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now