Examples of MultiSellEntry


Examples of com.l2jfrozen.gameserver.model.multisell.MultiSellEntry

                L2NpcInstance merchant = player.getTarget() instanceof L2NpcInstance ? (L2NpcInstance) player.getTarget() : null;

//              if(merchant == null) TODO: Check this
//                      return;

                MultiSellEntry entry = prepareEntry(merchant, templateEntry, applyTaxes, maintainEnchantment, enchantment);

                // Generate a list of distinct ingredients and counts in order to check if the correct item-counts
                // are possessed by the player
                FastList<MultiSellIngredient> _ingredientsList = new FastList<MultiSellIngredient>();
                boolean newIng = true;

                for (MultiSellIngredient e : entry.getIngredients())
                {
                        newIng = true;

                        // at this point, the template has already been modified so that enchantments are properly included
                        // whenever they need to be applied.  Uniqueness of items is thus judged by item id AND enchantment level
                        for (MultiSellIngredient ex : _ingredientsList)
                        {
                                // if the item was already added in the list, merely increment the count
                                // this happens if 1 list entry has the same ingredient twice (example 2 swords = 1 dual)
                                if (ex.getItemId() == e.getItemId() && ex.getEnchantmentLevel() == e.getEnchantmentLevel())
                                {
                                        if ((double) ex.getItemCount() + e.getItemCount() > Integer.MAX_VALUE)
                                        {
                                                player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED));
                                                _ingredientsList.clear();
                                                _ingredientsList = null;
                                                return;
                                        }
                                        ex.setItemCount(ex.getItemCount() + e.getItemCount());
                                        newIng = false;
                                }
                        }
                        if (newIng)
                        {
                                // If there is a maintainIngredient, then we do not need to check the enchantment parameter as the enchant level will be checked elsewhere
                                if (maintainEnchantment)
                                {
                                        maintainItemFound = true;
                                }

                                // if it's a new ingredient, just store its info directly (item id, count, enchantment)
                                _ingredientsList.add(new MultiSellIngredient(e));
                        }
                }

                // If there is no maintainIngredient, then we must make sure that the enchantment is not kept from the client packet, as it may have been forged
                if (!maintainItemFound)
                {
                        for (MultiSellIngredient product : entry.getProducts())
                        {
                                product.setEnchantmentLevel(0);
                        }
                }

                // now check if the player has sufficient items in the inventory to cover the ingredients' expences
                for (MultiSellIngredient e : _ingredientsList)
                {
                    if ((double) e.getItemCount() * _amount > Integer.MAX_VALUE)
                    {
                            player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED));
                            _ingredientsList.clear();
                            _ingredientsList = null;
                            return;
                    }

                    if (e.getItemId() != 65336 && e.getItemId() != 65436)
                    {
                        // 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
                        if (inv.getInventoryItemCount(e.getItemId(), maintainEnchantment ? e.getEnchantmentLevel() : -1) < (Config.ALT_BLACKSMITH_USE_RECIPES || !e.getMantainIngredient() ? e.getItemCount() * _amount : e.getItemCount()))
                        {
                            player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
                            _ingredientsList.clear();
                            _ingredientsList = null;
                            return;
                        }
                    }
                    else
                    {
                        if (e.getItemId() == 65336)
                        {
                            if (player.getClan() == null)
                            {
                                player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_A_CLAN_MEMBER));
                                return;
                            }

                            if (!player.isClanLeader())
                            {
                                player.sendPacket(new SystemMessage(SystemMessageId.ONLY_THE_CLAN_LEADER_IS_ENABLED));
                                return;
                            }

                            if (player.getClan().getReputationScore() < e.getItemCount() * _amount)
                            {
                                player.sendPacket(new SystemMessage(SystemMessageId.THE_CLAN_REPUTATION_SCORE_IS_TOO_LOW));
                                return;
                            }
                        }
                        if (e.getItemId() == 65436 && e.getItemCount() * _amount > player.getPcBangScore())
                        {
                                player.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
                                return;
                        }
                    }
                }

                _ingredientsList.clear();
                _ingredientsList = null;
                FastList<L2Augmentation> augmentation = new FastList<L2Augmentation>();
                /** All ok, remove items and add final product */

                for (MultiSellIngredient e : entry.getIngredients())
                {
                        if (e.getItemId() != 65336 && e.getItemId() != 65436)
                        {
                                for (MultiSellIngredient a : entry.getProducts())
                                {
                                        if (player.getInventoryLimit() < inv.getSize() + _amount && !ItemTable.getInstance().createDummyItem(a.getItemId()).isStackable())
                                        {
                                                player.sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
                                                return;
                                        }
                                        if (player.getInventoryLimit() < inv.getSize() && ItemTable.getInstance().createDummyItem(a.getItemId()).isStackable())
                                        {
                                                player.sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
                                                return;
                                        }
                                }
                                L2ItemInstance itemToTake = inv.getItemByItemId(e.getItemId()); // initialize and initial guess for the item to take.

                                //this is a cheat, transaction will be aborted and if any items already tanken will not be returned back to inventory!
                                if (itemToTake == null)
                                {
                                        _log.severe("Character: " + player.getName() + " is trying to cheat in multisell, merchatnt id:" + (merchant!=null?merchant.getNpcId():0));
                                        return;
                                }
                                if (itemToTake.fireEvent("MULTISELL", (Object[]) null) != null)
                                        return;

                                if (itemToTake.isWear())
                                {
                                        _log.severe("Character: " + player.getName() + " is trying to cheat in multisell with weared item");
                                        return;
                                }

                                if (Config.ALT_BLACKSMITH_USE_RECIPES || !e.getMantainIngredient())
                                {
                                        // if it's a stackable item, just reduce the amount from the first (only) instance that is found in the inventory
                                        if (itemToTake.isStackable())
                                        {
                                                if (!player.destroyItem("Multisell", itemToTake.getObjectId(), (e.getItemCount() * _amount), player.getTarget(), true))
                                                        return;
                                        }
                                        else
                                        {
                                                // for non-stackable items, one of two scenaria are possible:
                                                // a) list maintains enchantment: get the instances that exactly match the requested 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
                                                if (maintainEnchantment)
                                                {
                                                    // loop through this list and remove (one by one) each item until the required amount is taken.
                                                    L2ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId(), e.getEnchantmentLevel());
                                                    for (int i = 0; i < e.getItemCount() * _amount; i++)
                                                    {
                                                        if (inventoryContents[i].isAugmented())
                                                        {
                                                            augmentation.add(inventoryContents[i].getAugmentation());
                                                        }

                                                        if (inventoryContents[i].isEquipped())
                                                        {
                                                            if (inventoryContents[i].isAugmented())
                                                            {
                                                                inventoryContents[i].getAugmentation().removeBoni(player);
                                                            }
                                                        }

                                                        if (!player.destroyItem("Multisell", inventoryContents[i].getObjectId(), 1, player.getTarget(), true))
                                                            return;
                                                    }
                                                }
                                                else
                                                // b) enchantment is not maintained.  Get the instances with the LOWEST enchantment level
                                                {
                                                        /* NOTE: There are 2 ways to achieve the above goal.
                                                         * 1) Get all items that have the correct itemId, loop through them until the lowest enchantment
                                                         *              level is found.  Repeat all this for the next item until proper count of items is reached.
                                                         * 2) Get all items that have the correct itemId, sort them once based on enchantment level,
                                                         *              and get the range of items that is necessary.
                                                         * Method 1 is faster for a small number of items to be exchanged.
                                                         * Method 2 is faster for large amounts.
                                                         *
                                                         * EXPLANATION:
                                                         *   Worst case scenario for algorithm 1 will make it run in a number of cycles given by:
                                                         * m*(2n-m+1)/2 where m is the number of items to be exchanged and n is the total
                                                         * number of inventory items that have a matching id.
                                                         *   With algorithm 2 (sort), sorting takes n*log(n) time and the choice is done in a single cycle
                                                         * for case b (just grab the m first items) or in linear time for case a (find the beginning of items
                                                         * with correct enchantment, index x, and take all items from x to x+m).
                                                         * Basically, whenever m > log(n) we have: m*(2n-m+1)/2 = (2nm-m*m+m)/2 >
                                                         * (2nlogn-logn*logn+logn)/2 = nlog(n) - log(n*n) + log(n) = nlog(n) + log(n/n*n) =
                                                         * nlog(n) + log(1/n) = nlog(n) - log(n) = (n-1)log(n)
                                                         * So for m < log(n) then m*(2n-m+1)/2 > (n-1)log(n) and m*(2n-m+1)/2 > nlog(n)
                                                         *
                                                         * IDEALLY:
                                                         * In order to best optimize the performance, choose which algorithm to run, based on whether 2^m > n
                                                         * if ( (2<<(e.getItemCount() * _amount)) < inventoryContents.length )
                                                         *   // do Algorithm 1, no sorting
                                                         * else
                                                         *   // do Algorithm 2, sorting
                                                         *
                                                         * CURRENT IMPLEMENTATION:
                                                         * In general, it is going to be very rare for a person to do a massive exchange of non-stackable items
                                                         * For this reason, we assume that algorithm 1 will always suffice and we keep things simple.
                                                         * If, in the future, it becomes necessary that we optimize, the above discussion should make it clear
                                                         * what optimization exactly is necessary (based on the comments under "IDEALLY").
                                                         */

                                                        // choice 1.  Small number of items exchanged.  No sorting.
                                                        for (int i = 1; i <= e.getItemCount() * _amount; i++)
                                                        {
                                                                L2ItemInstance[] inventoryContents = inv.getAllItemsByItemId(e.getItemId());

                                                                itemToTake = inventoryContents[0];
                                                                // get item with the LOWEST enchantment level  from the inventory...
                                                                // +0 is lowest by default...
                                                                if (itemToTake.getEnchantLevel() > 0)
                                                                {
                                                                        for (L2ItemInstance inventoryContent : inventoryContents)
                                                                        {
                                                                                if (inventoryContent.getEnchantLevel() < itemToTake.getEnchantLevel())
                                                                                {
                                                                                        itemToTake = inventoryContent;
                                                                                        // nothing will have enchantment less than 0. If a zero-enchanted
                                                                                        // item is found, just take it
                                                                                        if (itemToTake.getEnchantLevel() == 0)
                                                                                        {
                                                                                                break;
                                                                                        }
                                                                                }
                                                                        }
                                                                }

                                                                if (itemToTake.isEquipped())
                                                                {
                                                                        if (itemToTake.isAugmented())
                                                                        {
                                                                                itemToTake.getAugmentation().removeBoni(player);
                                                                        }
                                                                }

                                                                if (!player.destroyItem("Multisell", itemToTake.getObjectId(), 1, player.getTarget(), true))
                                                                        return;

                                                        }
                                                }
                                        }
                                }
                        }
                        else
                        {
                                if (e.getItemId() == 65336)
                                {
                                        int repCost = player.getClan().getReputationScore() - e.getItemCount();
                                        player.getClan().setReputationScore(repCost, true);
                                        player.sendPacket(new SystemMessage(SystemMessageId.S1_DEDUCTED_FROM_CLAN_REP).addNumber(e.getItemCount()));
                                        player.getClan().broadcastToOnlineMembers(new PledgeShowInfoUpdate(player.getClan()));
                                }
                                else
                                {
                                        player.reducePcBangScore(e.getItemCount() * _amount);
                                        player.sendPacket(new SystemMessage(SystemMessageId.USING_S1_PCPOINT).addNumber(e.getItemCount()));
                                }
                        }
                }
                // Generate the appropriate items
                for (MultiSellIngredient e : entry.getProducts())
                {
                        if (ItemTable.getInstance().createDummyItem(e.getItemId()).isStackable())
                        {
                                inv.addItem("Multisell["+_listId+"]" , e.getItemId(), (e.getItemCount() * _amount), player, player.getTarget());
                        }
View Full Code Here

Examples of com.l2jfrozen.gameserver.model.multisell.MultiSellEntry

        // example: If the template has an item worth 120aa, and the tax is 10%,
        // then from 120aa, take 5/6 so that is 100aa, apply the 10% tax in adena (10a)
        // so the final price will be 120aa and 10a!
        private MultiSellEntry prepareEntry(L2NpcInstance merchant, MultiSellEntry templateEntry, boolean applyTaxes, boolean maintainEnchantment, int enchantLevel)
        {
                MultiSellEntry newEntry = new MultiSellEntry();
                newEntry.setEntryId(templateEntry.getEntryId());
                int totalAdenaCount = 0;
                boolean hasIngredient = false;

                for (MultiSellIngredient ing : templateEntry.getIngredients())
                {
                        // Load the ingredient from the template
                        MultiSellIngredient newIngredient = new MultiSellIngredient(ing);

                        if (newIngredient.getItemId() == 57 && newIngredient.isTaxIngredient())
                        {
                                double taxRate = 0.0;

                                if (applyTaxes)
                                {
                                        if (merchant != null && merchant.getIsInTown())
                                        {
                                                taxRate = merchant.getCastle().getTaxRate();
                                        }
                                }

                                _transactionTax = (int) Math.round(newIngredient.getItemCount() * taxRate);
                                totalAdenaCount += _transactionTax;
                                continue; // Do not yet add this adena amount to the list as non-taxIngredient adena might be entered later (order not guaranteed)
                        }
                        else if (ing.getItemId() == 57) // && !ing.isTaxIngredient()
                        {
                                totalAdenaCount += newIngredient.getItemCount();
                                continue; // Do not yet add this adena amount to the list as taxIngredient adena might be entered later (order not guaranteed)
                        }
                        // If it is an armor/weapon, modify the enchantment level appropriately, if necessary
                        else if (maintainEnchantment)
                        {
                                L2Item tempItem = ItemTable.getInstance().createDummyItem(newIngredient.getItemId()).getItem();
                                if (tempItem instanceof L2Armor || tempItem instanceof L2Weapon)
                                {
                                        newIngredient.setEnchantmentLevel(enchantLevel);
                                        hasIngredient = true;
                                }
                        }

                        // finally, add this ingredient to the entry
                        newEntry.addIngredient(newIngredient);
                }
                // Next add the adena amount, if any
                if (totalAdenaCount > 0)
                {
                        newEntry.addIngredient(new MultiSellIngredient(57, totalAdenaCount, false, false));
                }

                // Now modify the enchantment level of products, if necessary
                for (MultiSellIngredient ing : templateEntry.getProducts())
                {
                        // Load the ingredient from the template
                        MultiSellIngredient newIngredient = new MultiSellIngredient(ing);

                        if (maintainEnchantment && hasIngredient)
                        {
                                // If it is an armor/weapon, modify the enchantment level appropriately
                                // (note, if maintain enchantment is "false" this modification will result to a +0)
                                L2Item tempItem = ItemTable.getInstance().createDummyItem(newIngredient.getItemId()).getItem();

                                if (tempItem instanceof L2Armor || tempItem instanceof L2Weapon)
                                {
                                        if (enchantLevel==0 && maintainEnchantment)
                                                enchantLevel = ing.getEnchantmentLevel();
                                        newIngredient.setEnchantmentLevel(enchantLevel);
                                }
                        }
                        newEntry.addProduct(newIngredient);
                }
                return newEntry;
        }
View Full Code Here

Examples of l2p.gameserver.model.base.MultiSellEntry

    list.setKeepEnchant(false);
    list.setNoKey(true);
    int entId = 1;
    for(String SELLPET : SELLPETS)
    {
      MultiSellEntry e = L2Multisell.parseEntryFromStr(SELLPET);
      if(e != null)
      {
        e.setEntryId(entId++);
        list.addEntry(e);
      }
    }
    if(list.getEntries().size() == 0)
    {
View Full Code Here

Examples of l2p.gameserver.model.base.MultiSellEntry

      }
      L2Item itm = ItemTable.getInstance().getTemplate(i);
      int price = getSARemovePrice(itm);
      if(item[ItemTable.WEX_SA1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA1], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(i, 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA2], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(i, 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA3], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(i, 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_SA1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA1], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA2], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA3], 1));
        if(price > 0)
        {
          e1.addIngredient(new MultiSellIngredient(5575, price));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        list.addEntry(e1);
      }
    }
  }
