Jump to content

Recommended Posts

  • Premium
On 6/13/2023 at 1:40 PM, anton96 said:

Should this be placed under :?

#ifdef __SEND_TARGET_INFO__
bool ITEM_MANAGER::CreateDropItemVector(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::vector<LPITEM> & vec_item)
{
	if (pkChr->IsPolymorphed() || pkChr->IsPC())
	{
		return false;
	}

	int iLevel = pkKiller->GetLevel();

	BYTE bRank = pkChr->GetMobRank();
	LPITEM item = NULL;

	std::vector<CItemDropInfo>::iterator it = g_vec_pkCommonDropItem[bRank].begin();

Or does it go under :?

bool ITEM_MANAGER::CreateDropItem(LPCHARACTER pkChr, LPCHARACTER pkKiller, std::vector<LPITEM> & vec_item)
{
	int iLevel = pkKiller->GetLevel();

	int iDeltaPercent, iRandRange;
	if (!GetDropPct(pkChr, pkKiller, iDeltaPercent, iRandRange))
		return false;

	BYTE bRank = pkChr->GetMobRank();
	LPITEM item = NULL;

	// Common Drop Items
std::vector<CItemDropInfo>::iterator it = g_vec_pkCommonDropItem[bRank].begin();

I've gotten a bit confused as to what should calculate drop rate should replace...

I just had used the level to show drop from common drop items with the level difference chosen in common_drop_item.txt. You posted two different functions. The first one is the target info, the second one is where the items are actually dropped (that you should not touch).

Let's say I set an item from level 75 to 99, a player level 74 won't see the item in the info drop list:

	while (it != g_vec_pkCommonDropItem[bRank].end())
	{
		const CItemDropInfo & c_rInfo = *(it++);
		
      		//LEVEL CHECK
		if(iLevel < c_rInfo.m_iLevelStart || iLevel > c_rInfo.m_iLevelEnd)
			continue;

		TItemTable * table = GetTable(c_rInfo.m_dwVnum);

		if(!table)
			continue;

		int rarity = CalculateDropRarityCommonDropItem((c_rInfo.m_iPercent * iDeltaPercent) / 100, iRandRange);
		if(rarity){
			vec_item.emplace_back(c_rInfo.m_dwVnum, 1, rarity);
		}
	}

 

Edited by Intel
  • 1 year later...
  • 6 months later...
  • Premium
3 minutes ago, shadowofthelove said:

really hard to follow the topic as a begginer, can we get a reupload of the complete system please?

stephen colbert laughing GIF by The Late Show With Stephen Colbert

Edited by Metin2 Dev International
Core X - External 2 Internal
  • Lmao 1
  • 3 months later...
  • Active Member

Its a  long time  gone,  but this is probably one of  the most used  Systems, so I wanna contribute with something:

Unused methods which can be removed:
 

	def SetVisible(self, is_show):
		if is_show:
			self.Show()
		else:
			self.Hide()


	def SetAttachParent(self, parent):
		wndMgr.SetAttachParent(self.hWnd, parent.hWnd)


Reworking height calculation, for avoiding cutoffs of items:
 

spacer.png


uitarget.py

        class ItemListBoxItem(ui.ListBoxExNew.Item):
            def __init__(self, width):
                ui.ListBoxExNew.Item.__init__(self)
                image = ui.ExpandedImageBox()
                image.SetParent(self)
                image.Show()
                self.image = image
                nameLine = ui.TextLine()
                nameLine.SetParent(self)
                nameLine.SetPosition(32 + 5, 0)
                nameLine.Show()
                self.nameLine = nameLine
                self.SetSize(width, 32 + 5)
                self.baseTextY = 0 
            def LoadImage(self, image, name = None):
                self.image.LoadImage(image)
                
                imgWidth = self.image.GetWidth()
                imgHeight = self.image.GetHeight()
                
                calculatedHeight = max(32, imgHeight) + 5
                self.SetSize(self.GetWidth(), calculatedHeight)
                
                self.image.SetPosition(0, (calculatedHeight - imgHeight) / 2)
                self.baseTextY = (calculatedHeight - 15) / 2
                
                if name != None:
                    self.SetText(name)
                    self.nameLine.SetPosition(imgWidth + 5, self.baseTextY)
            def SetText(self, text):
                self.nameLine.SetText(text)
            def RefreshHeight(self):
                ui.ListBoxExNew.Item.RefreshHeight(self)
                fullHeight = float(self.GetHeight())
                if fullHeight == 0:
                    return
                self.image.SetRenderingRect(
                    0.0, 
                    0.0 - float(self.removeTop) / fullHeight, 
                    0.0, 
                    0.0 - float(self.removeBottom) / fullHeight
                )
                self.image.SetPosition(0, -self.removeTop)
                
                if self.nameLine:
                    imgWidth = self.image.GetWidth()
                
                    currentTextY = self.baseTextY - self.removeTop
                    self.nameLine.SetPosition(imgWidth + 5, currentTextY)
                    currentVisibleHeight = fullHeight - self.removeTop - self.removeBottom
                    textHeight = 15 
                    if currentTextY < 0 or (currentTextY + textHeight) > currentVisibleHeight:
                        self.nameLine.Hide()
                    else:
                        self.nameLine.Show()
        def __LoadInformation_Drops(self, race):
            self.AppendSeperator()
            if race in MONSTER_INFO_DATA:
                if len(MONSTER_INFO_DATA[race]["items"]) == 0:
                    self.AppendTextLine(localeInfo.TARGET_INFO_NO_ITEM_TEXT)
                else:
                    itemListBox = ui.ListBoxExNew(32 + 5, self.MAX_ITEM_COUNT)
                    itemListBox.SetSize(self.GetWidth() - 15 * 2 - ui.ScrollBar.SCROLLBAR_WIDTH, (32 + 5) * self.MAX_ITEM_COUNT)
                    height = 0
                    for curItem in MONSTER_INFO_DATA[race]["items"]:
                        if curItem.has_key("vnum_list"):
                            height += self.AppendItem(itemListBox, curItem["vnum_list"], curItem["count"])
                        else:
                            height += self.AppendItem(itemListBox, curItem["vnum"], curItem["count"])
                    if height < itemListBox.GetHeight():
                        itemListBox.SetSize(itemListBox.GetWidth(), height)
                    self.AppendWindow(itemListBox, 15)
                    itemListBox.SetBasePos(0)
                    if height > itemListBox.GetHeight():
                        itemScrollBar = ui.ScrollBar()
                        itemScrollBar.SetParent(self)
                        itemScrollBar.SetPosition(itemListBox.GetRight(), itemListBox.GetTop())
                        itemScrollBar.SetScrollBarSize(itemListBox.GetHeight())
                        itemScrollBar.SetMiddleBarSize(float(itemListBox.GetHeight()) / float(height))
                        itemScrollBar.Show()
                        itemListBox.SetScrollBar(itemScrollBar)
            else:
                self.AppendTextLine(localeInfo.TARGET_INFO_NO_ITEM_TEXT)


ui.py

    def __init__(self, stepSize, viewSteps):
        Window.__init__(self)
        self.viewItemCount=10
        self.basePos=0
        self.baseIndex=0
        self.maxSteps=0
        self.totalItemHeight = 0
        self.viewSteps = viewSteps
        self.stepSize = stepSize
        self.itemList=[]
        self.scrollBar=None
        
        self.SetWindowName("NONAME_ListBoxEx")
    def SetBasePos(self, basePos, forceRefresh = TRUE):
        if forceRefresh == FALSE and self.basePos == basePos:
            return
        for oldItem in self.itemList[self.baseIndex:self.baseIndex+self.viewItemCount]:
            oldItem.ResetCurrentHeight()
            oldItem.Hide()
        self.basePos = basePos
        pixelOffset = basePos 
        
        baseIndex = 0
        accumulatedHeight = 0
        
        while baseIndex < len(self.itemList):
            itemHeight = self.itemList[baseIndex].GetHeight()
            
            if accumulatedHeight + itemHeight > pixelOffset:
                topRemove = pixelOffset - accumulatedHeight
                self.itemList[baseIndex].SetRemoveTop(topRemove)
                break
            
            accumulatedHeight += itemHeight
            baseIndex += 1
            
        self.baseIndex = baseIndex
        self.viewItemCount = 0
        currentRenderY = 0
        viewHeightPixels = self.GetHeight()
        while baseIndex < len(self.itemList):
            item = self.itemList[baseIndex]
            itemCurrentHeight = item.GetCurrentHeight()
            
            if currentRenderY + itemCurrentHeight > viewHeightPixels:
                visibleAmount = viewHeightPixels - currentRenderY
                removeBottom = itemCurrentHeight - visibleAmount
                item.SetRemoveBottom(removeBottom)
                itemCurrentHeight = visibleAmount
            
            item.SetPosition(0, currentRenderY)
            item.Show()
            
            currentRenderY += itemCurrentHeight
            self.viewItemCount += 1
            baseIndex += 1
            if currentRenderY >= viewHeightPixels:
                break
    def RemoveAllItems(self):
        self.itemList=[]
        self.maxSteps=0
        self.totalItemHeight = 0
        if self.scrollBar:
            self.scrollBar.SetPos(0)
    def RemoveAllItems(self):
        self.itemList=[]
        self.maxSteps=0
        self.totalItemHeight = 0
        if self.scrollBar:
            self.scrollBar.SetPos(0)
    def RemoveItem(self, delItem):
        self.totalItemHeight -= delItem.GetHeight()
        self.itemList.remove(delItem)
        
        if self.stepSize > 0:
            self.maxSteps = int((self.totalItemHeight + self.stepSize - 1) / self.stepSize)
    def AppendItem(self, newItem):
        newItem.SetParent(self)
        self.itemList.append(newItem)
        self.totalItemHeight += newItem.GetHeight()
        if self.stepSize > 0:
            self.maxSteps = int((self.totalItemHeight + self.stepSize - 1) / self.stepSize)
    def __GetScrollLen(self):
        scrollLen = self.totalItemHeight - self.GetHeight()
        if scrollLen < 0:
            return 0
        return scrollLen
  • Metin2 Dev 1
  • Love 1

spacer.png

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.