Package lineage2.gameserver.model.items

Examples of lineage2.gameserver.model.items.ItemInstance


      if (_pet.getControlItemObjId() != dragonflute_id)
      {
        return false;
      }
    }
    ItemInstance dragonflute = GetDragonflute(st);
    if (dragonflute == null)
    {
      return false;
    }
    if (PetDataTable.getControlItemId(_pet.getNpcId()) != dragonflute.getItemId())
    {
      return false;
    }
    return true;
  }
View Full Code Here


 
  @Override
  public String onEvent(String event, QuestState st, NpcInstance npc)
  {
    int _state = st.getState();
    ItemInstance dragonflute = GetDragonflute(st);
    int dragonflute_id = st.getInt("dragonflute");
    int cond = st.getCond();
    if (event.equalsIgnoreCase("30610_05.htm") && (_state == CREATED))
    {
      st.setState(STARTED);
      st.setCond(1);
      st.playSound(SOUND_ACCEPT);
    }
    else if ((event.equalsIgnoreCase("30747_03.htm") || event.equalsIgnoreCase("30747_04.htm")) && (_state == STARTED) && (cond == 1))
    {
      if (dragonflute == null)
      {
        return "noquest";
      }
      if (dragonflute.getObjectId() != dragonflute_id)
      {
        if (Rnd.chance(10))
        {
          st.takeItems(dragonflute.getItemId(), 1);
          st.playSound(SOUND_FINISH);
          st.exitCurrentQuest(true);
        }
        return "30747_00.htm";
      }
View Full Code Here

  public String onTalk(NpcInstance npc, QuestState st)
  {
    int _state = st.getState();
    int npcId = npc.getNpcId();
    int cond = st.getCond();
    ItemInstance dragonflute = GetDragonflute(st);
    int dragonflute_id = st.getInt("dragonflute");
    if (_state == CREATED)
    {
      if (npcId != Cronos)
      {
        return "noquest";
      }
      if (st.getPlayer().getLevel() < 45)
      {
        st.exitCurrentQuest(true);
        return "30610_01.htm";
      }
      if (dragonflute == null)
      {
        st.exitCurrentQuest(true);
        return "30610_02.htm";
      }
      if (dragonflute.getEnchantLevel() < 55)
      {
        st.exitCurrentQuest(true);
        return "30610_03.htm";
      }
      st.setCond(0);
      st.set("dragonflute", String.valueOf(dragonflute.getObjectId()));
      return "30610_04.htm";
    }
    if (_state != STARTED)
    {
      return "noquest";
    }
    if (npcId == Cronos)
    {
      if (dragonflute == null)
      {
        return "30610_02.htm";
      }
      return dragonflute.getObjectId() == dragonflute_id ? "30610_07.htm" : "30610_06.htm";
    }
    if (npcId == Mimyu)
    {
      if ((st.getQuestItemsCount(Dragon_Bugle_of_Wind) + st.getQuestItemsCount(Dragon_Bugle_of_Star) + st.getQuestItemsCount(Dragon_Bugle_of_Twilight)) > 0)
      {
        return "30747_00b.htm";
      }
      if (dragonflute == null)
      {
        return "noquest";
      }
      if (cond == 1)
      {
        return "30747_01.htm";
      }
      if (cond == 2)
      {
        if (!HatchlingSummoned(st, false))
        {
          return "30747_09.htm";
        }
        if (st.getQuestItemsCount(Fairy_Leaf) == 0)
        {
          st.playSound(SOUND_FINISH);
          st.exitCurrentQuest(true);
          return "30747_11.htm";
        }
        return "30747_10.htm";
      }
      if (cond == 3)
      {
        if (dragonflute.getObjectId() != dragonflute_id)
        {
          return "30747_00a.htm";
        }
        if (st.getQuestItemsCount(Fairy_Leaf) > 0)
        {
          st.playSound(SOUND_FINISH);
          st.exitCurrentQuest(true);
          return "30747_11.htm";
        }
        if (!(CheckTree(st, Fairy_Tree_of_Wind) && CheckTree(st, Fairy_Tree_of_Star) && CheckTree(st, Fairy_Tree_of_Twilight) && CheckTree(st, Fairy_Tree_of_Abyss)))
        {
          st.playSound(SOUND_FINISH);
          st.exitCurrentQuest(true);
          return "30747_11.htm";
        }
        if (st.getInt("welldone") == 0)
        {
          if (!HatchlingSummoned(st, false))
          {
            return "30747_09.htm";
          }
          st.set("welldone", "1");
          return "30747_12.htm";
        }
        if (HatchlingSummoned(st, false) || (st.getPlayer().getSummonList() != null))
        {
          return "30747_13a.htm";
        }
        dragonflute.setItemId((Dragon_Bugle_of_Wind + dragonflute.getItemId()) - Dragonflute_of_Wind);
        dragonflute.setJdbcState(JdbcEntityState.UPDATED);
        dragonflute.update();
        st.getPlayer().sendPacket(new InventoryUpdate().addModifiedItem(dragonflute));
        st.playSound(SOUND_FINISH);
        st.exitCurrentQuest(true);
        return "30747_13.htm";
      }
View Full Code Here

      sb.append("<table width=400>");
      ItemInstance[] arr = activeChar.getInventory().getItems();
      int len = arr.length;
      for (int i = 0; i < len; i++)
      {
        ItemInstance _item = arr[i];
        if ((_item == null) || (_item.getTemplate() instanceof EtcItemTemplate) || _item.getTemplate().isBelt() || _item.getTemplate().isUnderwear() || !_item.isEquipped() || _item.isHeroWeapon() || _item.getTemplate().isBracelet() || _item.getTemplate().isCloak() || (_item.getTemplate().getCrystalType() == ItemTemplate.Grade.NONE) || ((_item.getItemId() >= 7816) && (_item.getItemId() <= 7831)) || _item.isShadowItem() || _item.isCommonItem() || _item.isTemporalItem() || (_item.getEnchantLevel() >= (Config.MAX_ENCHANT + 1)))
        {
          continue;
        }
        sb.append("<tr><td><img src=icon." + _item.getTemplate().getIcon() + " width=32 height=32></td><td>");
        sb.append("<font color=\"LEVEL\">" + _item.getTemplate().getName() + " " + (_item.getEnchantLevel() <= 0 ? "" : "</font><br><font color=3293F3>Enchanted to: +" + _item.getEnchantLevel()) + "</font><br1>");
        sb.append("Enchant for: <font color=\"LEVEL\">" + name + "</font>");
        sb.append("<img src=\"l2ui.squaregray\" width=\"170\" height=\"1\">");
        sb.append("</td><td>");
        sb.append("<button value=\"Enchant\" action=\"bypass _bbsechant;enchlistpage;" + _item.getObjectId() + "\" width=75 height=18 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
        sb.append("</td><td>");
        sb.append("<button value=\"Attribute\" action=\"bypass _bbsechant;enchlistpageAtrChus;" + _item.getObjectId() + "\" width=75 height=18 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
        sb.append("</td></tr>");
      }
      sb.append("</table>");
      String content = HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "pages/enchanter.htm", activeChar);
      content = content.replace("%enchanter%", sb.toString());
      ShowBoard.separateAndSend(BbsUtil.htmlAll(content, activeChar), activeChar);
    }
    if (command.startsWith("_bbsechant;enchlistpage;"))
    {
      StringTokenizer st = new StringTokenizer(command, ";");
      st.nextToken();
      st.nextToken();
      int ItemForEchantObjID = Integer.parseInt(st.nextToken());
      String name = "None Name";
      name = ItemHolder.getInstance().getTemplate(Config.ENCHANTER_ITEM_ID).getName();
      ItemInstance EhchantItem = activeChar.getInventory().getItemByObjectId(ItemForEchantObjID);
      StringBuilder sb = new StringBuilder();
      sb.append("Enchant selected ingredient?<br1><table width=300>");
      sb.append("<tr><td width=32><img src=icon." + EhchantItem.getTemplate().getIcon() + " width=32 height=32> <img src=\"l2ui.squaregray\" width=\"32\" height=\"1\"></td><td width=236><center>");
      sb.append("<font color=\"LEVEL\">" + EhchantItem.getTemplate().getName() + " " + (EhchantItem.getEnchantLevel() <= 0 ? "" : "</font><br1><font color=3293F3>Enchanted to: +" + EhchantItem.getEnchantLevel()) + "</font><br1>");
      sb.append("Enchant for: <font color=\"LEVEL\">" + name + "</font>");
      sb.append("<img src=\"l2ui.squaregray\" width=\"236\" height=\"1\"><center></td>");
      sb.append("<td width=32><img src=icon." + EhchantItem.getTemplate().getIcon() + " width=32 height=32> <img src=\"l2ui.squaregray\" width=\"32\" height=\"1\"></td>");
      sb.append("</tr>");
      sb.append("</table>");
      sb.append("<br>");
      sb.append("<br>");
      sb.append("<table border=0 width=400><tr><td width=200>");
      for (int i = 0; i < Config.ENCHANT_LEVELS.length; i++)
      {
        sb.append("<center><button value=\"Add +" + Config.ENCHANT_LEVELS[i] + " (Price:" + (EhchantItem.getTemplate().isWeapon() ? Config.ENCHANT_PRICE_WPN[i] : Config.ENCHANT_PRICE_ARM[i]) + " " + name + ")\" action=\"bypass _bbsechant;enchantgo;" + Config.ENCHANT_LEVELS[i] + ";" + (EhchantItem.getTemplate().isWeapon() ? Config.ENCHANT_PRICE_WPN[i] : Config.ENCHANT_PRICE_ARM[i]) + ";" + ItemForEchantObjID + "\" width=200 height=20 back=\"L2UI_CT1.Button_DF\" fore=\"L2UI_CT1.Button_DF\">");
        sb.append("<br1>");
      }
      sb.append("</td></tr></table><br1><button value=\"Back\" action=\"bypass _bbsechant;\" width=70 height=18 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
      String content = HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "pages/enchanter.htm", activeChar);
      content = content.replace("%enchanter%", sb.toString());
      ShowBoard.separateAndSend(BbsUtil.htmlAll(content, activeChar), activeChar);
    }
    if (command.startsWith("_bbsechant;enchlistpageAtrChus;"))
    {
      StringTokenizer st = new StringTokenizer(command, ";");
      st.nextToken();
      st.nextToken();
      int ItemForEchantObjID = Integer.parseInt(st.nextToken());
      String name = "None Name";
      name = ItemHolder.getInstance().getTemplate(Config.ENCHANTER_ITEM_ID).getName();
      ItemInstance EhchantItem = activeChar.getInventory().getItemByObjectId(ItemForEchantObjID);
      StringBuilder sb = new StringBuilder();
      sb.append("Enchant selected ingredient?<br><table width=300>");
      sb.append("<tr><td width=32><img src=icon." + EhchantItem.getTemplate().getIcon() + " width=32 height=32> <img src=\"l2ui.squaregray\" width=\"32\" height=\"1\"></td><td width=236><center>");
      sb.append("<font color=\"LEVEL\">" + EhchantItem.getTemplate().getName() + " " + (EhchantItem.getEnchantLevel() <= 0 ? "" : "</font><br1><font color=3293F3>Enchanted to: +" + EhchantItem.getEnchantLevel()) + "</font><br1>");
      sb.append("Enchant for: <font color=\"LEVEL\">" + name + "</font>");
      sb.append("<img src=\"l2ui.squaregray\" width=\"236\" height=\"1\"><center></td>");
      sb.append("<td width=32><img src=icon." + EhchantItem.getTemplate().getIcon() + " width=32 height=32> <img src=\"l2ui.squaregray\" width=\"32\" height=\"1\"></td>");
      sb.append("</tr>");
      sb.append("</table>");
      sb.append("<br>");
      sb.append("<br>");
      sb.append("<table border=0 width=400><tr><td width=200>");
      sb.append("<center><img src=icon.etc_wind_stone_i00 width=32 height=32></center><br>");
      sb.append("<button value=\"Wind \" action=\"bypass _bbsechant;enchlistpageAtr;2;" + ItemForEchantObjID + "\" width=200 height=20 back=\"L2UI_CT1.Button_DF\" fore=\"L2UI_CT1.Button_DF\">");
      sb.append("<br><center><img src=icon.etc_earth_stone_i00 width=32 height=32></center><br>");
      sb.append("<button value=\"Earth \" action=\"bypass _bbsechant;enchlistpageAtr;3;" + ItemForEchantObjID + "\" width=200 height=20 back=\"L2UI_CT1.Button_DF\" fore=\"L2UI_CT1.Button_DF\">");
      sb.append("<br><center><img src=icon.etc_fire_stone_i00 width=32 height=32></center><br>");
      sb.append("<button value=\"Fire \" action=\"bypass _bbsechant;enchlistpageAtr;0;" + ItemForEchantObjID + "\" width=200 height=20 back=\"L2UI_CT1.Button_DF\" fore=\"L2UI_CT1.Button_DF\">");
      sb.append("</td><td width=200>");
      sb.append("<center><img src=icon.etc_water_stone_i00 width=32 height=32></center><br>");
      sb.append("<button value=\"Water \" action=\"bypass _bbsechant;enchlistpageAtr;1;" + ItemForEchantObjID + "\" width=200 height=20 back=\"L2UI_CT1.Button_DF\" fore=\"L2UI_CT1.Button_DF\">");
      sb.append("<br><center><img src=icon.etc_holy_stone_i00 width=32 height=32></center><br>");
      sb.append("<button value=\"Divine \" action=\"bypass _bbsechant;enchlistpageAtr;4;" + ItemForEchantObjID + "\" width=200 height=20 back=\"L2UI_CT1.Button_DF\" fore=\"L2UI_CT1.Button_DF\">");
      sb.append("<br><center><img src=icon.etc_unholy_stone_i00 width=32 height=32></center><br>");
      sb.append("<button value=\"Dark \" action=\"bypass _bbsechant;enchlistpageAtr;5;" + ItemForEchantObjID + "\" width=200 height=20 back=\"L2UI_CT1.Button_DF\" fore=\"L2UI_CT1.Button_DF\">");
      sb.append("</td></tr></table><br1><button value=\"Back\" action=\"bypass _bbsechant;\" width=70 height=18 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
      String content = HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "pages/enchanter.htm", activeChar);
      content = content.replace("%enchanter%", sb.toString());
      ShowBoard.separateAndSend(BbsUtil.htmlAll(content, activeChar), activeChar);
    }
    if (command.startsWith("_bbsechant;enchlistpageAtr;"))
    {
      StringTokenizer st = new StringTokenizer(command, ";");
      st.nextToken();
      st.nextToken();
      int AtributType = Integer.parseInt(st.nextToken());
      int ItemForEchantObjID = Integer.parseInt(st.nextToken());
      String ElementName = "";
      if (AtributType == 0)
      {
        ElementName = "Fire";
      }
      else if (AtributType == 1)
      {
        ElementName = "Water";
      }
      else if (AtributType == 2)
      {
        ElementName = "Wind";
      }
      else if (AtributType == 3)
      {
        ElementName = "Earth";
      }
      else if (AtributType == 4)
      {
        ElementName = "Divine";
      }
      else if (AtributType == 5)
      {
        ElementName = "Dark";
      }
      String name = "None Name";
      name = ItemHolder.getInstance().getTemplate(Config.ENCHANTER_ITEM_ID).getName();
      ItemInstance EhchantItem = activeChar.getInventory().getItemByObjectId(ItemForEchantObjID);
      StringBuilder sb = new StringBuilder();
      sb.append("Chosen Element: <font color=\"LEVEL\">" + ElementName + "</font><br1> Enchant selected ingredient?<br1><table width=300>");
      sb.append("<tr><td width=32><img src=icon." + EhchantItem.getTemplate().getIcon() + " width=32 height=32> <img src=\"l2ui.squaregray\" width=\"32\" height=\"1\"></td><td width=236><center>");
      sb.append("<font color=\"LEVEL\">" + EhchantItem.getTemplate().getName() + " " + (EhchantItem.getEnchantLevel() <= 0 ? "" : "</font><br1><font color=3293F3>Enchant to: +" + EhchantItem.getEnchantLevel()) + "</font><br1>");
      sb.append("Enchant for: <font color=\"LEVEL\">" + name + "</font>");
      sb.append("<img src=\"l2ui.squaregray\" width=\"236\" height=\"1\"><center></td>");
      sb.append("<td width=32><img src=icon." + EhchantItem.getTemplate().getIcon() + " width=32 height=32> <img src=\"l2ui.squaregray\" width=\"32\" height=\"1\"></td>");
      sb.append("</tr>");
      sb.append("</table>");
      sb.append("<br1>");
      sb.append("<br1>");
      if (!EhchantItem.getTemplate().getName().contains("PvP") && ((EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.S) || (EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.S80) || (EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.S84) || (EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.R) || (EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.R95) || (EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.R99)))
      {
        sb.append("<table border=0 width=400><tr><td width=200>");
        for (int i = 0; i < (EhchantItem.getTemplate().isWeapon() ? Config.ENCHANT_ATTRIBUTE_LEVELS.length : Config.ENCHANT_ATTRIBUTE_LEVELS_ARM.length); i++)
        {
          sb.append("<center><button value=\"Add +" + (EhchantItem.getTemplate().isWeapon() ? Config.ENCHANT_ATTRIBUTE_LEVELS[i] : Config.ENCHANT_ATTRIBUTE_LEVELS_ARM[i]) + " (Price:" + (EhchantItem.getTemplate().isWeapon() ? Config.ATTRIBUTE_PRICE_WPN[i] : Config.ATTRIBUTE_PRICE_ARM[i]) + " " + name + ")\" action=\"bypass _bbsechant;enchantgoAtr;" + (EhchantItem.getTemplate().isWeapon() ? Config.ENCHANT_ATTRIBUTE_LEVELS[i] : Config.ENCHANT_ATTRIBUTE_LEVELS_ARM[i]) + ";" + AtributType + ";" + (EhchantItem.getTemplate().isWeapon() ? Config.ATTRIBUTE_PRICE_WPN[i] : Config.ATTRIBUTE_PRICE_ARM[i]) + ";" + ItemForEchantObjID + "\" width=200 height=20 back=\"L2UI_CT1.Button_DF\" fore=\"L2UI_CT1.Button_DF\">");
          sb.append("<br1>");
        }
        sb.append("</td></tr></table><br1>");
      }
      else if (EhchantItem.getTemplate().getName().contains("PvP") && Config.ENCHANT_ATT_PVP && ((EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.S) || (EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.S80) || (EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.S84) || (EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.R) || (EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.R95) || (EhchantItem.getTemplate().getCrystalType() == ItemTemplate.Grade.R99)))
      {
        sb.append("<table border=0 width=400><tr><td width=200>");
        for (int i = 0; i < (EhchantItem.getTemplate().isWeapon() ? Config.ENCHANT_ATTRIBUTE_LEVELS.length : Config.ENCHANT_ATTRIBUTE_LEVELS_ARM.length); i++)
        {
          sb.append("<center><button value=\"Add +" + (EhchantItem.getTemplate().isWeapon() ? Config.ENCHANT_ATTRIBUTE_LEVELS[i] : Config.ENCHANT_ATTRIBUTE_LEVELS_ARM[i]) + " (Price:" + (EhchantItem.getTemplate().isWeapon() ? Config.ATTRIBUTE_PRICE_WPN[i] : Config.ATTRIBUTE_PRICE_ARM[i]) + " " + name + ")\" action=\"bypass _bbsechant;enchantgoAtr;" + (EhchantItem.getTemplate().isWeapon() ? Config.ENCHANT_ATTRIBUTE_LEVELS[i] : Config.ENCHANT_ATTRIBUTE_LEVELS_ARM[i]) + ";" + AtributType + ";" + (EhchantItem.getTemplate().isWeapon() ? Config.ATTRIBUTE_PRICE_WPN[i] : Config.ATTRIBUTE_PRICE_ARM[i]) + ";" + ItemForEchantObjID + "\" width=200 height=20 back=\"L2UI_CT1.Button_DF\" fore=\"L2UI_CT1.Button_DF\">");
          sb.append("<br1>");
        }
        sb.append("</td></tr></table><br1>");
      }
      else
      {
        sb.append("<table border=0 width=400><tr><td width=200>");
        sb.append("<br1>");
        sb.append("<br1>");
        sb.append("<br1>");
        sb.append("<br1>");
        sb.append("<center><font color=\"LEVEL\">Enchant is impossible!</font></center>");
        sb.append("<br1>");
        sb.append("<br1>");
        sb.append("<br1>");
        sb.append("<br1>");
        sb.append("</td></tr></table><br>");
      }
      sb.append("<button value=\"Back\" action=\"bypass _bbsechant;\" width=70 height=18 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
      String content = HtmCache.getInstance().getNotNull(Config.BBS_HOME_DIR + "pages/enchanter.htm", activeChar);
      content = content.replace("%enchanter%", sb.toString());
      ShowBoard.separateAndSend(BbsUtil.htmlAll(content, activeChar), activeChar);
    }
    if (command.startsWith("_bbsechant;enchantgo;"))
    {
      StringTokenizer st = new StringTokenizer(command, ";");
      st.nextToken();
      st.nextToken();
      int EchantVal = Integer.parseInt(st.nextToken());
      int EchantPrice = Integer.parseInt(st.nextToken());
      int EchantObjID = Integer.parseInt(st.nextToken());
      ItemTemplate item = ItemHolder.getInstance().getTemplate(Config.ENCHANTER_ITEM_ID);
      ItemInstance pay = activeChar.getInventory().getItemByItemId(item.getItemId());
      ItemInstance EhchantItem = activeChar.getInventory().getItemByObjectId(EchantObjID);
      if ((pay != null) && (pay.getCount() >= EchantPrice))
      {
        activeChar.getInventory().destroyItem(pay, EchantPrice);
        if (EhchantItem.isEquipped())
        {
          activeChar.getInventory().unEquipItemInBodySlot(EhchantItem.getEquipSlot());
        }
        EhchantItem.setEnchantLevel(EchantVal);
        activeChar.getInventory().equipItem(EhchantItem);
        activeChar.sendPacket(new InventoryUpdate().addModifiedItem(EhchantItem));
        activeChar.broadcastUserInfo();
        activeChar.sendMessage("" + EhchantItem.getTemplate().getName() + " was enchanted to " + EchantVal + ". Thanks.");
        onBypassCommand(activeChar, "_bbsechant;");
      }
      else
      {
        activeChar.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
      }
    }
    if (command.startsWith("_bbsechant;enchantgoAtr;"))
    {
      StringTokenizer st = new StringTokenizer(command, ";");
      st.nextToken();
      st.nextToken();
      int EchantVal = Integer.parseInt(st.nextToken());
      int AtrType = Integer.parseInt(st.nextToken());
      Element el = Element.getElementById(AtrType);
      int EchantPrice = Integer.parseInt(st.nextToken());
      int EchantObjID = Integer.parseInt(st.nextToken());
      ItemTemplate item = ItemHolder.getInstance().getTemplate(Config.ENCHANTER_ITEM_ID);
      ItemInstance pay = activeChar.getInventory().getItemByItemId(item.getItemId());
      ItemInstance EhchantItem = activeChar.getInventory().getItemByObjectId(EchantObjID);
      if (EhchantItem.isWeapon())
      {
        if ((pay != null) && (pay.getCount() >= EchantPrice))
        {
          activeChar.getInventory().destroyItem(pay, EchantPrice);
          if (EhchantItem.isEquipped())
          {
            activeChar.getInventory().unEquipItemInBodySlot(EhchantItem.getEquipSlot());
          }
          EhchantItem.setAttributeElement(el, EchantVal);
          activeChar.getInventory().equipItem(EhchantItem);
          activeChar.sendPacket(new InventoryUpdate().addModifiedItem(EhchantItem));
          activeChar.broadcastUserInfo();
          activeChar.sendMessage("" + EhchantItem.getTemplate().getName() + " was enchanted to " + EchantVal + ". Thanks.");
          onBypassCommand(activeChar, "_bbsechant;");
        }
        else
        {
          activeChar.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
        }
      }
      else if (EhchantItem.isArmor())
      {
        if (!canEnchantArmorAttribute(AtrType, EhchantItem))
        {
          activeChar.sendMessage("attribute reservation by region?");
          onBypassCommand(activeChar, "_bbsechant;");
          return;
        }
        if ((pay != null) && (pay.getCount() >= EchantPrice))
        {
          activeChar.getInventory().destroyItem(pay, EchantPrice);
          if (EhchantItem.isEquipped())
          {
            activeChar.getInventory().unEquipItemInBodySlot(EhchantItem.getEquipSlot());
          }
          EhchantItem.setAttributeElement(el, EchantVal);
          activeChar.getInventory().equipItem(EhchantItem);
          activeChar.sendPacket(new InventoryUpdate().addModifiedItem(EhchantItem));
          activeChar.broadcastUserInfo();
          activeChar.sendMessage("" + EhchantItem.getTemplate().getName() + " was enchanted to " + EchantVal + ". Thanks.");
          onBypassCommand(activeChar, "_bbsechant;");
        }
      }
    }
  }
View Full Code Here

    Player p = (Player) activeChar;
    if (p.isInStoreMode() || p.isProcessingRequest())
    {
      return false;
    }
    ItemInstance item = activeChar.getActiveWeaponInstance();
    if ((item != null) && (((WeaponTemplate) item.getTemplate()).getKamaelConvert() == 0))
    {
      activeChar.sendPacket(SystemMsg.YOU_CANNOT_CONVERT_THIS_ITEM);
      return false;
    }
    return super.checkCondition(activeChar, target, forceUse, dontMove, first);
View Full Code Here

   */
  @Override
  public void useSkill(Creature activeChar, List<Creature> targets)
  {
    final Player player = (Player) activeChar;
    final ItemInstance item = activeChar.getActiveWeaponInstance();
    if (item == null)
    {
      return;
    }
    int itemId = ((WeaponTemplate) item.getTemplate()).getKamaelConvert();
    if (itemId == 0)
    {
      return;
    }
    player.getInventory().unEquipItem(item);
    player.sendPacket(new InventoryUpdate().addRemovedItem(item));
    item.setItemId(itemId);
    player.sendPacket(new ShortCutInit(player));
    for (int shotId : player.getAutoSoulShot())
    {
      player.sendPacket(new ExAutoSoulShot(shotId, true));
    }
View Full Code Here

   */
  @Override
  public void useSkill(Creature caster, List<Creature> targets)
  {
    Player activeChar = caster.getPlayer();
    ItemInstance controlItem = activeChar.getPetControlItem();
    if (controlItem == null)
    {
      return;
    }
    int npcId = PetDataTable.getSummonId(controlItem);
View Full Code Here

  public void restorePet()
  {
    int controlItemId = _owner.getVarInt("petss@");
    if (controlItemId > 0)
    {
      ItemInstance controlItem = _owner.getInventory().getItemByObjectId(controlItemId);
      if (controlItem == null)
      {
        return;
      }
      _owner.setPetControlItem(controlItem);
View Full Code Here

   * @param eng BlockCheckerEngine
   * @param player Player
   */
  private void dropItem(NpcInstance block, int id, BlockCheckerEngine eng, Player player)
  {
    final ItemInstance drop = ItemFunctions.createItem(id);
    drop.dropToTheGround(block, Location.findPointToStay(block, 50));
    eng.addNewDrop(drop);
  }
View Full Code Here

      return false;
    }
    if (object.isItem())
    {
      String dialog;
      ItemInstance item = (ItemInstance) object;
      dialog = HtmCache.getInstance().getNotNull("scripts/actions/admin.L2ItemInstance.onActionShift.htm", player);
      dialog = dialog.replaceFirst("%name%", String.valueOf(item.getTemplate().getName()));
      dialog = dialog.replaceFirst("%objId%", String.valueOf(item.getObjectId()));
      dialog = dialog.replaceFirst("%itemId%", String.valueOf(item.getItemId()));
      dialog = dialog.replaceFirst("%grade%", String.valueOf(item.getCrystalType()));
      dialog = dialog.replaceFirst("%count%", String.valueOf(item.getCount()));
      Player owner = GameObjectsStorage.getPlayer(item.getOwnerId());
      dialog = dialog.replaceFirst("%owner%", String.valueOf(owner == null ? "none" : owner.getName()));
      dialog = dialog.replaceFirst("%ownerId%", String.valueOf(item.getOwnerId()));
      for (Element e : Element.VALUES)
      {
        dialog = dialog.replaceFirst("%" + e.name().toLowerCase() + "Val%", String.valueOf(item.getAttributeElementValue(e, true)));
      }
      dialog = dialog.replaceFirst("%attrElement%", String.valueOf(item.getAttributeElement()));
      dialog = dialog.replaceFirst("%attrValue%", String.valueOf(item.getAttributeElementValue()));
      dialog = dialog.replaceFirst("%enchLevel%", String.valueOf(item.getEnchantLevel()));
      dialog = dialog.replaceFirst("%type%", String.valueOf(item.getItemType()));
      dialog = dialog.replaceFirst("%dropTime%", String.valueOf(item.getDropTimeOwner()));
      show(dialog, player);
      player.sendActionFailed();
    }
    return true;
  }
View Full Code Here

TOP

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

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.