Package l2p.gameserver.model.items

Examples of l2p.gameserver.model.items.PcInventory


    if(activeChar.isOutOfControl() || activeChar.isActionsDisabled() || activeChar.isCastingNow() || activeChar.isAttackingNow())
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, Msg.ActionFail);
      return;
    }
    PcInventory inventory = activeChar.getInventory();
    L2ItemInstance itemToEnchant = inventory.getItemByObjectId(_objectId);
    L2ItemInstance stone = activeChar.getEnchantScroll();
    activeChar.setEnchantScroll(null);
    if(itemToEnchant == null || stone == null)
    {
      activeChar.sendActionFailed();
      return;
    }
    if(itemToEnchant.getOwnerId() != activeChar.getObjectId())
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, Msg.ActionFail);
      return;
    }
    L2Item item = itemToEnchant.getItem();
    // only weapon & armor
    if(!item.isWeapon() && !item.isArmor())
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, Msg.ActionFail);
      return;
    }
    // only S80 & S84
    if(item.getCrystalType().cry != L2Item.CRYSTAL_S)
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, Msg.ActionFail);
      return;
    }
    // only normal weapons & armors
    @SuppressWarnings("rawtypes")
    Enum type = item.getItemType();
    if(type == WeaponType.ETC || type == WeaponType.PET || type == ArmorType.PET || type == ArmorType.SIGIL)
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, Msg.ActionFail);
      return;
    }
    if((!Config.AttributToPvpItem && item.isPvP()) || item.isUnderwear() || item.isBelt())
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, Msg.ActionFail);
      return;
    }
    if(!itemToEnchant.canBeEnchanted() && !(item.isCloak() && Config.ALLOW_ATTRIBUTE_CLOAKS))
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, Msg.ActionFail);
      return;
    }
    if(itemToEnchant.getLocation() != L2ItemInstance.ItemLocation.INVENTORY && itemToEnchant.getLocation() != L2ItemInstance.ItemLocation.PAPERDOLL)
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, Msg.ActionFail);
      return;
    }
    if(activeChar.getPrivateStoreType() != L2Player.STORE_PRIVATE_NONE)
    {
      activeChar.sendPacket(Msg.YOU_CANNOT_ADD_ELEMENTAL_POWER_WHILE_OPERATING_A_PRIVATE_STORE_OR_PRIVATE_WORKSHOP, Msg.ActionFail);
      return;
    }
    if(itemToEnchant.isStackable() || (stone = inventory.getItemByObjectId(stone.getObjectId())) == null)
    {
      activeChar.sendActionFailed();
      return;
    }
    int itemType2 = item.getType2();
    if(itemToEnchant.getAttributeElement() != L2Item.ATTRIBUTE_NONE && itemToEnchant.getAttributeElement() != stone.getEnchantAttributeStoneElement(itemType2 == L2Item.TYPE2_SHIELD_ARMOR))
    {
      activeChar.sendPacket(Msg.ANOTHER_ELEMENTAL_POWER_HAS_ALREADY_BEEN_ADDED_THIS_ELEMENTAL_POWER_CANNOT_BE_ADDED, Msg.ActionFail);
      return;
    }
    int maxValue = itemType2 == L2Item.TYPE2_WEAPON ? 150 : 60;
    if(stone.isAttributeCrystal())
    {
      maxValue += itemType2 == L2Item.TYPE2_WEAPON ? 150 : 60;
    }
    if(itemToEnchant.getAttributeElementValue() >= maxValue)
    {
      activeChar.sendPacket(Msg.ELEMENTAL_POWER_ENCHANCER_USAGE_HAS_BEEN_CANCELLED, Msg.ActionFail);
      return;
    }
    Log.add(activeChar.getName() + "|Trying to attribute enchant|" + itemToEnchant.getItemId() + "|attribute:" + stone.getEnchantAttributeStoneElement(itemType2 == L2Item.TYPE2_SHIELD_ARMOR) + "|" + itemToEnchant.getObjectId(), "enchants");
    L2ItemInstance removedStone;
    synchronized(inventory)
    {
      removedStone = inventory.destroyItem(stone.getObjectId(), 1, true);
    }
    if(removedStone == null)
    {
      activeChar.sendActionFailed();
      return;
    }
    if(Rnd.chance(stone.isAttributeCrystal() ? Config.ENCHANT_ATTRIBUTE_CRYSTAL_CHANCE : Config.ENCHANT_ATTRIBUTE_STONE_CHANCE))
    {
      if(itemToEnchant.getEnchantLevel() == 0)
      {
        SystemMessage sm = new SystemMessage(SystemMessage.S2_ELEMENTAL_POWER_HAS_BEEN_ADDED_SUCCESSFULLY_TO_S1);
        sm.addItemName(itemToEnchant.getItemId());
        sm.addItemName(stone.getItemId());
        activeChar.sendPacket(sm);
      }
      else
      {
        SystemMessage sm = new SystemMessage(SystemMessage.S3_ELEMENTAL_POWER_HAS_BEEN_ADDED_SUCCESSFULLY_TO__S1S2);
        sm.addNumber(itemToEnchant.getEnchantLevel());
        sm.addItemName(itemToEnchant.getItemId());
        sm.addItemName(stone.getItemId());
        activeChar.sendPacket(sm);
      }
      int value = itemType2 == L2Item.TYPE2_WEAPON ? 5 : 6;
      // Для оружия 1й камень дает +20 атрибута
      if(itemToEnchant.getAttributeElementValue() == 0 && itemType2 == L2Item.TYPE2_WEAPON)
      {
        value = 20;
      }
      itemToEnchant.setAttributeElement(stone.getEnchantAttributeStoneElement(itemType2 == L2Item.TYPE2_SHIELD_ARMOR), itemToEnchant.getAttributeElementValue() + value, true);
      inventory.refreshListeners();
      activeChar.sendPacket(new InventoryUpdate().addModifiedItem(itemToEnchant));
      Log.add(activeChar.getName() + "|Successfully enchanted by attribute|" + itemToEnchant.getItemId() + "|to+" + itemToEnchant.getAttributeElementValue() + "|" + (stone.isAttributeCrystal() ? Config.ENCHANT_ATTRIBUTE_CRYSTAL_CHANCE : Config.ENCHANT_ATTRIBUTE_STONE_CHANCE), "enchants");
      Log.LogItem(activeChar, Log.EnchantItem, itemToEnchant);
    }
    else