View Full Code Here

Examples of l2p.gameserver.model.base.MultiSellEntry

      {
        continue;
      }
      if(item[ItemTable.WEX_FOUNDATION] > 0 && item[ItemTable.WEX_RARE] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_FOUNDATION], 1));
        if(item[ItemTable.WEX_VARNISH_COUNT] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(12374, item[ItemTable.WEX_VARNISH_COUNT]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE], 1));
        list.addEntry(e1);
      }
    }
    int[][] armors = ItemTable.getInstance().getArmorEx();
    for(int i = 0; i < armors.length; i++)
    {
      int[] item = armors[i];
      if(item == null)
      {
        continue;
      }
      if(item[ItemTable.AEX_FOUNDATION] <= 0)
      {
        continue;
      }
      if(item[ItemTable.AEX_SEALED_RARE_1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
        if(item[ItemTable.AEX_VARNISH] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.AEX_SEALED_RARE_1], 1));
        list.addEntry(e1);
        if(item[ItemTable.AEX_SEALED_RARE_2] > 0)
        {
          MultiSellEntry e2 = new MultiSellEntry(entId++);
          e2.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
          if(item[ItemTable.AEX_VARNISH] > 0)
          {
            e2.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
          }
          e2.addProduct(new MultiSellIngredient(item[ItemTable.AEX_SEALED_RARE_2], 1));
          list.addEntry(e2);
        }
        if(item[ItemTable.AEX_SEALED_RARE_3] > 0)
        {
          MultiSellEntry e3 = new MultiSellEntry(entId++);
          e3.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
          if(item[ItemTable.AEX_VARNISH] > 0)
          {
            e3.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
          }
          e3.addProduct(new MultiSellIngredient(item[ItemTable.AEX_SEALED_RARE_3], 1));
          list.addEntry(e3);
        }
      }
      else if(item[ItemTable.AEX_UNSEALED_RARE_1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
        if(item[ItemTable.AEX_VARNISH] > 0)
        {
          e1.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
        }
        e1.addProduct(new MultiSellIngredient(item[ItemTable.AEX_UNSEALED_RARE_1], 1));
        list.addEntry(e1);
        if(item[ItemTable.AEX_UNSEALED_RARE_2] > 0)
        {
          MultiSellEntry e2 = new MultiSellEntry(entId++);
          e2.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
          if(item[ItemTable.AEX_VARNISH] > 0)
          {
            e2.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
          }
          e2.addProduct(new MultiSellIngredient(item[ItemTable.AEX_UNSEALED_RARE_2], 1));
          list.addEntry(e2);
        }
        if(item[ItemTable.AEX_UNSEALED_RARE_3] > 0)
        {
          MultiSellEntry e3 = new MultiSellEntry(entId++);
          e3.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_FOUNDATION], 1));
          if(item[ItemTable.AEX_VARNISH] > 0)
          {
            e3.addIngredient(new MultiSellIngredient(12374, item[ItemTable.AEX_VARNISH]));
          }
          e3.addProduct(new MultiSellIngredient(item[ItemTable.AEX_UNSEALED_RARE_3], 1));
          list.addEntry(e3);
        }
      }
    }
  }
