Package lineage2.gameserver.model.items

Examples of lineage2.gameserver.model.items.TradeItem


   * @param damage int
   */
  @Override
  protected void onEvtAttacked(Creature attacker, int damage)
  {
    final NpcInstance actor = getActor();
    if (_firstTimeAttacked)
    {
      Functions.npcSay(actor, "A non-permitted target has been discovered.");
      Functions.npcSay(actor, "Starting intruder removal system.");
      _firstTimeAttacked = false;
View Full Code Here


   * @param killer Creature
   */
  @Override
  protected void onEvtDead(Creature killer)
  {
    final NpcInstance actor = getActor();
    actor.broadcastPacket(new PlaySound(PlaySound.Type.MUSIC, "BS02_D", 1, 0, actor.getLoc()));
    Functions.npcSay(actor, "A fatal error has occurred");
    Functions.npcSay(actor, "System is being shut down...");
    Functions.npcSay(actor, "......");
    try
    {
      final NpcInstance cubic1 = NpcHolder.getInstance().getTemplate(TELEPORTATION_CUBIC_ID).getNewInstance();
      cubic1.setReflection(actor.getReflection());
      cubic1.setCurrentHpMp(cubic1.getMaxHp(), cubic1.getMaxMp(), true);
      cubic1.spawnMe(CUBIC_1_POSITION);
      final NpcInstance cubic2 = NpcHolder.getInstance().getTemplate(TELEPORTATION_CUBIC_ID).getNewInstance();
      cubic2.setReflection(actor.getReflection());
      cubic2.setCurrentHpMp(cubic1.getMaxHp(), cubic1.getMaxMp(), true);
      cubic2.spawnMe(CUBIC_2_POSITION);
      ThreadPoolManager.getInstance().schedule(new DeSpawnScheduleTimerTask(cubic1, cubic2), CUBIC_DESPAWN_TIME);
    }
    catch (Exception e)
    {
      e.printStackTrace();
View Full Code Here

   */
  @Override
  protected void onEvtSpawn()
  {
    super.onEvtSpawn();
    final NpcInstance actor = getActor();
    if (Rnd.chance(50))
    {
      actor.setNpcState(1);
    }
    ThreadPoolManager.getInstance().scheduleAtFixedRate(new Switch(), 5 * 60 * 1000L, 5 * 60 * 1000L);
  }
 
View Full Code Here

     * Method runImpl.
     */
    @Override
    public void runImpl()
    {
      final NpcInstance actor = getActor();
      if (actor.getNpcState() == 1)
      {
        actor.setNpcState(2);
      }
      else
      {
        actor.setNpcState(1);
      }
    }
View Full Code Here

          if (si.getObjectId() == item.getObjectId())
          {
            if (si.getCount() == item.getCount())
              continue loop;
            // Показывает остаток вещей для продажи
            TradeItem ti = new TradeItem(item);
            ti.setCount(item.getCount() - si.getCount());
            _sellList.add(ti);
            continue loop;
          }
        _sellList.add(new TradeItem(item));
      }
  }
View Full Code Here

    List<TradeItem> buyList = buyer.getBuyList();
    ItemInstance[] items = seller.getInventory().getItems();

    for (TradeItem bi : buyList)
    {
      TradeItem si = null;
      for (ItemInstance item : items)
        if (item.getItemId() == bi.getItemId() && item.canBeTraded(seller))
        {
          si = new TradeItem(item);
          _sellList.add(si);
          si.setOwnersPrice(bi.getOwnersPrice());
          si.setCount(bi.getCount());
          si.setCurrentValue(Math.min(bi.getCount(), item.getCount()));
        }
      if (si == null)
      {
        si = new TradeItem();
        si.setItemId(bi.getItemId());
        si.setOwnersPrice(bi.getOwnersPrice());
        si.setCount(bi.getCount());
        si.setCurrentValue(0);
        _sellList.add(si);
      }
    }
  }
View Full Code Here

      for (int i = 0; i < _count; i++)
      {
        int objectId = _items[i];
        long count = _itemQ[i];
        long price = _itemP[i];
        TradeItem bi = null;
        for (TradeItem si : sellList)
        {
          if (si.getObjectId() == objectId)
          {
            if (si.getOwnersPrice() == price)
            {
              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)
          {
            if (si.getObjectId() == bi.getObjectId())
            {
              si.setCount(si.getCount() - bi.getCount());
              if (si.getCount() < 1L)
              {
                sellList.remove(si);
              }
              break;
View Full Code Here

      else
      {
        ItemInstance[] items = activeChar.getRefund().getItems();
        _refundList = new ArrayList<TradeItem>(items.length);
        for (ItemInstance item : items)
          _refundList.add(new TradeItem(item));

        items = activeChar.getInventory().getItems();
        _sellList = new ArrayList<TradeItem>(items.length);
        for (ItemInstance item : items)
          if (item.canBeSold(activeChar))
            _sellList.add(new TradeItem(item));
      }
    }
View Full Code Here

                            {
                              continue;
                            }
                            counterItems++;
                            long price = i.getAttributes().getNamedItem("price") != null ? Long.parseLong(i.getAttributes().getNamedItem("price").getNodeValue()) : Math.round(template.getReferencePrice() * markup);
                            TradeItem item = new TradeItem();
                            item.setItemId(itemId);
                            final int itemCount = i.getAttributes().getNamedItem("count") != null ? Integer.parseInt(i.getAttributes().getNamedItem("count").getNodeValue()) : 0;
                            final int itemRechargeTime = i.getAttributes().getNamedItem("time") != null ? Integer.parseInt(i.getAttributes().getNamedItem("time").getNodeValue()) : 0;
                            item.setOwnersPrice(price);
                            item.setCount(itemCount);
                            item.setCurrentValue(itemCount);
                            item.setLastRechargeTime((int) (System.currentTimeMillis() / 60000));
                            item.setRechargeTime(itemRechargeTime);
                            tl.addItem(item);
                          }
                        }
                        _lists.put(shop_id, tl);
                      }
View Full Code Here

     */
    public synchronized void updateItems(List<TradeItem> buyList)
    {
      for (TradeItem ti : buyList)
      {
        TradeItem ic = getItemByItemId(ti.getItemId());
        if (ic.isCountLimited())
        {
          ic.setCurrentValue(Math.max(ic.getCurrentValue() - ti.getCount(), 0));
        }
      }
    }
View Full Code Here

TOP

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

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.