Enchantment level support for multisells.

This commit is contained in:
mobius 2015-01-31 22:49:02 +00:00
parent bf7b56f0ba
commit 1289171727
6 changed files with 18 additions and 12 deletions

View File

@ -37,7 +37,9 @@ TAGS:
<list></list> : start and end the list <list></list> : start and end the list
<item></item> : start and end a single entry within the list <item></item> : start and end a single entry within the list
<production id="itemID" count="amount"/> : add a product for the entry <production id="itemID" count="amount"/> : add a product for the entry
<ingredient id="ItemID" count="amount"/> : add an ingredient for the entry. <ingredient id="ItemID" count="amount"/> : add an ingredient for the entry
enchantmentLevel : add item enchantment level
Sample: Sample:
<list applyTaxes="true"> <list applyTaxes="true">
@ -48,7 +50,7 @@ Sample:
<ingredient id="57" count="200"> <ingredient id="57" count="200">
</item> </item>
<item> <item>
<production id="123" count="1"> <production id="123" enchantmentLevel="16" count="1">
<ingredient id="57" count="2030"> <ingredient id="57" count="2030">
</item> </item>
</list> </list>

View File

@ -23,6 +23,7 @@
<xs:element name="ingredient" minOccurs="1" maxOccurs="unbounded"> <xs:element name="ingredient" minOccurs="1" 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="maintainIngredient" type="xs:boolean" /> <xs:attribute name="maintainIngredient" type="xs:boolean" />
</xs:complexType> </xs:complexType>
@ -30,6 +31,7 @@
<xs:element name="production" minOccurs="1" maxOccurs="unbounded"> <xs:element name="production" minOccurs="1" 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="chance" type="xs:integer" use="optional" /> <xs:attribute name="chance" type="xs:integer" use="optional" />
</xs:complexType> </xs:complexType>

View File