View Full Code Here

Examples of l2p.gameserver.model.base.MultiSellEntry

      {
        continue;
      }
      if(item[ItemTable.WEX_PVP1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA1] > 0 ? item[ItemTable.WEX_SA1] : i, 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_PVP1], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_PVP2] > 0 && item[ItemTable.WEX_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA2], 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_PVP2], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_PVP3] > 0 && item[ItemTable.WEX_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_SA3], 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_PVP3], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP1] > 0 && (item[ItemTable.WEX_RARE_SA1] > 0 || item[ItemTable.WEX_RARE] > 0))
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA1] > 0 ? item[ItemTable.WEX_RARE_SA1] : item[ItemTable.WEX_RARE], 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP1], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP2] > 0 && item[ItemTable.WEX_RARE_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA2], 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP2], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP3] > 0 && item[ItemTable.WEX_RARE_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA3], 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP3], 1));
        list.addEntry(e1);
      }
    }
    int[][] armors = ItemTable.getInstance().getArmorEx();
    for(int i = 0; i < armors.length; i++)
    {
      int[] item = armors[i];
      if(item == null || item[ItemTable.AEX_PvP] <= 0)
      {
        continue;
      }
      L2Item itm = ItemTable.getInstance().getTemplate(item[ItemTable.AEX_UNSEALED_1] > 0 ? item[ItemTable.AEX_UNSEALED_1] : i);
      int[] price = getPvPArmorPrice(itm);
      if(price == null)
      {
        continue;
      }
      if(item[ItemTable.AEX_PvP] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(itm.getItemId(), 1));
        e1.addIngredient(new MultiSellIngredient(L2Item.ITEM_ID_FAME, price[0]));
        e1.addIngredient(new MultiSellIngredient(57, price[1]));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.AEX_PvP], 1));
        list.addEntry(e1);
      }
    }
  }
