Package l2p.gameserver.model.items

Examples of l2p.gameserver.model.items.L2ItemInstance$LifeTimeTask


  @Override
  public void useSkill(L2Character activeChar, GArray<L2Character> targets)
  {
    final L2Player player = (L2Player) activeChar;
    final L2ItemInstance item = activeChar.getActiveWeaponInstance();
    if(item == null)
    {
      return;
    }
    int itemtoexchange = convertWeaponId(item.getItemId());
    if(itemtoexchange == 0) // how can it be?
    {
      return;
    }
    player.getInventory().unEquipItemInBodySlotAndNotify(item.getBodyPart(), item);
    player.sendPacket(new InventoryUpdate().addRemovedItem(item));
    item.setItemId(itemtoexchange);
    player.sendPacket(new ShortCutInit(player));
    for(int shotId : player.getAutoSoulShot())
    {
      player.sendPacket(new ExAutoSoulShot(shotId, true));
    }
View Full Code Here


    return true;
  }

  private void dropItem(L2NpcInstance npc, int itemId, int count)
  {
    L2ItemInstance item = ItemTable.getInstance().createItem(itemId);
    item.setCount(count);
    item.dropMe(npc, npc.getLoc());
  }
View Full Code Here

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

    _money = player.getAdena();
    _castle = castleId;
    _procureList = CastleManager.getInstance().getCastleByIndex(_castle).getCropProcure(0);
    for(CropProcure c : _procureList)
    {
      L2ItemInstance item = player.getInventory().getItemByItemId(c.getId());
      if(item != null && c.getAmount() > 0)
      {
        _sellList.put(item, c.getAmount());
      }
    }
View Full Code Here

    public void calc(Env env) {
      if (env.value == 0) {
        return;
      }
      L2Character cha = env.character;
      L2ItemInstance shld = ((L2Player) cha).getInventory()
          .getPaperdollItem(Inventory.PAPERDOLL_LHAND);
      if (shld == null || shld.getItemType() != WeaponType.NONE) {
        return;
      }
      env.value *= DEXbonus[cha.getDEX()];
    }
