Package lineage2.gameserver.model

Examples of lineage2.gameserver.model.Player$SummonSkillCastingTask


   * Method runImpl.
   */
  @Override
  protected void runImpl()
  {
    Player player = getClient().getActiveChar();
    if (player == null)
    {
      return;
    }
    player.sendPacket(new ExListMpccWaiting(player, _listId, _locationId, _allLevels));
  }
View Full Code Here


   * Method runImpl.
   */
  @Override
  protected void runImpl()
  {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null)
    {
      return;
    }
    if (activeChar.isActionsDisabled())
    {
      activeChar.sendActionFailed();
      return;
    }
    if (activeChar.isInStoreMode())
    {
      activeChar.sendActionFailed();
      return;
    }
    if (activeChar.isProcessingRequest())
    {
      activeChar.sendActionFailed();
      return;
    }
    if (activeChar.isFishing())
    {
      activeChar.sendPacket(SystemMsg.YOU_CANNOT_DO_THAT_WHILE_FISHING_);
      return;
    }
    RecipeTemplate recipe = RecipeHolder.getInstance().getRecipeByRecipeId(_recipeId);
    if ((recipe == null) || (recipe.getMaterials().length == 0))
    {
      activeChar.sendPacket(SystemMsg.THE_RECIPE_IS_INCORRECT);
      return;
    }
    if (activeChar.getCurrentMp() < recipe.getMpConsume())
    {
      activeChar.sendPacket(SystemMsg.NOT_ENOUGH_MP, new RecipeItemMakeInfo(activeChar, recipe, 0));
      return;
    }
    if (!activeChar.findRecipe(_recipeId))
    {
      activeChar.sendPacket(SystemMsg.PLEASE_REGISTER_A_RECIPE, ActionFail.STATIC);
      return;
    }
    activeChar.getInventory().writeLock();
    try
    {
      RecipeComponent[] materials = recipe.getMaterials();
      for (RecipeComponent material : materials)
      {
        if (material.getCount() == 0)
        {
          continue;
        }
        if (Config.ALT_GAME_UNREGISTER_RECIPE && (ItemHolder.getInstance().getTemplate(material.getItemId()).getItemType() == EtcItemType.RECIPE))
        {
          RecipeTemplate rp = RecipeHolder.getInstance().getRecipeByRecipeItem(material.getItemId());
          if (activeChar.hasRecipe(rp))
          {
            continue;
          }
          activeChar.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_MATERIALS_TO_PERFORM_THAT_ACTION, new RecipeItemMakeInfo(activeChar, recipe, 0));
          return;
        }
        ItemInstance item = activeChar.getInventory().getItemByItemId(material.getItemId());
        if ((item == null) || (item.getCount() < material.getCount()))
        {
          activeChar.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_MATERIALS_TO_PERFORM_THAT_ACTION, new RecipeItemMakeInfo(activeChar, recipe, 0));
          return;
        }
      }
      for (RecipeComponent material : materials)
      {
        if (material.getCount() == 0)
        {
          continue;
        }
        if (Config.ALT_GAME_UNREGISTER_RECIPE && (ItemHolder.getInstance().getTemplate(material.getItemId()).getItemType() == EtcItemType.RECIPE))
        {
          activeChar.unregisterRecipe(RecipeHolder.getInstance().getRecipeByRecipeItem(material.getItemId()).getId());
        }
        else
        {
          if (!activeChar.getInventory().destroyItemByItemId(material.getItemId(), material.getCount()))
          {
            continue;
          }
          activeChar.sendPacket(SystemMessage2.removeItems(material.getItemId(), material.getCount()));
        }
      }
    }
    finally
    {
      activeChar.getInventory().writeUnlock();
    }
    activeChar.resetWaitSitTime();
    activeChar.reduceCurrentMp(recipe.getMpConsume(), null);
    RecipeComponent product = recipe.getRandomProduct();
    int itemId = product.getItemId();
    long itemsCount = product.getCount();
    int success = 0;
    if (Rnd.chance(recipe.getSuccessRate()))
    {
      ItemFunctions.addItem(activeChar, itemId, itemsCount, true);
      success = 1;
    }
    else
    {
      activeChar.sendPacket(new SystemMessage(SystemMessage.S1_MANUFACTURING_FAILURE).addItemName(itemId));
    }
    activeChar.sendPacket(new RecipeItemMakeInfo(activeChar, recipe, success));
  }
