Package l2p.gameserver.model.items

Examples of l2p.gameserver.model.items.L2ItemInstance


          Inventory inv = ((L2Playable) activeChar).getInventory();
          if(inv == null)
          {
            inv = player.getInventory();
          }
          L2ItemInstance requiredItems = inv.getItemByItemId(_itemConsumeId[i]);
          if(requiredItems == null || requiredItems.getCount() < _itemConsume[i])
          {
            if(activeChar == player)
            {
              player.sendPacket(Msg.INCORRECT_ITEM_COUNT);
            }
View Full Code Here


    {
      return;
    }
    L2Player player = _inv.getOwner().getPlayer();
    // checks if player worns chest item
    L2ItemInstance chestItem = _inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST);
    if(chestItem == null)
    {
      return;
    }
    // checks if there is armorset for chest item that player worns
    L2ArmorSet armorSet = ArmorSetsTable.getInstance().getSet(chestItem.getItemId());
    if(armorSet == null)
    {
      return;
    }
    boolean update = false;
View Full Code Here

      removeSkillId2 = armorSet.getShieldSkill();
      removeSkillId3 = armorSet.getEnchant6skill();
    }
    else
    {
      L2ItemInstance chestItem = _inv.getPaperdollItem(Inventory.PAPERDOLL_CHEST);
      if(chestItem == null)
      {
        return;
      }
      L2ArmorSet armorSet = ArmorSetsTable.getInstance().getSet(chestItem.getItemId());
      if(armorSet == null)
      {
        return;
      }
      if(armorSet.containItem(slot, item.getItemId())) // removed part of set
View Full Code Here

      {
        return;
      }
      if(player.isTerritoryFlagEquipped())
      {
        L2ItemInstance flag = player.getActiveWeaponInstance();
        if(flag != null && flag.getCustomType1() != 77) // 77 это эвентовый флаг
        {
          L2TerritoryFlagInstance flagNpc = TerritorySiege.getNpcFlagByItemId(flag.getItemId());
          flagNpc.returnToCastle(player);
        }
      }
    }
View Full Code Here

            return;
        }
        if (Config.DROP_COUNTER) {
            lastAttacker.incrementDropCounter(itemId, itemCount);
        }
        L2ItemInstance item;
        for (long i = 0; i < itemCount; i++) {
            item = ItemTable.getInstance().createItem(itemId);
            // Set the Item quantity dropped if L2ItemInstance is stackable
            if (item.isStackable()) {
                i = itemCount; // Set so loop won't happent again
                item.setCount(itemCount); // Set item count
            }
            if (isRaid() || this instanceof L2ReflectionBossInstance) {
                SystemMessage sm;
                if (itemId == 57) {
                    sm = new SystemMessage(SystemMessage.S1_DIED_AND_HAS_DROPPED_S2_ADENA);
                    sm.addString(getName());
                    sm.addNumber(item.getCount());
                } else {
                    sm = new SystemMessage(SystemMessage.S1_DIED_AND_DROPPED_S3_S2);
                    sm.addString(getName());
                    sm.addItemName(itemId);
                    sm.addNumber(item.getCount());
                }
                broadcastPacket(sm);
            }
            lastAttacker.doAutoLootOrDrop(item, this);
        }
