Project update.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops;
|
||||
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IAmountMultiplierStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IChanceMultiplierStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IGroupedItemDropCalculationStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IKillerChanceModifierStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IPreciseDeterminationStrategy;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public enum DropListScope implements IDropItemFactory, IGroupedDropItemFactory
|
||||
{
|
||||
DEATH((itemId, min, max, chance) -> new GeneralDropItem(itemId, min, max, chance, IAmountMultiplierStrategy.DROP, IChanceMultiplierStrategy.DROP), chance -> new GroupedGeneralDropItem(chance)),
|
||||
CORPSE((itemId, min, max, chance) -> new GeneralDropItem(itemId, min, max, chance, IAmountMultiplierStrategy.SPOIL, IChanceMultiplierStrategy.SPOIL), DEATH),
|
||||
|
||||
/**
|
||||
* This droplist scope isn't affected by ANY rates, nor Champion, etc...
|
||||
*/
|
||||
STATIC((itemId, min, max, chance) -> new GeneralDropItem(itemId, min, max, chance, IAmountMultiplierStrategy.STATIC, IChanceMultiplierStrategy.STATIC, IPreciseDeterminationStrategy.ALWAYS, IKillerChanceModifierStrategy.NO_RULES), chance -> new GroupedGeneralDropItem(chance, IGroupedItemDropCalculationStrategy.DEFAULT_STRATEGY, IKillerChanceModifierStrategy.NO_RULES, IPreciseDeterminationStrategy.ALWAYS)),
|
||||
QUEST((itemId, min, max, chance) -> new GeneralDropItem(itemId, min, max, chance, IAmountMultiplierStrategy.STATIC, IChanceMultiplierStrategy.QUEST, IPreciseDeterminationStrategy.ALWAYS, IKillerChanceModifierStrategy.NO_RULES), STATIC);
|
||||
|
||||
private final IDropItemFactory _factory;
|
||||
private final IGroupedDropItemFactory _groupFactory;
|
||||
|
||||
private DropListScope(IDropItemFactory factory, IGroupedDropItemFactory groupFactory)
|
||||
{
|
||||
_factory = factory;
|
||||
_groupFactory = groupFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDropItem newDropItem(int itemId, long min, long max, double chance)
|
||||
{
|
||||
return _factory.newDropItem(itemId, min, max, chance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroupedGeneralDropItem newGroupedDropItem(double chance)
|
||||
{
|
||||
return _groupFactory.newGroupedDropItem(chance);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public final 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
|
||||
* @param max the max count
|
||||
* @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()
|
||||
{
|
||||
return _amountStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _chanceStrategy
|
||||
*/
|
||||
public final IChanceMultiplierStrategy getChanceStrategy()
|
||||
{
|
||||
return _chanceStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _preciseStrategy
|
||||
*/
|
||||
public final IPreciseDeterminationStrategy getPreciseStrategy()
|
||||
{
|
||||
return _preciseStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _killerStrategy
|
||||
*/
|
||||
public final INonGroupedKillerChanceModifierStrategy getKillerChanceModifierStrategy()
|
||||
{
|
||||
return _killerStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _dropCalculationStrategy
|
||||
*/
|
||||
public final IDropCalculationStrategy getDropCalculationStrategy()
|
||||
{
|
||||
return _dropCalculationStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item id
|
||||
* @return the item id
|
||||
*/
|
||||
public final int getItemId()
|
||||
{
|
||||
return _itemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base min drop count
|
||||
* @return the min
|
||||
*/
|
||||
public final 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
|
||||
* @return the min modified by any rates.
|
||||
*/
|
||||
public final 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base max drop count
|
||||
* @return the max
|
||||
*/
|
||||
public final 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
|
||||
* @return the max modified by any rates.
|
||||
*/
|
||||
public final 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the chance of this drop item.
|
||||
* @return the chance
|
||||
*/
|
||||
public final 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
|
||||
* @return the chance modified by any rates.
|
||||
*/
|
||||
public final double getChance(L2Character victim)
|
||||
{
|
||||
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())
|
||||
{
|
||||
if (Config.PREMIUM_RATE_DROP_CHANCE_MULTIPLIER.get(_itemId) != null)
|
||||
{
|
||||
return getKillerChanceModifier(victim, killer) * getChance(victim) * Config.PREMIUM_RATE_DROP_CHANCE_MULTIPLIER.get(_itemId);
|
||||
}
|
||||
return getKillerChanceModifier(victim, killer) * getChance(victim) * Config.PREMIUM_RATE_DROP_CHANCE;
|
||||
}
|
||||
return getKillerChanceModifier(victim, killer) * getChance(victim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.IGroupedItemDropCalculationStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IKillerChanceModifierStrategy;
|
||||
import com.l2jmobius.gameserver.model.drops.strategy.IPreciseDeterminationStrategy;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public final class GroupedGeneralDropItem implements IDropItem
|
||||
{
|
||||
private final double _chance;
|
||||
private List<GeneralDropItem> _items;
|
||||
protected final IGroupedItemDropCalculationStrategy _dropCalculationStrategy;
|
||||
protected final IKillerChanceModifierStrategy _killerChanceModifierStrategy;
|
||||
protected final IPreciseDeterminationStrategy _preciseStrategy;
|
||||
|
||||
/**
|
||||
* @param chance the chance of this drop item.
|
||||
*/
|
||||
public GroupedGeneralDropItem(double chance)
|
||||
{
|
||||
this(chance, IGroupedItemDropCalculationStrategy.DEFAULT_STRATEGY, IKillerChanceModifierStrategy.DEFAULT_STRATEGY, IPreciseDeterminationStrategy.DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param chance the chance of this drop item.
|
||||
* @param dropStrategy to calculate drops.
|
||||
* @param killerStrategy
|
||||
* @param preciseStrategy
|
||||
*/
|
||||
public GroupedGeneralDropItem(double chance, IGroupedItemDropCalculationStrategy dropStrategy, IKillerChanceModifierStrategy killerStrategy, IPreciseDeterminationStrategy preciseStrategy)
|
||||
{
|
||||
_chance = chance;
|
||||
_dropCalculationStrategy = dropStrategy;
|
||||
_killerChanceModifierStrategy = killerStrategy;
|
||||
_preciseStrategy = preciseStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the chance of this drop item.
|
||||
* @return the chance
|
||||
*/
|
||||
public final double getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the items.
|
||||
* @return the items
|
||||
*/
|
||||
public final List<GeneralDropItem> getItems()
|
||||
{
|
||||
return _items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the strategy
|
||||
*/
|
||||
public final IGroupedItemDropCalculationStrategy getDropCalculationStrategy()
|
||||
{
|
||||
return _dropCalculationStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _killerChanceModifierStrategy
|
||||
*/
|
||||
public IKillerChanceModifierStrategy getKillerChanceModifierStrategy()
|
||||
{
|
||||
return _killerChanceModifierStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the _preciseStrategy
|
||||
*/
|
||||
public final IPreciseDeterminationStrategy getPreciseStrategy()
|
||||
{
|
||||
return _preciseStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an item list to this drop item.
|
||||
* @param items the item list
|
||||
*/
|
||||
public final void setItems(List<GeneralDropItem> items)
|
||||
{
|
||||
_items = Collections.unmodifiableList(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of items in the group with chance multiplied by chance of the group
|
||||
* @return the list of items with modified chances
|
||||
*/
|
||||
public final List<GeneralDropItem> extractMe()
|
||||
{
|
||||
final List<GeneralDropItem> items = new ArrayList<>();
|
||||
for (GeneralDropItem item : getItems())
|
||||
{
|
||||
// precise and killer strategies of the group
|
||||
items.add(new GeneralDropItem(item.getItemId(), item.getMin(), item.getMax(), (item.getChance() * getChance()) / 100, item.getAmountStrategy(), item.getChanceStrategy(), getPreciseStrategy(), getKillerChanceModifierStrategy(), item.getDropCalculationStrategy()));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* statically normalizes a group, useful when need to convert legacy SQL data
|
||||
* @return a new group with items, which have a sum of getChance() of 100%
|
||||
*/
|
||||
public final GroupedGeneralDropItem normalizeMe()
|
||||
{
|
||||
double sumchance = 0;
|
||||
for (GeneralDropItem item : getItems())
|
||||
{
|
||||
sumchance += (item.getChance() * getChance()) / 100;
|
||||
}
|
||||
final double sumchance1 = sumchance;
|
||||
final GroupedGeneralDropItem group = new GroupedGeneralDropItem(sumchance1, getDropCalculationStrategy(), IKillerChanceModifierStrategy.NO_RULES, getPreciseStrategy());
|
||||
final List<GeneralDropItem> items = new ArrayList<>();
|
||||
for (GeneralDropItem item : getItems())
|
||||
{
|
||||
// modify only the chance, leave all other rules intact
|
||||
items.add(new GeneralDropItem(item.getItemId(), item.getMin(), item.getMax(), (item.getChance() * getChance()) / sumchance1, item.getAmountStrategy(), item.getChanceStrategy(), item.getPreciseStrategy(), item.getKillerChanceModifierStrategy(), item.getDropCalculationStrategy()));
|
||||
}
|
||||
group.setItems(items);
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a normalized group taking into account all drop modifiers, needed when handling a group which has items with different chance rates
|
||||
* @param victim
|
||||
* @param killer
|
||||
* @return a new normalized group with all drop modifiers applied
|
||||
*/
|
||||
public final GroupedGeneralDropItem normalizeMe(L2Character victim, L2Character killer)
|
||||
{
|
||||
return normalizeMe(victim, killer, true, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a normalized group taking into account all drop modifiers, needed when handling a group which has items with different chance rates
|
||||
* @param victim
|
||||
* @param killer
|
||||
* @param chanceModifier an additional chance modifier
|
||||
* @return a new normalized group with all drop modifiers applied
|
||||
*/
|
||||
public final GroupedGeneralDropItem normalizeMe(L2Character victim, L2Character killer, double chanceModifier)
|
||||
{
|
||||
return normalizeMe(victim, killer, true, chanceModifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a normalized group taking into account all drop modifiers, needed when handling a group which has items with different chance rates
|
||||
* @param victim
|
||||
* @return a new normalized group with all victim modifiers applied
|
||||
*/
|
||||
public final GroupedGeneralDropItem normalizeMe(L2Character victim)
|
||||
{
|
||||
return normalizeMe(victim, null, false, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a normalized group taking into account all drop modifiers, needed when handling a group which has items with different chance rates
|
||||
* @param victim
|
||||
* @param chanceModifier an additional chance modifier
|
||||
* @return a new normalized group with all victim modifiers applied
|
||||
*/
|
||||
public final GroupedGeneralDropItem normalizeMe(L2Character victim, double chanceModifier)
|
||||
{
|
||||
return normalizeMe(victim, null, false, chanceModifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a normalized group taking into account all drop modifiers, needed when handling a group which has items with different chance rates
|
||||
* @param victim
|
||||
* @param killer
|
||||
* @param applyKillerModifier if to modify chance by {@link GroupedGeneralDropItem#getKillerChanceModifier(L2Character, L2Character)}
|
||||
* @param chanceModifier an additional chance modifier
|
||||
* @return a new normalized group with all drop modifiers applied
|
||||
*/
|
||||
private final GroupedGeneralDropItem normalizeMe(L2Character victim, L2Character killer, boolean applyKillerModifier, double chanceModifier)
|
||||
{
|
||||
if (applyKillerModifier)
|
||||
{
|
||||
chanceModifier *= (getKillerChanceModifier(victim, killer));
|
||||
}
|
||||
double sumchance = 0;
|
||||
for (GeneralDropItem item : getItems())
|
||||
{
|
||||
sumchance += (item.getChance(victim, killer) * getChance() * chanceModifier) / 100;
|
||||
}
|
||||
final GroupedGeneralDropItem group = new GroupedGeneralDropItem(sumchance, getDropCalculationStrategy(), IKillerChanceModifierStrategy.NO_RULES, getPreciseStrategy()); // to discard further deep blue calculations
|
||||
final List<GeneralDropItem> items = new ArrayList<>();
|
||||
for (GeneralDropItem item : getItems())
|
||||
{
|
||||
// the item is made almost "static"
|
||||
items.add(new GeneralDropItem(item.getItemId(), item.getMin(victim, killer), item.getMax(victim, killer), (item.getChance(victim, killer) * getChance() * chanceModifier) / sumchance, IAmountMultiplierStrategy.STATIC, IChanceMultiplierStrategy.STATIC, getPreciseStrategy(), IKillerChanceModifierStrategy.NO_RULES, item.getDropCalculationStrategy()));
|
||||
}
|
||||
group.setItems(items);
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final List<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
|
||||
{
|
||||
return _dropCalculationStrategy.calculateDrops(this, victim, killer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
*/
|
||||
public final double getKillerChanceModifier(L2Character victim, L2Character killer)
|
||||
{
|
||||
return _killerChanceModifierStrategy.getKillerChanceModifier(this, victim, killer);
|
||||
}
|
||||
|
||||
public boolean isPreciseCalculated()
|
||||
{
|
||||
return _preciseStrategy.isPreciseCalculated(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public interface IDropItem
|
||||
{
|
||||
/**
|
||||
* Calculates drops of this drop item.
|
||||
* @param victim the victim
|
||||
* @param killer the killer
|
||||
* @return {@code null} or empty collection if there are no drops, a collection containing all items to drop otherwise
|
||||
*/
|
||||
public List<ItemHolder> calculateDrops(L2Character victim, L2Character killer);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public interface IDropItemFactory
|
||||
{
|
||||
/**
|
||||
* @param itemId the item id
|
||||
* @param min the min count
|
||||
* @param max the max count
|
||||
* @param chance the chance of this drop item
|
||||
* @return the drop item created by this factory
|
||||
*/
|
||||
public IDropItem newDropItem(int itemId, long min, long max, double chance);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public interface IGroupedDropItemFactory
|
||||
{
|
||||
public GroupedGeneralDropItem newGroupedDropItem(double chance);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops.strategy;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.drops.GeneralDropItem;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public interface IAmountMultiplierStrategy
|
||||
{
|
||||
public static final IAmountMultiplierStrategy DROP = DEFAULT_STRATEGY(Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER);
|
||||
public static final IAmountMultiplierStrategy SPOIL = DEFAULT_STRATEGY(Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER);
|
||||
public static final IAmountMultiplierStrategy STATIC = (item, victim) -> 1;
|
||||
|
||||
public static IAmountMultiplierStrategy DEFAULT_STRATEGY(final double defaultMultiplier)
|
||||
{
|
||||
return (item, victim) ->
|
||||
{
|
||||
double multiplier = 1;
|
||||
if (victim.isChampion())
|
||||
{
|
||||
multiplier *= item.getItemId() != Inventory.ADENA_ID ? Config.L2JMOD_CHAMPION_REWARDS_AMOUNT : Config.L2JMOD_CHAMPION_ADENAS_REWARDS_AMOUNT;
|
||||
}
|
||||
final Float dropAmountMultiplier = Config.RATE_DROP_AMOUNT_MULTIPLIER.get(item.getItemId());
|
||||
if (dropAmountMultiplier != null)
|
||||
{
|
||||
multiplier *= dropAmountMultiplier;
|
||||
}
|
||||
else if (ItemTable.getInstance().getTemplate(item.getItemId()).hasExImmediateEffect())
|
||||
{
|
||||
multiplier *= Config.RATE_HERB_DROP_AMOUNT_MULTIPLIER;
|
||||
}
|
||||
else if (victim.isRaid())
|
||||
{
|
||||
multiplier *= Config.RATE_RAID_DROP_AMOUNT_MULTIPLIER;
|
||||
}
|
||||
else
|
||||
{
|
||||
multiplier *= defaultMultiplier;
|
||||
}
|
||||
return multiplier;
|
||||
};
|
||||
}
|
||||
|
||||
public double getAmountMultiplier(GeneralDropItem item, L2Character victim);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops.strategy;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.drops.GeneralDropItem;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public interface IChanceMultiplierStrategy
|
||||
{
|
||||
public static final IChanceMultiplierStrategy DROP = DEFAULT_STRATEGY(Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER);
|
||||
public static final IChanceMultiplierStrategy SPOIL = DEFAULT_STRATEGY(Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER);
|
||||
public static final IChanceMultiplierStrategy STATIC = (item, victim) -> 1;
|
||||
|
||||
public static final IChanceMultiplierStrategy QUEST = (item, victim) ->
|
||||
{
|
||||
double championmult;
|
||||
if ((item.getItemId() == Inventory.ADENA_ID) || (item.getItemId() == Inventory.ANCIENT_ADENA_ID))
|
||||
{
|
||||
championmult = Config.L2JMOD_CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||
}
|
||||
else
|
||||
{
|
||||
championmult = Config.L2JMOD_CHAMPION_REWARDS_CHANCE;
|
||||
}
|
||||
|
||||
return (Config.L2JMOD_CHAMPION_ENABLE && (victim != null) && victim.isChampion()) ? (Config.RATE_QUEST_DROP * championmult) : Config.RATE_QUEST_DROP;
|
||||
};
|
||||
|
||||
public static IChanceMultiplierStrategy DEFAULT_STRATEGY(final double defaultMultiplier)
|
||||
{
|
||||
return (item, victim) ->
|
||||
{
|
||||
float multiplier = 1;
|
||||
if (victim.isChampion())
|
||||
{
|
||||
multiplier *= item.getItemId() != Inventory.ADENA_ID ? Config.L2JMOD_CHAMPION_REWARDS_CHANCE : Config.L2JMOD_CHAMPION_ADENAS_REWARDS_CHANCE;
|
||||
}
|
||||
final Float dropChanceMultiplier = Config.RATE_DROP_CHANCE_MULTIPLIER.get(item.getItemId());
|
||||
if (dropChanceMultiplier != null)
|
||||
{
|
||||
multiplier *= dropChanceMultiplier;
|
||||
}
|
||||
else if (ItemTable.getInstance().getTemplate(item.getItemId()).hasExImmediateEffect())
|
||||
{
|
||||
multiplier *= Config.RATE_HERB_DROP_CHANCE_MULTIPLIER;
|
||||
}
|
||||
else if (victim.isRaid())
|
||||
{
|
||||
multiplier *= Config.RATE_RAID_DROP_CHANCE_MULTIPLIER;
|
||||
}
|
||||
else
|
||||
{
|
||||
multiplier *= defaultMultiplier;
|
||||
}
|
||||
return multiplier;
|
||||
};
|
||||
}
|
||||
|
||||
public double getChanceMultiplier(GeneralDropItem item, L2Character victim);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops.strategy;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.drops.GeneralDropItem;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public interface IDropCalculationStrategy
|
||||
{
|
||||
public static final IDropCalculationStrategy DEFAULT_STRATEGY = (item, victim, killer) ->
|
||||
{
|
||||
final double chance = item.getChance(victim, killer);
|
||||
if (chance > (Rnd.nextDouble() * 100))
|
||||
{
|
||||
int amountMultiply = 1;
|
||||
if (item.isPreciseCalculated() && (chance > 100))
|
||||
{
|
||||
amountMultiply = (int) chance / 100;
|
||||
if ((chance % 100) > (Rnd.nextDouble() * 100))
|
||||
{
|
||||
amountMultiply++;
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.singletonList(new ItemHolder(item.getItemId(), Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer)) * amountMultiply));
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
public List<ItemHolder> calculateDrops(GeneralDropItem item, L2Character victim, L2Character killer);
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops.strategy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.drops.GeneralDropItem;
|
||||
import com.l2jmobius.gameserver.model.drops.GroupedGeneralDropItem;
|
||||
import com.l2jmobius.gameserver.model.drops.IDropItem;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public interface IGroupedItemDropCalculationStrategy
|
||||
{
|
||||
/**
|
||||
* The default strategy used in L2J to calculate drops. When the group's chance raises over 100% and group has precise calculation, the dropped item's amount increases.
|
||||
*/
|
||||
public static final IGroupedItemDropCalculationStrategy DEFAULT_STRATEGY = new IGroupedItemDropCalculationStrategy()
|
||||
{
|
||||
private final Map<GroupedGeneralDropItem, GeneralDropItem> singleItemCache = new ConcurrentHashMap<>();
|
||||
|
||||
private GeneralDropItem getSingleItem(GroupedGeneralDropItem dropItem)
|
||||
{
|
||||
final GeneralDropItem item1 = dropItem.getItems().iterator().next();
|
||||
singleItemCache.putIfAbsent(dropItem, new GeneralDropItem(item1.getItemId(), item1.getMin(), item1.getMax(), (item1.getChance() * dropItem.getChance()) / 100, item1.getAmountStrategy(), item1.getChanceStrategy(), dropItem.getPreciseStrategy(), dropItem.getKillerChanceModifierStrategy(), item1.getDropCalculationStrategy()));
|
||||
return singleItemCache.get(dropItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemHolder> calculateDrops(GroupedGeneralDropItem dropItem, L2Character victim, L2Character killer)
|
||||
{
|
||||
if (dropItem.getItems().size() == 1)
|
||||
{
|
||||
return getSingleItem(dropItem).calculateDrops(victim, killer);
|
||||
}
|
||||
|
||||
final GroupedGeneralDropItem normalized = dropItem.normalizeMe(victim, killer);
|
||||
if (normalized.getChance() > (Rnd.nextDouble() * 100))
|
||||
{
|
||||
final double random = (Rnd.nextDouble() * 100);
|
||||
double totalChance = 0;
|
||||
for (GeneralDropItem item2 : normalized.getItems())
|
||||
{
|
||||
// Grouped item chance rates should not be modified (the whole magic was already done by normalizing thus the items' chance sum is always 100%).
|
||||
totalChance += Math.sqrt(item2.getChance());
|
||||
if (totalChance > random)
|
||||
{
|
||||
int amountMultiply = 1;
|
||||
if (dropItem.isPreciseCalculated() && (normalized.getChance() >= 100))
|
||||
{
|
||||
amountMultiply = (int) (normalized.getChance()) / 100;
|
||||
if ((normalized.getChance() % 100) > (Rnd.nextDouble() * 100))
|
||||
{
|
||||
amountMultiply++;
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.singletonList(new ItemHolder(item2.getItemId(), Rnd.get(item2.getMin(victim, killer), item2.getMax(victim, killer)) * amountMultiply));
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This strategy calculates a group's drop by calculating drops of its individual items and merging its results.
|
||||
*/
|
||||
public static final IGroupedItemDropCalculationStrategy DISBAND_GROUP = (item, victim, killer) ->
|
||||
{
|
||||
final List<ItemHolder> dropped = new ArrayList<>();
|
||||
for (IDropItem dropItem : item.extractMe())
|
||||
{
|
||||
dropped.addAll(dropItem.calculateDrops(victim, killer));
|
||||
}
|
||||
return dropped.isEmpty() ? null : dropped;
|
||||
};
|
||||
|
||||
/**
|
||||
* This strategy when group has precise calculation rolls multiple times over group to determine drops when group's chance raises over 100% instead of just multiplying the dropped item's amount. Thus it can produce different items from group at once.
|
||||
*/
|
||||
public static final IGroupedItemDropCalculationStrategy PRECISE_MULTIPLE_GROUP_ROLLS = (item, victim, killer) ->
|
||||
{
|
||||
if (!item.isPreciseCalculated())
|
||||
{
|
||||
// if item hasn't precise calculation there's no change from DEFAULT_STRATEGY
|
||||
return DEFAULT_STRATEGY.calculateDrops(item, victim, victim);
|
||||
}
|
||||
final GroupedGeneralDropItem newItem = new GroupedGeneralDropItem(item.getChance(), DEFAULT_STRATEGY, item.getKillerChanceModifierStrategy(), IPreciseDeterminationStrategy.NEVER);
|
||||
newItem.setItems(item.getItems());
|
||||
final GroupedGeneralDropItem normalized = newItem.normalizeMe(victim, killer);
|
||||
// Let's determine the number of rolls.
|
||||
int rolls = (int) (normalized.getChance() / 100);
|
||||
if ((Rnd.nextDouble() * 100) < (normalized.getChance() % 100))
|
||||
{
|
||||
rolls++;
|
||||
}
|
||||
final List<ItemHolder> dropped = new ArrayList<>(rolls);
|
||||
for (int i = 0; i < rolls; i++)
|
||||
{
|
||||
// As further normalizing on already normalized drop group does nothing, we can just pass the calculation to DEFAULT_STRATEGY with precise calculation disabled as we handle it.
|
||||
dropped.addAll(normalized.calculateDrops(victim, killer));
|
||||
}
|
||||
return dropped.isEmpty() ? null : dropped;
|
||||
};
|
||||
|
||||
public List<ItemHolder> calculateDrops(GroupedGeneralDropItem item, L2Character victim, L2Character killer);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops.strategy;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.drops.GeneralDropItem;
|
||||
import com.l2jmobius.gameserver.model.drops.IDropItem;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public interface IKillerChanceModifierStrategy extends INonGroupedKillerChanceModifierStrategy
|
||||
{
|
||||
public static final IKillerChanceModifierStrategy DEFAULT_STRATEGY = (item, victim, killer) ->
|
||||
{
|
||||
final int levelDifference = victim.getLevel() - killer.getLevel();
|
||||
if ((victim.isRaid()) && Config.DEEPBLUE_DROP_RULES_RAID)
|
||||
{
|
||||
// FIXME: Config?
|
||||
return Math.max(0, Math.min(1, (levelDifference * 0.15) + 1));
|
||||
}
|
||||
else if (Config.DEEPBLUE_DROP_RULES)
|
||||
{
|
||||
return Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100.0) / 100;
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
public static final INonGroupedKillerChanceModifierStrategy DEFAULT_NONGROUP_STRATEGY = (item, victim, killer) ->
|
||||
{
|
||||
if (((!(victim.isRaid())) && Config.DEEPBLUE_DROP_RULES) || ((victim.isRaid()) && Config.DEEPBLUE_DROP_RULES_RAID))
|
||||
{
|
||||
final int levelDifference = victim.getLevel() - killer.getLevel();
|
||||
if (item.getItemId() == Inventory.ADENA_ID)
|
||||
{
|
||||
return Util.map(levelDifference, -Config.DROP_ADENA_MAX_LEVEL_DIFFERENCE, -Config.DROP_ADENA_MIN_LEVEL_DIFFERENCE, Config.DROP_ADENA_MIN_LEVEL_GAP_CHANCE, 100.0) / 100;
|
||||
}
|
||||
return Util.map(levelDifference, -Config.DROP_ITEM_MAX_LEVEL_DIFFERENCE, -Config.DROP_ITEM_MIN_LEVEL_DIFFERENCE, Config.DROP_ITEM_MIN_LEVEL_GAP_CHANCE, 100.0) / 100;
|
||||
}
|
||||
return 1;
|
||||
};
|
||||
|
||||
IKillerChanceModifierStrategy NO_RULES = (item, victim, killer) -> 1;
|
||||
|
||||
public double getKillerChanceModifier(IDropItem item, L2Character victim, L2Character killer);
|
||||
|
||||
@Override
|
||||
public default double getKillerChanceModifier(GeneralDropItem item, L2Character victim, L2Character killer)
|
||||
{
|
||||
return getKillerChanceModifier((IDropItem) item, victim, killer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops.strategy;
|
||||
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.drops.GeneralDropItem;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public interface INonGroupedKillerChanceModifierStrategy
|
||||
{
|
||||
public double getKillerChanceModifier(GeneralDropItem item, L2Character victim, L2Character killer);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.drops.strategy;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.model.drops.IDropItem;
|
||||
|
||||
/**
|
||||
* @author Battlecruiser
|
||||
*/
|
||||
public interface IPreciseDeterminationStrategy
|
||||
{
|
||||
public static final IPreciseDeterminationStrategy ALWAYS = dropItem -> true;
|
||||
|
||||
public static final IPreciseDeterminationStrategy DEFAULT = dropItem -> Config.PRECISE_DROP_CALCULATION;
|
||||
|
||||
public static final IPreciseDeterminationStrategy NEVER = dropItem -> false;
|
||||
|
||||
/**
|
||||
* @param dropItem
|
||||
* @return <code>true</code> if drop calculation strategy should use precise rules
|
||||
*/
|
||||
public boolean isPreciseCalculated(IDropItem dropItem);
|
||||
}
|
||||
Reference in New Issue
Block a user