View Full Code Here

          {
            L2ItemInstance[] list = inv.getAllItemsById(ingridientItemId);
            // Если энчант имеет значение - то ищем вещи с точно таким энчантом
            if(_keepenchant)
            {
              L2ItemInstance itemToTake = null;
              for(L2ItemInstance itm : list)
              {
                if((itm.getEnchantLevel() == _enchant || itm.getItem().getType2() > 2) && !_items.contains(new ItemData(itm.getItemId(), itm.getCount(), itm)) && !itm.isShadowItem() && !itm.isTemporalItem() && (itm.getCustomFlags() & L2ItemInstance.FLAG_NO_TRADE) != L2ItemInstance.FLAG_NO_TRADE)
                {
                  itemToTake = itm;
                  if(itm.getAttributeElement() != L2Item.ATTRIBUTE_NONE)
                  {
                    _enchantAttr = itm.getAttributeElement();
                    _enchantAttrVal = itm.getAttributeElementValue();
                  }
                  break;
                }
              }
              if(itemToTake == null)
              {
                activeChar.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_REQUIRED_ITEMS);
                return;
              }
              if(!checkItem(itemToTake, activeChar))
              {
                activeChar.sendActionFailed();
                return;
              }
              if(itemToTake.getAugmentation() != null)
              {
                augmentation = itemToTake.getAugmentation();
              }
              _items.add(new ItemData(itemToTake.getItemId(), 1, itemToTake));
            }
            // Если энчант не обрабатывается берется вещь с наименьшим энчантом
            else
            {
              L2ItemInstance itemToTake = null;
              for(L2ItemInstance itm : list)
              {
                if(!_items.contains(new ItemData(itm.getItemId(), itm.getCount(), itm)) && (itemToTake == null || itm.getEnchantLevel() < itemToTake.getEnchantLevel()) && !itm.isShadowItem() && !itm.isTemporalItem() && (itm.getCustomFlags() & L2ItemInstance.FLAG_NO_TRADE) != L2ItemInstance.FLAG_NO_TRADE && checkItem(itm, activeChar))
                {
                  itemToTake = itm;
                  if(itemToTake.getEnchantLevel() == 0)
                  {
                    break;
                  }
                }
              }
              if(itemToTake == null)
              {
                activeChar.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_REQUIRED_ITEMS);
                return;
              }
              if(itemToTake.getAugmentation() != null)
              {
                augmentation = itemToTake.getAugmentation();
              }
              _items.add(new ItemData(itemToTake.getItemId(), 1, itemToTake));
            }
          }
        }
        else if(ingridientItemId == L2Item.ITEM_ID_CLAN_REPUTATION_SCORE)
        {
          if(activeChar.getClan() == null)
          {
            activeChar.sendPacket(Msg.YOU_ARE_NOT_A_CLAN_MEMBER);
            return;
          }
          if(activeChar.getClan().getReputationScore() < total_amount)
          {
            activeChar.sendPacket(Msg.THE_CLAN_REPUTATION_SCORE_IS_TOO_LOW);
            return;
          }
          if(activeChar.getClan().getLeaderId() != activeChar.getObjectId())
          {
            activeChar.sendPacket(new SystemMessage(SystemMessage.S1_IS_NOT_A_CLAN_LEADER).addString(activeChar.getName()));
            return;
          }
          _items.add(new ItemData(ingridientItemId, total_amount, null));
        }
        else if(ingridientItemId == L2Item.ITEM_ID_PC_BANG_POINTS)
        {
          if(activeChar.getPcBangPoints() < total_amount)
          {
            activeChar.sendPacket(Msg.YOU_ARE_SHORT_OF_ACCUMULATED_POINTS);
            return;
          }
          _items.add(new ItemData(ingridientItemId, total_amount, null));
        }
        else if(ingridientItemId == L2Item.ITEM_ID_FAME)
        {
          if(activeChar.getFame() < total_amount)
          {
            activeChar.sendPacket(Msg.NOT_ENOUGH_FAME_POINTS);
            return;
          }
          _items.add(new ItemData(ingridientItemId, total_amount, null));
        }
        else
        {
          if(ingridientItemId == 57)
          {
            totalAdenaCost += ingridientItemCount * _amount;
          }
          L2ItemInstance item = inv.getItemByItemId(ingridientItemId);
          if(item == null || item.getCount() < total_amount)
          {
            activeChar.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_REQUIRED_ITEMS);
            return;
          }
          _items.add(new ItemData(item.getItemId(), total_amount, item));
        }
        if(activeChar.getAdena() < totalAdenaCost)
        {
          activeChar.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
          return;
        }
      }
      for(ItemData id : _items)
      {
        long count = id.getCount();
        if(count > 0)
        {
          L2ItemInstance item = id.getItem();
          if(item != null)
          {
            activeChar.sendPacket(SystemMessage.removeItems(item.getItemId(), count));
            if(logExchange)
            {
              msgb.append("\t<destroy id=").append(item.getItemId()).append(" oid=").append(item.getObjectId()).append(" count=").append(count).append(">\n");
            }
            if(item.isEquipped())
            {
              inv.unEquipItemInSlot(item.getEquipSlot());
            }
            inv.destroyItem(item, count, true);
          }
          else if(id.getId() == L2Item.ITEM_ID_CLAN_REPUTATION_SCORE)
          {
            activeChar.getClan().incReputation((int) -count, false, "MultiSell" + _listId);
            activeChar.sendPacket(new SystemMessage(SystemMessage.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_REPUTATION_SCORE).addNumber(count));
          }
          else if(id.getId() == L2Item.ITEM_ID_PC_BANG_POINTS)
          {
            activeChar.setPcBangPoints(activeChar.getPcBangPoints() - (int) count);
            activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_ARE_USING_S1_POINT).addNumber(count), new ExPCCafePointInfo(activeChar));
          }
          else if(id.getId() == L2Item.ITEM_ID_FAME)
          {
            activeChar.setFame(activeChar.getFame() - (int) count, "MultiSell" + _listId);
            activeChar.sendPacket(new SystemMessage(SystemMessage.S2_S1_HAS_DISAPPEARED).addNumber(count).addString("Fame"));
          }
        }
      }
      if(tax > 0 && !_notax)
      {
        if(castle != null)
        {
          activeChar.sendMessage("Tax: " + tax);
          if(merchant != null && merchant.getReflection().getId() == 0)
          {
            castle.addToTreasury(tax, true, false);
            Log.add(castle.getName() + "|" + tax + "|Multisell", "treasury");
          }
        }
      }
      for(MultiSellIngredient in : productId)
      {
        if(in.getItemId() <= 0)
        {
          if(in.getItemId() == L2Item.ITEM_ID_CLAN_REPUTATION_SCORE)
          {
            activeChar.getClan().incReputation((int) (in.getItemCount() * _amount), false, "MultiSell" + _listId);
            activeChar.sendPacket(new SystemMessage(SystemMessage.YOUR_CLAN_HAS_ADDED_1S_POINTS_TO_ITS_CLAN_REPUTATION_SCORE).addNumber(in.getItemCount() * _amount));
          }
          else if(in.getItemId() == L2Item.ITEM_ID_PC_BANG_POINTS)
          {
            activeChar.setPcBangPoints(activeChar.getPcBangPoints() + (int) (in.getItemCount() * _amount));
            activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_ACQUIRED_S1_PC_BANG_POINT).addNumber(in.getItemCount() * _amount), new ExPCCafePointInfo(activeChar));
          }
          else if(in.getItemId() == L2Item.ITEM_ID_FAME)
          {
            activeChar.setFame(activeChar.getFame() + (int) (in.getItemCount() * _amount), "MultiSell" + _listId);
          }
        }
        else if(ItemTable.getInstance().getTemplate(in.getItemId()).isStackable())
        {
          L2ItemInstance product = ItemTable.getInstance().createItem(in.getItemId());
          double total = in.getItemCount() * _amount;
          if(total < 0 || total > Long.MAX_VALUE)
          {
            activeChar.sendActionFailed();
            return;
          }
          product.setCount((long) total);
          activeChar.sendPacket(SystemMessage.obtainItems(product));
          if(logExchange)
          {
            msgb.append("\t<add id=").append(product.getItemId()).append(" count=").append(product.getCount()).append(">\n");
          }
          inv.addItem(product);
        }
        else
        {
          for(int i = 0; i < _amount; i++)
          {
            L2ItemInstance product = inv.addItem(ItemTable.getInstance().createItem(in.getItemId()));
            if(_keepenchant)
            {
              product.setEnchantLevel(_enchant);
              if(_enchantAttr != L2Item.ATTRIBUTE_NONE)
              {
                product.setAttributeElement(_enchantAttr, _enchantAttrVal, true);
              }
            }
            if(in.getElementValue() > 0)
            {
              product.setAttributeElement(in.getElement(), in.getElementValue(), true);
            }
            if(augmentation != null && product.isEquipable() && product.canBeEnchanted() && !product.isRaidAccessory())
            {
              product.setAugmentation(augmentation);
            }
            if(logExchange)
            {
              msgb.append("\t<add id=").append(product.getItemId()).append(" oid=").append(product.getObjectId()).append(" count=").append(product.getCount()).append(">\n");
            }
            activeChar.sendPacket(SystemMessage.obtainItems(product));
          }
        }
      }