View Full Code Here

            player.reduceAdena(price, true);
            sm = new SystemMessage(SystemMessage.ACQUIRED__S1_S2);
            sm.addNumber(lotonumber);
            sm.addItemName(4442);
            player.sendPacket(sm);
            L2ItemInstance item = ItemTable.getInstance().createItem(4442);
            item.setCustomType1(lotonumber);
            item.setEnchantLevel(enchant);
            item.setCustomType2(type2);
            player.getInventory().addItem(item);
            Log.LogItem(player, Log.BuyItem, item);
            html.setHtml("<html><body>Lottery Ticket Seller:<br>Thank you for playing the lottery<br>The winners will be announced at 7:00 pm <br><center><a action=\"bypass -h npc_%objectId%_Chat 0\">Back</a></center></body></html>");
        } else if (val == 23) // 23 - current lottery jackpot
        {
            filename = getHtmlPath(npcId, 3);
            html.setFile(filename);
        } else if (val == 24) {
            filename = getHtmlPath(npcId, 4);
            html.setFile(filename);
            int lotonumber = LotteryManager.getInstance().getId();
            String message = "";
            for (L2ItemInstance item : player.getInventory().getItems()) {
                if (item == null) {
                    continue;
                }
                if (item.getItemId() == 4442 && item.getCustomType1() < lotonumber) {
                    message = message + "<a action=\"bypass -h npc_%objectId%_Loto " + item.getObjectId() + "\">"
                            + item.getCustomType1() + " Event Number ";
                    int[] numbers = LotteryManager.getInstance().decodeNumbers(item.getEnchantLevel(),
                            item.getCustomType2());
                    for (int i = 0; i < 5; i++) {
                        message += numbers[i] + " ";
                    }
                    int[] check = LotteryManager.getInstance().checkTicket(item);
                    if (check[0] > 0) {
                        switch (check[0]) {
                        case 1:
                            message += "- 1st Prize";
                            break;
                        case 2:
                            message += "- 2nd Prize";
                            break;
                        case 3:
                            message += "- 3th Prize";
                            break;
                        case 4:
                            message += "- 4th Prize";
                            break;
                        }
                        message += " " + check[1] + "a.";
                    }
                    message += "</a><br>";
                }
            }
            if ("".equals(message)) {
                message += "There is no winning lottery ticket...<br>";
            }
            html.replace("%result%", message);
        } else if (val == 25) {
            filename = getHtmlPath(npcId, 2);
            html.setFile(filename);
        } else if (val > 25) {
            int lotonumber = LotteryManager.getInstance().getId();
            L2ItemInstance item = player.getInventory().getItemByObjectId(val);
            if (item == null || item.getItemId() != 4442 || item.getCustomType1() >= lotonumber) {
                return;
            }
            int[] check = LotteryManager.getInstance().checkTicket(item);
            player.sendPacket(SystemMessage.removeItems(4442, 1));
            int adena = check[1];
View Full Code Here

    L2Player partyLeader = associatedParty.getPartyLeader();
    if(partyLeader == null)
    {
      return;
    }
    L2ItemInstance bloodOfferings = ItemTable.getInstance().createItem(SevenSignsFestival.FESTIVAL_BLOOD_OFFERING);
    int mult = 1;
    if(getChampion() == 1)
    {
      mult = 12;
    }
    else if(getChampion() == 2)
    {
      mult = 75;
    }
    bloodOfferings.setCount(_bonusMultiplier * mult);
    partyLeader.getInventory().addItem(bloodOfferings);
    partyLeader.sendPacket(SystemMessage.obtainItems(SevenSignsFestival.FESTIVAL_BLOOD_OFFERING, _bonusMultiplier * mult, 0));
  }
