Custom droplist chance recalc (probaly bug)

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
ibedoya
Posts: 14
Joined: Thu Jun 21, 2012 5:37 pm

Custom droplist chance recalc (probaly bug)

Post by ibedoya »

When you add a custom droplist in custom_droplist table (ofc) because you want to change some rates (so you are adding existing items but diferent chances), in L2DropCategory.java, addDropData() function recalculate the values besides add drops, as it should be.

But if the drop exists (is the case), _categoryChance and _categoryBalancedChance is re-calculated but for some reason (probably a bug) in _categoryBalancedChance is using only RATE_DROP_ITEMS config when should use RATE_DROP_ITEMS_BY_RAID if it's the case.

Below if is not a replace (new item), is using RATE_DROP_ITEMS_BY_RAID if needed.

Here the function: (I added 3 comments in this way /*** comment ***/ for a better understanding of the problem)

Code: Select all

    public void addDropData(L2DropData drop, boolean raid)    {        boolean found = false;                if (drop.isQuestDrop()) {            //if (_questDrops == null)            //  _questDrops = new FastList<L2DropData>(0);            //_questDrops.add(drop);        }        else        {            if (Config.CUSTOM_DROPLIST_TABLE)            {                // If the drop exists is replaced                for (L2DropData d : _drops)                {                    if (d.getItemId() == drop.getItemId())                    {                        d.setMinDrop(drop.getMinDrop());                        d.setMaxDrop(drop.getMaxDrop());                        if (d.getChance() != drop.getChance())                        {                            // Re-calculate Chance                            _categoryChance -= d.getChance();                            /*** Here the bug, is using only RATE_DROP_ITEMS ***/                            _categoryBalancedChance -= Math.min((d.getChance() * Config.RATE_DROP_ITEMS), L2DropData.MAX_CHANCE);                            d.setChance(drop.getChance());                            _categoryChance += d.getChance();                            /*** Here the bug, is using only RATE_DROP_ITEMS ***/                            _categoryBalancedChance += Math.min((d.getChance() * Config.RATE_DROP_ITEMS), L2DropData.MAX_CHANCE);                        }                        found = true;                        break;                    }                }            }                        if (!found)            {                _drops.add(drop);                _categoryChance += drop.getChance();                // for drop selection inside a category: max 100 % chance for getting an item, scaling all values to that.                /*** Here is using RATE_DROP_ITEMS_BY_RAID correctly ***/                _categoryBalancedChance += Math.min((drop.getChance()*(raid?Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS)),L2DropData.MAX_CHANCE);            }        }    }
I'm pretty sure this is a bug.

I can't make posts in the properly section: viewforum.php?f=77

Regards.
nthnhfrost
Posts: 1
Joined: Mon Mar 11, 2013 1:09 pm
Location: Portland, ME

Re: Custom droplist chance recalc (probaly bug)

Post by nthnhfrost »

Yeah, you are correct, this is a bug...
Post Reply