Package lineage2.gameserver.model.items

Examples of lineage2.gameserver.model.items.ItemInstance


            {
              if (count > si.getCount())
              {
                break loop;
              }
              ItemInstance item = seller.getInventory().getItemByObjectId(objectId);
              if ((item == null) || (item.getCount() < count) || !item.canBeTraded(seller))
              {
                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++;
              }
              bi = new TradeItem();
              bi.setObjectId(objectId);
              bi.setItemId(item.getItemId());
              bi.setCount(count);
              bi.setOwnersPrice(price);
              buyList.add(bi);
              break;
            }
          }
        }
      }
    }
    catch (ArithmeticException ae)
    {
      buyList.clear();
      sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
      return;
    }
    finally
    {
      try
      {
        if ((buyList.size() != _count) || ((seller.getPrivateStoreType() == Player.STORE_PRIVATE_SELL_PACKAGE) && (buyList.size() != sellList.size())))
        {
          buyer.sendPacket(Msg.THE_ATTEMPT_TO_TRADE_HAS_FAILED);
          buyer.sendActionFailed();
          return;
        }
        if (!buyer.getInventory().validateWeight(weight))
        {
          buyer.sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
          buyer.sendActionFailed();
          return;
        }
        if (!buyer.getInventory().validateCapacity(slots))
        {
          buyer.sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
          buyer.sendActionFailed();
          return;
        }
        if (!buyer.reduceAdena(totalCost))
        {
          buyer.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
          buyer.sendActionFailed();
          return;
        }
        ItemInstance item;
        for (TradeItem bi : buyList)
        {
          item = seller.getInventory().removeItemByObjectId(bi.getObjectId(), bi.getCount());
          for (TradeItem si : sellList)
          {
View Full Code Here


        player.enableSkill(skill);
      }
    }
    player.sendSkillList();
    player.sendPacket(new SkillCoolTime(player));
    ItemInstance wpn = player.getActiveWeaponInstance();
    if ((wpn != null) && wpn.isHeroWeapon())
    {
      player.getInventory().unEquipItem(wpn);
      player.abortAttack(true, true);
    }
    Set<Integer> activeSoulShots = player.getAutoSoulShot();
    for (int itemId : activeSoulShots)
    {
      player.removeAutoSoulShot(itemId);
      player.sendPacket(new ExAutoSoulShot(itemId, false));
    }
    ItemInstance weapon = player.getActiveWeaponInstance();
    if (weapon != null)
    {
      weapon.setChargedSpiritshot(ItemInstance.CHARGED_NONE);
      weapon.setChargedSoulshot(ItemInstance.CHARGED_NONE);
    }
    player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
    player.setCurrentCp(player.getMaxCp());
    player.broadcastUserInfo();
  }
View Full Code Here

      player.setAppearanceStone(null);
      return;
    }

    PcInventory inventory = player.getInventory();
    ItemInstance targetItem = inventory.getItemByObjectId(_targetItemObjId);
    ItemInstance stone = player.getAppearanceStone();
    if(targetItem == null || stone == null)
    {
      player.sendPacket(ExShapeShiftingResult.FAIL);
      player.setAppearanceStone(null);
      return;
    }

    if(!targetItem.canBeAppearance())
    {
      player.sendPacket(ExPutShapeShiftingTargetItemResult.FAIL);
      return;
    }

    if(targetItem.getLocation() != ItemInstance.ItemLocation.INVENTORY && targetItem.getLocation() != ItemInstance.ItemLocation.PAPERDOLL)
    {
      player.sendPacket(ExShapeShiftingResult.FAIL);
      player.setAppearanceStone(null);
      return;
    }

    if((stone = inventory.getItemByObjectId(stone.getObjectId())) == null)
    {
      player.sendPacket(ExShapeShiftingResult.FAIL);
      player.setAppearanceStone(null);
      return;
    }

    AppearanceStone appearanceStone = EnchantItemHolder.getInstance().getAppearanceStone(stone.getItemId());
    if(appearanceStone == null)
    {
      player.sendPacket(ExShapeShiftingResult.FAIL);
      player.setAppearanceStone(null);
      return;
View Full Code Here

      return this;
    }
    removePlayerOnKillListener();
    for (int itemId : _quest.getItems())
    {
      ItemInstance item = player.getInventory().getItemByItemId(itemId);
      if ((item == null) || (itemId == 57))
      {
        continue;
      }
      long count = item.getCount();
      player.getInventory().destroyItemByItemId(itemId, count);
      player.getWarehouse().destroyItemByItemId(itemId, count);
    }
    if (repeatable)
    {
View Full Code Here

    {
      return;
    }
    for (int i = 0; i < count; i++)
    {
      ItemInstance item = ItemFunctions.createItem(itemId);
      if (element != Element.NONE)
      {
        item.setAttributeElement(element, power);
      }
      player.getInventory().addItem(item);
    }
    player.sendPacket(SystemMessage2.obtainItems(template.getItemId(), count, 0));
    player.sendChanges();
View Full Code Here

    Player player = getPlayer();
    if (player == null)
    {
      return;
    }
    ItemInstance item = ItemFunctions.createItem(itemId);
    item.setCount(count);
    item.dropToTheGround(player, npc);
  }
