Support for multisell maintain ingredient.

This commit is contained in:
MobiusDev
2018-05-23 14:52:12 +00:00
parent 4114fee07c
commit 7148655e9a
28 changed files with 175 additions and 14 deletions

View File

@@ -20,8 +20,9 @@
<xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded"> <xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required" /> <xs:attribute name="id" type="xs:integer" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="count" type="xs:positiveInteger" use="required" /> <xs:attribute name="count" type="xs:positiveInteger" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="maintainIngredient" type="xs:boolean" />
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="production" minOccurs="1" maxOccurs="unbounded"> <xs:element name="production" minOccurs="1" maxOccurs="unbounded">

View File

@@ -99,7 +99,8 @@ public final class MultisellData implements IGameXmlReader
final int id = parseInteger(d.getAttributes(), "id"); final int id = parseInteger(d.getAttributes(), "id");
final long count = parseLong(d.getAttributes(), "count"); final long count = parseLong(d.getAttributes(), "count");
final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0); final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel); final Boolean maintainIngredient = parseBoolean(d.getAttributes(), "maintainIngredient", false);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel, maintainIngredient);
if (itemExists(ingredient)) if (itemExists(ingredient))
{ {

View File

@@ -29,6 +29,7 @@ public class ItemChanceHolder extends ItemHolder
{ {
private final double _chance; private final double _chance;
private final byte _enchantmentLevel; private final byte _enchantmentLevel;
private final boolean _maintainIngredient;
public ItemChanceHolder(int id, double chance) public ItemChanceHolder(int id, double chance)
{ {
@@ -40,6 +41,7 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = 0; _enchantmentLevel = 0;
_maintainIngredient = false;
} }
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel) public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel)
@@ -47,6 +49,15 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = enchantmentLevel; _enchantmentLevel = enchantmentLevel;
_maintainIngredient = false;
}
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel, boolean maintainIngredient)
{
super(id, count);
_chance = chance;
_enchantmentLevel = enchantmentLevel;
_maintainIngredient = maintainIngredient;
} }
/** /**
@@ -67,6 +78,11 @@ public class ItemChanceHolder extends ItemHolder
return _enchantmentLevel; return _enchantmentLevel;
} }
public boolean isMaintainIngredient()
{
return _maintainIngredient;
}
/** /**
* Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected. * Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected.
* @param holders list of holders to calculate chance from. * @param holders list of holders to calculate chance from.

View File

@@ -288,6 +288,11 @@ public class MultiSellChoose implements IClientIncomingPacket
// Take all ingredients // Take all ingredients
for (ItemChanceHolder ingredient : entry.getIngredients()) for (ItemChanceHolder ingredient : entry.getIngredients())
{ {
if (ingredient.isMaintainIngredient())
{
continue;
}
final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount); final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount);
final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId()); final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId());
if (specialItem != null) if (specialItem != null)

View File

@@ -20,8 +20,9 @@
<xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded"> <xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required" /> <xs:attribute name="id" type="xs:integer" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="count" type="xs:positiveInteger" use="required" /> <xs:attribute name="count" type="xs:positiveInteger" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="maintainIngredient" type="xs:boolean" />
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="production" minOccurs="1" maxOccurs="unbounded"> <xs:element name="production" minOccurs="1" maxOccurs="unbounded">

View File

@@ -99,7 +99,8 @@ public final class MultisellData implements IGameXmlReader
final int id = parseInteger(d.getAttributes(), "id"); final int id = parseInteger(d.getAttributes(), "id");
final long count = parseLong(d.getAttributes(), "count"); final long count = parseLong(d.getAttributes(), "count");
final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0); final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel); final Boolean maintainIngredient = parseBoolean(d.getAttributes(), "maintainIngredient", false);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel, maintainIngredient);
if (itemExists(ingredient)) if (itemExists(ingredient))
{ {

View File

@@ -29,6 +29,7 @@ public class ItemChanceHolder extends ItemHolder
{ {
private final double _chance; private final double _chance;
private final byte _enchantmentLevel; private final byte _enchantmentLevel;
private final boolean _maintainIngredient;
public ItemChanceHolder(int id, double chance) public ItemChanceHolder(int id, double chance)
{ {
@@ -40,6 +41,7 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = 0; _enchantmentLevel = 0;
_maintainIngredient = false;
} }
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel) public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel)
@@ -47,6 +49,15 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = enchantmentLevel; _enchantmentLevel = enchantmentLevel;
_maintainIngredient = false;
}
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel, boolean maintainIngredient)
{
super(id, count);
_chance = chance;
_enchantmentLevel = enchantmentLevel;
_maintainIngredient = maintainIngredient;
} }
/** /**
@@ -67,6 +78,11 @@ public class ItemChanceHolder extends ItemHolder
return _enchantmentLevel; return _enchantmentLevel;
} }
public boolean isMaintainIngredient()
{
return _maintainIngredient;
}
/** /**
* Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected. * Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected.
* @param holders list of holders to calculate chance from. * @param holders list of holders to calculate chance from.

View File

@@ -316,6 +316,11 @@ public class MultiSellChoose implements IClientIncomingPacket
// Take all ingredients // Take all ingredients
for (ItemChanceHolder ingredient : entry.getIngredients()) for (ItemChanceHolder ingredient : entry.getIngredients())
{ {
if (ingredient.isMaintainIngredient())
{
continue;
}
final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount); final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount);
final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId()); final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId());
if (specialItem != null) if (specialItem != null)

View File

@@ -20,8 +20,9 @@
<xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded"> <xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required" /> <xs:attribute name="id" type="xs:integer" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="count" type="xs:positiveInteger" use="required" /> <xs:attribute name="count" type="xs:positiveInteger" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="maintainIngredient" type="xs:boolean" />
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="production" minOccurs="1" maxOccurs="unbounded"> <xs:element name="production" minOccurs="1" maxOccurs="unbounded">

View File

@@ -99,7 +99,8 @@ public final class MultisellData implements IGameXmlReader
final int id = parseInteger(d.getAttributes(), "id"); final int id = parseInteger(d.getAttributes(), "id");
final long count = parseLong(d.getAttributes(), "count"); final long count = parseLong(d.getAttributes(), "count");
final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0); final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel); final Boolean maintainIngredient = parseBoolean(d.getAttributes(), "maintainIngredient", false);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel, maintainIngredient);
if (itemExists(ingredient)) if (itemExists(ingredient))
{ {

View File

@@ -29,6 +29,7 @@ public class ItemChanceHolder extends ItemHolder
{ {
private final double _chance; private final double _chance;
private final byte _enchantmentLevel; private final byte _enchantmentLevel;
private final boolean _maintainIngredient;
public ItemChanceHolder(int id, double chance) public ItemChanceHolder(int id, double chance)
{ {
@@ -40,6 +41,7 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = 0; _enchantmentLevel = 0;
_maintainIngredient = false;
} }
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel) public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel)
@@ -47,6 +49,15 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = enchantmentLevel; _enchantmentLevel = enchantmentLevel;
_maintainIngredient = false;
}
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel, boolean maintainIngredient)
{
super(id, count);
_chance = chance;
_enchantmentLevel = enchantmentLevel;
_maintainIngredient = maintainIngredient;
} }
/** /**
@@ -67,6 +78,11 @@ public class ItemChanceHolder extends ItemHolder
return _enchantmentLevel; return _enchantmentLevel;
} }
public boolean isMaintainIngredient()
{
return _maintainIngredient;
}
/** /**
* Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected. * Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected.
* @param holders list of holders to calculate chance from. * @param holders list of holders to calculate chance from.

View File

@@ -316,6 +316,11 @@ public class MultiSellChoose implements IClientIncomingPacket
// Take all ingredients // Take all ingredients
for (ItemChanceHolder ingredient : entry.getIngredients()) for (ItemChanceHolder ingredient : entry.getIngredients())
{ {
if (ingredient.isMaintainIngredient())
{
continue;
}
final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount); final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount);
final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId()); final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId());
if (specialItem != null) if (specialItem != null)

View File

@@ -20,8 +20,9 @@
<xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded"> <xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required" /> <xs:attribute name="id" type="xs:integer" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="count" type="xs:positiveInteger" use="required" /> <xs:attribute name="count" type="xs:positiveInteger" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="maintainIngredient" type="xs:boolean" />
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="production" minOccurs="1" maxOccurs="unbounded"> <xs:element name="production" minOccurs="1" maxOccurs="unbounded">

View File

@@ -99,7 +99,8 @@ public final class MultisellData implements IGameXmlReader
final int id = parseInteger(d.getAttributes(), "id"); final int id = parseInteger(d.getAttributes(), "id");
final long count = parseLong(d.getAttributes(), "count"); final long count = parseLong(d.getAttributes(), "count");
final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0); final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel); final Boolean maintainIngredient = parseBoolean(d.getAttributes(), "maintainIngredient", false);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel, maintainIngredient);
if (itemExists(ingredient)) if (itemExists(ingredient))
{ {

View File

@@ -29,6 +29,7 @@ public class ItemChanceHolder extends ItemHolder
{ {
private final double _chance; private final double _chance;
private final byte _enchantmentLevel; private final byte _enchantmentLevel;
private final boolean _maintainIngredient;
public ItemChanceHolder(int id, double chance) public ItemChanceHolder(int id, double chance)
{ {
@@ -40,6 +41,7 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = 0; _enchantmentLevel = 0;
_maintainIngredient = false;
} }
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel) public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel)
@@ -47,6 +49,15 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = enchantmentLevel; _enchantmentLevel = enchantmentLevel;
_maintainIngredient = false;
}
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel, boolean maintainIngredient)
{
super(id, count);
_chance = chance;
_enchantmentLevel = enchantmentLevel;
_maintainIngredient = maintainIngredient;
} }
/** /**
@@ -67,6 +78,11 @@ public class ItemChanceHolder extends ItemHolder
return _enchantmentLevel; return _enchantmentLevel;
} }
public boolean isMaintainIngredient()
{
return _maintainIngredient;
}
/** /**
* Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected. * Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected.
* @param holders list of holders to calculate chance from. * @param holders list of holders to calculate chance from.

View File

@@ -316,6 +316,11 @@ public class MultiSellChoose implements IClientIncomingPacket
// Take all ingredients // Take all ingredients
for (ItemChanceHolder ingredient : entry.getIngredients()) for (ItemChanceHolder ingredient : entry.getIngredients())
{ {
if (ingredient.isMaintainIngredient())
{
continue;
}
final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount); final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount);
final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId()); final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId());
if (specialItem != null) if (specialItem != null)

View File

@@ -20,8 +20,9 @@
<xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded"> <xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required" /> <xs:attribute name="id" type="xs:integer" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="count" type="xs:positiveInteger" use="required" /> <xs:attribute name="count" type="xs:positiveInteger" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="maintainIngredient" type="xs:boolean" />
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="production" minOccurs="1" maxOccurs="unbounded"> <xs:element name="production" minOccurs="1" maxOccurs="unbounded">

View File

@@ -99,7 +99,8 @@ public final class MultisellData implements IGameXmlReader
final int id = parseInteger(d.getAttributes(), "id"); final int id = parseInteger(d.getAttributes(), "id");
final long count = parseLong(d.getAttributes(), "count"); final long count = parseLong(d.getAttributes(), "count");
final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0); final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel); final Boolean maintainIngredient = parseBoolean(d.getAttributes(), "maintainIngredient", false);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel, maintainIngredient);
if (itemExists(ingredient)) if (itemExists(ingredient))
{ {

View File

@@ -29,6 +29,7 @@ public class ItemChanceHolder extends ItemHolder
{ {
private final double _chance; private final double _chance;
private final byte _enchantmentLevel; private final byte _enchantmentLevel;
private final boolean _maintainIngredient;
public ItemChanceHolder(int id, double chance) public ItemChanceHolder(int id, double chance)
{ {
@@ -40,6 +41,7 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = 0; _enchantmentLevel = 0;
_maintainIngredient = false;
} }
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel) public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel)
@@ -47,6 +49,15 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = enchantmentLevel; _enchantmentLevel = enchantmentLevel;
_maintainIngredient = false;
}
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel, boolean maintainIngredient)
{
super(id, count);
_chance = chance;
_enchantmentLevel = enchantmentLevel;
_maintainIngredient = maintainIngredient;
} }
/** /**
@@ -67,6 +78,11 @@ public class ItemChanceHolder extends ItemHolder
return _enchantmentLevel; return _enchantmentLevel;
} }
public boolean isMaintainIngredient()
{
return _maintainIngredient;
}
/** /**
* Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected. * Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected.
* @param holders list of holders to calculate chance from. * @param holders list of holders to calculate chance from.

View File

@@ -316,6 +316,11 @@ public class MultiSellChoose implements IClientIncomingPacket
// Take all ingredients // Take all ingredients
for (ItemChanceHolder ingredient : entry.getIngredients()) for (ItemChanceHolder ingredient : entry.getIngredients())
{ {
if (ingredient.isMaintainIngredient())
{
continue;
}
final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount); final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount);
final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId()); final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId());
if (specialItem != null) if (specialItem != null)

View File

@@ -20,8 +20,9 @@
<xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded"> <xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required" /> <xs:attribute name="id" type="xs:integer" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="count" type="xs:positiveInteger" use="required" /> <xs:attribute name="count" type="xs:positiveInteger" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="maintainIngredient" type="xs:boolean" />
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="production" minOccurs="1" maxOccurs="unbounded"> <xs:element name="production" minOccurs="1" maxOccurs="unbounded">

View File

@@ -99,7 +99,8 @@ public final class MultisellData implements IGameXmlReader
final int id = parseInteger(d.getAttributes(), "id"); final int id = parseInteger(d.getAttributes(), "id");
final long count = parseLong(d.getAttributes(), "count"); final long count = parseLong(d.getAttributes(), "count");
final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0); final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel); final Boolean maintainIngredient = parseBoolean(d.getAttributes(), "maintainIngredient", false);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel, maintainIngredient);
if (itemExists(ingredient)) if (itemExists(ingredient))
{ {

View File

@@ -29,6 +29,7 @@ public class ItemChanceHolder extends ItemHolder
{ {
private final double _chance; private final double _chance;
private final byte _enchantmentLevel; private final byte _enchantmentLevel;
private final boolean _maintainIngredient;
public ItemChanceHolder(int id, double chance) public ItemChanceHolder(int id, double chance)
{ {
@@ -40,6 +41,7 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = 0; _enchantmentLevel = 0;
_maintainIngredient = false;
} }
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel) public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel)
@@ -47,6 +49,15 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = enchantmentLevel; _enchantmentLevel = enchantmentLevel;
_maintainIngredient = false;
}
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel, boolean maintainIngredient)
{
super(id, count);
_chance = chance;
_enchantmentLevel = enchantmentLevel;
_maintainIngredient = maintainIngredient;
} }
/** /**
@@ -67,6 +78,11 @@ public class ItemChanceHolder extends ItemHolder
return _enchantmentLevel; return _enchantmentLevel;
} }
public boolean isMaintainIngredient()
{
return _maintainIngredient;
}
/** /**
* Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected. * Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected.
* @param holders list of holders to calculate chance from. * @param holders list of holders to calculate chance from.

View File

@@ -316,6 +316,11 @@ public class MultiSellChoose implements IClientIncomingPacket
// Take all ingredients // Take all ingredients
for (ItemChanceHolder ingredient : entry.getIngredients()) for (ItemChanceHolder ingredient : entry.getIngredients())
{ {
if (ingredient.isMaintainIngredient())
{
continue;
}
final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount); final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount);
final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId()); final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId());
if (specialItem != null) if (specialItem != null)

View File

@@ -20,8 +20,9 @@
<xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded"> <xs:element name="ingredient" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required" /> <xs:attribute name="id" type="xs:integer" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="count" type="xs:positiveInteger" use="required" /> <xs:attribute name="count" type="xs:positiveInteger" use="required" />
<xs:attribute name="enchantmentLevel" type="xs:integer" />
<xs:attribute name="maintainIngredient" type="xs:boolean" />
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="production" minOccurs="1" maxOccurs="unbounded"> <xs:element name="production" minOccurs="1" maxOccurs="unbounded">

View File

@@ -99,7 +99,8 @@ public final class MultisellData implements IGameXmlReader
final int id = parseInteger(d.getAttributes(), "id"); final int id = parseInteger(d.getAttributes(), "id");
final long count = parseLong(d.getAttributes(), "count"); final long count = parseLong(d.getAttributes(), "count");
final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0); final byte enchantmentLevel = parseByte(d.getAttributes(), "enchantmentLevel", (byte) 0);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel); final Boolean maintainIngredient = parseBoolean(d.getAttributes(), "maintainIngredient", false);
final ItemChanceHolder ingredient = new ItemChanceHolder(id, 0, count, enchantmentLevel, maintainIngredient);
if (itemExists(ingredient)) if (itemExists(ingredient))
{ {

View File

@@ -29,6 +29,7 @@ public class ItemChanceHolder extends ItemHolder
{ {
private final double _chance; private final double _chance;
private final byte _enchantmentLevel; private final byte _enchantmentLevel;
private final boolean _maintainIngredient;
public ItemChanceHolder(int id, double chance) public ItemChanceHolder(int id, double chance)
{ {
@@ -40,6 +41,7 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = 0; _enchantmentLevel = 0;
_maintainIngredient = false;
} }
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel) public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel)
@@ -47,6 +49,15 @@ public class ItemChanceHolder extends ItemHolder
super(id, count); super(id, count);
_chance = chance; _chance = chance;
_enchantmentLevel = enchantmentLevel; _enchantmentLevel = enchantmentLevel;
_maintainIngredient = false;
}
public ItemChanceHolder(int id, double chance, long count, byte enchantmentLevel, boolean maintainIngredient)
{
super(id, count);
_chance = chance;
_enchantmentLevel = enchantmentLevel;
_maintainIngredient = maintainIngredient;
} }
/** /**
@@ -67,6 +78,11 @@ public class ItemChanceHolder extends ItemHolder
return _enchantmentLevel; return _enchantmentLevel;
} }
public boolean isMaintainIngredient()
{
return _maintainIngredient;
}
/** /**
* Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected. * Calculates a cumulative chance of all given holders. If all holders' chance sum up to 100% or above, there is 100% guarantee a holder will be selected.
* @param holders list of holders to calculate chance from. * @param holders list of holders to calculate chance from.

View File

@@ -316,6 +316,11 @@ public class MultiSellChoose implements IClientIncomingPacket
// Take all ingredients // Take all ingredients
for (ItemChanceHolder ingredient : entry.getIngredients()) for (ItemChanceHolder ingredient : entry.getIngredients())
{ {
if (ingredient.isMaintainIngredient())
{
continue;
}
final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount); final long totalCount = Math.multiplyExact(list.getIngredientCount(ingredient), _amount);
final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId()); final SpecialItemType specialItem = SpecialItemType.getByClientId(ingredient.getId());
if (specialItem != null) if (specialItem != null)