View Full Code Here

    boolean isAutoSoulShot = false;
    if(player.getAutoSoulShot().contains(FishshotId))
    {
      isAutoSoulShot = true;
    }
    L2ItemInstance weaponInst = player.getActiveWeaponInstance();
    L2Weapon weaponItem = player.getActiveWeaponItem();
    if(weaponInst == null || weaponItem.getItemType() != WeaponType.ROD)
    {
      if(!isAutoSoulShot)
      {
        player.sendPacket(Msg.CANNOT_USE_SOULSHOTS);
      }
      return;
    }
    if(item.getCount() < 1)
    {
      if(isAutoSoulShot)
      {
        player.removeAutoSoulShot(FishshotId);
        player.sendPacket(new ExAutoSoulShot(FishshotId, false), new SystemMessage(SystemMessage.THE_AUTOMATIC_USE_OF_S1_WILL_NOW_BE_CANCELLED).addString(item.getName()));
        return;
      }
      player.sendPacket(Msg.NOT_ENOUGH_SPIRITSHOTS);
      return;
    }
    // spiritshot is already active
    if(weaponInst.getChargedFishshot())
    {
      return;
    }
    int grade = weaponItem.getCrystalType().externalOrdinal;
    if(grade == 0 && FishshotId != 6535 || grade == 1 && FishshotId != 6536 || grade == 2 && FishshotId != 6537 || grade == 3 && FishshotId != 6538 || grade == 4 && FishshotId != 6539 || grade == 5 && FishshotId != 6540)
    {
      if(isAutoSoulShot)
      {
        return;
      }
      player.sendPacket(Msg.THIS_FISHING_SHOT_IS_NOT_FIT_FOR_THE_FISHING_POLE_CRYSTAL);
      return;
    }
    weaponInst.setChargedFishshot(true);
    player.getInventory().destroyItem(item.getObjectId(), 1, false);
    player.sendPacket(Msg.POWER_OF_MANA_ENABLED);
    player.broadcastPacket(new MagicSkillUse(player, player, _skillIds[grade], 1, 0, 0));
  }
