Package lineage2.gameserver.model.items

Examples of lineage2.gameserver.model.items.ItemInstance$FuncDefence


      player.sendPacket(ExPutEnchantTargetItemResult.FAIL);
      player.setEnchantScroll(null);
      return;
    }
    PcInventory inventory = player.getInventory();
    ItemInstance itemToEnchant = inventory.getItemByObjectId(_objectId);
    ItemInstance scroll = player.getEnchantScroll();
    if ((itemToEnchant == null) || (scroll == null))
    {
      player.sendPacket(ExPutEnchantTargetItemResult.FAIL);
      player.setEnchantScroll(null);
      return;
    }
    Log.add(player.getName() + "|Trying to put enchant|" + itemToEnchant.getItemId() + "|+" + itemToEnchant.getEnchantLevel() + "|" + itemToEnchant.getObjectId(), "enchants");
    EnchantScrollInfo esi = EnchantScrollManager.getScrollInfo(scroll.getItemId());
    if (esi == null)
    {
      player.sendActionFailed();
      return;
    }
    if (!checkItem(itemToEnchant, esi))
    {
      player.sendPacket(ExPutEnchantTargetItemResult.FAIL);
      player.sendPacket(SystemMsg.INAPPROPRIATE_ENCHANT_CONDITIONS);
      player.setEnchantScroll(null);
      return;
    }
    if ((scroll = inventory.getItemByObjectId(scroll.getObjectId())) == null)
    {
      player.sendPacket(ExPutEnchantTargetItemResult.FAIL);
      player.setEnchantScroll(null);
      return;
    }
View Full Code Here


  private boolean canGiveReward()
  {
    int FreeInvSlots = st.getPlayer().getInventoryLimit() - st.getPlayer().getInventory().getSize();
    for (Integer itemId : rewards.keySet())
    {
      ItemInstance item = st.getPlayer().getInventory().getItemByItemId(itemId);
      if ((item == null) || !item.isStackable())
      {
        FreeInvSlots--;
      }
    }
    return FreeInvSlots > 0;
View Full Code Here

    if (activeChar == null)
    {
      return;
    }
    activeChar.setActive();
    ItemInstance item = activeChar.getInventory().getItemByObjectId(_objectId);
    if (item == null)
    {
      activeChar.sendActionFailed();
      return;
    }
    int itemId = item.getItemId();
    if (activeChar.isInStoreMode())
    {
      if (PetDataTable.isPetControlItem(item))
      {
        activeChar.sendPacket(SystemMsg.YOU_CANNOT_SUMMON_DURING_A_TRADE_OR_WHILE_USING_A_PRIVATE_STORE);
      }
      else
      {
        activeChar.sendPacket(SystemMsg.YOU_MAY_NOT_USE_ITEMS_IN_A_PRIVATE_STORE_OR_PRIVATE_WORK_SHOP);
      }
      return;
    }
    if (activeChar.isFishing() && ((itemId < 6535) || (itemId > 6540)))
    {
      activeChar.sendPacket(SystemMsg.YOU_CANNOT_DO_THAT_WHILE_FISHING_2);
      return;
    }
    if (activeChar.isSharedGroupDisabled(item.getTemplate().getReuseGroup()))
    {
      activeChar.sendReuseMessage(item);
      return;
    }
    if (!item.getTemplate().testCondition(activeChar, item))
    {
      return;
    }
    if (activeChar.getInventory().isLockedItem(item))
    {
      return;
    }
    if (item.getTemplate().isForPet())
    {
      activeChar.sendPacket(SystemMsg.YOU_MAY_NOT_EQUIP_A_PET_ITEM);
      return;
    }
    if (Config.ALT_IMPROVED_PETS_LIMITED_USE && activeChar.isMageClass() && (item.getItemId() == 10311))
    {
      activeChar.sendPacket(new SystemMessage2(SystemMsg.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS).addItemName(itemId));
      return;
    }
    if (Config.ALT_IMPROVED_PETS_LIMITED_USE && !activeChar.isMageClass() && (item.getItemId() == 10313))
    {
      activeChar.sendPacket(new SystemMessage2(SystemMsg.S1_CANNOT_BE_USED_DUE_TO_UNSUITABLE_TERMS).addItemName(itemId));
      return;
    }
    if (activeChar.isOutOfControl())
    {
      activeChar.sendActionFailed();
      return;
    }
    int[] IDENTIFY_CRISIS =
    {
      1570
    };
    if (activeChar.getEffectList().containEffectFromSkills(IDENTIFY_CRISIS))
    {
      activeChar.sendPacket(SystemMsg.YOU_CAN_NOT_CHANGE_CLASS_DUE_TO_DISRUPTION_OF_THE_IDENTIFICATION);
      activeChar.sendActionFailed();
      return;
    }
    boolean success = item.getTemplate().getHandler().useItem(activeChar, item, _ctrlPressed);
    if (success)
    {
      long nextTimeUse = item.getTemplate().getReuseType().next(item);
      if (nextTimeUse > System.currentTimeMillis())
      {
        TimeStamp timeStamp = new TimeStamp(item.getItemId(), nextTimeUse, item.getTemplate().getReuseDelay());
        activeChar.addSharedGroupReuse(item.getTemplate().getReuseGroup(), timeStamp);
        if (item.getTemplate().getReuseDelay() > 0)
        {
          activeChar.sendPacket(new ExUseSharedGroupItem(item.getTemplate().getDisplayReuseGroup(), timeStamp));
        }
      }
    }
    activeChar.getListeners().onUseItem(item); // DynamicQuest
  }
