Package lineage2.gameserver.model.items

Examples of lineage2.gameserver.model.items.PcInventory


    Player activeChar = getClient().getActiveChar();
    if (activeChar == null)
    {
      return;
    }
    PcInventory inventory = activeChar.getInventory();
    ItemInstance itemToEnchant = inventory.getItemByObjectId(_itemId);
    ItemInstance catalyst = inventory.getItemByObjectId(_catalystId);
    if (ItemFunctions.checkCatalyst(itemToEnchant, catalyst))
    {
      activeChar.sendPacket(new ExPutEnchantSupportItemResult(1));
    }
    else
View Full Code Here


    if (activeChar.isInTrade())
    {
      activeChar.sendActionFailed();
      return;
    }
    PcInventory inventory = activeChar.getInventory();
    ItemInstance itemToEnchant = inventory.getItemByObjectId(_objectId);
    ItemInstance stone = activeChar.getEnchantScroll();
    activeChar.setEnchantScroll(null);
    if ((itemToEnchant == null) || (stone == null))
    {
      activeChar.sendActionFailed();
      return;
    }
    ItemTemplate item = itemToEnchant.getTemplate();
    if (!itemToEnchant.canBeEnchanted() || (item.getCrystalType().cry < ItemTemplate.CRYSTAL_S))
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, ActionFail.STATIC);
      return;
    }
    if ((itemToEnchant.getLocation() != ItemInstance.ItemLocation.INVENTORY) && (itemToEnchant.getLocation() != ItemInstance.ItemLocation.PAPERDOLL))
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, ActionFail.STATIC);
      return;
    }
    if (itemToEnchant.isStackable() || ((stone = inventory.getItemByObjectId(stone.getObjectId())) == null))
    {
      activeChar.sendActionFailed();
      return;
    }
    AttributeStoneInfo asi = AttributeStoneManager.getStoneInfo(stone.getItemId());
    if (asi == null)
    {
      return;
    }
    Element element = itemToEnchant.isArmor() ? Element.getReverseElement(asi.getElement()) : asi.getElement();
    if (itemToEnchant.isArmor())
    {
      if (itemToEnchant.getAttributeElementValue(Element.getReverseElement(element), false) != 0)
      {
        activeChar.sendPacket(Msg.ANOTHER_ELEMENTAL_POWER_HAS_ALREADY_BEEN_ADDED_THIS_ELEMENTAL_POWER_CANNOT_BE_ADDED, ActionFail.STATIC);
        return;
      }
    }
    else if (itemToEnchant.isWeapon())
    {
      if ((itemToEnchant.getAttributeElement() != Element.NONE) && (itemToEnchant.getAttributeElement() != element))
      {
        activeChar.sendPacket(Msg.ANOTHER_ELEMENTAL_POWER_HAS_ALREADY_BEEN_ADDED_THIS_ELEMENTAL_POWER_CANNOT_BE_ADDED, ActionFail.STATIC);
        return;
      }
    }
    else
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, ActionFail.STATIC);
      return;
    }
    if (item.isUnderwear() || item.isCloak() || item.isBracelet() || item.isBelt() || !item.isAttributable())
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, ActionFail.STATIC);
      return;
    }
    int maxValue = itemToEnchant.isWeapon() ? asi.getMaxWeapon() : asi.getMaxArmor();
    int minValue = itemToEnchant.isWeapon() ? asi.getMinWeapon() : asi.getMinArmor();
    int currentValue = itemToEnchant.getAttributeElementValue(element, false);
    if ((currentValue >= maxValue) || (currentValue < minValue))
    {
      activeChar.sendPacket(Msg.ELEMENTAL_POWER_ENCHANCER_USAGE_HAS_BEEN_CANCELLED, ActionFail.STATIC);
      return;
    }
    if (itemToEnchant.getOwnerId() != activeChar.getObjectId())
    {
      activeChar.sendPacket(Msg.INAPPROPRIATE_ENCHANT_CONDITIONS, ActionFail.STATIC);
      return;
    }
    if (!inventory.destroyItem(stone, 1L))
    {
      activeChar.sendActionFailed();
      return;
    }
    if (Rnd.chance(asi.getChance()))