@ -32,6 +32,7 @@ public class Ingredient
{ {
private int _itemId; private int _itemId;
private long _itemCount; private long _itemCount;
private final int _enchantmentLevel;
private boolean _isTaxIngredient; private boolean _isTaxIngredient;
private boolean _maintainIngredient; private boolean _maintainIngredient;
private L2Item _template = null; private L2Item _template = null;
@ -40,13 +41,14 @@ public class Ingredient
public Ingredient(StatsSet set) public Ingredient(StatsSet set)
{ {
this(set.getInt("id"), set.getLong("count"), set.getInt("chance", 0), set.getBoolean("isTaxIngredient", false), set.getBoolean("maintainIngredient", false)); this(set.getInt("id"), set.getLong("count"), set.getInt("enchantmentLevel", 0), set.getInt("chance", 0), set.getBoolean("isTaxIngredient", false), set.getBoolean("maintainIngredient", false));
} }
public Ingredient(int itemId, long itemCount, int chance, boolean isTaxIngredient, boolean maintainIngredient) public Ingredient(int itemId, long itemCount, int enchantmentLevel, int chance, boolean isTaxIngredient, boolean maintainIngredient)
{ {
_itemId = itemId; _itemId = itemId;
_itemCount = itemCount; _itemCount = itemCount;
_enchantmentLevel = enchantmentLevel;
_chance = chance; _chance = chance;
_isTaxIngredient = isTaxIngredient; _isTaxIngredient = isTaxIngredient;
_maintainIngredient = maintainIngredient; _maintainIngredient = maintainIngredient;
@ -61,7 +63,7 @@ public class Ingredient
*/ */
public Ingredient getCopy() public Ingredient getCopy()
{ {
return new Ingredient(_itemId, _itemCount, _chance, _isTaxIngredient, _maintainIngredient); return new Ingredient(_itemId, _itemCount, _enchantmentLevel, _chance, _isTaxIngredient, _maintainIngredient);
} }
public final L2Item getTemplate() public final L2Item getTemplate()
@ -86,7 +88,7 @@ public class Ingredient
public final int getEnchantLevel() public final int getEnchantLevel()
{ {
return _itemInfo != null ? _itemInfo.getEnchantLevel() : 0; return _itemInfo == null ? _enchantmentLevel : _itemInfo.getEnchantLevel();
} }
public final void setItemId(int itemId) public final void setItemId(int itemId)

View File

@ -81,7 +81,7 @@ public class PreparedEntry extends Entry
adenaAmount += _taxAmount; // do not forget tax adenaAmount += _taxAmount; // do not forget tax
if (adenaAmount > 0) if (adenaAmount > 0)
{ {
_ingredients.add(new Ingredient(ADENA_ID, adenaAmount, 0, false, false)); _ingredients.add(new Ingredient(ADENA_ID, adenaAmount, 0, 0, false, false));
} }
// now copy products // now copy products

View File

@ -205,7 +205,7 @@ public class MultiSellChoose extends L2GameClientPacket
// if this is not a list that maintains enchantment, check the count of all items that have the given id. // if this is not a list that maintains enchantment, check the count of all items that have the given id.
// otherwise, check only the count of items with exactly the needed enchantment level // otherwise, check only the count of items with exactly the needed enchantment level
final long required = ((Config.ALT_BLACKSMITH_USE_RECIPES || !e.getMaintainIngredient()) ? (e.getItemCount() * _amount) : e.getItemCount()); final long required = ((Config.ALT_BLACKSMITH_USE_RECIPES || !e.getMaintainIngredient()) ? (e.getItemCount() * _amount) : e.getItemCount());
if (inv.getInventoryItemCount(e.getItemId(), list.getMaintainEnchantment() ? e.getEnchantLevel() : -1, false) < required) if (inv.getInventoryItemCount(e.getItemId(), (list.getMaintainEnchantment() || (e.getEnchantLevel() > 0)) ? e.getEnchantLevel() : -1, false) < required)
{ {
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_NEED_S2_S1_S); SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_NEED_S2_S1_S);
sm.addItemName(e.getTemplate()); sm.addItemName(e.getTemplate());
@ -267,7 +267,7 @@ public class MultiSellChoose extends L2GameClientPacket
// b) list does not maintain enchantment: get the instances with the LOWEST enchantment level // b) list does not maintain enchantment: get the instances with the LOWEST enchantment level
// a) if enchantment is maintained, then get a list of items that exactly match this enchantment // a) if enchantment is maintained, then get a list of items that exactly match this enchantment
if (list.getMaintainEnchantment()) if (list.getMaintainEnchantment() || (e.getEnchantLevel() > 0))
{ {
// loop through this list and remove (one by one) each item until the required amount is taken. // loop through this list and remove (one by one) each item until the required amount is taken.
L2ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId(), e.getEnchantLevel(), false); L2ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId(), e.getEnchantLevel(), false);
@ -400,7 +400,7 @@ public class MultiSellChoose extends L2GameClientPacket
for (int i = 0; i < (e.getItemCount() * _amount); i++) for (int i = 0; i < (e.getItemCount() * _amount); i++)
{ {
product = inv.addItem("Multisell", e.getItemId(), 1, player, player.getTarget()); product = inv.addItem("Multisell", e.getItemId(), 1, player, player.getTarget());
if ((product != null) && list.getMaintainEnchantment()) if ((product != null) && (list.getMaintainEnchantment() || (e.getEnchantLevel() > 0)))
{ {
if (i < augmentation.size()) if (i < augmentation.size())
{ {

View File

@ -110,7 +110,7 @@ public final class MultiSellList extends L2GameServerPacket
} }
else else
{ {
writeH(0x00); // enchant level writeH(ing.getEnchantLevel()); // enchant level
writeD(ing.getChance()); // augment id writeD(ing.getChance()); // augment id
writeD(0x00); // mana writeD(0x00); // mana
writeD(0x00); // time ? writeD(0x00); // time ?
@ -146,7 +146,7 @@ public final class MultiSellList extends L2GameServerPacket
} }
else else
{ {
writeH(0x00); // enchant level writeH(ing.getEnchantLevel()); // enchant level
writeD(ing.getChance()); // augment id writeD(ing.getChance()); // augment id
writeD(0x00); // mana writeD(0x00); // mana
writeH(0x00); // attack element writeH(0x00); // attack element