Package com.l2jfrozen.gameserver.templates

Examples of com.l2jfrozen.gameserver.templates.L2Item


      try
      {
        CropProcure crop = CastleManager.getInstance().getCastleById(manorId).getCrop(itemId, CastleManorManager.PERIOD_CURRENT);
        int rewardItemId = L2Manor.getInstance().getRewardItem(itemId, crop.getReward());
        L2Item template = ItemTable.getInstance().getTemplate(rewardItemId);
        weight += count * template.getWeight();

        if(!template.isStackable())
        {
          slots += count;
        }
        else if(player.getInventory().getItemByItemId(itemId) == null)
        {
View Full Code Here


      {
        Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id.", Config.DEFAULT_PUNISH);
        return;
      }

      L2Item template = ItemTable.getInstance().getTemplate(itemId);

      if(template == null)
      {
        continue;
      }

      // Check count
      if(count > Integer.MAX_VALUE || !template.isStackable() && count > 1)
      {
        //Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase invalid quantity of items at the same time.", Config.DEFAULT_PUNISH);
        SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED);
        sendPacket(sm);
        sm = null;
        return;
      }

      if(_listId < 1000000)
      {
        //list = TradeController.getInstance().getBuyList(_listId);
        price = list.getPriceForItemId(itemId);

        if(itemId >= 3960 && itemId <= 4026)
        {
          price *= Config.RATE_SIEGE_GUARDS_PRICE;
        }

      }
      /* TODO: Disabled until Leaseholders are rewritten ;-)
            }
            else
            {
              L2ItemInstance li = merchant.findLeaseItem(itemId, 0);
              if (li == null || li.getCount() < cnt)
              {
                cnt = li.getCount();
                if (cnt <= 0)
                {
                  items.remove(i);
                  continue;
                }
                items.get(i).setCount((int)cnt);
              }
              price = li.getPriceToSell(); // lease holder sells the item
              weight = li.getItem().getWeight();
            }

      */
      if(price < 0)
      {
        _log.warning("ERROR, no price found .. wrong buylist ??");
        sendPacket(ActionFailed.STATIC_PACKET);
        return;
      }

      if(price == 0 && !player.isGM() && Config.ONLY_GM_ITEMS_FREE)
      {
        player.sendMessage("Ohh Cheat dont work? You have a problem now!");
        Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried buy item for 0 adena.", Config.DEFAULT_PUNISH);
        return;
      }

      subTotal += (long) count * price; // Before tax
      tax = (int) (subTotal * taxRate);

      // Check subTotal + tax
      if(subTotal + tax > Integer.MAX_VALUE)
      {
        //Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + Integer.MAX_VALUE + " adena worth of goods.", Config.DEFAULT_PUNISH);
        SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED);
        sendPacket(sm);
        sm = null;
        return;
      }

      weight += (long) count * template.getWeight();
      if(!template.isStackable())
      {
        slots += count;
      }
      else if(player.getInventory().getItemByItemId(itemId) == null)
      {
View Full Code Here

      if(residual < count)
        return;

      totalPrice += count * price;

      L2Item template = ItemTable.getInstance().getTemplate(seedId);
      totalWeight += count * template.getWeight();
      if(!template.isStackable())
      {
        slots += count;
      }
      else if(player.getInventory().getItemByItemId(seedId) == null)
      {
View Full Code Here

        SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_EXCEEDED_QUANTITY_THAT_CAN_BE_INPUTTED);
        sendPacket(sm);
        return;
      }

      L2Item template = ItemTable.getInstance().getTemplate(L2Manor.getInstance().getRewardItem(itemId, manor.getCastle().getCrop(itemId, CastleManorManager.PERIOD_CURRENT).getReward()));
      weight += count * template.getWeight();

      if(!template.isStackable())
      {
        slots += count;
      }
      else if(player.getInventory().getItemByItemId(itemId) == null)
      {
View Full Code Here

      {
        Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " sent a false BuyList list_id.", Config.DEFAULT_PUNISH);
        return;
      }

      L2Item template = ItemTable.getInstance().getTemplate(itemId);
      weight += template.getWeight();
      slots++;

      totalPrice += Config.WEAR_PRICE;
      if(totalPrice > Integer.MAX_VALUE)
      {
View Full Code Here

        continue; // do not adena yet, as taxIngredient adena entries might occur next (order not guaranteed)
      }
      // if it is an armor/weapon, modify the enchantment level appropriately, if necessary
      else if(maintainEnchantment)
      {
        L2Item tempItem = ItemTable.getInstance().createDummyItem(ing.getItemId()).getItem();
        if(tempItem instanceof L2Armor || tempItem instanceof L2Weapon)
        {
          newIngredient.setEnchantmentLevel(enchantLevel);
        }

        tempItem = null;
      }

      // finally, add this ingredient to the entry
      newEntry.addIngredient(newIngredient);
      newIngredient = null;
    }

    // now add the adena, if any.
    if(adenaAmount > 0)
    {
      newEntry.addIngredient(new MultiSellIngredient(57, adenaAmount, 0, false, false));
    }

    // Now modify the enchantment level of products, if necessary
    for(MultiSellIngredient ing : templateEntry.getProducts())
    {
      // load the ingredient from the template
      MultiSellIngredient newIngredient = new MultiSellIngredient(ing);

      if(maintainEnchantment)
      {
        // if it is an armor/weapon, modify the enchantment level appropriately
        // (note, if maintain enchantment is "false" this modification will result to a +0)
        L2Item tempItem = ItemTable.getInstance().createDummyItem(ing.getItemId()).getItem();

        if(tempItem instanceof L2Armor || tempItem instanceof L2Weapon)
        {
          newIngredient.setEnchantmentLevel(enchantLevel);
        }
View Full Code Here

   
    if (weaponId < 1)
      return null;
   
    // Get the weapon item equiped in the right hand of the L2NpcInstance
    L2Item item = ItemTable.getInstance().getTemplate(getTemplate().rhand);
   
    if (!(item instanceof L2Weapon))
      return null;
   
    return (L2Weapon) item;
View Full Code Here

   
    if (weaponId < 1)
      return null;
   
    // Get the weapon item equiped in the right hand of the L2NpcInstance
    L2Item item = ItemTable.getInstance().getTemplate(getTemplate().lhand);
   
    if (!(item instanceof L2Weapon))
      return null;
   
    return (L2Weapon) item;
View Full Code Here

    // If item hasn't be found in inventory, create new one
    else
    {
      for(int i = 0; i < count; i++)
      {
        L2Item template = ItemTable.getInstance().getTemplate(itemId);

        if(template == null)
        {
          _log.log(Level.WARNING, (actor != null ? "[" + actor.getName() + "] " : "") + "Invalid ItemId requested: ", itemId);
          return null;
        }

        item = ItemTable.getInstance().createItem(process, itemId, template.isStackable() ? count : 1, actor, reference);
        item.setOwnerId(getOwnerId());
       
        if(process.equals("AutoLoot")){
          item.setLocation(ItemLocation.INVENTORY);
        }else
          item.setLocation(getBaseLocation());
       
        item.setLastChange(L2ItemInstance.ADDED);

        // Add item in inventory
        addItem(item);
        // Updates database
        item.updateDatabase();

        // If stackable, end loop as entire count is included in 1 instance of item
        if(template.isStackable() || !Config.MULTIPLE_ITEM_DROP)
        {
          break;
        }

        template = null;
View Full Code Here

          }

          // Check if the autoLoot mode is active
          if(Config.AUTO_LOOT)
          {
            L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
           
            if(item_templ == null){
              _log.info("ERROR: Item id to autoloot " + item.getItemId() + " has not template into items/armor/weapon tables.. It cannot be dropped..");
              //DropItem(player, item);
            }else{
             
              if(!player.getInventory().validateCapacity(item_templ) || (!Config.AUTO_LOOT_BOSS && this instanceof L2RaidBossInstance) || (!Config.AUTO_LOOT_BOSS && this instanceof L2GrandBossInstance))
                DropItem(player, item);
              else
                player.doAutoLoot(this, item); // Give this or these Item(s) to the L2PcInstance that has killed the L2Attackable
           
            }
         
          }
          else
          {
            DropItem(player, item); // drop the item on the ground
          }

          // Broadcast message if RaidBoss was defeated
          if(this instanceof L2RaidBossInstance || this instanceof L2GrandBossInstance  )
          {
            SystemMessage sm;
            sm = new SystemMessage(SystemMessageId.S1_DIED_DROPPED_S3_S2);
            sm.addString(getName());
            sm.addItemName(item.getItemId());
            sm.addNumber(item.getCount());
            broadcastPacket(sm);
            sm = null;
          }
        }
      }

      item = null;
    }

    // Apply Special Item drop with rnd qty for champions
    if(Config.L2JMOD_CHAMPION_ENABLE && isChampion() && player.getLevel() <= getLevel()+3 && Config.L2JMOD_CHAMPION_REWARD > 0 && Rnd.get(100) < Config.L2JMOD_CHAMPION_REWARD)
    {
      int champqty = Rnd.get(Config.L2JMOD_CHAMPION_REWARD_QTY);
      champqty++; //quantity should actually vary between 1 and whatever admin specified as max, inclusive.

      RewardItem item = new RewardItem(Config.L2JMOD_CHAMPION_REWARD_ID, champqty);

      // Give this or these Item(s) to the L2PcInstance that has killed the L2Attackable
      if(Config.AUTO_LOOT)
      {
        L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
       
        if(!player.getInventory().validateCapacity(item_templ))
          DropItem(player, item);
        else
          player.addItem("ChampionLoot", item.getItemId(), item.getCount(), this, true);
         
      }
      else
      {
        DropItem(player, item);
      }

      item = null;
    }

    //Instant Item Drop :>
    double rateHp = getStat().calcStat(Stats.MAX_HP, 1, this, null);

    if(rateHp < 2 && String.valueOf(npcTemplate.type).contentEquals("L2Monster")) //only L2Monster with <= 1x HP can drop herbs
    {
      boolean _hp = false;
      boolean _mp = false;
      boolean _spec = false;

      //ptk - patk type enhance
      int random = Rnd.get(1000); // note *10

      if(random < Config.RATE_DROP_SPECIAL_HERBS && !_spec) // && !_spec useless yet
      {
        RewardItem item = new RewardItem(8612, 1); // Herb of Warrior

        if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
        {
          L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
         
          if(!player.getInventory().validateCapacity(item_templ))
            DropItem(player, item);
          else
            player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
        }
        else
        {
          DropItem(player, item);
        }

        item = null;
        _spec = true;
      }
      else
      {
        for(int i = 0; i < 3; i++)
        {
          random = Rnd.get(100);

          if(random < Config.RATE_DROP_COMMON_HERBS)
          {
            RewardItem item = null;
            if(i == 0)
            {
              item = new RewardItem(8606, 1); // Herb of Power
            }
            if(i == 1)
            {
              item = new RewardItem(8608, 1); // Herb of Atk. Spd.
            }
            if(i == 2)
            {
              item = new RewardItem(8610, 1); // Herb of Critical Attack
            }
           
            if (item == null)
            {
              break;
            }
           
            if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
            {
              L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
             
              if(!player.getInventory().validateCapacity(item_templ))
                DropItem(player, item);
              else
                player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
            }
            else
            {
              DropItem(player, item);
            }
            break;
          }
        }
      }

      //mtk - matk type enhance
      random = Rnd.get(1000); // note *10

      if(random < Config.RATE_DROP_SPECIAL_HERBS && !_spec)
      {
        RewardItem item = new RewardItem(8613, 1); // Herb of Mystic

        if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
        {
          L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
         
          if(!player.getInventory().validateCapacity(item_templ))
            DropItem(player, item);
          else
            player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
        }
        else
        {
          DropItem(player, item);
        }

        item = null;
        _spec = true;
      }
      else
      {
        for(int i = 0; i < 2; i++)
        {
          random = Rnd.get(100);

          if(random < Config.RATE_DROP_COMMON_HERBS)
          {
            RewardItem item = null;
            if(i == 0)
            {
              item = new RewardItem(8607, 1); // Herb of Magic
            }
            if(i == 1)
            {
              item = new RewardItem(8609, 1); // Herb of Casting Speed
            }
            if (item == null)
            {
              break;
            }
            if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
            {
              L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
             
              if(!player.getInventory().validateCapacity(item_templ))
                DropItem(player, item);
              else
                player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
            }
            else
            {
              DropItem(player, item);
            }
            break;
          }
        }
      }

      //hp+mp type
      random = Rnd.get(1000); // note *10

      if(random < Config.RATE_DROP_SPECIAL_HERBS && !_spec)
      {
        RewardItem item = new RewardItem(8614, 1); // Herb of Recovery

        if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
        {
          L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
         
          if(!player.getInventory().validateCapacity(item_templ))
            DropItem(player, item);
          else
            player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
        }
        else
        {
          DropItem(player, item);
        }

        item = null;
        _mp = true;
        _hp = true;
        _spec = true;
      }

      //hp - restore hp type
      if(!_hp)
      {
        random = Rnd.get(100);
        if(random < Config.RATE_DROP_MP_HP_HERBS)
        {
          RewardItem item = new RewardItem(8600, 1); // Herb of Life

          if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
          {
            L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
           
            if(!player.getInventory().validateCapacity(item_templ))
              DropItem(player, item);
            else
              player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
          }
          else
          {
            DropItem(player, item);
          }

          item = null;
          _hp = true;
        }
      }
      if(!_hp)
      {
        random = Rnd.get(100);

        if(random < Config.RATE_DROP_GREATER_HERBS)
        {
          RewardItem item = new RewardItem(8601, 1); // Greater Herb of Life

          if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
          {
            L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
           
            if(!player.getInventory().validateCapacity(item_templ))
              DropItem(player, item);
            else
              player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
          }
          else
          {
            DropItem(player, item);
          }

          item = null;
          _hp = true;
        }
      }
      if(!_hp)
      {
        random = Rnd.get(1000); // note *10

        if(random < Config.RATE_DROP_SUPERIOR_HERBS)
        {
          RewardItem item = new RewardItem(8602, 1); // Superior Herb of Life

          if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
          {
            L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
           
            if(!player.getInventory().validateCapacity(item_templ))
              DropItem(player, item);
            else
              player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
          }
          else
          {
            DropItem(player, item);
          }

          item = null;
        }
      }
      //mp - restore mp type
      if(!_mp)
      {
        random = Rnd.get(100);

        if(random < Config.RATE_DROP_MP_HP_HERBS)
        {
          RewardItem item = new RewardItem(8603, 1); // Herb of Mana

          if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
          {
            L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
           
            if(!player.getInventory().validateCapacity(item_templ))
              DropItem(player, item);
            else
              player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
          }
          else
          {
            DropItem(player, item);
          }

          item = null;
          _mp = true;
        }
      }
      if(!_mp)
      {
        random = Rnd.get(100);

        if(random < Config.RATE_DROP_GREATER_HERBS)
        {
          RewardItem item = new RewardItem(8604, 1); // Greater Herb of Mana

          if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
          {
            L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
           
            if(!player.getInventory().validateCapacity(item_templ))
              DropItem(player, item);
            else
              player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
          }
          else
          {
            DropItem(player, item);
          }

          item = null;
          _mp = true;
        }
      }
      if(!_mp)
      {
        random = Rnd.get(1000); // note *10

        if(random < Config.RATE_DROP_SUPERIOR_HERBS)
        {
          RewardItem item = new RewardItem(8605, 1); // Superior Herb of Mana

          if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
          {
            L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
           
            if(!player.getInventory().validateCapacity(item_templ))
              DropItem(player, item);
            else
              player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
          }
          else
          {
            DropItem(player, item);
          }

          item = null;
        }
      }
      // speed enhance type
      random = Rnd.get(100);

      if(random < Config.RATE_DROP_COMMON_HERBS)
      {
        RewardItem item = new RewardItem(8611, 1); // Herb of Speed

        if(Config.AUTO_LOOT && Config.AUTO_LOOT_HERBS)
        {
          L2Item item_templ = ItemTable.getInstance().getTemplate(item.getItemId());
         
          if(!player.getInventory().validateCapacity(item_templ))
            DropItem(player, item);
          else
            player.addItem("Loot", item.getItemId(), item.getCount(), this, true);
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.templates.L2Item

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.