View Full Code Here

   * Method runImpl.
   */
  @Override
  protected void runImpl()
  {
    Player player = getClient().getActiveChar();
    if (player == null)
    {
      return;
    }
    if (!isValidPlayer(player))
    {
      player.sendPacket(ExPutEnchantTargetItemResult.FAIL);
      player.setEnchantScroll(null);
      return;
    }
    PcInventory inventory = player.getInventory();
    ItemInstance itemToEnchant = inventory.getItemByObjectId(_objectId);
    ItemInstance scroll = player.getEnchantScroll();
    if ((itemToEnchant == null) || (scroll == null))
    {
      player.sendPacket(ExPutEnchantTargetItemResult.FAIL);
      player.setEnchantScroll(null);
      return;
    }
    Log.add(player.getName() + "|Trying to put enchant|" + itemToEnchant.getItemId() + "|+" + itemToEnchant.getEnchantLevel() + "|" + itemToEnchant.getObjectId(), "enchants");
    EnchantScrollInfo esi = EnchantScrollManager.getScrollInfo(scroll.getItemId());
    if (esi == null)
    {
      player.sendActionFailed();
      return;
    }
    if (!checkItem(itemToEnchant, esi))
    {
      player.sendPacket(ExPutEnchantTargetItemResult.FAIL);
      player.sendPacket(SystemMsg.INAPPROPRIATE_ENCHANT_CONDITIONS);
      player.setEnchantScroll(null);
      return;
    }
    if ((scroll = inventory.getItemByObjectId(scroll.getObjectId())) == null)
    {
      player.sendPacket(ExPutEnchantTargetItemResult.FAIL);
      player.setEnchantScroll(null);
      return;
    }
    if ((itemToEnchant.getEnchantLevel() >= esi.getMax()) || (itemToEnchant.getEnchantLevel() < esi.getMin()))
    {
      player.sendPacket(ExPutEnchantTargetItemResult.FAIL);
      player.sendPacket(SystemMsg.INAPPROPRIATE_ENCHANT_CONDITIONS);
      player.setEnchantScroll(null);
      return;
    }
    if (itemToEnchant.getOwnerId() != player.getObjectId())
    {
      player.sendPacket(ExPutEnchantTargetItemResult.FAIL);
      player.setEnchantScroll(null);
      return;
    }
    player.sendPacket(ExPutEnchantTargetItemResult.SUCCESS);
  }
