return;
}
}
int enchantLevel = 0;
ItemAttributes attributes = null;
int augmentationId = 0;
for (ItemData id : items)
{
long count = id.getCount();
if (count > 0)
{
if (id.getId() == ItemTemplate.ITEM_ID_CLAN_REPUTATION_SCORE)
{
activeChar.getClan().incReputation((int) -count, false, "MultiSell");
activeChar.sendPacket(new SystemMessage(SystemMessage.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_REPUTATION_SCORE).addNumber(count));
}
else if (id.getId() == ItemTemplate.ITEM_ID_PC_BANG_POINTS)
{
activeChar.reducePcBangPoints((int) count);
}
else if (id.getId() == ItemTemplate.ITEM_ID_FAME)
{
activeChar.setFame(activeChar.getFame() - (int) count, "MultiSell");
activeChar.sendPacket(new SystemMessage(SystemMessage.S2_S1_HAS_DISAPPEARED).addNumber(count).addString("Fame"));
}
else
{
if (inventory.destroyItem(id.getItem(), count))
{
if (keepenchant && id.getItem().canBeEnchanted())
{
enchantLevel = id.getItem().getEnchantLevel();
attributes = id.getItem().getAttributes();
augmentationId = id.getItem().getAugmentationId();
}
activeChar.sendPacket(SystemMessage2.removeItems(id.getId(), count));
continue;
}
return;
}
}
}
if ((tax > 0) && !notax)
{
if (castle != null)
{
activeChar.sendMessage(new CustomMessage("trade.HavePaidTax", activeChar).addNumber(tax));
if ((merchant != null) && (merchant.getReflection() == ReflectionManager.DEFAULT))
{
castle.addToTreasury(tax, true, false);
}
}
}
double rndNum = 100.0D * Rnd.nextDouble();
double chance = 0.0D;
double chanceFrom = 0.0D;
cycle1 :
for (MultiSellIngredient in : entry.getProduction())
{
if (in.getItemId() <= 0)
{
if (in.getItemId() == ItemTemplate.ITEM_ID_CLAN_REPUTATION_SCORE)
{
activeChar.getClan().incReputation((int) (in.getItemCount() * _amount), false, "MultiSell");
activeChar.sendPacket(new SystemMessage(SystemMessage.YOUR_CLAN_HAS_ADDED_1S_POINTS_TO_ITS_CLAN_REPUTATION_SCORE).addNumber(in.getItemCount() * _amount));
}
else if (in.getItemId() == ItemTemplate.ITEM_ID_PC_BANG_POINTS)
{
activeChar.addPcBangPoints((int) (in.getItemCount() * _amount), false);
}
else if (in.getItemId() == ItemTemplate.ITEM_ID_FAME)
{
activeChar.setFame(activeChar.getFame() + (int) (in.getItemCount() * _amount), "MultiSell");
}
}
else if (ItemHolder.getInstance().getTemplate(in.getItemId()).isStackable())
{
long total = SafeMath.mulAndLimit(in.getItemCount(), _amount);
if (in.getChance() >= 0)
{
chance = in.getChance();
if ((rndNum >= chanceFrom) && (rndNum <= (chance + chanceFrom)))
{
ItemFunctions.addItem(activeChar, in.getItemId(), total, true);
break;
}
chanceFrom += chance;
}
else
{
ItemFunctions.addItem(activeChar, in.getItemId(), total, true);
}
}
else
{
for (int i = 0; i < _amount; i++)
{
ItemInstance product = ItemFunctions.createItem(in.getItemId());
if (keepenchant && product.canBeEnchanted())
{
if (in.getChance() >= 0)
{
chance = in.getChance();
if ((rndNum >= chanceFrom) && (rndNum <= (chance + chanceFrom)))
{
product.setEnchantLevel(enchantLevel);
if (attributes != null)
{
product.setAttributes(attributes.clone());
}
if (augmentationId != 0)
{
product.setAugmentationId(augmentationId);
}
inventory.addItem(product);
activeChar.sendPacket(SystemMessage2.obtainItems(product));
break cycle1;
}
chanceFrom += chance;
}
else
{
product.setEnchantLevel(enchantLevel);
if (attributes != null)
{
product.setAttributes(attributes.clone());
}
if (augmentationId != 0)
{
product.setAugmentationId(augmentationId);
}