Proper way to drop lucky drops.
This commit is contained in:
@@ -446,8 +446,7 @@ public class NpcData implements IGameXmlReader
|
||||
final NamedNodeMap drop_attrs = drop_node.getAttributes();
|
||||
if ("item".equals(drop_node.getNodeName().toLowerCase()))
|
||||
{
|
||||
final double chance = parseDouble(drop_attrs, "chance");
|
||||
final DropHolder dropItem = new DropHolder(dropType, parseInteger(drop_attrs, "id"), parseLong(drop_attrs, "min"), parseLong(drop_attrs, "max"), dropType == DropType.LUCKY_DROP ? chance / 100 : chance);
|
||||
final DropHolder dropItem = new DropHolder(dropType, parseInteger(drop_attrs, "id"), parseLong(drop_attrs, "min"), parseLong(drop_attrs, "max"), parseDouble(drop_attrs, "chance"));
|
||||
if (ItemTable.getInstance().getTemplate(parseInteger(drop_attrs, "id")) == null)
|
||||
{
|
||||
LOGGER.warning("DropListItem: Could not find item with id " + parseInteger(drop_attrs, "id") + ".");
|
||||
@@ -630,7 +629,7 @@ public class NpcData implements IGameXmlReader
|
||||
switch (dropHolder.getDropType())
|
||||
{
|
||||
case DROP:
|
||||
case LUCKY_DROP: // TODO: Luck is added to death drops.
|
||||
case LUCKY_DROP: // Lucky drops are added to normal drops and calculated later
|
||||
{
|
||||
template.addDrop(dropHolder);
|
||||
break;
|
||||
|
@@ -671,7 +671,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
||||
switch (dropItem.getDropType())
|
||||
{
|
||||
case DROP:
|
||||
case LUCKY_DROP:
|
||||
{
|
||||
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
|
||||
|
||||
@@ -769,6 +768,15 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LUCKY_DROP:
|
||||
{
|
||||
// try chance before luck
|
||||
if (((Rnd.nextDouble() * 100) < dropItem.getChance()) && killer.getActingPlayer().tryLuck())
|
||||
{
|
||||
return new ItemHolder(dropItem.getItemId(), Rnd.get(dropItem.getMin(), dropItem.getMax()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPOIL:
|
||||
{
|
||||
// chance
|
||||
|
@@ -446,8 +446,7 @@ public class NpcData implements IGameXmlReader
|
||||
final NamedNodeMap drop_attrs = drop_node.getAttributes();
|
||||
if ("item".equals(drop_node.getNodeName().toLowerCase()))
|
||||
{
|
||||
final double chance = parseDouble(drop_attrs, "chance");
|
||||
final DropHolder dropItem = new DropHolder(dropType, parseInteger(drop_attrs, "id"), parseLong(drop_attrs, "min"), parseLong(drop_attrs, "max"), dropType == DropType.LUCKY_DROP ? chance / 100 : chance);
|
||||
final DropHolder dropItem = new DropHolder(dropType, parseInteger(drop_attrs, "id"), parseLong(drop_attrs, "min"), parseLong(drop_attrs, "max"), parseDouble(drop_attrs, "chance"));
|
||||
if (ItemTable.getInstance().getTemplate(parseInteger(drop_attrs, "id")) == null)
|
||||
{
|
||||
LOGGER.warning("DropListItem: Could not find item with id " + parseInteger(drop_attrs, "id") + ".");
|
||||
@@ -630,7 +629,7 @@ public class NpcData implements IGameXmlReader
|
||||
switch (dropHolder.getDropType())
|
||||
{
|
||||
case DROP:
|
||||
case LUCKY_DROP: // TODO: Luck is added to death drops.
|
||||
case LUCKY_DROP: // Lucky drops are added to normal drops and calculated later
|
||||
{
|
||||
template.addDrop(dropHolder);
|
||||
break;
|
||||
|
@@ -671,7 +671,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
||||
switch (dropItem.getDropType())
|
||||
{
|
||||
case DROP:
|
||||
case LUCKY_DROP:
|
||||
{
|
||||
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
|
||||
|
||||
@@ -769,6 +768,15 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LUCKY_DROP:
|
||||
{
|
||||
// try chance before luck
|
||||
if (((Rnd.nextDouble() * 100) < dropItem.getChance()) && killer.getActingPlayer().tryLuck())
|
||||
{
|
||||
return new ItemHolder(dropItem.getItemId(), Rnd.get(dropItem.getMin(), dropItem.getMax()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPOIL:
|
||||
{
|
||||
// chance
|
||||
|
@@ -446,8 +446,7 @@ public class NpcData implements IGameXmlReader
|
||||
final NamedNodeMap drop_attrs = drop_node.getAttributes();
|
||||
if ("item".equals(drop_node.getNodeName().toLowerCase()))
|
||||
{
|
||||
final double chance = parseDouble(drop_attrs, "chance");
|
||||
final DropHolder dropItem = new DropHolder(dropType, parseInteger(drop_attrs, "id"), parseLong(drop_attrs, "min"), parseLong(drop_attrs, "max"), dropType == DropType.LUCKY_DROP ? chance / 100 : chance);
|
||||
final DropHolder dropItem = new DropHolder(dropType, parseInteger(drop_attrs, "id"), parseLong(drop_attrs, "min"), parseLong(drop_attrs, "max"), parseDouble(drop_attrs, "chance"));
|
||||
if (ItemTable.getInstance().getTemplate(parseInteger(drop_attrs, "id")) == null)
|
||||
{
|
||||
LOGGER.warning("DropListItem: Could not find item with id " + parseInteger(drop_attrs, "id") + ".");
|
||||
@@ -630,7 +629,7 @@ public class NpcData implements IGameXmlReader
|
||||
switch (dropHolder.getDropType())
|
||||
{
|
||||
case DROP:
|
||||
case LUCKY_DROP: // TODO: Luck is added to death drops.
|
||||
case LUCKY_DROP: // Lucky drops are added to normal drops and calculated later
|
||||
{
|
||||
template.addDrop(dropHolder);
|
||||
break;
|
||||
|
@@ -671,7 +671,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
||||
switch (dropItem.getDropType())
|
||||
{
|
||||
case DROP:
|
||||
case LUCKY_DROP:
|
||||
{
|
||||
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
|
||||
|
||||
@@ -769,6 +768,15 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LUCKY_DROP:
|
||||
{
|
||||
// try chance before luck
|
||||
if (((Rnd.nextDouble() * 100) < dropItem.getChance()) && killer.getActingPlayer().tryLuck())
|
||||
{
|
||||
return new ItemHolder(dropItem.getItemId(), Rnd.get(dropItem.getMin(), dropItem.getMax()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SPOIL:
|
||||
{
|
||||
// chance
|
||||
|
Reference in New Issue
Block a user