View Full Code Here

  @Override
  public String onTalk(NpcInstance npc, QuestState st)
  {
    st.getCond();
    npc.getNpcId();
    Player player = st.getPlayer();
    String htmltext = "noquest";
    if (npc.getNpcId() == NPC_SEBIO)
    {
      switch (st.getState())
      {
        case COMPLETED:
          htmltext = "32978-06.htm";
          break;
        case CREATED:
          if (player.getLevel() < 85)
          {
            htmltext = "32978-05.htm";
          }
          else
          {
View Full Code Here

   * Method runImpl.
   */
  @Override
  protected void runImpl()
  {
    Player player = getClient().getActiveChar();
    if ((player == null) || !Config.EX_NEW_PETITION_SYSTEM)
    {
      return;
    }
    PetitionMainGroup group = PetitionGroupHolder.getInstance().getPetitionGroup(_petitionGroupId);
    if (group == null)
    {
      return;
    }
    player.setPetitionGroup(group);
    player.sendPacket(new ExResponseShowStepTwo(player, group));
  }
View Full Code Here

   * Method runImpl.
   */
  @Override
  protected void runImpl()
  {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null)
    {
      return;
    }
    if ((activeChar.getPrivateStoreType() != Player.STORE_PRIVATE_NONE) || activeChar.isDead())
    {
      return;
    }
    ItemInstance item = activeChar.getInventory().getItemByItemId(_itemId);
    if (item == null)
    {
      return;
    }
    if (_type)
    {
      activeChar.addAutoSoulShot(_itemId);
      activeChar.sendPacket(new ExAutoSoulShot(_itemId, true));
      activeChar.sendPacket(new SystemMessage(SystemMessage.THE_USE_OF_S1_WILL_NOW_BE_AUTOMATED).addString(item.getName()));
      IItemHandler handler = item.getTemplate().getHandler();
      handler.useItem(activeChar, item, false);
      return;
    }
    activeChar.removeAutoSoulShot(_itemId);
    activeChar.sendPacket(new ExAutoSoulShot(_itemId, false));
    activeChar.sendPacket(new SystemMessage(SystemMessage.THE_AUTOMATIC_USE_OF_S1_WILL_NOW_BE_CANCELLED).addString(item.getName()));
  }
View Full Code Here

   * Method runImpl.
   */
  @Override
  protected void runImpl()
  {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null)
    {
      return;
    }
    activeChar.setPrivateStoreType(Player.STORE_PRIVATE_NONE);
    activeChar.standUp();
    activeChar.broadcastCharInfo();
  }
View Full Code Here

   * Method runImpl.
   */
  @Override
  protected void runImpl()
  {
    Player player = getClient().getActiveChar();
    if (player == null)
    {
      return;
    }
    if (StringUtils.isEmpty(_name))
    {
      return;
    }
    int key = 0;
    IntObjectMap<String> postFriends = player.getPostFriends();
    for (IntObjectMap.Entry<String> entry : postFriends.entrySet())
    {
      if (entry.getValue().equalsIgnoreCase(_name))
      {
        key = entry.getKey();
      }
    }
    if (key == 0)
    {
      player.sendPacket(SystemMsg.THE_NAME_IS_NOT_CURRENTLY_REGISTERED);
      return;
    }
    player.getPostFriends().remove(key);
    CharacterPostFriendDAO.getInstance().delete(player, key);
    player.sendPacket(new SystemMessage2(SystemMsg.S1_WAS_SUCCESSFULLY_DELETED_FROM_YOUR_CONTACT_LIST).addString(_name));
  }
View Full Code Here

   * Method runImpl.
   */
  @Override
  protected void runImpl()
  {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null)
    {
      return;
    }
    if (activeChar.isActionsDisabled())
    {
      activeChar.sendActionFailed();
      return;
    }
    Player manufacturer = (Player) activeChar.getVisibleObject(_manufacturerId);
    if ((manufacturer == null) || (manufacturer.getPrivateStoreType() != Player.STORE_PRIVATE_MANUFACTURE) || !manufacturer.isInRangeZ(activeChar, Creature.INTERACTION_DISTANCE))
    {
      activeChar.sendActionFailed();
      return;
    }
    activeChar.sendPacket(new RecipeShopSellList(activeChar, manufacturer));
View Full Code Here

   * Method runImpl.
   */
  @Override
  protected void runImpl()
  {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null)
    {
      return;
    }
    if (activeChar.getTransformation() != 0)
    {
      activeChar.sendMessage("You must leave transformation mode first.");
      return;
    }
    if ((activeChar.getLevel() < 76) || (activeChar.getClassLevel() < 4))
    {
      activeChar.sendMessage("You must have 3rd class change quest completed.");
      return;
    }
    EnchantSkillLearn sl = SkillTreeTable.getSkillEnchant(_skillId, _skillLvl);
    if (sl == null)
    {
      return;
    }
    int slevel = activeChar.getSkillLevel(_skillId);
    if (slevel == -1)
    {
      return;
    }
    int enchantLevel = SkillTreeTable.convertEnchantLevel(sl.getBaseLevel(), _skillLvl, sl.getMaxLevel());
    if (slevel >= enchantLevel)
    {
      return;
    }
    if (slevel == sl.getBaseLevel() ? (_skillLvl % 100) != 1 : slevel != (enchantLevel - 1))
    {
      activeChar.sendMessage("Incorrect enchant level.");
      return;
    }
    Skill skill = SkillTable.getInstance().getInfo(_skillId, enchantLevel);
    if (skill == null)
    {
      return;
    }
    int[] cost = sl.getCost();
    int requiredSp = cost[1] * SkillTreeTable.SAFE_ENCHANT_COST_MULTIPLIER * sl.getCostMult();
    int requiredAdena = cost[0] * SkillTreeTable.SAFE_ENCHANT_COST_MULTIPLIER * sl.getCostMult();
    int rate = sl.getRate(activeChar);
    if (activeChar.getSp() < requiredSp)
    {
      sendPacket(Msg.SP_REQUIRED_FOR_SKILL_ENCHANT_IS_INSUFFICIENT);
      return;
    }
    if (activeChar.getAdena() < requiredAdena)
    {
      sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
      return;
    }
    if (_skillId < 10000)
    {
      if (Functions.getItemCount(activeChar, SkillTreeTable.SAFE_ENCHANT_BOOK) == 0)
      {
        activeChar.sendPacket(Msg.ITEMS_REQUIRED_FOR_SKILL_ENCHANT_ARE_INSUFFICIENT);
        return;
      }
      Functions.removeItem(activeChar, SkillTreeTable.SAFE_ENCHANT_BOOK, 1);
    }
    else if (_skillId >= 10000)
    {
      if (Functions.getItemCount(activeChar, SkillTreeTable.NEW_SAFE_ENCHANT_BOOK) == 0)
      {
        activeChar.sendPacket(Msg.ITEMS_REQUIRED_FOR_SKILL_ENCHANT_ARE_INSUFFICIENT);
        return;
      }
      Functions.removeItem(activeChar, SkillTreeTable.NEW_SAFE_ENCHANT_BOOK, 1);
    }
    if (Rnd.chance(rate))
    {
      activeChar.addSkill(skill, true);
      activeChar.addExpAndSp(0, -1 * requiredSp);
      Functions.removeItem(activeChar, 57, requiredAdena);
      activeChar.sendPacket(new SystemMessage(SystemMessage.SP_HAS_DECREASED_BY_S1).addNumber(requiredSp), new SystemMessage(SystemMessage.SUCCEEDED_IN_ENCHANTING_SKILL_S1).addSkillName(_skillId, _skillLvl), new ExEnchantSkillResult(1));
      activeChar.sendSkillList();
      RequestExEnchantSkill.updateSkillShortcuts(activeChar, _skillId, _skillLvl);
      Log.add(activeChar.getName() + "|Successfully safe enchanted|" + _skillId + "|to+" + _skillLvl + "|" + rate, "enchant_skills");
    }
    else
    {
      activeChar.sendPacket(new SystemMessage(SystemMessage.Skill_enchant_failed_Current_level_of_enchant_skill_S1_will_remain_unchanged).addSkillName(_skillId, _skillLvl), new ExEnchantSkillResult(0));
      Log.add(activeChar.getName() + "|Failed to safe enchant|" + _skillId + "|to+" + _skillLvl + "|" + rate, "enchant_skills");
    }
    activeChar.sendPacket(new ExEnchantSkillInfo(_skillId, activeChar.getSkillDisplayLevel(_skillId)));
  }
View Full Code Here

TOP

Related Classes of lineage2.gameserver.model.Player$SummonSkillCastingTask

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.