View Full Code Here

Examples of l2p.gameserver.model.base.MultiSellEntry

      {
        continue;
      }
      if(item[ItemTable.WEX_PVP1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_PVP1], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_SA1] > 0 ? item[ItemTable.WEX_SA1] : i, 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_PVP2] > 0 && item[ItemTable.WEX_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_PVP2], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_SA2], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_PVP3] > 0 && item[ItemTable.WEX_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_PVP3], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_SA3], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP1] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP1], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA1] > 0 ? item[ItemTable.WEX_RARE_SA1] : item[ItemTable.WEX_RARE], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP2] > 0 && item[ItemTable.WEX_RARE_SA2] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP2], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA2], 1));
        list.addEntry(e1);
      }
      if(item[ItemTable.WEX_RARE_PVP3] > 0 && item[ItemTable.WEX_RARE_SA3] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.WEX_RARE_PVP3], 1));
        e1.addProduct(new MultiSellIngredient(item[ItemTable.WEX_RARE_SA3], 1));
        list.addEntry(e1);
      }
    }
    int[][] armors = ItemTable.getInstance().getArmorEx();
    for(int i = 0; i < armors.length; i++)
    {
      int[] item = armors[i];
      if(item == null)
      {
        continue;
      }
      L2Item itm = ItemTable.getInstance().getTemplate(i);
      int[] price = getPvPArmorPrice(itm);
      if(price == null)
      {
        continue;
      }
      if(item[ItemTable.AEX_PvP] > 0)
      {
        MultiSellEntry e1 = new MultiSellEntry(entId++);
        e1.addIngredient(new MultiSellIngredient(item[ItemTable.AEX_PvP], 1));
        if(item[ItemTable.AEX_UNSEALED_1] > 0)
        {
          e1.addProduct(new MultiSellIngredient(item[ItemTable.AEX_UNSEALED_1], 1));
        }
        else
        {
          e1.addProduct(new MultiSellIngredient(i, 1));
        }
        list.addEntry(e1);
      }
    }
  }