View Full Code Here

    Player player = getPlayer();
    if (player == null)
    {
      return 0;
    }
    ItemInstance item = player.getInventory().getItemByItemId(itemId);
    if (item == null)
    {
      return 0;
    }
    if ((count < 0) || (count > item.getCount()))
    {
      count = item.getCount();
    }
    player.getInventory().destroyItemByItemId(itemId, count);
    player.sendPacket(SystemMessage2.removeItems(itemId, count));
    return count;
  }
View Full Code Here

      {
        con = DatabaseFactory.getInstance().getConnection();
        st = con.prepareStatement("SELECT * FROM items_delayed WHERE owner_id=? AND payment_status=0");
        st.setInt(1, player_id);
        rset = st.executeQuery();
        ItemInstance item, newItem;
        st_delete = con.prepareStatement("UPDATE items_delayed SET payment_status=1 WHERE payment_id=?");
        while (rset.next())
        {
          final int ITEM_ID = rset.getInt("item_id");
          final long ITEM_COUNT = rset.getLong("count");
          final int ITEM_ENCHANT = rset.getInt("enchant_level");
          final int PAYMENT_ID = rset.getInt("payment_id");
          final int FLAGS = rset.getInt("flags");
          rset.getInt("attribute");
          rset.getInt("attribute_level");
          boolean stackable = ItemHolder.getInstance().getTemplate(ITEM_ID).isStackable();
          boolean success = false;
          for (int i = 0; i < (stackable ? 1 : ITEM_COUNT); i++)
          {
            item = ItemFunctions.createItem(ITEM_ID);
            if (item.isStackable())
            {
              item.setCount(ITEM_COUNT);
            }
            else
            {
              item.setEnchantLevel(ITEM_ENCHANT);
            }
            item.setLocation(ItemLocation.INVENTORY);
            item.setCustomFlags(FLAGS);
            if (ITEM_COUNT > 0)
            {
              newItem = inv.addItem(item);
              if (newItem == null)
              {
View Full Code Here

    double mpGain = player.calcStat(Stats.MANAHEAL_EFFECTIVNESS, 100., target, null);
    double critPerc = 2 * player.calcStat(Stats.CRITICAL_DAMAGE, target, null);
    double critStatic = player.calcStat(Stats.CRITICAL_DAMAGE_STATIC, target, null);
    double mCritDmg = player.calcStat(Stats.MCRITICAL_DAMAGE, target, null);
    double blowRate = player.calcStat(Stats.FATALBLOW_RATE, target, null);
    ItemInstance shld = player.getSecondaryWeaponInstance();
    boolean shield = (shld != null) && (shld.getItemType() == WeaponType.NONE);
    double shieldDef = shield ? player.calcStat(Stats.SHIELD_DEFENCE, player.getTemplate().getBaseShldDef(), target, null) : 0.;
    double shieldRate = shield ? player.calcStat(Stats.SHIELD_RATE, target, null) : 0.;
    double xpRate = player.getRateExp();
    double spRate = player.getRateSp();
    double dropRate = player.getRateItems();
View Full Code Here

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

TOP

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

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.