Package lineage2.gameserver.templates.item

Examples of lineage2.gameserver.templates.item.RecipeTemplate


      statement.setInt(1, getObjectId());
      rset = statement.executeQuery();
      while (rset.next())
      {
        int id = rset.getInt("id");
        RecipeTemplate recipe = RecipeHolder.getInstance().getRecipeByRecipeId(id);
        registerRecipe(recipe, false);
      }
    }
    catch (Exception e)
    {
View Full Code Here


    if ((manufacturer == null) || (manufacturer.getPrivateStoreType() != Player.STORE_PRIVATE_MANUFACTURE) || !manufacturer.isInRangeZ(buyer, Creature.INTERACTION_DISTANCE))
    {
      buyer.sendActionFailed();
      return;
    }
    RecipeTemplate recipe = null;
    for (ManufactureItem mi : manufacturer.getCreateList())
    {
      if (mi.getRecipeId() == _recipeId)
      {
        if (_price == mi.getCost())
        {
          recipe = RecipeHolder.getInstance().getRecipeByRecipeId(_recipeId);
          break;
        }
      }
    }
    if (recipe == null)
    {
      buyer.sendActionFailed();
      return;
    }
    if (recipe.getMaterials().length == 0)
    {
      manufacturer.sendPacket(SystemMsg.THE_RECIPE_IS_INCORRECT);
      buyer.sendPacket(SystemMsg.THE_RECIPE_IS_INCORRECT);
      return;
    }
    if (!manufacturer.findRecipe(_recipeId))
    {
      buyer.sendActionFailed();
      return;
    }
    int success = 0;
    if (manufacturer.getCurrentMp() < recipe.getMpConsume())
    {
      manufacturer.sendPacket(SystemMsg.NOT_ENOUGH_MP);
      buyer.sendPacket(SystemMsg.NOT_ENOUGH_MP, new RecipeShopItemInfo(buyer, manufacturer, _recipeId, _price, success));
      return;
    }
    buyer.getInventory().writeLock();
    try
    {
      if (buyer.getAdena() < _price)
      {
        buyer.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA, new RecipeShopItemInfo(buyer, manufacturer, _recipeId, _price, success));
        return;
      }
      RecipeTemplate.RecipeComponent[] materials = recipe.getMaterials();
      for (RecipeTemplate.RecipeComponent material : materials)
      {
        if (material.getCount() == 0)
        {
          continue;
        }
        ItemInstance item = buyer.getInventory().getItemByItemId(material.getItemId());
        if ((item == null) || (material.getCount() > item.getCount()))
        {
          buyer.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_MATERIALS_TO_PERFORM_THAT_ACTION, new RecipeShopItemInfo(buyer, manufacturer, _recipeId, _price, success));
          return;
        }
      }
      if (!buyer.reduceAdena(_price, false))
      {
        buyer.sendPacket(SystemMsg.YOU_DO_NOT_HAVE_ENOUGH_ADENA, new RecipeShopItemInfo(buyer, manufacturer, _recipeId, _price, success));
        return;
      }
      for (RecipeTemplate.RecipeComponent material : materials)
      {
        if (material.getCount() == 0)
        {
          continue;
        }
        buyer.getInventory().destroyItemByItemId(material.getItemId(), material.getCount());
        buyer.sendPacket(SystemMessage2.removeItems(material.getItemId(), material.getCount()));
      }
      long tax = TradeHelper.getTax(manufacturer, _price);
      if (tax > 0)
      {
        _price -= tax;
      }
      manufacturer.addAdena(_price);
    }
    finally
    {
      buyer.getInventory().writeUnlock();
    }
    manufacturer.reduceCurrentMp(recipe.getMpConsume(), null);
    manufacturer.sendStatusUpdate(false, false, StatusUpdateField.CUR_MP);
    RecipeTemplate.RecipeComponent product = recipe.getRandomProduct();
    int itemId = product.getItemId();
    long itemsCount = product.getCount();
    if (Rnd.chance(recipe.getSuccessRate()))
    {
      ItemFunctions.addItem(buyer, itemId, itemsCount, true);
      if (itemsCount > 1)
      {
        SystemMessage sm = new SystemMessage(SystemMessage.S1_CREATED_S2_S3_AT_THE_PRICE_OF_S4_ADENA);
View Full Code Here

    if ((playable == null) || !playable.isPlayer())
    {
      return false;
    }
    final Player player = (Player) playable;
    final RecipeTemplate rp = RecipeHolder.getInstance().getRecipeByRecipeItem(item.getItemId());
    if (rp.isDwarven())
    {
      if (player.getDwarvenRecipeLimit() > 0)
      {
        if (player.getDwarvenRecipeBook().size() >= player.getDwarvenRecipeLimit())
        {
          player.sendPacket(Msg.NO_FURTHER_RECIPES_MAY_BE_REGISTERED);
          return false;
        }
        if (rp.getLevel() > player.getSkillLevel(Skill.SKILL_CRAFTING))
        {
          player.sendPacket(Msg.CREATE_ITEM_LEVEL_IS_TOO_LOW_TO_REGISTER_THIS_RECIPE);
          return false;
        }
        if (player.hasRecipe(rp))
View Full Code Here

    if (activeChar.getPrivateStoreType() == Player.STORE_PRIVATE_MANUFACTURE)
    {
      activeChar.sendActionFailed();
      return;
    }
    RecipeTemplate rp = RecipeHolder.getInstance().getRecipeByRecipeId(_recipeId);
    if (rp == null)
    {
      activeChar.sendActionFailed();
      return;
    }
    activeChar.unregisterRecipe(_recipeId);
    activeChar.sendPacket(new RecipeBookItemList(activeChar, rp.isDwarven()));
  }
View Full Code Here

   * @param template NpcTemplate
   */
  public Kama26BossInstance(int objectId, NpcTemplate template)
  {
    super(objectId, template);
    getMinionList().addMinion(new MinionData(18556, 1));
  }
View Full Code Here

    ThreadPoolManager.getInstance().schedule(new RunnableImpl()
    {
      @Override
      public void runImpl()
      {
        final NpcTemplate template = NpcHolder.getInstance().getTemplate(18602);
        if (template != null)
        {
          final NpcInstance a = template.getNewInstance();
          a.setCurrentHpMp(a.getMaxHp(), a.getMaxMp());
          a.spawnMe(actor.getLoc());
        }
      }
    }, 10000L);
View Full Code Here

      {
        player.sendPacket(Msg.YOU_CANNOT_TELEPORT_TO_A_VILLAGE_THAT_IS_IN_A_SIEGE);
        return;
      }
    }
    final Location pos = Location.findPointToStay(x, y, z, 50, 100, player.getGeoIndex());
    if (price > 0)
    {
      player.reduceAdena(price, true);
    }
    player.teleToLocation(pos);
View Full Code Here

      player.sendPacket(SystemMessage2.removeItems(item, count));
    }
    final int x = Integer.parseInt(param[0]);
    final int y = Integer.parseInt(param[1]);
    final int z = Integer.parseInt(param[2]);
    final Location pos = Location.findPointToStay(x, y, z, 20, 70, player.getGeoIndex());
    player.teleToLocation(pos);
  }
View Full Code Here

      return;
    }
    final String var = player.getVar("DCBackCoords");
    if ((var == null) || var.isEmpty())
    {
      player.teleToLocation(new Location(43768, -48232, -800), 0);
      return;
    }
    player.teleToLocation(Location.parseLoc(var), 0);
    player.unsetVar("DCBackCoords");
  }
View Full Code Here

    }
    for (Player player : World.getAroundPlayers(actor, 200, 200))
    {
      if (player != null)
      {
        player.teleToLocation(new Location(207559, 86429, -1000));
      }
    }
    return true;
  }
View Full Code Here

TOP

Related Classes of lineage2.gameserver.templates.item.RecipeTemplate

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.