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();
|
final NamedNodeMap drop_attrs = drop_node.getAttributes();
|
||||||
if ("item".equals(drop_node.getNodeName().toLowerCase()))
|
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"), 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);
|
|
||||||
if (ItemTable.getInstance().getTemplate(parseInteger(drop_attrs, "id")) == null)
|
if (ItemTable.getInstance().getTemplate(parseInteger(drop_attrs, "id")) == null)
|
||||||
{
|
{
|
||||||
LOGGER.warning("DropListItem: Could not find item with id " + parseInteger(drop_attrs, "id") + ".");
|
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())
|
switch (dropHolder.getDropType())
|
||||||
{
|
{
|
||||||
case DROP:
|
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);
|
template.addDrop(dropHolder);
|
||||||
break;
|
break;
|
||||||
|
@@ -671,7 +671,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
|||||||
switch (dropItem.getDropType())
|
switch (dropItem.getDropType())
|
||||||
{
|
{
|
||||||
case DROP:
|
case DROP:
|
||||||
case LUCKY_DROP:
|
|
||||||
{
|
{
|
||||||
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
|
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
|
||||||
|
|
||||||
@@ -769,6 +768,15 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
case SPOIL:
|
||||||
{
|
{
|
||||||
// chance
|
// chance
|
||||||
|
@@ -446,8 +446,7 @@ public class NpcData implements IGameXmlReader
|
|||||||
final NamedNodeMap drop_attrs = drop_node.getAttributes();
|
final NamedNodeMap drop_attrs = drop_node.getAttributes();
|
||||||
if ("item".equals(drop_node.getNodeName().toLowerCase()))
|
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"), 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);
|
|
||||||
if (ItemTable.getInstance().getTemplate(parseInteger(drop_attrs, "id")) == null)
|
if (ItemTable.getInstance().getTemplate(parseInteger(drop_attrs, "id")) == null)
|
||||||
{
|
{
|
||||||
LOGGER.warning("DropListItem: Could not find item with id " + parseInteger(drop_attrs, "id") + ".");
|
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())
|
switch (dropHolder.getDropType())
|
||||||
{
|
{
|
||||||
case DROP:
|
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);
|
template.addDrop(dropHolder);
|
||||||
break;
|
break;
|
||||||
|
@@ -671,7 +671,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
|||||||
switch (dropItem.getDropType())
|
switch (dropItem.getDropType())
|
||||||
{
|
{
|
||||||
case DROP:
|
case DROP:
|
||||||
case LUCKY_DROP:
|
|
||||||
{
|
{
|
||||||
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
|
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
|
||||||
|
|
||||||
@@ -769,6 +768,15 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
case SPOIL:
|
||||||
{
|
{
|
||||||
// chance
|
// chance
|
||||||
|
@@ -446,8 +446,7 @@ public class NpcData implements IGameXmlReader
|
|||||||
final NamedNodeMap drop_attrs = drop_node.getAttributes();
|
final NamedNodeMap drop_attrs = drop_node.getAttributes();
|
||||||
if ("item".equals(drop_node.getNodeName().toLowerCase()))
|
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"), 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);
|
|
||||||
if (ItemTable.getInstance().getTemplate(parseInteger(drop_attrs, "id")) == null)
|
if (ItemTable.getInstance().getTemplate(parseInteger(drop_attrs, "id")) == null)
|
||||||
{
|
{
|
||||||
LOGGER.warning("DropListItem: Could not find item with id " + parseInteger(drop_attrs, "id") + ".");
|
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())
|
switch (dropHolder.getDropType())
|
||||||
{
|
{
|
||||||
case DROP:
|
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);
|
template.addDrop(dropHolder);
|
||||||
break;
|
break;
|
||||||
|
@@ -671,7 +671,6 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
|||||||
switch (dropItem.getDropType())
|
switch (dropItem.getDropType())
|
||||||
{
|
{
|
||||||
case DROP:
|
case DROP:
|
||||||
case LUCKY_DROP:
|
|
||||||
{
|
{
|
||||||
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
|
final L2Item item = ItemTable.getInstance().getTemplate(dropItem.getItemId());
|
||||||
|
|
||||||
@@ -769,6 +768,15 @@ public final class L2NpcTemplate extends L2CharTemplate implements IIdentifiable
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
case SPOIL:
|
||||||
{
|
{
|
||||||
// chance
|
// chance
|
||||||
|
Reference in New Issue
Block a user