View Full Code Here

        return;
      }
      int itemId = Integer.parseInt(command.substring(9).trim());
      int reputation = 0;
      long itemCount = 0;
      L2ItemInstance item = player.getInventory().getItemByItemId(itemId);
      long playerItemCount = item == null ? 0 : item.getCount();
      switch(itemId)
      {
        case 9911: // Blood alliance
          reputation = Config.ClanTraderBloodAllianceReputation;
          itemCount = Config.ClanTraderBloodAllianceItemCount;
View Full Code Here

      cha.sendPacket(Msg.YOU_CANNOT_SEND_A_MAIL_TO_YOURSELF);
      return;
    }
    for(int i = 0; i < _attItems.length; i++)
    {
      L2ItemInstance item = cha.getInventory().getItemByObjectId(_attItems[i]);
      if(item == null || item.getCount() < _attItemsQ[i] || (item.getItemId() == 57 && item.getCount() + _price < _attItemsQ[i] + _price) || !item.canBeTraded(cha))
      {
        cha.sendPacket(Msg.THE_ITEM_THAT_YOU_RE_TRYING_TO_SEND_CANNOT_BE_FORWARDED_BECAUSE_IT_ISN_T_PROPER);
        return;
      }
    }
    long curTime = System.currentTimeMillis();
    Long lastMailTime = (Long) cha.getProperty(PropertyCollection.MailSent);
    if(lastMailTime != null && lastMailTime + (cha.getLevel() >= 20 ? 60000L : 300000L) > curTime)
    {
      cha.sendMessage("Mail is allowed once per " + (cha.getLevel() >= 20 ? "minute." : "5 minutes."));
      return;
    }
    cha.addProperty(PropertyCollection.MailSent, curTime);
    if(_price > 0)
    {
      String tradeBan = cha.getVar("tradeBan");
      if(tradeBan != null && (tradeBan.equals("-1") || Long.parseLong(tradeBan) >= System.currentTimeMillis()))
      {
        cha.sendMessage("Your trade is banned! Expires: " + (tradeBan.equals("-1") ? "never" : Util.formatTime((Long.parseLong(tradeBan) - System.currentTimeMillis()) / 1000)) + ".");
        return;
      }
    }
    // ищем цель и проверяем блоклисты
    if(cha.isInBlockList(_targetName)) // тем кто в блоклисте не шлем
    {
      cha.sendPacket(new SystemMessage(SystemMessage.YOU_HAVE_BLOCKED_C1).addString(_targetName));
      return;
    }
    int targetId;
    L2Player target = L2World.getPlayer(_targetName);
    if(target != null)
    {
      targetId = target.getObjectId();
      if(target.isInBlockList(cha)) // цель заблокировала отправителя
      {
        cha.sendPacket(new SystemMessage(SystemMessage.S1_HAS_BLOCKED_YOU_YOU_CANNOT_SEND_MAIL_TO_S1_).addString(_targetName));
        return;
      }
    }
    else
    {
      targetId = Util.GetCharIDbyName(_targetName);
      if(targetId > 0 && mysql.simple_get_int("target_Id", "character_blocklist", "obj_Id=" + targetId + " AND target_Id=" + cha.getObjectId()) > 0) // цель заблокировала отправителя
      {
        cha.sendPacket(new SystemMessage(SystemMessage.S1_HAS_BLOCKED_YOU_YOU_CANNOT_SEND_MAIL_TO_S1_).addString(_targetName));
        return;
      }
    }
    if(targetId == 0) // не нашли цель?
    {
      cha.sendPacket(Msg.WHEN_THE_RECIPIENT_DOESN_T_EXIST_OR_THE_CHARACTER_HAS_BEEN_DELETED_SENDING_MAIL_IS_NOT_POSSIBLE);
      return;
    }
    int expiretime = (_messageType == 1 ? 12 : 360) * 3600 + (int) (System.currentTimeMillis() / 1000);
    long serviceCost = 100 + _attItems.length * 1000;
    if(cha.getAdena() < serviceCost)
    {
      cha.sendPacket(Msg.YOU_CANNOT_FORWARD_BECAUSE_YOU_DON_T_HAVE_ENOUGH_ADENA);
      return;
    }
    for(int i = 0; i < _attItems.length; i++)
    {
      L2ItemInstance item = cha.getInventory().getItemByObjectId(_attItems[i]);
      if(item == null || item.getCount() < _attItemsQ[i] || item.getItemId() == 57 && item.getCount() < _attItemsQ[i] + serviceCost)
      {
        cha.sendPacket(Msg.THE_ITEM_THAT_YOU_RE_TRYING_TO_SEND_CANNOT_BE_FORWARDED_BECAUSE_IT_ISN_T_PROPER);
        return;
      }
    }
View Full Code Here

   * Проверяет, есть ли у игрока player в наличии необходимое количество вещей
   */
  public static boolean validateTrade(L2Player player, Collection<TradeItem> items)
  {
    Inventory playersInv = player.getInventory();
    L2ItemInstance playerItem;
    synchronized(items)
    {
      for(TradeItem item : items)
      {
        playerItem = playersInv.getItemByObjectId(item.getObjectId());
        if(playerItem == null || playerItem.getCount() < item.getCount() || playerItem.getEnchantLevel() < item.getEnchantLevel() || !playerItem.canBeTraded(player))
        {
          return false;
        }
      }
      // TODO: добавить проверку на перевес после трейда с учетом отданного
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.items.L2ItemInstance

Copyright © 2018 www.massapicom. 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.