Adjustments for grouped drop bonus chance.
This commit is contained in:
parent
9d3f1711e1
commit
260d4534a5
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -112,6 +112,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -112,6 +112,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -112,6 +112,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -112,6 +112,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -112,6 +112,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -112,6 +112,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -112,6 +112,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -112,6 +112,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -112,6 +112,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -112,6 +112,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -97,6 +97,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -696,18 +696,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -715,15 +714,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -763,70 +756,96 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
if (rateChance == 1)
|
||||||
}
|
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -850,6 +869,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -962,18 +982,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1021,6 +1046,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
return new ItemHolder(itemId, (int) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (int) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -97,6 +97,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -696,18 +696,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -715,15 +714,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -763,70 +756,96 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
if (rateChance == 1)
|
||||||
}
|
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -850,6 +869,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -962,18 +982,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1021,6 +1046,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -98,6 +98,7 @@ DropChanceMultiplierByItemId = 57,1;21747,0;21748,0;21749,0
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -696,18 +696,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -715,15 +714,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -763,70 +756,96 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
if (rateChance == 1)
|
||||||
}
|
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -850,6 +869,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -962,18 +982,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1021,6 +1046,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -758,18 +758,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -777,15 +776,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -824,74 +817,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -915,6 +933,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1101,18 +1120,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1154,7 +1178,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1162,11 +1185,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -758,18 +758,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -777,15 +776,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -824,74 +817,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -915,6 +933,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1101,18 +1120,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1154,7 +1178,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1162,11 +1185,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -758,18 +758,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -777,15 +776,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -824,74 +817,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -915,6 +933,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1101,18 +1120,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1154,7 +1178,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1162,11 +1185,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -758,18 +758,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -777,15 +776,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -824,74 +817,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -915,6 +933,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1101,18 +1120,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1154,7 +1178,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1162,11 +1185,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -773,18 +773,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -792,15 +791,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -839,74 +832,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -930,6 +948,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1116,18 +1135,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1169,7 +1193,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1177,11 +1200,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -773,18 +773,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -792,15 +791,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -839,74 +832,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -930,6 +948,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1116,18 +1135,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1169,7 +1193,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1177,11 +1200,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -773,18 +773,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -792,15 +791,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -839,74 +832,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -930,6 +948,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1116,18 +1135,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1169,7 +1193,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1177,11 +1200,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -773,18 +773,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -792,15 +791,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -839,74 +832,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -930,6 +948,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1116,18 +1135,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1169,7 +1193,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1177,11 +1200,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -757,18 +757,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -776,15 +775,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -823,74 +816,99 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculate if item will drop
|
|
||||||
totalChance += dropItem.getChance();
|
totalChance += dropItem.getChance();
|
||||||
if (dropChance >= totalChance)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -914,6 +932,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1026,18 +1045,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1079,7 +1103,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1087,11 +1110,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -772,18 +772,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -791,15 +790,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -838,74 +831,103 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
if (item.getId() == Inventory.LCOIN_ID)
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE_LCOIN, 1);
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate if item will drop
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
totalChance += dropItem.getChance();
|
if (rateChance == 1)
|
||||||
if (dropChance >= totalChance)
|
|
||||||
{
|
{
|
||||||
continue;
|
totalChance += dropItem.getChance();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -929,6 +951,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1041,18 +1064,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1094,7 +1122,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1102,11 +1129,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -772,18 +772,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -791,15 +790,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -838,74 +831,103 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
if (item.getId() == Inventory.LCOIN_ID)
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE_LCOIN, 1);
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate if item will drop
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
totalChance += dropItem.getChance();
|
if (rateChance == 1)
|
||||||
if (dropChance >= totalChance)
|
|
||||||
{
|
{
|
||||||
continue;
|
totalChance += dropItem.getChance();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -929,6 +951,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1041,18 +1064,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1094,7 +1122,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1102,11 +1129,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -790,18 +790,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -809,15 +808,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -856,74 +849,103 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
if (item.getId() == Inventory.LCOIN_ID)
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE_LCOIN, 1);
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate if item will drop
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
totalChance += dropItem.getChance();
|
if (rateChance == 1)
|
||||||
if (dropChance >= totalChance)
|
|
||||||
{
|
{
|
||||||
continue;
|
totalChance += dropItem.getChance();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -947,6 +969,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1059,18 +1082,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1112,7 +1140,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1120,11 +1147,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
@ -109,6 +109,7 @@ DropChanceMultiplierByItemId = 57,1
|
|||||||
# Maximum drop occurrences.
|
# Maximum drop occurrences.
|
||||||
# Note: Items that have 100% drop chance without server rate multipliers
|
# Note: Items that have 100% drop chance without server rate multipliers
|
||||||
# are not counted by this value. They will drop as extra drops.
|
# are not counted by this value. They will drop as extra drops.
|
||||||
|
# Also grouped drops with total chance over 100% break this configuration.
|
||||||
DropMaxOccurrencesNormal = 2
|
DropMaxOccurrencesNormal = 2
|
||||||
DropMaxOccurrencesRaidboss = 7
|
DropMaxOccurrencesRaidboss = 7
|
||||||
|
|
||||||
|
@ -790,18 +790,17 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
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 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);
|
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> calculatedDrops = null;
|
||||||
|
int dropOccurrenceCounter = victim.isRaid() ? Config.DROP_MAX_OCCURRENCES_RAIDBOSS : Config.DROP_MAX_OCCURRENCES_NORMAL;
|
||||||
|
if (dropOccurrenceCounter > 0)
|
||||||
|
{
|
||||||
|
List<ItemHolder> randomDrops = null;
|
||||||
|
ItemHolder cachedItem = null;
|
||||||
|
double totalChance; // total group chance is 100
|
||||||
for (DropGroupHolder group : _dropGroups)
|
for (DropGroupHolder group : _dropGroups)
|
||||||
{
|
{
|
||||||
if (dropOccurrenceCounter <= 0)
|
totalChance = 0;
|
||||||
{
|
GROUP_DROP: for (DropHolder dropItem : group.getDropList())
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
double groupRate = 1;
|
|
||||||
final List<DropHolder> groupDrops = group.getDropList();
|
|
||||||
for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
@ -809,15 +808,9 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
|
|
||||||
// chance
|
// chance
|
||||||
double rateChance = 1;
|
double rateChance = 1;
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
if (Config.RATE_DROP_CHANCE_BY_ID.get(itemId) != null)
|
||||||
if (itemChance != null)
|
|
||||||
{
|
{
|
||||||
if (itemChance <= 0)
|
rateChance *= Config.RATE_DROP_CHANCE_BY_ID.get(itemId);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rateChance *= itemChance;
|
|
||||||
if (champion && (itemId == Inventory.ADENA_ID))
|
if (champion && (itemId == Inventory.ADENA_ID))
|
||||||
{
|
{
|
||||||
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
rateChance *= Config.CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||||
@ -856,74 +849,103 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
rateChance *= Config.PREMIUM_RATE_DROP_CHANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep lowest to avoid chance by id configuration conflicts
|
|
||||||
groupRate = Math.min(groupRate, rateChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop rate effect
|
// bonus drop rate effect
|
||||||
groupRate *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE, 1);
|
||||||
|
if (item.getId() == Inventory.LCOIN_ID)
|
||||||
if ((Rnd.nextDouble() * 100) < (group.getChance() * groupRate))
|
|
||||||
{
|
{
|
||||||
double totalChance = 0; // total group chance is 100
|
rateChance *= killer.getStat().getMul(Stat.BONUS_DROP_RATE_LCOIN, 1);
|
||||||
final double dropChance = Rnd.nextDouble() * 100;
|
|
||||||
GROUP_DROP: for (DropHolder dropItem : groupDrops)
|
|
||||||
{
|
|
||||||
if (dropOccurrenceCounter <= 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate if item will drop
|
// only use total chance on x1, custom rates break this logic because total chance is more than 100%
|
||||||
totalChance += dropItem.getChance();
|
if (rateChance == 1)
|
||||||
if (dropChance >= totalChance)
|
|
||||||
{
|
{
|
||||||
continue;
|
totalChance += dropItem.getChance();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
totalChance = dropItem.getChance();
|
||||||
|
}
|
||||||
|
final double groupItemChance = totalChance * (group.getChance() / 100) * rateChance;
|
||||||
|
|
||||||
|
// check if maximum drop occurrences have been reached
|
||||||
|
// items that have 100% drop chance without server rate multipliers drop normally
|
||||||
|
if ((dropOccurrenceCounter == 0) && (groupItemChance < 100) && (randomDrops != null) && (calculatedDrops != null))
|
||||||
|
{
|
||||||
|
if ((rateChance == 1) && !randomDrops.isEmpty()) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
// 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
|
// check level gap that may prevent to drop item
|
||||||
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
if ((Rnd.nextDouble() * 100) > (dropItem.getItemId() == Inventory.ADENA_ID ? levelGapChanceToDropAdena : levelGapChanceToDrop))
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip zero chance drops
|
// calculate chances
|
||||||
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
final ItemHolder drop = calculateGroupDrop(group, dropItem, victim, killer, groupItemChance);
|
||||||
if ((itemChance != null) && (itemChance <= 0))
|
if (drop == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue GROUP_DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the drop
|
// create lists
|
||||||
final ItemHolder drop = calculateGroupDrop(dropItem, victim, killer);
|
if (randomDrops == null)
|
||||||
|
{
|
||||||
// create list
|
randomDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
|
}
|
||||||
if (calculatedDrops == null)
|
if (calculatedDrops == null)
|
||||||
{
|
{
|
||||||
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
calculatedDrops = new ArrayList<>(dropOccurrenceCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
|
final Float itemChance = Config.RATE_DROP_CHANCE_BY_ID.get(dropItem.getItemId());
|
||||||
if (itemChance != null)
|
if (itemChance != null)
|
||||||
{
|
{
|
||||||
if ((dropItem.getChance() * itemChance) < 100)
|
if ((groupItemChance * itemChance) < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (dropItem.getChance() < 100)
|
}
|
||||||
|
else if (groupItemChance < 100)
|
||||||
{
|
{
|
||||||
dropOccurrenceCounter--;
|
dropOccurrenceCounter--;
|
||||||
|
if (rateChance == 1) // custom rates break this logic because total chance is more than 100%
|
||||||
|
{
|
||||||
|
randomDrops.add(drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
calculatedDrops.add(drop);
|
calculatedDrops.add(drop);
|
||||||
|
|
||||||
// no more drops from this group
|
// no more drops from this group, only use on x1, custom rates break this logic because total chance is more than 100%
|
||||||
|
if (rateChance == 1)
|
||||||
|
{
|
||||||
break GROUP_DROP;
|
break GROUP_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
|
// champion extra drop
|
||||||
if (victim.isChampion())
|
if (victim.isChampion())
|
||||||
{
|
{
|
||||||
@ -947,6 +969,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
calculatedDrops.addAll(Config.CHAMPION_REWARD_ITEMS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return calculatedDrops;
|
return calculatedDrops;
|
||||||
}
|
}
|
||||||
@ -1059,18 +1082,23 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param group
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
* @param killer
|
* @param killer
|
||||||
|
* @param chance
|
||||||
* @return ItemHolder
|
* @return ItemHolder
|
||||||
*/
|
*/
|
||||||
private ItemHolder calculateGroupDrop(DropHolder dropItem, Creature victim, Creature killer)
|
private ItemHolder calculateGroupDrop(DropGroupHolder group, DropHolder dropItem, Creature victim, Creature killer, double chance)
|
||||||
{
|
{
|
||||||
final int itemId = dropItem.getItemId();
|
final int itemId = dropItem.getItemId();
|
||||||
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
final ItemTemplate item = ItemTable.getInstance().getTemplate(itemId);
|
||||||
final boolean champion = victim.isChampion();
|
final boolean champion = victim.isChampion();
|
||||||
|
|
||||||
// calculate amount
|
// calculate if item will drop
|
||||||
|
if ((Rnd.nextDouble() * 100) < chance)
|
||||||
|
{
|
||||||
|
// amount is calculated after chance returned success
|
||||||
double rateAmount = 1;
|
double rateAmount = 1;
|
||||||
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
if (Config.RATE_DROP_AMOUNT_BY_ID.get(itemId) != null)
|
||||||
{
|
{
|
||||||
@ -1112,7 +1140,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
rateAmount *= Config.PREMIUM_RATE_DROP_AMOUNT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// bonus drop amount effect
|
// bonus drop amount effect
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_AMOUNT, 1);
|
||||||
@ -1120,11 +1147,15 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
|||||||
{
|
{
|
||||||
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
rateAmount *= killer.getStat().getMul(Stat.BONUS_DROP_ADENA, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// finally
|
// finally
|
||||||
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
return new ItemHolder(itemId, (long) (Rnd.get(dropItem.getMin(), dropItem.getMax()) * rateAmount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param dropItem
|
* @param dropItem
|
||||||
* @param victim
|
* @param victim
|
||||||
|
Loading…
Reference in New Issue
Block a user