diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3deef75027..2f00edff90 100644 --- a/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_01.0_Ertheia/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3deef75027..2f00edff90 100644 --- a/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_02.5_Underground/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3deef75027..2f00edff90 100644 --- a/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_03.0_Helios/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3deef75027..2f00edff90 100644 --- a/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_04.0_GrandCrusade/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3deef75027..2f00edff90 100644 --- a/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_05.0_Salvation/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3deef75027..2f00edff90 100644 --- a/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_05.5_EtinasFate/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3deef75027..2f00edff90 100644 --- a/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_06.0_Fafurion/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3deef75027..2f00edff90 100644 --- a/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_07.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/NpcData.java index e4026cf322..b919af12d7 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 0dd4b41ae1..4f84e5177a 100644 --- a/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_08.2_Homunculus/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/NpcData.java index e4026cf322..b919af12d7 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 0dd4b41ae1..4f84e5177a 100644 --- a/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_09.2_ReturnOfTheQueenAnt/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 6f4e0d65b6..eb9bd48b95 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -632,7 +632,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()) diff --git a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 88fcff8d57..ff6dbcddda 100644 --- a/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_CT_2.4_Epilogue/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -632,7 +632,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -641,10 +641,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 @@ -680,9 +680,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) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 6f4e0d65b6..eb9bd48b95 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -632,7 +632,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()) diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 88fcff8d57..ff6dbcddda 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -632,7 +632,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -641,10 +641,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 @@ -680,9 +680,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) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 15b4ad5bf4..227d2b6c73 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -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 calculatedDrops = null; List 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) diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 15b4ad5bf4..227d2b6c73 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -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 calculatedDrops = null; List 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) diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 129d640563..5c34c803b3 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -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()) diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 15b4ad5bf4..227d2b6c73 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -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 calculatedDrops = null; List 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) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 4cf0e0eacc..ad8d9f0b6f 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -617,7 +617,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()) diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3938eeabc6..3c912c38af 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -709,7 +709,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -718,10 +718,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 @@ -757,9 +757,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) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 4cf0e0eacc..ad8d9f0b6f 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -617,7 +617,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()) diff --git a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3938eeabc6..3c912c38af 100644 --- a/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_Classic_2.4_SecretOfEmpire/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -709,7 +709,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -718,10 +718,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 @@ -757,9 +757,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) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 4cf0e0eacc..ad8d9f0b6f 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -617,7 +617,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()) diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 3938eeabc6..3c912c38af 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -709,7 +709,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -718,10 +718,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 @@ -757,9 +757,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) diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/NpcData.java index a31c727d64..aee14ccf90 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -624,7 +624,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()) diff --git a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index af80fd1293..3768159034 100644 --- a/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_Classic_Interlude/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -693,7 +693,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -702,10 +702,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 @@ -741,9 +741,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) diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 81eb65aea7..5218209791 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -632,7 +632,8 @@ public class NpcData implements IXmlReader dropLists.add(new DropHolder(DropType.DROP, Inventory.LCOIN_ID, Config.LCOIN_MIN_QUANTITY, Config.LCOIN_MAX_QUANTITY, Config.LCOIN_DROP_CHANCE)); } - 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) { // Drop materials for random craft configuration. diff --git a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 0b095f02e2..9ae944caf7 100644 --- a/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_Essence_4.2_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -708,7 +708,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -717,10 +717,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 @@ -756,9 +756,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) diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/NpcData.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/NpcData.java index 81eb65aea7..5218209791 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/NpcData.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/data/xml/NpcData.java @@ -632,7 +632,8 @@ public class NpcData implements IXmlReader dropLists.add(new DropHolder(DropType.DROP, Inventory.LCOIN_ID, Config.LCOIN_MIN_QUANTITY, Config.LCOIN_MAX_QUANTITY, Config.LCOIN_DROP_CHANCE)); } - 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) { // Drop materials for random craft configuration. diff --git a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java index 0b095f02e2..9ae944caf7 100644 --- a/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java +++ b/L2J_Mobius_Essence_5.2_FrostLord/java/org/l2jmobius/gameserver/model/actor/templates/NpcTemplate.java @@ -708,7 +708,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL; List calculatedDrops = null; List randomDrops = null; - ItemHolder replacedItem = null; + ItemHolder cachedItem = null; if (dropOccurrenceCounter > 0) { for (DropHolder dropItem : dropList) @@ -717,10 +717,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 @@ -756,9 +756,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)