Changed back to previous drop system.
This commit is contained in:
@@ -16,34 +16,28 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IAmountMultiplierStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IChanceMultiplierStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IDropCalculationStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IKillerChanceModifierStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.INonGroupedKillerChanceModifierStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IPreciseDeterminationStrategy;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public final class GeneralDropItem implements IDropItem
|
||||
public class GeneralDropItem implements IDropItem
|
||||
{
|
||||
private final int _itemId;
|
||||
private final long _min;
|
||||
private final long _max;
|
||||
private final double _chance;
|
||||
|
||||
protected final IAmountMultiplierStrategy _amountStrategy;
|
||||
protected final IChanceMultiplierStrategy _chanceStrategy;
|
||||
protected final IPreciseDeterminationStrategy _preciseStrategy;
|
||||
protected final INonGroupedKillerChanceModifierStrategy _killerStrategy;
|
||||
protected final IDropCalculationStrategy _dropCalculationStrategy;
|
||||
|
||||
/**
|
||||
* @param itemId the item id
|
||||
* @param min the min count
|
||||
@@ -51,225 +45,243 @@ public final class GeneralDropItem implements IDropItem
|
||||
* @param chance the chance of this drop item
|
||||
*/
|
||||
public GeneralDropItem(int itemId, long min, long max, double chance)
|
||||
{
|
||||
this(itemId, min, max, chance, 1, 1);
|
||||
}
|
||||
|
||||
public GeneralDropItem(int itemId, long min, long max, double chance, double defaultAmountMultiplier, double defaultChanceMultiplier)
|
||||
{
|
||||
this(itemId, min, max, defaultChanceMultiplier, IAmountMultiplierStrategy.DEFAULT_STRATEGY(defaultAmountMultiplier), IChanceMultiplierStrategy.DEFAULT_STRATEGY(defaultChanceMultiplier));
|
||||
}
|
||||
|
||||
public GeneralDropItem(int itemId, long min, long max, double chance, IAmountMultiplierStrategy amountMultiplierStrategy, IChanceMultiplierStrategy chanceMultiplierStrategy)
|
||||
{
|
||||
this(itemId, min, max, chance, amountMultiplierStrategy, chanceMultiplierStrategy, IPreciseDeterminationStrategy.DEFAULT, IKillerChanceModifierStrategy.DEFAULT_NONGROUP_STRATEGY);
|
||||
}
|
||||
|
||||
public GeneralDropItem(int itemId, long min, long max, double chance, IAmountMultiplierStrategy amountMultiplierStrategy, IChanceMultiplierStrategy chanceMultiplierStrategy, IPreciseDeterminationStrategy preciseStrategy, INonGroupedKillerChanceModifierStrategy killerStrategy)
|
||||
{
|
||||
this(itemId, min, max, chance, amountMultiplierStrategy, chanceMultiplierStrategy, preciseStrategy, killerStrategy, IDropCalculationStrategy.DEFAULT_STRATEGY);
|
||||
}
|
||||
|
||||
public GeneralDropItem(int itemId, long min, long max, double chance, IAmountMultiplierStrategy amountMultiplierStrategy, IChanceMultiplierStrategy chanceMultiplierStrategy, IPreciseDeterminationStrategy preciseStrategy, INonGroupedKillerChanceModifierStrategy killerStrategy, IDropCalculationStrategy dropCalculationStrategy)
|
||||
{
|
||||
_itemId = itemId;
|
||||
_min = min;
|
||||
_max = max;
|
||||
_chance = chance;
|
||||
_amountStrategy = amountMultiplierStrategy;
|
||||
_chanceStrategy = chanceMultiplierStrategy;
|
||||
_preciseStrategy = preciseStrategy;
|
||||
_killerStrategy = killerStrategy;
|
||||
_dropCalculationStrategy = dropCalculationStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _amountStrategy
|
||||
*/
|
||||
public final IAmountMultiplierStrategy getAmountStrategy()
|
||||
protected double getGlobalChanceMultiplier(boolean isPremium)
|
||||
{
|
||||
return _amountStrategy;
|
||||
return 1.;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _chanceStrategy
|
||||
*/
|
||||
public final IChanceMultiplierStrategy getChanceStrategy()
|
||||
protected double getGlobalAmountMultiplier(boolean isPremium)
|
||||
{
|
||||
return _chanceStrategy;
|
||||
return 1.;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _preciseStrategy
|
||||
*/
|
||||
public final IPreciseDeterminationStrategy getPreciseStrategy()
|
||||
private final long getMinMax(L2Character victim, L2Character killer, long val)
|
||||
{
|
||||
return _preciseStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _killerStrategy
|
||||
*/
|
||||
public final INonGroupedKillerChanceModifierStrategy getKillerChanceModifierStrategy()
|
||||
{
|
||||
return _killerStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _dropCalculationStrategy
|
||||
*/
|
||||
public final IDropCalculationStrategy getDropCalculationStrategy()
|
||||
{
|
||||
return _dropCalculationStrategy;
|
||||
double multiplier = 1;
|
||||
|
||||
// individual drop amount
|
||||
Float individualDropAmountMultiplier = null;
|
||||
if (killer.getActingPlayer().hasPremiumStatus())
|
||||
{
|
||||
final Float normalMultiplier = Config.RATE_DROP_AMOUNT_BY_ID.get(getItemId());
|
||||
final Float premiumMultiplier = Config.PREMIUM_RATE_DROP_AMOUNT_BY_ID.get(getItemId());
|
||||
if ((normalMultiplier != null) && (premiumMultiplier != null))
|
||||
{
|
||||
individualDropAmountMultiplier = normalMultiplier * premiumMultiplier;
|
||||
}
|
||||
else if (normalMultiplier != null)
|
||||
{
|
||||
individualDropAmountMultiplier = normalMultiplier;
|
||||
}
|
||||
else if (premiumMultiplier != null)
|
||||
{
|
||||
individualDropAmountMultiplier = premiumMultiplier;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
individualDropAmountMultiplier = Config.RATE_DROP_AMOUNT_BY_ID.get(getItemId());
|
||||
}
|
||||
|
||||
if (individualDropAmountMultiplier != null)
|
||||
{
|
||||
// individual amount list multiplier
|
||||
multiplier *= individualDropAmountMultiplier;
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Item item = ItemTable.getInstance().getTemplate(getItemId());
|
||||
// global amount multiplier
|
||||
if ((item != null) && item.hasExImmediateEffect())
|
||||
{
|
||||
// global herb amount multiplier
|
||||
multiplier *= Config.RATE_HERB_DROP_AMOUNT_MULTIPLIER;
|
||||
}
|
||||
else if (victim.isRaid())
|
||||
{
|
||||
// global raid amount multiplier
|
||||
multiplier *= Config.RATE_RAID_DROP_AMOUNT_MULTIPLIER;
|
||||
}
|
||||
else
|
||||
{
|
||||
// drop type specific amount multiplier
|
||||
multiplier *= getGlobalAmountMultiplier(killer.getActingPlayer().hasPremiumStatus());
|
||||
}
|
||||
}
|
||||
|
||||
// global champions amount multiplier
|
||||
if (victim.isChampion())
|
||||
{
|
||||
multiplier *= getItemId() != Inventory.ADENA_ID ? Config.L2JMOD_CHAMPION_REWARDS_AMOUNT : Config.L2JMOD_CHAMPION_ADENAS_REWARDS_AMOUNT;
|
||||
}
|
||||
|
||||
return (long) (val * multiplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item id
|
||||
* @return the item id
|
||||
*/
|
||||
public final int getItemId()
|
||||
public int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base min drop count
|
||||
* Gets the min drop count
|
||||
* @return the min
|
||||
*/
|
||||
public final long getMin()
|
||||
public long getMin()
|
||||
{
|
||||
return _min;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the min drop count modified by server rates
|
||||
* @param victim the victim who drops the item
|
||||
* @param killer who kills the victim
|
||||
* Gets the min drop count
|
||||
* @param victim the victim
|
||||
* @param killer the killer
|
||||
* @return the min modified by any rates.
|
||||
*/
|
||||
public final long getMin(L2Character victim, L2Character killer)
|
||||
public long getMin(L2Character victim, L2Character killer)
|
||||
{
|
||||
if (Config.PREMIUM_SYSTEM_ENABLED && killer.isPlayer() && killer.getActingPlayer().hasPremiumStatus())
|
||||
{
|
||||
if (Config.PREMIUM_RATE_DROP_AMOUNT_MULTIPLIER.get(_itemId) != null)
|
||||
{
|
||||
return (long) (getMin() * getAmountMultiplier(victim) * Config.PREMIUM_RATE_DROP_AMOUNT_MULTIPLIER.get(_itemId));
|
||||
}
|
||||
return (long) (getMin() * getAmountMultiplier(victim) * Config.PREMIUM_RATE_DROP_AMOUNT);
|
||||
}
|
||||
return (long) (getMin() * getAmountMultiplier(victim));
|
||||
return getMinMax(victim, killer, getMin());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base max drop count
|
||||
* Gets the max drop count
|
||||
* @return the max
|
||||
*/
|
||||
public final long getMax()
|
||||
public long getMax()
|
||||
{
|
||||
return _max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max drop count modified by server rates
|
||||
* @param victim the victim who drops the item
|
||||
* @param killer who kills the victim
|
||||
* Gets the max drop count
|
||||
* @param victim the victim
|
||||
* @param killer the killer
|
||||
* @return the max modified by any rates.
|
||||
*/
|
||||
public final long getMax(L2Character victim, L2Character killer)
|
||||
public long getMax(L2Character victim, L2Character killer)
|
||||
{
|
||||
if (Config.PREMIUM_SYSTEM_ENABLED && killer.isPlayer() && killer.getActingPlayer().hasPremiumStatus())
|
||||
{
|
||||
if (Config.PREMIUM_RATE_DROP_AMOUNT_MULTIPLIER.get(_itemId) != null)
|
||||
{
|
||||
return (long) (getMax() * getAmountMultiplier(victim) * Config.PREMIUM_RATE_DROP_AMOUNT_MULTIPLIER.get(_itemId));
|
||||
}
|
||||
return (long) (getMax() * getAmountMultiplier(victim) * Config.PREMIUM_RATE_DROP_AMOUNT);
|
||||
}
|
||||
return (long) (getMax() * getAmountMultiplier(victim));
|
||||
return getMinMax(victim, killer, getMax());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the chance of this drop item.
|
||||
* @return the chance
|
||||
*/
|
||||
public final double getChance()
|
||||
public double getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the general chance to drop this item modified by rates. <br>
|
||||
* This shall be used in calculating chance within drop groups.
|
||||
* @param victim the victim who drops the item
|
||||
* Gets the chance of this drop item.
|
||||
* @param victim the victim
|
||||
* @param killer the killer
|
||||
* @return the chance modified by any rates.
|
||||
*/
|
||||
public final double getChance(L2Character victim)
|
||||
public double getChance(L2Character victim, L2Character killer)
|
||||
{
|
||||
return getChance() * getChanceMultiplier(victim);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the chance of dropping this item for current killer and victim (modified by server rates and another rules based on killer) <br>
|
||||
* This shall be used to calculate chance outside of drop groups.
|
||||
* @param victim the victim who drops the item
|
||||
* @param killer who kills the victim
|
||||
* @return a chance to drop modified by deep blue drop rules
|
||||
*/
|
||||
public final double getChance(L2Character victim, L2Character killer)
|
||||
{
|
||||
if (Config.PREMIUM_SYSTEM_ENABLED && killer.isPlayer() && killer.getActingPlayer().hasPremiumStatus())
|
||||
double multiplier = 1;
|
||||
|
||||
// individual drop chance
|
||||
Float individualDropChanceMultiplier = null;
|
||||
if (killer.getActingPlayer().hasPremiumStatus())
|
||||
{
|
||||
if (Config.PREMIUM_RATE_DROP_CHANCE_MULTIPLIER.get(_itemId) != null)
|
||||
final Float normalMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(getItemId());
|
||||
final Float premiumMultiplier = Config.PREMIUM_RATE_DROP_CHANCE_BY_ID.get(getItemId());
|
||||
if ((normalMultiplier != null) && (premiumMultiplier != null))
|
||||
{
|
||||
return getKillerChanceModifier(victim, killer) * getChance(victim) * Config.PREMIUM_RATE_DROP_CHANCE_MULTIPLIER.get(_itemId);
|
||||
individualDropChanceMultiplier = normalMultiplier * premiumMultiplier;
|
||||
}
|
||||
else if (normalMultiplier != null)
|
||||
{
|
||||
individualDropChanceMultiplier = normalMultiplier;
|
||||
}
|
||||
else if (premiumMultiplier != null)
|
||||
{
|
||||
individualDropChanceMultiplier = premiumMultiplier;
|
||||
}
|
||||
return getKillerChanceModifier(victim, killer) * getChance(victim) * Config.PREMIUM_RATE_DROP_CHANCE;
|
||||
}
|
||||
return getKillerChanceModifier(victim, killer) * getChance(victim);
|
||||
else
|
||||
{
|
||||
individualDropChanceMultiplier = Config.RATE_DROP_CHANCE_BY_ID.get(getItemId());
|
||||
}
|
||||
|
||||
if (individualDropChanceMultiplier != null)
|
||||
{
|
||||
multiplier *= individualDropChanceMultiplier;
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Item item = ItemTable.getInstance().getTemplate(getItemId());
|
||||
if ((item != null) && item.hasExImmediateEffect())
|
||||
{
|
||||
multiplier *= Config.RATE_HERB_DROP_CHANCE_MULTIPLIER;
|
||||
}
|
||||
else if (victim.isRaid())
|
||||
{
|
||||
// global raid chance multiplier
|
||||
multiplier *= Config.RATE_RAID_DROP_CHANCE_MULTIPLIER;
|
||||
}
|
||||
else
|
||||
{
|
||||
multiplier *= getGlobalChanceMultiplier(killer.getActingPlayer().hasPremiumStatus());
|
||||
}
|
||||
}
|
||||
|
||||
if (victim.isChampion())
|
||||
{
|
||||
multiplier *= getItemId() != Inventory.ADENA_ID ? Config.L2JMOD_CHAMPION_REWARDS_CHANCE : Config.L2JMOD_CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||
}
|
||||
|
||||
return (getChance() * multiplier);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see com.l2jserver.gameserver.model.drop.IDropItem#calculateDrops(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.actor.L2Character)
|
||||
*/
|
||||
@Override
|
||||
public final List<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
|
||||
public Collection<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
|
||||
{
|
||||
return _dropCalculationStrategy.calculateDrops(this, victim, killer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if chance over 100% should be handled
|
||||
*/
|
||||
public final boolean isPreciseCalculated()
|
||||
{
|
||||
return _preciseStrategy.isPreciseCalculated(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This handles by default deep blue drop rules. It may also be used to handle another drop chance rules based on killer
|
||||
* @param victim the victim who drops the item
|
||||
* @param killer who kills the victim
|
||||
* @return a number between 0 and 1 (usually)
|
||||
*/
|
||||
protected final double getKillerChanceModifier(L2Character victim, L2Character killer)
|
||||
{
|
||||
return _killerStrategy.getKillerChanceModifier(this, victim, killer);
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets standard server rates for this item
|
||||
* @param victim who drops the item
|
||||
* @return
|
||||
*/
|
||||
protected final double getAmountMultiplier(L2Character victim)
|
||||
{
|
||||
return _amountStrategy.getAmountMultiplier(this, victim);
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets standard server rates for this item
|
||||
* @param victim who drops the item
|
||||
* @return
|
||||
*/
|
||||
protected final double getChanceMultiplier(L2Character victim)
|
||||
{
|
||||
return _chanceStrategy.getChanceMultiplier(this, victim);
|
||||
final int levelDifference = victim.getLevel() - killer.getLevel();
|
||||
final double levelGapChanceToDrop;
|
||||
if (getItemId() == Inventory.ADENA_ID)
|
||||
{
|
||||
levelGapChanceToDrop = Util.map(levelDifference, -Config.DROP_ADENA_MAX_LEVEL_DIFFERENCE, -Config.DROP_ADENA_MIN_LEVEL_DIFFERENCE, Config.DROP_ADENA_MIN_LEVEL_GAP_CHANCE, 100.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
levelGapChanceToDrop = Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100.0);
|
||||
}
|
||||
|
||||
// There is a chance of level gap that it wont drop this item
|
||||
if (levelGapChanceToDrop < (Rnd.nextDouble() * 100))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
final double chance = getChance(victim, killer);
|
||||
final boolean successes = chance > (Rnd.nextDouble() * 100);
|
||||
if (successes)
|
||||
{
|
||||
final Collection<ItemHolder> items = new ArrayList<>(1);
|
||||
final long baseDropCount = Rnd.get(getMin(victim, killer), getMax(victim, killer));
|
||||
final long finaldropCount = (long) (Config.L2JMOD_OLD_DROP_BEHAVIOR ? (baseDropCount * Math.max(1, chance / 100)) + (chance > 100 ? (chance % 100) > (Rnd.nextDouble() * 100) ? baseDropCount : 0 : 0) : baseDropCount);
|
||||
items.add(new ItemHolder(getItemId(), finaldropCount));
|
||||
return items;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user