Drop calculation fix for dropping 0 count items.
Author yksdtc. Source: http://www.l2jserver.com/forum/viewtopic.php?f=128&t=31068
This commit is contained in:
@@ -264,21 +264,13 @@ public class GeneralDropItem implements IDropItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
final double chance = getChance(victim, killer);
|
final double chance = getChance(victim, killer);
|
||||||
int successes;
|
final boolean successes = chance > (Rnd.nextDouble() * 100);
|
||||||
if (!Config.L2JMOD_OLD_DROP_BEHAVIOR)
|
if (successes)
|
||||||
{
|
|
||||||
successes = chance > (Rnd.nextDouble() * 100) ? 1 : 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
successes = (int) (chance / 100);
|
|
||||||
successes += (chance % 100) > (Rnd.nextDouble() * 100) ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (successes > 0)
|
|
||||||
{
|
{
|
||||||
final Collection<ItemHolder> items = new ArrayList<>(1);
|
final Collection<ItemHolder> items = new ArrayList<>(1);
|
||||||
items.add(new ItemHolder(getItemId(), Rnd.get(getMin(victim, killer), getMax(victim, killer)) * successes));
|
final long baseDropCount = Rnd.get(getMin(victim, killer), getMax(victim, killer));
|
||||||
|
final long finaldropCount = (long) (Config.L2JMOD_OLD_DROP_BEHAVIOR ? (baseDropCount * Math.max(1, chance / 100)) + (chance > 100 ? (chance % 100) > (Rnd.nextDouble() * 100) ? baseDropCount : 0 : 0) : baseDropCount);
|
||||||
|
items.add(new ItemHolder(getItemId(), finaldropCount));
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -126,28 +126,24 @@ public class GroupedGeneralDropItem implements IDropItem
|
|||||||
}
|
}
|
||||||
|
|
||||||
final double chance = getChance(victim, killer) * chanceModifier;
|
final double chance = getChance(victim, killer) * chanceModifier;
|
||||||
int successes;
|
final boolean successes = chance > (Rnd.nextDouble() * 100);
|
||||||
if (!Config.L2JMOD_OLD_DROP_BEHAVIOR)
|
|
||||||
{
|
|
||||||
successes = chance > (Rnd.nextDouble() * 100) ? 1 : 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
successes = (int) (chance / 100);
|
|
||||||
successes += (chance % 100) > (Rnd.nextDouble() * 100) ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
double totalChance = 0;
|
if (successes)
|
||||||
final double random = (Rnd.nextDouble() * 100);
|
|
||||||
for (GeneralDropItem item : getItems())
|
|
||||||
{
|
{
|
||||||
// Grouped item chance rates should not be modified.
|
double totalChance = 0;
|
||||||
totalChance += item.getChance();
|
final double random = (Rnd.nextDouble() * 100);
|
||||||
if (totalChance > random)
|
for (GeneralDropItem item : getItems())
|
||||||
{
|
{
|
||||||
final Collection<ItemHolder> items = new ArrayList<>(1);
|
// Grouped item chance rates should not be modified.
|
||||||
items.add(new ItemHolder(item.getItemId(), Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer)) * successes));
|
totalChance += item.getChance();
|
||||||
return items;
|
if (totalChance > random)
|
||||||
|
{
|
||||||
|
final Collection<ItemHolder> items = new ArrayList<>(1);
|
||||||
|
final long baseDropCount = Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
|
||||||
|
final long finaldropCount = (long) (Config.L2JMOD_OLD_DROP_BEHAVIOR ? (baseDropCount * Math.max(1, chance / 100)) + (chance > 100 ? (chance % 100) > (Rnd.nextDouble() * 100) ? baseDropCount : 0 : 0) : baseDropCount);
|
||||||
|
items.add(new ItemHolder(item.getItemId(), finaldropCount));
|
||||||
|
return items;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user