L2JMobius

Classic Zaken Drop Calculator issue

kamikadzz · 1 · 4492

Offline kamikadzz

  • Black Sheep
  • Knight
  • ***
    • Posts: 65
Hi,

So this is the same in every codebase, and I have tested this in HF, Zaken and the same issue happens:

Code: [Select]
public List<ItemHolder> calculateDrops(DropType dropType, Creature victim, Creature killer)
{
final List<DropHolder> dropList = dropType == DropType.SPOIL ? _dropListSpoil : _dropListDeath;
if (dropList == null)
{
return null;
}

// level difference calculations
final int levelDifference = victim.getLevel() - killer.getLevel();
final double levelGapChanceToDropAdena = Util.map(levelDifference, -Config.DROP_ADENA_MAX_LEVEL_DIFFERENCE, -Config.DROP_ADENA_MIN_LEVEL_DIFFERENCE, Config.DROP_ADENA_MIN_LEVEL_GAP_CHANCE, 100d);
final double levelGapChanceToDrop = Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100d);

int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
List<ItemHolder> calculatedDrops = null;
List<ItemHolder> randomDrops = null;
ItemHolder cachedItem = null;
if (dropOccurrenceCounter > 0)
{
for (DropHolder dropItem : dropList)
{
// check if maximum drop occurrences have been reached
// items that have 100% drop chance without server rate multipliers drop normally
if ((dropOccurrenceCounter == 0) && (dropItem.getChance() < 100) && (randomDrops != null) && (calculatedDrops != null))
{
// remove highest chance item (temporarily if no other item replaces it)
cachedItem = randomDrops.remove(0);
calculatedDrops.remove(cachedItem);
dropOccurrenceCounter = 1;
}

// check level gap that may prevent to drop item
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
{
continue;
}

// calculate chances
final ItemHolder drop = calculateDrop(dropItem, victim, killer);
if (drop == null)
{
continue;
}

// create lists
if (randomDrops == null)
{
randomDrops = new ArrayList<>(dropOccurrenceCounter);
}
if (calculatedDrops == null)
{
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
}

// finally
if (dropItem.getChance() < 100)
{
dropOccurrenceCounter--;
randomDrops.add(drop);
}
calculatedDrops.add(drop);
}
}
// add temporarily removed item when not replaced
if ((dropOccurrenceCounter > 0) && (cachedItem != null) && (calculatedDrops != null))
{
calculatedDrops.add(cachedItem);
}
// clear random drops
if (randomDrops != null)
{
randomDrops.clear();
randomDrops = null;
}

// champion extra drop
if (victim.isChampion())
{
if ((victim.getLevel() < killer.getLevel()) && (Rnd.get(100) < Config.CHAMPION_REWARD_LOWER_LEVEL_ITEM_CHANCE))
{
return calculatedDrops;
}
if ((victim.getLevel() > killer.getLevel()) && (Rnd.get(100) < Config.CHAMPION_REWARD_HIGHER_LEVEL_ITEM_CHANCE))
{
return calculatedDrops;
}

// create list
if (calculatedDrops == null)
{
calculatedDrops = new ArrayList<>();
}

calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
}

return calculatedDrops;
}

As u can see from logs (i added to debugg all of this)

Code: [Select]
[29/03 18:07:07] Drop ok for: Adena with chance: 49.80279756250642 and amount 7395
[29/03 18:07:07] Adena  chance: 70.0 equals true
[29/03 18:07:07] Drop no ok for: Animal Skin with chance 69.53114295220664
[29/03 18:07:07] Drop ok for: Ring of Ages Gemstone with chance: 26.576356513682253 and amount 1
[29/03 18:07:07] Ring of Ages Gemstone  chance: 9.115 equals true
[29/03 18:07:07] Drop no ok for: Stem with chance 50.43566530158341
[29/03 18:07:07] Drop no ok for: Earring of Seal Gemstone with chance 28.16656177353338
[29/03 18:07:07] Drop no ok for: Steel Arrow with chance 81.65884466529637
[29/03 18:07:07] Drop ok for: Necklace of Mermaid Teardrop with chance: 15.619328068989224 and amount 1
[29/03 18:07:07] Necklace of Mermaid Teardrop  chance: 4.413 equals true
[29/03 18:07:07] Drop no ok for: Recipe: Full Plate Gauntlets with chance 62.074923298189574
[29/03 18:07:07] Drop no ok for: Recipe: Blessed Gloves with chance 41.1967056787375
[29/03 18:07:07] Drop no ok for: Ring of Ages with chance 75.25026774682048
[29/03 18:07:07] Drop no ok for: Earring of Seal with chance 7.46473894298455
[29/03 18:07:07] Drop no ok for: Necklace of Mermaid with chance 74.58129533863631
[29/03 18:07:07] ===============================================================
[29/03 18:07:07] Random Drops: 1916 1
[29/03 18:07:07] test: 1916 1
[29/03 18:07:07] test: 1915 1

We dropped the items Adena, Ages Gemstone and Mermaid Teardrop.

After quite a lot of checking, turns out that DropMaxOccurrencesNormal is responsible for number of items dropped from Mob and DropMaxOccurrencesRaidboss not maximum instances of items. Not sure if this is what intended as I assumed it was (if item chance is 90% and u set 4x rates the maximum it can drop is 2 not 3-4). Correct me if i am wrong please.