Sync with L2JServer Jan 26th 2015.

This commit is contained in:
mobius
2015-01-27 01:59:37 +00:00
parent 5d7ab65416
commit bfe682bbe3
63 changed files with 1049 additions and 1306 deletions

View File

@@ -19,7 +19,7 @@
package com.l2jserver.gameserver.model.drops;
import java.util.ArrayList;
import java.util.List;
import java.util.Collection;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.ItemTable;
@@ -231,13 +231,10 @@ public class GeneralDropItem implements IDropItem
}
}
// global champions chance multiplier, there is no such option yet
// @formatter:off
/*if (victim.isChampion())
if (victim.isChampion())
{
multiplier *= getItemId() != Inventory.ADENA_ID ? Config.L2JMOD_CHAMPION_REWARDS_CHANCE : Config.L2JMOD_CHAMPION_ADENAS_REWARDS_CHANCE;
}*/
// @formatter:on
multiplier *= Config.L2JMOD_CHAMPION_REWARDS;
}
return (getChance() * multiplier);
}
@@ -247,7 +244,7 @@ public class GeneralDropItem implements IDropItem
* @see com.l2jserver.gameserver.model.drop.IDropItem#calculateDrops(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.actor.L2Character)
*/
@Override
public List<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
public Collection<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
{
final int levelDifference = victim.getLevel() - killer.getLevel();
final double levelGapChanceToDrop;
@@ -266,48 +263,25 @@ public class GeneralDropItem implements IDropItem
return null;
}
final List<ItemHolder> items = new ArrayList<>(1);
if (Config.L2JMOD_OLD_DROP_BEHAVIOR)
final double chance = getChance(victim, killer);
int successes;
if (!Config.L2JMOD_OLD_DROP_BEHAVIOR)
{
double chance = getChance(victim, killer);
if (Config.L2JMOD_CHAMPION_ENABLE && victim.isChampion() && (getItemId() != Inventory.ADENA_ID))
{
chance *= Config.L2JMOD_CHAMPION_REWARDS;
}
long amount = 0;
if (chance > 100)
{
int chanceOveflow = (int) (chance / 100);
chance = chance % 100;
while (chanceOveflow > 0)
{
amount += Rnd.get(getMin(victim, killer), getMax(victim, killer));
chanceOveflow--;
}
}
if (chance > (Rnd.nextDouble() * 100))
{
amount += Rnd.get(getMin(victim, killer), getMax(victim, killer));
}
if (amount > 0)
{
items.add(new ItemHolder(getItemId(), amount));
}
successes = chance > (Rnd.nextDouble() * 100) ? 1 : 0;
}
else
{
if (getChance(victim, killer) > (Rnd.nextDouble() * 100))
{
final long amount = Rnd.get(getMin(victim, killer), getMax(victim, killer));
items.add(new ItemHolder(getItemId(), amount));
}
successes = (int) (chance / 100);
successes += (chance % 100) > (Rnd.nextDouble() * 100) ? 1 : 0;
}
return items;
if (successes > 0)
{
final Collection<ItemHolder> items = new ArrayList<>(1);
items.add(new ItemHolder(getItemId(), Rnd.get(getMin(victim, killer), getMax(victim, killer)) * successes));
return items;
}
return null;
}
}

View File

@@ -19,6 +19,7 @@
package com.l2jserver.gameserver.model.drops;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -104,9 +105,9 @@ public class GroupedGeneralDropItem implements IDropItem
* @see com.l2jserver.gameserver.model.drop.IDropItem#calculateDrops(com.l2jserver.gameserver.model.actor.L2Character, com.l2jserver.gameserver.model.actor.L2Character)
*/
@Override
public List<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
public Collection<ItemHolder> calculateDrops(L2Character victim, L2Character killer)
{
int levelDifference = victim.getLevel() - killer.getLevel();
final int levelDifference = victim.getLevel() - killer.getLevel();
double chanceModifier;
if (victim instanceof L2RaidBossInstance)
{
@@ -124,61 +125,29 @@ public class GroupedGeneralDropItem implements IDropItem
}
}
if ((getChance(victim, killer) * chanceModifier) > (Rnd.nextDouble() * 100))
final double chance = getChance(victim, killer) * chanceModifier;
int successes;
if (!Config.L2JMOD_OLD_DROP_BEHAVIOR)
{
final List<ItemHolder> items = new ArrayList<>(1);
long amount = 0;
double totalChance = 0;
double random = (Rnd.nextDouble() * 100);
double chance = 0;
if (Config.L2JMOD_OLD_DROP_BEHAVIOR)
successes = chance > (Rnd.nextDouble() * 100) ? 1 : 0;
}
else
{
successes = (int) (chance / 100);
successes += (chance % 100) > (Rnd.nextDouble() * 100) ? 1 : 0;
}
double totalChance = 0;
final double random = (Rnd.nextDouble() * 100);
for (GeneralDropItem item : getItems())
{
// Grouped item chance rates should not be modified.
totalChance += item.getChance();
if (totalChance > random)
{
for (GeneralDropItem item : getItems())
{
// Grouped item chance rates should not be modified.
totalChance += item.getChance();
if (totalChance > 100)
{
int chanceOverflow = (int) (totalChance / 100);
chance = totalChance % 100;
while (chanceOverflow > 0)
{
amount += Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
chanceOverflow--;
}
}
else
{
chance = totalChance;
}
if (chance > random)
{
amount += Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
}
if (amount > 0)
{
items.add(new ItemHolder(item.getItemId(), amount));
return items;
}
}
}
else
{
for (GeneralDropItem item : getItems())
{
// Grouped item chance rates should not be modified.
totalChance += item.getChance();
if (totalChance > random)
{
amount = Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer));
items.add(new ItemHolder(item.getItemId(), amount));
return items;
}
}
final Collection<ItemHolder> items = new ArrayList<>(1);
items.add(new ItemHolder(item.getItemId(), Rnd.get(item.getMin(victim, killer), item.getMax(victim, killer)) * successes));
return items;
}
}

View File

@@ -18,7 +18,7 @@
*/
package com.l2jserver.gameserver.model.drops;
import java.util.List;
import java.util.Collection;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.holders.ItemHolder;
@@ -32,7 +32,7 @@ public interface IDropItem
* Calculates drops of this drop item.
* @param victim the victim
* @param killer the killer
* @return {@code null} or empty list if there are no drops, a list containing all items to drop otherwise
* @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);
public Collection<ItemHolder> calculateDrops(L2Character victim, L2Character killer);
}