Premium Istny 79 Posted April 14, 2016 Premium Share Posted April 14, 2016 M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) So someone published item swap on epvp... Here is better version from me with background color It's possible i forget about something so give me a call You can change background color in OnRenderPickingSlot() function (PythonGridSlotWindow.cpp) Spoiler SERVER SIDE: open char_item.cpp in function bool CHARACTER::MoveItem replace Spoiler if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell)){ } with this Spoiler 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 = 4; //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; } CLIENT SIDE: open PythonGridSlotWindow.cpp replace CGridSlotWindow::OnRenderPickingSlot() function with this Spoiler void CGridSlotWindow::OnRenderPickingSlot() { if (!UI::CWindowManager::Instance().IsAttaching()) return; BYTE byWidth, byHeight; UI::CWindowManager::Instance().GetAttachingIconSize(&byWidth, &byHeight); std::list<TSlot*> SlotList; if (GetPickedSlotList(byWidth, byHeight, &SlotList)) { DWORD dwSlotNumber = UI::CWindowManager::Instance().GetAttachingSlotNumber(); DWORD dwItemIndex = UI::CWindowManager::Instance().GetAttachingIndex(); // UseMode ŔĚ°í.. if (m_isUseMode) { // Pick µČ ľĆŔĚĹŰŔĚ ŔÖŔ¸¸é.. TSlot * pSlot = *SlotList.begin(); TSlot * pCenterSlot; if (GetSlotPointer(pSlot->dwCenterSlotNumber, &pCenterSlot)) if (pCenterSlot->isItem) { if (m_isUsableItem) CPythonGraphic::Instance().SetDiffuseColor(1.0f, 1.0f, 0.0f, 0.5f); else CPythonGraphic::Instance().SetDiffuseColor(1.0f, 0.0f, 0.0f, 0.5f); CPythonGraphic::Instance().RenderBar2d( m_rect.left + pCenterSlot->ixPosition, m_rect.top + pCenterSlot->iyPosition, m_rect.left + pCenterSlot->ixPosition + pCenterSlot->byxPlacedItemSize * ITEM_WIDTH, m_rect.top + pCenterSlot->iyPosition + pCenterSlot->byyPlacedItemSize * ITEM_HEIGHT); return; } } // ľĆ´Ď¸é ±×łÉ żĹ±â±â if (!CheckMoving(dwSlotNumber, dwItemIndex, SlotList)){ if(m_isUsableItem2) CPythonGraphic::Instance().SetDiffuseColor(0.0f, 0.55f, 0.55f, 0.5f);//here you can change swapable item color else CPythonGraphic::Instance().SetDiffuseColor(1.0f, 0.0f, 0.0f, 0.5f); } else CPythonGraphic::Instance().SetDiffuseColor(1.0f, 1.0f, 1.0f, 0.5f); RECT Rect; Rect.left = m_rect.right; Rect.top = m_rect.bottom; Rect.right = 0; Rect.bottom = 0; for (std::list<TSlot*>::iterator itor = SlotList.begin(); itor != SlotList.end(); ++itor) { TSlot * pSlot = *itor; Rect.left = min(Rect.left, m_rect.left + pSlot->ixPosition); Rect.top = min(Rect.top, m_rect.top + pSlot->iyPosition); Rect.right = max(Rect.right, m_rect.left + pSlot->ixPosition + pSlot->byxPlacedItemSize*ITEM_WIDTH); Rect.bottom = max(Rect.bottom, m_rect.top + pSlot->iyPosition + pSlot->byxPlacedItemSize*ITEM_HEIGHT); } CPythonGraphic::Instance().RenderBar2d(Rect.left, Rect.top, Rect.right, Rect.bottom); } } Open PythonSlotWindow.cpp add under void CSlotWindow::SetUsableItem(BOOL bFlag) this function Spoiler void CSlotWindow::SetUsableItem2(BOOL bFlag) { m_isUsableItem2 = bFlag; } next add int void CSlotWindow::__Initialize() Spoiler m_isUsableItem2 = FALSE; in namespace UI add under BOOL m_isUsableItem Spoiler BOOL m_isUsableItem2; open PythonSlotWindow.h add this under void SetUsableItem(BOOL bFlag); Spoiler void SetUsableItem2(BOOL bFlag); open PythonWindowManagerModule.cpp add this under PyObject * wndMgrSetUsableItem(PyObject * poSelf, PyObject * poArgs) Spoiler PyObject * wndMgrSetUsableItem2(PyObject * poSelf, PyObject * poArgs) { UI::CWindow * pWin; if (!PyTuple_GetWindow(poArgs, 0, &pWin)) return Py_BuildException(); int iFlag; if (!PyTuple_GetInteger(poArgs, 1, &iFlag)) return Py_BuildException(); if (!pWin->IsType(UI::CSlotWindow::Type())) return Py_BuildException(); UI::CSlotWindow * pSlotWin = (UI::CSlotWindow *)pWin; pSlotWin->SetUsableItem2(iFlag); return Py_BuildNone(); } add this under { "SetUsableItem", wndMgrSetUsableItem, METH_VARARGS }, Spoiler { "SetUsableItem2", wndMgrSetUsableItem2, METH_VARARGS }, PYTHON: open ui.py and add this function Spoiler def SetUsableItem2(self, flag): wndMgr.SetUsableItem2(self.hWnd, flag) open uiinventory.py in function def OverOutItem(self): add Spoiler self.wndItem.SetUsableItem2(FALSE) replace OverInItem function with this Spoiler def OverInItem(self, overSlotPos): overSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos) self.wndItem.SetUsableItem(FALSE) self.wndItem.SetUsableItem2(FALSE) if mouseModule.mouseController.isAttached(): attachedItemType = mouseModule.mouseController.GetAttachedType() if player.SLOT_TYPE_INVENTORY == attachedItemType: attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() attachedItemVNum = mouseModule.mouseController.GetAttachedItemIndex() if self.__CanUseSrcItemToDstItem(attachedItemVNum, attachedSlotPos, overSlotPos): self.wndItem.SetUsableItem(TRUE) self.ShowToolTip(overSlotPos) return else: srcItem = player.GetItemIndex(attachedSlotPos) item.SelectItem(srcItem) item1_size = str(item.GetItemSize()) dstItem = player.GetItemIndex(overSlotPos) item.SelectItem(dstItem) item2_size = str(item.GetItemSize()) if item2_size == item1_size: if attachedSlotPos != overSlotPos: self.wndItem.SetUsableItem2(TRUE) self.ShowToolTip(overSlotPos) return if item1_size == "(1, 2)": if attachedSlotPos != overSlotPos: if item2_size == "(1, 1)": second_item = player.GetItemIndex(overSlotPos+5) item.SelectItem(second_item) second_item_size = str(item.GetItemSize()) if second_item_size != "(1, 2)" and second_item_size != "(1, 3)": self.wndItem.SetUsableItem2(TRUE) self.ShowToolTip(overSlotPos) return if item1_size == "(1, 3)": if attachedSlotPos != overSlotPos: if item2_size == "(1, 1)": second_item = player.GetItemIndex(overSlotPos+5) item.SelectItem(second_item) second_item_size = str(item.GetItemSize()) if second_item_size != "(1, 3)": third_item = player.GetItemIndex(overSlotPos+10) item.SelectItem(third_item) third_item_size = str(item.GetItemSize()) if third_item_size != "(1, 2)" and third_item_size != "(1, 3)": self.wndItem.SetUsableItem2(TRUE) self.ShowToolTip(overSlotPos) return elif item2_size == "(1, 2)": second_item = player.GetItemIndex(overSlotPos+10) item.SelectItem(second_item) second_item_size = str(item.GetItemSize()) if second_item_size != "(1, 2)" and second_item_size != "(1, 3)": self.wndItem.SetUsableItem2(TRUE) self.ShowToolTip(overSlotPos) return self.ShowToolTip(overSlotPos) maybe someone will do better python part ^.^ ####################################################################################################### I don't remember now but this was not working perfect because of overin so i created additional function, let me know is it necessary ADDITIONAL PART: in PythonGridSlotWindow.cpp add function Spoiler BOOL CGridSlotWindow::GetPickedSlotPointer2(TSlot ** ppSlot) { if (!UI::CWindowManager::Instance().IsAttaching()) return CSlotWindow::GetPickedSlotPointer(ppSlot); BYTE byWidth, byHeight; UI::CWindowManager::Instance().GetAttachingIconSize(&byWidth, &byHeight); std::list<TSlot*> SlotList; if (!GetPickedSlotList(byWidth, byHeight, &SlotList)) return FALSE; TSlot * pMinSlot = NULL; //DWORD dwSlotNumber = UI::CWindowManager::Instance().GetAttachingSlotNumber(); //DWORD dwAttachingItemIndex = UI::CWindowManager::Instance().GetAttachingIndex(); for (std::list<TSlot*>::iterator itor = SlotList.begin(); itor != SlotList.end(); ++itor) { TSlot * pSlot = *itor; // NOTE : ÇŃ ˝˝·Ô ŔĚ»ó »çŔĚÁîŔÇ ľĆŔĚĹŰŔÇ °ćżě °ˇŔĺ żŢÂĘ Ŕ§ŔÇ ˝˝·Ô Ć÷ŔÎĹ͸¦ ¸®ĹĎÇŃ´Ů. // ¸í˝ĂŔűŔĚÁö ¸řÇŃ ÄÚµĺ.. ´ő ÁÁŔş ąćąýŔş ľř´Â°ˇ? - [levites] if (!pMinSlot) { pMinSlot = pSlot; } else { if (pSlot->dwSlotNumber < pMinSlot->dwSlotNumber) { pMinSlot = pSlot; } else { if (!pMinSlot->isItem && pSlot->isItem) { //pMinSlot = pSlot; } } } } if (!pMinSlot) { return FALSE; } else { TSlot * pCenterSlot; if (!GetSlotPointer(pMinSlot->dwCenterSlotNumber, &pCenterSlot)) return FALSE; *ppSlot = pCenterSlot; // ÇöŔç ľĆŔĚĹŰŔ» µé°í ŔÖ´Â ÁßŔĚ°í.. if (UI::CWindowManager::Instance().IsAttaching()) { DWORD dwSlotNumber = UI::CWindowManager::Instance().GetAttachingSlotNumber(); if (dwSlotNumber == pCenterSlot->dwSlotNumber) { *ppSlot = pMinSlot; } } } return TRUE; } in PythonGridSlotWindow.h add under BOOL GetPickedSlotPointer(TSlot ** ppSlot); Spoiler BOOL GetPickedSlotPointer2(TSlot ** ppSlot); in PythonSlotWindow.cpp replace function OnMouseLeftButtonDown() with this Spoiler BOOL CSlotWindow::OnMouseLeftButtonDown() { TSlot * pSlot; if (!GetPickedSlotPointer2(&pSlot)) { UI::CWindowManager::Instance().DeattachIcon(); return TRUE; } if (pSlot->isItem && !(pSlot->dwState & SLOT_STATE_LOCK)) { OnSelectItemSlot(pSlot->dwSlotNumber); } else { OnSelectEmptySlot(pSlot->dwSlotNumber); } return TRUE; } under frunction GetPickedSlotPointer(TSlot ** ppSlot) add this Spoiler BOOL CSlotWindow::GetPickedSlotPointer2(TSlot ** ppSlot) { long lx, ly; CWindowManager::Instance().GetMousePosition(lx, ly); int ixLocal = lx - m_rect.left; int iyLocal = ly - m_rect.top; // NOTE : żŢÂĘ ¸ÇŔ§ »ó´Ü ÇŃ°÷ŔĚ ±âÁŘ Ŕ̶ó´Â ÁˇŔ» ŔĚżëÇŘ żŢÂĘ Ŕ§żˇĽşÎĹÍ żŔ¸ĄÂĘ ľĆ·ˇ·Î // Â÷·Ę·Î °Ë»öÇŘ °¨Ŕ¸·Î˝á µ¤Çô ŔÖ´Â SlotŔş ŔÚµż ą«˝Ă µČ´Ů´Â ĆŻĽşŔ» ŔĚżëÇŃ´Ů. - [levites] for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor) { TSlot & rSlot = *itor; int ixCellSize = rSlot.ixCellSize; int iyCellSize = rSlot.iyCellSize; // NOTE : ItemŔĚ Hide µÇľîŔÖŔ» °ćżě¸¦ Ŕ§ÇŃ.. if (rSlot.isItem) { ixCellSize = max(rSlot.ixCellSize, int(rSlot.byxPlacedItemSize * ITEM_WIDTH)); iyCellSize = max(rSlot.iyCellSize, int(rSlot.byyPlacedItemSize * ITEM_HEIGHT)); } if (ixLocal >= rSlot.ixPosition) if (iyLocal >= rSlot.iyPosition) if (ixLocal <= rSlot.ixPosition + ixCellSize) if (iyLocal <= rSlot.iyPosition + iyCellSize) { *ppSlot = &rSlot; return TRUE; } } return FALSE; } in PythonSlotWindow.h add under GetPickedSlotPointer(TSlot ** ppSlot); this Spoiler virtual BOOL GetPickedSlotPointer2(TSlot ** ppSlot); DONE 14 1 2 1 10 Link to comment Share on other sites More sharing options...
Thorer 19 Posted April 14, 2016 Share Posted April 14, 2016 Its my system and this version is bugged, items will dissapear. Fucking pieces of shit. Link to comment Share on other sites More sharing options...
Premium Istny 79 Posted April 14, 2016 Author Premium Share Posted April 14, 2016 5 minutes ago, Thorer said: Its my system and this version is bugged, items will dissapear. Fucking pieces of shit. from this what i remember, when i was creating this sytem, when you swapped smaller item into bigger, this bigger item was invisible, after server restart you can see it again Link to comment Share on other sites More sharing options...
Premium TAUMP 841 Posted April 14, 2016 Premium Share Posted April 14, 2016 I use only effect xD Link to comment Share on other sites More sharing options...
Juppsy 4 Posted April 15, 2016 Share Posted April 15, 2016 You have a little mistake. On char_item.cpp part you have "estination_size" instread of "destination_size". Regards. #Edit: I tested it, it works good but my client syserr spam 0415 19:07:11581 :: Cannot find item by 0 Anyone know why? 1 Link to comment Share on other sites More sharing options...
avertuss 48 Posted April 26, 2016 Share Posted April 26, 2016 Bugged or no? Link to comment Share on other sites More sharing options...
Premium Istny 79 Posted April 26, 2016 Author Premium Share Posted April 26, 2016 1 hour ago, avertuss said: Bugged or no? I'm using this on my server from couple months. no bugs 1 Link to comment Share on other sites More sharing options...
BackPlayer 55 Posted May 14, 2016 Share Posted May 14, 2016 Spoiler can you help me with this problem? https://metin2dev.org/board/index.php?/topic/11743-citem-swap-bug/ Copy & Paste to work Link to comment Share on other sites More sharing options...
xRooT 24 Posted July 3, 2016 Share Posted July 3, 2016 (edited) ok good syserr.txt Edited August 20, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
GolDRoger 0 Posted September 2, 2016 Share Posted September 2, 2016 "this version is bugged, items will dissapear. " Same result for me Link to comment Share on other sites More sharing options...
Tacticus 73 Posted September 2, 2016 Share Posted September 2, 2016 nop work good...but exist bug with belt window Link to comment Share on other sites More sharing options...
Recommended Posts