View Full Code Here


    L2Player activeChar = getClient().getActiveChar();
    if(activeChar == null || _items == null || !activeChar.getPlayerAccess().UseWarehouse)
    {
      return;
    }
    PcInventory inventory = activeChar.getInventory();
    long adenaDeposit = 0;
    int adenaObjId;
    L2ItemInstance adena = inventory.getItemByItemId(57);
    if(adena != null)
    {
      adenaObjId = adena.getObjectId();
    }
    else
    {
      adenaObjId = -1;
    }
    for(Integer itemObjectId : _items.keySet())
    {
      L2ItemInstance item = inventory.getItemByObjectId(itemObjectId);
      if(item == null || item.isEquipped())
      {
        return;
      }
      if(_items.get(itemObjectId) < 0)
      {
        return;
      }
      if(itemObjectId == adenaObjId)
      {
        adenaDeposit = _items.get(itemObjectId);
      }
    }
    L2NpcInstance freighter = activeChar.getLastNpc();
    if(freighter == null || !activeChar.isInRange(freighter.getLoc(), L2Character.INTERACTION_DISTANCE))
    {
      activeChar.sendPacket(Msg.YOU_FAILED_AT_SENDING_THE_PACKAGE_BECAUSE_YOU_ARE_TOO_FAR_FROM_THE_WAREHOUSE);
      return;
    }
    int fee = _items.size() * _FREIGHT_FEE;
    if(fee + adenaDeposit > activeChar.getAdena())
    {
      activeChar.sendPacket(Msg.YOU_LACK_THE_FUNDS_NEEDED_TO_PAY_FOR_THIS_TRANSACTION);
      return;
    }
    Warehouse warehouse = new PcFreight(_objectID);
    // Item Max Limit Check
    if(_items.size() + warehouse.listItems(ItemClass.ALL).length > activeChar.getFreightLimit())
    {
      activeChar.sendPacket(Msg.THE_CAPACITY_OF_THE_WAREHOUSE_HAS_BEEN_EXCEEDED);
      return;
    }
    // Transfer the items from activeChar's Inventory Instance to destChar's Freight Instance
    for(Integer itemObjectId : _items.keySet())
    {
      L2ItemInstance found = inventory.getItemByObjectId(itemObjectId);
      if(found == null || !found.canBeDropped(activeChar, false))
      {
        continue;
      }
      warehouse.addItem(inventory.dropItem(found, _items.get(itemObjectId), false), null);
    }
    activeChar.reduceAdena(fee, true);
    activeChar.updateStats();
    // Delete destination L2Player used for freight
    activeChar.sendPacket(Msg.THE_TRANSACTION_IS_COMPLETE);
View Full Code Here

TOP

Related Classes of l2p.gameserver.model.items.PcInventory

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.