Simplified drop replacement logic.
This commit is contained in:
@@ -614,7 +614,8 @@ public class NpcData implements IXmlReader
|
||||
|
||||
if (dropLists != null)
|
||||
{
|
||||
Collections.shuffle(dropLists);
|
||||
// Drops are sorted by chance (high to low).
|
||||
Collections.sort(dropLists, (d1, d2) -> Double.valueOf(d2.getChance()).compareTo(Double.valueOf(d1.getChance())));
|
||||
for (DropHolder dropHolder : dropLists)
|
||||
{
|
||||
switch (dropHolder.getDropType())
|
||||
|
@@ -694,7 +694,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
||||
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||
List<ItemHolder> calculatedDrops = null;
|
||||
List<ItemHolder> randomDrops = null;
|
||||
ItemHolder replacedItem = null;
|
||||
ItemHolder cachedItem = null;
|
||||
if (dropOccurrenceCounter > 0)
|
||||
{
|
||||
for (DropHolder dropItem : dropList)
|
||||
@@ -703,10 +703,10 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
||||
// items that have 100% drop chance without server rate multipliers drop normally
|
||||
if ((dropOccurrenceCounter == 0) && (dropItem.getChance() < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||
{
|
||||
// remove a random existing drop (temporarily if not other item replaces it)
|
||||
dropOccurrenceCounter++;
|
||||
replacedItem = randomDrops.remove(Rnd.get(randomDrops.size()));
|
||||
calculatedDrops.remove(replacedItem);
|
||||
// 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
|
||||
@@ -742,9 +742,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
||||
}
|
||||
}
|
||||
// add temporarily removed item when not replaced
|
||||
if ((dropOccurrenceCounter > 0) && (replacedItem != null) && (calculatedDrops != null))
|
||||
if ((dropOccurrenceCounter > 0) && (cachedItem != null) && (calculatedDrops != null))
|
||||
{
|
||||
calculatedDrops.add(replacedItem);
|
||||
calculatedDrops.add(cachedItem);
|
||||
}
|
||||
// clear random drops
|
||||
if (randomDrops != null)
|
||||
|
Reference in New Issue
Block a user