View Full Code Here

Examples of l2p.gameserver.model.base.MultiSellEntry

      {
        for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
        {
          if("item".equalsIgnoreCase(d.getNodeName()))
          {
            MultiSellEntry e = parseEntry(d, id);
            if(e != null)
            {
              e.setEntryId(entId++);
              list.addEntry(e);
            }
          }
          else if("config".equalsIgnoreCase(d.getNodeName()))
          {
View Full Code Here

Examples of l2p.gameserver.model.base.MultiSellEntry

    return list;
  }

  protected MultiSellEntry parseEntry(Node n, int MultiSellId)
  {
    MultiSellEntry entry = new MultiSellEntry();
    l2p.util.Log.add(MultiSellId + " loading new entry", "multiselldebug");
    GArray<String> debuglist = new GArray<String>();
    for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
    {
      //l2p.util.Log.add(MultiSellId + " processing node " + d.getNodeName(), "multiselldebug");
      debuglist.add(d.getNodeName() + " " + d.getAttributes() + " " + d.getNodeName().hashCode() + " " + d.getNodeName().length());
      if(NODE_INGRIDIENT.equalsIgnoreCase(d.getNodeName()))
      {
        int id = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
        long count = Long.parseLong(d.getAttributes().getNamedItem("count").getNodeValue());
        int enchant = 0, element = L2Item.ATTRIBUTE_NONE, elementValue = 0;
        if(d.getAttributes().getNamedItem("enchant") != null)
        {
          enchant = Integer.parseInt(d.getAttributes().getNamedItem("enchant").getNodeValue());
        }
        if(d.getAttributes().getNamedItem("element") != null)
        {
          element = Integer.parseInt(d.getAttributes().getNamedItem("element").getNodeValue());
        }
        if(d.getAttributes().getNamedItem("elementValue") != null)
        {
          elementValue = Integer.parseInt(d.getAttributes().getNamedItem("elementValue").getNodeValue());
        }
        l2p.util.Log.add(MultiSellId + " loaded ingredient " + id + " count " + count, "multiselldebug");
        entry.addIngredient(new MultiSellIngredient(id, count, enchant, element, elementValue));
      }
      else if(NODE_PRODUCTION.equalsIgnoreCase(d.getNodeName()))
      {
        int id = Integer.parseInt(d.getAttributes().getNamedItem("id").getNodeValue());
        long count = Long.parseLong(d.getAttributes().getNamedItem("count").getNodeValue());
        int enchant = 0, element = L2Item.ATTRIBUTE_NONE, elementValue = 0;
        if(d.getAttributes().getNamedItem("enchant") != null)
        {
          enchant = Integer.parseInt(d.getAttributes().getNamedItem("enchant").getNodeValue());
        }
        if(d.getAttributes().getNamedItem("element") != null)
        {
          element = Integer.parseInt(d.getAttributes().getNamedItem("element").getNodeValue());
        }
        if(d.getAttributes().getNamedItem("elementValue") != null)
        {
          elementValue = Integer.parseInt(d.getAttributes().getNamedItem("elementValue").getNodeValue());
        }
        if(!Config.ALT_ALLOW_SHADOW_WEAPONS && id > 0)
        {
          L2Item item = ItemTable.getInstance().getTemplate(id);
          if(item != null && item.isShadowItem() && item.isWeapon() && !Config.ALT_ALLOW_SHADOW_WEAPONS)
          {
            return null;
          }
        }
        l2p.util.Log.add(MultiSellId + " loaded product " + id + " count " + count, "multiselldebug");
        entry.addProduct(new MultiSellIngredient(id, count, enchant, element, elementValue));
      }
      else
      {
        l2p.util.Log.add(MultiSellId + " skipping node " + d.getNodeName(), "multiselldebug");
      }
    }
    if(entry.getIngredients().isEmpty() || entry.getProduction().isEmpty())
    {
      l2p.util.Log.add(MultiSellId + " wrong node", "multiselldebug");
      l2p.util.Log.add(MultiSellId + " LIST: " + debuglist.toString(), "multiselldebug");
      for(Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
      {
        l2p.util.Log.add(d.getNodeName() + " " + d.getAttributes() + " " + d.getNodeName().hashCode() + " " + d.getNodeName().length() + " IsProduction: " + NODE_PRODUCTION.equalsIgnoreCase(d.getNodeName()), "multiselldebug");
      }
      return null;
    }
    if(entry.getIngredients().size() == 1 && entry.getProduction().size() == 1 && entry.getIngredients().get(0).getItemId() == 57)
    {
      L2Item item = ItemTable.getInstance().getTemplate(entry.getProduction().get(0).getItemId());
      if(item == null)
      {
        _log.warning("WARNING!!! MultiSell [" + MultiSellId + "] Production [" + entry.getProduction().get(0).getItemId() + "] is null");
        return null;
      }
      if(MultiSellId < 70000 || MultiSellId > 70010) // Все кроме GM Shop
      {
        if(item.getReferencePrice() > entry.getIngredients().get(0).getItemCount())
        {
          _log.warning("WARNING!!! MultiSell [" + MultiSellId + "] Production '" + item.getName() + "' [" + entry.getProduction().get(0).getItemId() + "] price is lower than referenced | " + item.getReferencePrice() + " > " + entry.getIngredients().get(0).getItemCount());
        }
      }
      //return null;
    }
    return entry;
View Full Code Here

Examples of l2p.gameserver.model.base.MultiSellEntry

    long[] ingredient, production;
    if((ingredient = parseItemIdAndCount(a[0])) == null || (production = parseItemIdAndCount(a[1])) == null)
    {
      return null;
    }
    MultiSellEntry entry = new MultiSellEntry();
    entry.addIngredient(new MultiSellIngredient((int) ingredient[0], ingredient[1]));
    entry.addProduct(new MultiSellIngredient((int) production[0], production[1]));
    return entry;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.