View Full Code Here

      for (int i = 0; i < _count; i++)
      {
        int objectId = _items[i];
        long count = _itemQ[i];
        long price = _itemP[i];
        ItemInstance item = seller.getInventory().getItemByObjectId(objectId);
        if ((item == null) || (item.getCount() < count) || !item.canBeTraded(seller))
        {
          break loop;
        }
        TradeItem si = null;
        for (TradeItem bi : buyList)
        {
          if (bi.getItemId() == item.getItemId())
          {
            if (bi.getOwnersPrice() == price)
            {
              if (count > bi.getCount())
              {
                break loop;
              }
              totalCost = SafeMath.addAndCheck(totalCost, SafeMath.mulAndCheck(count, price));
              weight = SafeMath.addAndCheck(weight, SafeMath.mulAndCheck(count, item.getTemplate().getWeight()));
              if (!item.isStackable() || (buyer.getInventory().getItemByItemId(item.getItemId()) == null))
              {
                slots++;
              }
              si = new TradeItem();
              si.setObjectId(objectId);
              si.setItemId(item.getItemId());
              si.setCount(count);
              si.setOwnersPrice(price);
              sellList.add(si);
              break;
            }
          }
        }
      }
    }
    catch (ArithmeticException ae)
    {
      sellList.clear();
      sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
      return;
    }
    finally
    {
      try
      {
        if (sellList.size() != _count)
        {
          seller.sendPacket(Msg.THE_ATTEMPT_TO_SELL_HAS_FAILED);
          seller.sendActionFailed();
          return;
        }
        if (!buyer.getInventory().validateWeight(weight))
        {
          buyer.sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
          seller.sendPacket(Msg.THE_ATTEMPT_TO_SELL_HAS_FAILED);
          seller.sendActionFailed();
          return;
        }
        if (!buyer.getInventory().validateCapacity(slots))
        {
          buyer.sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
          seller.sendPacket(Msg.THE_ATTEMPT_TO_SELL_HAS_FAILED);
          seller.sendActionFailed();
          return;
        }
        if (!buyer.reduceAdena(totalCost))
        {
          buyer.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
          seller.sendPacket(Msg.THE_ATTEMPT_TO_SELL_HAS_FAILED);
          seller.sendActionFailed();
          return;
        }
        ItemInstance item;
        for (TradeItem si : sellList)
        {
          item = seller.getInventory().removeItemByObjectId(si.getObjectId(), si.getCount());
          for (TradeItem bi : buyList)
          {
View Full Code Here

      activeChar.sendActionFailed();
      return;
    }
    PetInventory petInventory = pet.getInventory();
    PcInventory playerInventory = activeChar.getInventory();
    ItemInstance item = playerInventory.getItemByObjectId(_objectId);
    if ((item == null) || (item.getCount() < _amount) || !item.canBeDropped(activeChar, false))
    {
      activeChar.sendActionFailed();
      return;
    }
    int slots = 0;
    long weight = item.getTemplate().getWeight() * _amount;
    if (!item.getTemplate().isStackable() || (pet.getInventory().getItemByItemId(item.getItemId()) == null))
    {
      slots = 1;
    }
    if (!pet.getInventory().validateWeight(weight))
    {
View Full Code Here

    if (player.getInventory().destroyItemByItemId(Config.SERVICES_CHANGE_PET_NAME_ITEM, Config.SERVICES_CHANGE_PET_NAME_PRICE))
    {
      pl_pet.setName(pl_pet.getTemplate().name);
      pl_pet.broadcastCharInfo();
      PetInstance _pet = (PetInstance) pl_pet;
      ItemInstance control = _pet.getControlItem();
      if (control != null)
      {
        control.setCustomType2(1);
        control.setJdbcState(JdbcEntityState.UPDATED);
        control.update();
        player.sendPacket(new InventoryUpdate().addModifiedItem(control));
      }
      show("�?м�? �?терто.", player);
    }
    else if (Config.SERVICES_CHANGE_PET_NAME_ITEM == 57)
View Full Code Here

      show("�?ет должен быт�? вызван.", player);
      return;
    }
    if (player.getInventory().destroyItemByItemId(Config.SERVICES_EXCHANGE_BABY_PET_ITEM, Config.SERVICES_EXCHANGE_BABY_PET_PRICE))
    {
      ItemInstance control = player.getInventory().getItemByObjectId(pl_pet.getControlItemObjId());
      control.setItemId(L2Pet.IMPROVED_BABY_COUGAR.getControlItemId());
      control.setJdbcState(JdbcEntityState.UPDATED);
      control.update();
      player.sendPacket(new InventoryUpdate().addModifiedItem(control));
      player.getSummonList().unsummonPet(false);
      show("�?ет изменен.", player);
    }
    else if (Config.SERVICES_EXCHANGE_BABY_PET_ITEM == 57)
View Full Code Here

      show("Этот пет тол�?ко дл�? воинов.", player);
      return;
    }
    if (player.getInventory().destroyItemByItemId(Config.SERVICES_EXCHANGE_BABY_PET_ITEM, Config.SERVICES_EXCHANGE_BABY_PET_PRICE))
    {
      ItemInstance control = player.getInventory().getItemByObjectId(pl_pet.getControlItemObjId());
      control.setItemId(L2Pet.IMPROVED_BABY_BUFFALO.getControlItemId());
      control/**
       * Method exToKookaburra.
       */
      .setJdbcState(JdbcEntityState.UPDATED);
      control.update();
      player.sendPacket(new InventoryUpdate().addModifiedItem(control));
      player.getSummonList().unsummonPet(false);
      show("�?ет изменен.", player);
    }
    else if (Config.SERVICES_EXCHANGE_BABY_PET_ITEM == 57)
View Full Code Here

      show("Этот пет тол�?ко дл�? магов.", player);
      return;
    }
    if (player.getInventory().destroyItemByItemId(Config.SERVICES_EXCHANGE_BABY_PET_ITEM, Config.SERVICES_EXCHANGE_BABY_PET_PRICE))
    {
      ItemInstance control = player.getInventory().getItemByObjectId(pl_pet.getControlItemObjId());
      control.setItemId(L2Pet.IMPROVED_BABY_KOOKABURRA.getControlItemId());
      control.setJdbcState(JdbcEntityState.UPDATED);
      control.update();
      player.sendPacket(new InventoryUpdate().addModifiedItem(control));
      player.getSummonList().unsummonPet(false);
      show("�?ет изменен.", player);
    }
    else if (Config.SERVICES_EXCHANGE_BABY_PET_ITEM == 57)
View Full Code Here

      show("scripts/services/petevolve/no_level.htm", player, npc);
      return;
    }
    int controlItemId = pl_pet.getControlItemObjId();
    player.getSummonList().unsummonPet(false);
    ItemInstance control = player.getInventory().getItemByObjectId(controlItemId);
    control.setItemId(GREAT_WOLF_NECKLACE);
    control.setEnchantLevel(L2Pet.GREAT_WOLF.getMinLevel());
    control.setJdbcState(JdbcEntityState.UPDATED);
    control.update();
    player.sendItemList(false);
    show("scripts/services/petevolve/yes_wolf.htm", player, npc);
  }
View Full Code Here

TOP

Related Classes of lineage2.gameserver.model.items.ItemInstance$FuncDefence

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.