View Full Code Here

      player.setEnchantScroll(null);
      player.sendPacket(EnchantResult.CANCEL);
      player.sendPacket(SystemMsg.INAPPROPRIATE_ENCHANT_CONDITIONS);
      player.sendActionFailed();
    }
    PcInventory inventory = player.getInventory();
    inventory.writeLock();
    try
    {
      ItemInstance item = inventory.getItemByObjectId(_objectId);
      ItemInstance scroll = player.getEnchantScroll();
      ItemInstance catalyst = _catalystObjId > 0 ? inventory.getItemByObjectId(_catalystObjId) : null;
      if (!ItemFunctions.checkCatalyst(item, catalyst))
      {
        catalyst = null;
      }
      if ((item == null) || (scroll == null))
      {
        player.sendActionFailed();
        return;
      }
      EnchantScrollInfo esi = EnchantScrollManager.getScrollInfo(scroll.getItemId());
      if (esi == null)
      {
        player.sendActionFailed();
        return;
      }
      if ((item.getEnchantLevel() >= esi.getMax()) || (item.getEnchantLevel() < esi.getMin()))
      {
        player.sendPacket(EnchantResult.CANCEL);
        player.sendPacket(SystemMsg.INAPPROPRIATE_ENCHANT_CONDITIONS);
        player.sendActionFailed();
        return;
      }
      if (esi.getType() != EnchantScrollType.SPECIAL)
      {
        if (!checkItem(item, esi))
        {
          player.sendPacket(EnchantResult.CANCEL);
          player.sendPacket(SystemMsg.DOES_NOT_FIT_STRENGTHENING_CONDITIONS_OF_THE_SCROLL);
          player.sendActionFailed();
          return;
        }
      }
      if ((!inventory.destroyItem(scroll, 1)) || ((catalyst != null) && (!inventory.destroyItem(catalyst, 1))))
      {
        player.sendPacket(EnchantResult.CANCEL);
        player.sendActionFailed();
        return;
      }
      boolean equipped = item.isEquipped();
      if (equipped)
      {
        inventory.isRefresh = true;
        inventory.unEquipItem(item);
      }
      int safeEnchantLevel = item.getTemplate().getBodyPart() == 32768 ? (esi.getSafe() + 1) : esi.getSafe();
      int chance = esi.getChance();
      if (catalyst != null)
      {
        chance += ItemFunctions.getCatalystPower(catalyst.getItemId());
      }
      if ((esi.getType() == EnchantScrollType.ANCIENT) || (esi.getType() == EnchantScrollType.ITEM_MALL))
      {
        chance += 10;
      }
      if (esi.getType() == EnchantScrollType.DIVINE)
      {
        chance = 100;
      }
      if (item.getEnchantLevel() <= safeEnchantLevel)
      {
        chance = 100;
      }
      chance = Math.min(chance, 100);

      if (item.isArmor())
        WorldStatisticsManager.getInstance().updateStat(player, CategoryType.ARMOR_ENCHANT_TRY, item.getCrystalType().ordinal(), item.getEnchantLevel() + 1);
      else if (item.isWeapon())
        WorldStatisticsManager.getInstance().updateStat(player, CategoryType.WEAPON_ENCHANT_TRY, item.getCrystalType().ordinal(), item.getEnchantLevel() + 1);
     
      if (Rnd.chance(chance))
      {
        item.setEnchantLevel(item.getEnchantLevel() + 1);
        item.setJdbcState(JdbcEntityState.UPDATED);
        item.update();
        if (equipped)
        {
          inventory.equipItem(item);
          inventory.isRefresh = false;
        }
        player.sendPacket(new InventoryUpdate().addModifiedItem(item));

        if (item.isArmor())
          WorldStatisticsManager.getInstance().updateStat(player, CategoryType.ARMOR_ENCHANT_MAX, item.getCrystalType().ordinal(), item.getEnchantLevel());

        if (item.isWeapon())

          WorldStatisticsManager.getInstance().updateStat(player, CategoryType.WEAPON_ENCHANT_MAX, item.getCrystalType().ordinal(), item.getEnchantLevel());

        player.sendPacket(new EnchantResult(0, 0, 0L, item.getEnchantLevel()));

        if (Config.SHOW_ENCHANT_EFFECT_RESULT)
        {
          player.broadcastPacket(new L2GameServerPacket[] { new SystemMessage(3013).addName(player).addNumber(item.getEnchantLevel()).addItemName(item.getItemId()) });
          player.broadcastPacket(new L2GameServerPacket[] { new MagicSkillUse(player, player, 5965, 1, 500, 1500L) });
        }
      }
      else
      {
        switch (esi.getType())
        {
          case NORMAL:
            if (item.isEquipped())
            {
              player.sendDisarmMessage(item);
            }
            if (!inventory.destroyItem(item, 1L))
            {
              player.sendActionFailed();
              return;
            }
            int crystalId = item.getCrystalType().cry;
            if ((crystalId > 0) && (item.getTemplate().getCrystalCount() > 0))
            {
              int crystalAmount = (int) (item.getTemplate().getCrystalCount() * 0.87D);
              if (item.getEnchantLevel() > 3)
              {
                crystalAmount = (int) (crystalAmount + (item.getTemplate().getCrystalCount() * 0.25D * (item.getEnchantLevel() - 3)));
              }
              if (crystalAmount < 1)
              {
                crystalAmount = 1;
              }
              player.sendPacket(new EnchantResult(1, crystalId, crystalAmount));
              ItemFunctions.addItem(player, crystalId, crystalAmount, true);
            }
            else
            {
              player.sendPacket(EnchantResult.FAILED_NO_CRYSTALS);
            }
            break;
          case DESTRUCTION:
            item.setEnchantLevel(item.getEnchantLevel());
            item.setJdbcState(JdbcEntityState.UPDATED);
            item.update();
            if (equipped)
            {
              inventory.equipItem(item);
              inventory.isRefresh = false;
            }
            player.sendPacket(new InventoryUpdate().addModifiedItem(item));
            player.sendPacket(SystemMsg.THE_BLESSED_ENCHANT_FAILED);
            player.sendPacket(EnchantResult.ANCIENT_FAILED);
            break;
          case BLESSED:
          case ITEM_MALL:
          case CRYSTALL:
            item.setEnchantLevel(0);
            item.setJdbcState(JdbcEntityState.UPDATED);
            item.update();
            if (equipped)
            {
              inventory.equipItem(item);
              inventory.isRefresh = false;
            }
            player.sendPacket(new InventoryUpdate().addModifiedItem(item));
            player.sendPacket(SystemMsg.THE_BLESSED_ENCHANT_FAILED);
            player.sendPacket(EnchantResult.BLESSED_FAILED);
            break;
          case ANCIENT:
            player.sendPacket(EnchantResult.ANCIENT_FAILED);
            break;
          default:
            break;
        }
      }
    }
    finally
    {
      inventory.writeUnlock();
      player.setEnchantScroll(null);
      player.updateStats();
    }
  }