View Full Code Here

    if(door.key <= 0 || item.getItemId() != door.key) // ключ не подходит к двери
    {
      player.sendPacket(Msg.YOU_ARE_UNABLE_TO_UNLOCK_THE_DOOR);
      return;
    }
    L2ItemInstance ri = player.getInventory().destroyItem(item, 1, true);
    player.sendPacket(SystemMessage.removeItems(ri.getItemId(), 1), new SystemMessage("l2p.gameserver.skills.skillclasses.Unlock.Success", player));
    door.openMe();
    door.onOpen();
  }
View Full Code Here

      newChar.setTitle("");
    }
    ItemTable itemTable = ItemTable.getInstance();
    for(L2Item i : template.getItems())
    {
      L2ItemInstance item = itemTable.createItem(i.getItemId());
      newChar.getInventory().addItem(item);
      if(item.getItemId() == 5588) // tutorial book
      {
        newChar.registerShortCut(new L2ShortCut(11, 0, L2ShortCut.TYPE_ITEM, item.getObjectId(), -1));
      }
      if(item.isEquipable() && (newChar.getActiveWeaponItem() == null || item.getItem().getType2() != L2Item.TYPE2_WEAPON))
      {
        newChar.getInventory().equipItem(item, false);
      }
    }
    // Scroll of Escape: Kamael Village
    L2ItemInstance item = itemTable.createItem(9716);
    item.setCount(5);
    newChar.getInventory().addItem(item);
    // Adventurer's Scroll of Escape
    item = itemTable.createItem(10650);
    item.setCount(10);
    newChar.getInventory().addItem(item);
    for(L2SkillLearn skill : SkillTreeTable.getInstance().getAvailableSkills(newChar, newChar.getClassId()))
    {
      newChar.addSkill(SkillTable.getInstance().getInfo(skill.id, skill.skillLevel), true);
    }
View Full Code Here

        }
        else
        {
          continue;
        }
        L2ItemInstance item = ItemTable.getInstance().createItem(_minId > 0 ? Rnd.get(_minId, _maxId) : _itemId);
        final int count = Rnd.get(_minCount, _maxCount);
        item.setCount(count);
        activeChar.sendPacket(SystemMessage.obtainItems(item));
        item = inventory.addItem(item);
        activeChar.sendChanges();
        getEffects(activeChar, target, getActivateRate() > 0, false);
      }
View Full Code Here

TOP

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

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.