Package com.l2jfrozen.gameserver.model.actor.instance

Examples of com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance$ScheduleConsumeManaTask


  {
    if(!(playable instanceof L2PcInstance))
      return;

    L2PcInstance activeChar = (L2PcInstance) playable;
    L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
    L2Weapon weaponItem = activeChar.getActiveWeaponItem();
    int itemId = item.getItemId();

    // Check if Soulshot can be used
    if(weaponInst == null || weaponItem.getSoulShotCount() == 0)
    {
      if(!activeChar.getAutoSoulShot().containsKey(itemId))
      {
        activeChar.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_SOULSHOTS));
      }
      return;
    }

    if(activeChar.isParalyzed())
    {
      activeChar.sendMessage("You Cannot Use This While You Are Paralyzed");
      activeChar.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Check for correct grade
    int weaponGrade = weaponItem.getCrystalType();
    if(weaponGrade == L2Item.CRYSTAL_NONE && itemId != 5789 && itemId != 1835 || weaponGrade == L2Item.CRYSTAL_D && itemId != 1463 || weaponGrade == L2Item.CRYSTAL_C && itemId != 1464 || weaponGrade == L2Item.CRYSTAL_B && itemId != 1465 || weaponGrade == L2Item.CRYSTAL_A && itemId != 1466 || weaponGrade == L2Item.CRYSTAL_S && itemId != 1467)
    {
      if(!activeChar.getAutoSoulShot().containsKey(itemId))
      {
        activeChar.sendPacket(new SystemMessage(SystemMessageId.SOULSHOTS_GRADE_MISMATCH));
      }
      return;
    }

    activeChar.soulShotLock.lock();
    try
    {
      // Check if Soulshot is already active
      if(weaponInst.getChargedSoulshot() != L2ItemInstance.CHARGED_NONE)
        return;

      // Consume Soulshots if player has enough of them
      int saSSCount = (int) activeChar.getStat().calcStat(Stats.SOULSHOT_COUNT, 0, null, null);
      int SSCount = saSSCount == 0 ? weaponItem.getSoulShotCount() : saSSCount;

      weaponItem = null;

      // TODO: test ss
      if(!Config.DONT_DESTROY_SS)
      {
        if(!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), SSCount, null, false))
        {
          if(activeChar.getAutoSoulShot().containsKey(itemId))
          {
            activeChar.removeAutoSoulShot(itemId);
            activeChar.sendPacket(new ExAutoSoulShot(itemId, 0));

            SystemMessage sm = new SystemMessage(SystemMessageId.AUTO_USE_OF_S1_CANCELLED);
            sm.addString(item.getItem().getName());
            activeChar.sendPacket(sm);
            sm = null;
          }
          else
          {
            activeChar.sendPacket(new SystemMessage(SystemMessageId.NOT_ENOUGH_SOULSHOTS));
          }
          return;
        }
      }

      // Charge soulshot
      weaponInst.setChargedSoulshot(L2ItemInstance.CHARGED_SOULSHOT);

      weaponInst = null;
    }
    finally
    {
View Full Code Here


      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    L2Weapon weaponItem = player.getActiveWeaponItem();
    L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
    if(weaponInst == null || weaponItem == null || weaponItem.getItemType() != L2WeaponType.ROD)
    {
      SystemMessage sm = new SystemMessage(SystemMessageId.S1_CANNOT_BE_USED);
        activeChar.sendPacket(sm);
        sm = null;
      return;
    }

    int SS = 1;
    int pen = 0;

    if(weaponInst.getChargedFishshot())
      SS = 2;

    double gradebonus = 1 + weaponItem.getCrystalType() * 0.1;
    int dmg = (int)(skill.getPower()*gradebonus*SS);
    weaponItem = null;
    if(player.getSkillLevel(1315) <= skill.getLevel()-2) //1315 - Fish Expertise
    {//Penalty
      player.sendPacket(new SystemMessage(SystemMessageId.REELING_PUMPING_3_LEVELS_HIGHER_THAN_FISHING_PENALTY));
      pen = 50;
      int penatlydmg = dmg - pen;
      if(player.isGM())
        player.sendMessage("Dmg w/o penalty = " + dmg);
      dmg = penatlydmg;
    }
    player = null;

    if(SS > 1)
    {
      weaponInst.setChargedFishshot(false);
    }
    weaponInst = null;

    if(skill.getSkillType() == SkillType.REELING)//Realing
    {
View Full Code Here

  public L2ItemInstance transferItem(String process, int objectId, int count, ItemContainer target, L2PcInstance actor, L2Object reference)
  {
    if(target == null)
      return null;

    L2ItemInstance sourceitem = getItemByObjectId(objectId);
    if(sourceitem == null)
      return null;

    L2ItemInstance targetitem = sourceitem.isStackable() ? target.getItemByItemId(sourceitem.getItemId()) : null;

    synchronized (sourceitem)
    {
      // check if this item still present in this container
      if(getItemByObjectId(objectId) != sourceitem)
        return null;

      // Check if requested quantity is available
      if(count > sourceitem.getCount())
      {
        count = sourceitem.getCount();
      }

      // If possible, move entire item object
      if(sourceitem.getCount() == count && targetitem == null)
      {
        removeItem(sourceitem);
        target.addItem(process, sourceitem, actor, reference);
        targetitem = sourceitem;
      }
      else
      {
        if(sourceitem.getCount() > count) // If possible, only update counts
        {
          sourceitem.changeCount(process, -count, actor, reference);
        }
        else
        // Otherwise destroy old item
        {
          removeItem(sourceitem);
          ItemTable.getInstance().destroyItem(process, sourceitem, actor, reference);
        }

        if(targetitem != null) // If possible, only update counts
        {
          targetitem.changeCount(process, count, actor, reference);
        }
        else
        // Otherwise add new item
        {
          targetitem = target.addItem(process, sourceitem.getItemId(), count, actor, reference);
        }
      }

      // Updates database
      sourceitem.updateDatabase();
      if(targetitem != sourceitem && targetitem != null)
      {
        targetitem.updateDatabase();
      }

      if(sourceitem.isAugmented())
      {
        sourceitem.getAugmentation().removeBoni(actor);
View Full Code Here

   * @param reference : L2Object Object referencing current action like NPC selling item or previous item in transformation
   * @return L2ItemInstance corresponding to the destroyed item or the updated item in inventory
   */
  public L2ItemInstance destroyItem(String process, int objectId, int count, L2PcInstance actor, L2Object reference)
  {
    L2ItemInstance item = getItemByObjectId(objectId);
   
    if (item == null)
      return null;
   
    // Adjust item quantity
    if (item.getCount() > count)
    {
      synchronized (item)
      {
        item.changeCount(process, -count, actor, reference);
        item.setLastChange(L2ItemInstance.MODIFIED);
       
        item.updateDatabase();
        refreshWeight();
      }
     
      return item;
    }
View Full Code Here

  public boolean testImpl(Env env)
  {
    if(!(env.player instanceof L2PcInstance))
      return false;
    Inventory inv = ((L2PcInstance) env.player).getInventory();
    L2ItemInstance item = inv.getPaperdollItem(_slot);
    if(item == null)
      return false;
    return (item.getItem().getItemMask() & _mask) != 0;
  }
View Full Code Here

   * @param reference : L2Object Object referencing current action like NPC selling item or previous item in transformation
   * @return L2ItemInstance corresponding to the destroyed item or the updated item in inventory
   */
  public L2ItemInstance destroyItemByItemId(String process, int itemId, int count, L2PcInstance actor, L2Object reference)
  {
    L2ItemInstance item = getItemByItemId(itemId);
   
    if (item == null)
      return null;
   
    synchronized (item)
    {
      // Adjust item quantity
      if (item.getCount() > count)
      {
        item.changeCount(process, -count, actor, reference);
        item.setLastChange(L2ItemInstance.MODIFIED);
      }
      // Directly drop entire item
      else
        return destroyItem(process, item, actor, reference);
     
      item.updateDatabase();
      refreshWeight();
    }
   
    return item;
  }
View Full Code Here

     
      if(items!=null){
       
        for(int i=0;i<items.size();i++)
        {
          L2ItemInstance item = items.get(i);
         
          if(item != null)
          {
            item.updateDatabase();
          }
        }
       
      }
     
View Full Code Here

      PreparedStatement statement = con.prepareStatement("SELECT object_id FROM items WHERE owner_id=? AND (loc=?) " + "ORDER BY object_id DESC");
      statement.setInt(1, getOwnerId());
      statement.setString(2, getBaseLocation().name());
      ResultSet inv = statement.executeQuery();

      L2ItemInstance item;

      while(inv.next())
      {
        int objectId = inv.getInt(1);

        item = L2ItemInstance.restoreFromDb(objectId);

        if(item == null)
        {
          continue;
        }

        L2World.getInstance().storeObject(item);

        // If stackable item is found in inventory just add to current quantity
        if(item.isStackable() && getItemByItemId(item.getItemId()) != null)
        {
          addItem("Restore", item, null, getOwner());
        }
        else
        {
View Full Code Here

    {
      int order = tradeList.getItems().size() + 1; // last item order + 1
      int itemID = Integer.parseInt(args[2]);
      int price = Integer.parseInt(args[3]);

      L2ItemInstance newItem = ItemTable.getInstance().createDummyItem(itemID);
      newItem.setPriceToSell(price);
      newItem.setCount(-1);
      tradeList.addItem(newItem);
      storeTradeList(itemID, price, tradeListID, order);

      activeChar.sendMessage("Added " + newItem.getItem().getName() + " to Trade List " + tradeList.getListId());
      showShopList(activeChar, tradeListID, 1);

      newItem = null;

      return;
View Full Code Here

            int price = rset.getInt("price");
            int count = rset.getInt("count");
            int currentCount = rset.getInt("currentCount");
            int time = rset.getInt("time");

            L2ItemInstance item = ItemTable.getInstance().createDummyItem(itemId);

            if(item == null)
            {
              rset.close();
              statement.close();

              rset = null;
              statement = null;
              continue;
            }

            if(count > -1)
            {
              item.setCountDecrease(true);
              LimitedItem = true;
            }

            item.setPriceToSell(price);
            item.setTime(time);
            item.setInitCount(count);

            if(currentCount > -1)
            {
              item.setCount(currentCount);
            }
            else
            {
              item.setCount(count);
            }

            buy1.addItem(item);
            item = null;
            buy1.setNpcId(rset1.getString("npc_id"));

            try
            {
              while(rset.next()) //TODO aici
              {
                dummyItemCount++;
                itemId = rset.getInt("item_id");
                price = rset.getInt("price");
                count = rset.getInt("count");
                time = rset.getInt("time");
                currentCount = rset.getInt("currentCount");
                L2ItemInstance item2 = ItemTable.getInstance().createDummyItem(itemId);

                if(item2 == null)
                {
                  continue;
                }

                if(count > -1)
                {
                  item2.setCountDecrease(true);
                  LimitedItem = true;
                }
                item2.setPriceToSell(price);
                item2.setTime(time);
                item2.setInitCount(count);
                if(currentCount > -1)
                {
                  item2.setCount(currentCount);
                }
                else
                {
                  item2.setCount(count);
                }
                buy1.addItem(item2);
              }
            }
            catch(Exception e)
            {
              if(Config.ENABLE_ALL_EXCEPTIONS)
                e.printStackTrace();
             
              _log.warning("TradeController: Problem with buylist " + buy1.getListId() + " item " + itemId);
            }
            if(LimitedItem)
            {
              _listsTaskItem.put(new Integer(buy1.getListId()), buy1);
            }
            else
            {
              _lists.put(new Integer(buy1.getListId()), buy1);
            }

            _nextListId = Math.max(_nextListId, buy1.getListId() + 1);
            buy1 = null;
          }

          rset.close();
          statement.close();

          rset = null;
          statement = null;
        }
        rset1.close();
        statement1.close();

        rset1 = null;
        statement1 = null;

        if(Config.DEBUG)
        {
          _log.fine("created " + dummyItemCount + " Dummy-Items for buylists");
        }

        _log.config("TradeController: Loaded " + _lists.size() + " Buylists.");
        _log.config("TradeController: Loaded " + _listsTaskItem.size() + " Limited Buylists.");
        /*
         *  Restore Task for reinitialyze count of buy item
         */
        try
        {
          int time = 0;
          long savetimer = 0;
          long currentMillis = System.currentTimeMillis();

          PreparedStatement statement2 = con.prepareStatement("SELECT DISTINCT time, savetimer FROM merchant_buylists WHERE time <> 0 ORDER BY time");
          ResultSet rset2 = statement2.executeQuery();

          while(rset2.next())
          {
            time = rset2.getInt("time");
            savetimer = rset2.getLong("savetimer");
            if(savetimer - currentMillis > 0)
            {
              ThreadPoolManager.getInstance().scheduleGeneral(new RestoreCount(time), savetimer - System.currentTimeMillis());
            }
            else
            {
              ThreadPoolManager.getInstance().scheduleGeneral(new RestoreCount(time), 0);
            }
          }
          rset2.close();
          statement2.close();

          rset2 = null;
          statement2 = null;
        }
        catch(Exception e)
        {
          _log.warning("TradeController: Could not restore Timer for Item count.");
          e.printStackTrace();
        }
      }
      catch(Exception e)
      {
        // problem with initializing spawn, go to next one
        _log.warning("TradeController: Buylists could not be initialized.");
        e.printStackTrace();
      }
      finally
      {
        CloseUtil.close(con);
        con = null;
      }
      /*
       * If enabled, initialize the custom buylist
       */
      if(Config.CUSTOM_MERCHANT_TABLES)// Custom merchat Tabels
      {
        try
        {
          int initialSize = _lists.size();
          con = L2DatabaseFactory.getInstance().getConnection(false);

          PreparedStatement statement1 = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
          {
              "shop_id", "npc_id"
          }) + " FROM custom_merchant_shopids");

          ResultSet rset1 = statement1.executeQuery();

          while(rset1.next())
          {
            PreparedStatement statement = con.prepareStatement("SELECT " + L2DatabaseFactory.getInstance().safetyString(new String[]
            {
                "item_id", "price", "shop_id", "order", "count", "time", "currentCount"
            }) + " FROM custom_merchant_buylists WHERE shop_id=? ORDER BY " + L2DatabaseFactory.getInstance().safetyString(new String[]
            {
              "order"
            }) + " ASC");

            statement.setString(1, String.valueOf(rset1.getInt("shop_id")));
            ResultSet rset = statement.executeQuery();

            if(rset.next())
            {
              LimitedItem = false;
              dummyItemCount++;
              L2TradeList buy1 = new L2TradeList(rset1.getInt("shop_id"));
              int itemId = rset.getInt("item_id");
              int price = rset.getInt("price");
              int count = rset.getInt("count");
              int currentCount = rset.getInt("currentCount");
              int time = rset.getInt("time");
              L2ItemInstance item = ItemTable.getInstance().createDummyItem(itemId);
              if(item == null)
              {
                rset.close();
                statement.close();

                rset = null;
                statement = null;
                continue;
              }

              if(count > -1)
              {
                item.setCountDecrease(true);
                LimitedItem = true;
              }
              item.setPriceToSell(price);
              item.setTime(time);
              item.setInitCount(count);

              if(currentCount > -1)
              {
                item.setCount(currentCount);
              }
              else
              {
                item.setCount(count);
              }

              buy1.addItem(item);
              item = null;
              buy1.setNpcId(rset1.getString("npc_id"));

              try
              {
                while(rset.next())
                {
                  dummyItemCount++;
                  itemId = rset.getInt("item_id");
                  price = rset.getInt("price");
                  count = rset.getInt("count");
                  time = rset.getInt("time");
                  currentCount = rset.getInt("currentCount");
                  L2ItemInstance item2 = ItemTable.getInstance().createDummyItem(itemId);
                  if(item2 == null)
                  {
                    continue;
                  }
                  if(count > -1)
                  {
                    item2.setCountDecrease(true);
                    LimitedItem = true;
                  }
                  item2.setPriceToSell(price);
                  item2.setTime(time);
                  item2.setInitCount(count);
                  if(currentCount > -1)
                  {
                    item2.setCount(currentCount);
                  }
                  else
                  {
                    item2.setCount(count);
                  }
                  buy1.addItem(item2);

                  item2 = null;
                }
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance$ScheduleConsumeManaTask

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.