View Full Code Here

      Player player = cha.getPlayer();
     
      QuestState qs = player.getQuestState(_10301_ShadowOfTerrorBlackishRedFog.class);
      if(qs != null && qs.getCond() == 3 && player.getVar("instance10301") == null)
      {
        Quest q = QuestManager.getQuest(10301);
        player.processQuestEvent(q.getName(), "enterInstance", null);
        //player.setVar("instance10301", "true", -1);
        return;
      }
      if (!player.getVarB("@25_20_telzone_to_magmeld"))
      {
View Full Code Here

    {
      htmltext = "32640-10.htm";
    }
    else if (id == CREATED)
    {
      QuestState ImTheOnlyOneYouCanTrust = st.getPlayer().getQuestState(_240_ImTheOnlyOneYouCanTrust.class);
      if ((st.getPlayer().getLevel() >= 81) && (ImTheOnlyOneYouCanTrust != null) && ImTheOnlyOneYouCanTrust.isCompleted())
      {
        htmltext = "32640-1.htm";
      }
      else
      {
View Full Code Here

      {
        return;
      }
      Player player = cha.getPlayer();
     
      QuestState qs = player.getQuestState(_10301_ShadowOfTerrorBlackishRedFog.class);
      if(qs != null && qs.getCond() == 3 && player.getVar("instance10301") == null)
      {
        Quest q = QuestManager.getQuest(10301);
        player.processQuestEvent(q.getName(), "enterInstance", null);
        //player.setVar("instance10301", "true", -1);
        return;
View Full Code Here

      Class.forName(GarbageCollector.class.getName());
    }
    Shutdown.getInstance().schedule(Config.RESTART_AT_TIME, Shutdown.RESTART);
    _log.info("GameServer Started");
    _log.info("Maximum Numbers of Connected Players: " + Config.MAXIMUM_ONLINE_USERS);
    GamePacketHandler gph = new GamePacketHandler();
    InetAddress serverAddr = Config.GAMESERVER_HOSTNAME.equalsIgnoreCase("*") ? null : InetAddress.getByName(Config.GAMESERVER_HOSTNAME);
    _selectorThreads = new SelectorThread[Config.PORTS_GAME.length];
    for (int i = 0; i < Config.PORTS_GAME.length; i++)
    {
      _selectorThreads[i] = new SelectorThread<>(Config.SELECTOR_CONFIG, gph, gph, gph, null);
View Full Code Here

        getInstance().getListenerEngine().onDay();
      }
      for (Player player : GameObjectsStorage.getAllPlayersForIterate())
      {
        player.checkDayNightMessages();
        player.sendPacket(new ClientSetTime());
      }
    }
View Full Code Here

  void changeAura(NpcInstance actor, int npcId)
  {
    if (npcId != actor.getDisplayId())
    {
      actor.setDisplayId(npcId);
      DeleteObject d = new DeleteObject(actor);
      L2GameServerPacket su = new StatusUpdate(actor).addAttribute(StatusUpdateField.CUR_HP, StatusUpdateField.MAX_HP);
      for (Player player : World.getAroundPlayers(actor))
      {
        player.sendPacket(d, new NpcInfo(actor, player));
        if (player.getTarget() == actor)
View Full Code Here

  public void onShutdown()
  {}
 
  public void broadcastPacket(int value, boolean b)
  {
    L2GameServerPacket trigger = new EventTrigger(value, b);
    for (Player player : GameObjectsStorage.getAllPlayersForIterate())
      player.sendPacket(trigger);

  }
View Full Code Here

TOP

Related Classes of lineage2.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.