Package l2p.gameserver.serverpackets

Examples of l2p.gameserver.serverpackets.RecipeShopItemInfo


    if(price == -1)
    {
      activeChar.sendActionFailed();
      return;
    }
    activeChar.sendPacket(new RecipeShopItemInfo(_manufacturerObjectId, _recipeId, price, 0xFFFFFFFF, activeChar));
  }
View Full Code Here


    synchronized(player)
    {
      if(player.getCurrentMp() < recipeList.getMpCost())
      {
        player.sendPacket(Msg.NOT_ENOUGH_MP);
        employer.sendPacket(Msg.NOT_ENOUGH_MP, new RecipeShopItemInfo(player.getObjectId(), recipeListId, price, success, employer));
        return;
      }
      if(!player.findRecipe(recipeListId))
      {
        player.sendPacket(Msg.PLEASE_REGISTER_A_RECIPE, Msg.ActionFail);
        return;
      }
    }
    if(employer.getAdena() < price)
    {
      employer.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA, new RecipeShopItemInfo(player.getObjectId(), recipeListId, price, success, employer));
      return;
    }
    synchronized(employer.getInventory())
    {
      L2RecipeComponent[] recipes = recipeList.getRecipes();
      Inventory inventory = employer.getInventory();
      for(L2RecipeComponent recipe : recipes)
      {
        if(recipe.getQuantity() == 0)
        {
          continue;
        }
        L2ItemInstance invItem = inventory.getItemByItemId(recipe.getItemId());
        if(invItem == null || recipe.getQuantity() > invItem.getCount())
        {
          employer.sendPacket(Msg.NOT_ENOUGH_MATERIALS, new RecipeShopItemInfo(player.getObjectId(), recipeListId, price, success, employer));
          return;
        }
      }
      player.reduceCurrentMp(recipeList.getMpCost(), null);
      for(L2RecipeComponent recipe : recipes)
      {
        if(recipe.getQuantity() != 0)
        {
          L2ItemInstance invItem = inventory.getItemByItemId(recipe.getItemId());
          inventory.destroyItem(invItem, recipe.getQuantity(), false);
          employer.sendPacket(SystemMessage.removeItems(invItem.getItemId(), recipe.getQuantity()));
        }
      }
    }
    if(price > 0)
    {
      employer.reduceAdena(price, false);
      player.addAdena(price);
      int tax = (int) (price * Config.SERVICES_TRADE_TAX / 100);
      if(player.isInZone(L2Zone.ZoneType.offshore))
      {
        tax = (int) (price * Config.SERVICES_OFFSHORE_TRADE_TAX / 100);
      }
      if(Config.SERVICES_TRADE_TAX_ONLY_OFFLINE && !player.isInOfflineMode())
      {
        tax = 0;
      }
      if(player.getReflection().getId() == -1) // Особая зона в Parnassus
      {
        tax = 0;
      }
      if(tax > 0)
      {
        player.reduceAdena(tax, false);
        Stat.addTax(tax);
        player.sendMessage(new CustomMessage("trade.HavePaidTax", player).addNumber(tax));
      }
    }
    int tryCount = 1, successCount = 0;
    if(rollMW(player, recipeList))
    {
      tryCount++;
    }
    SystemMessage msgtoemployer;
    SystemMessage msgtomaster;
    for(int i = 0; i < tryCount; i++)
    {
      if(Rnd.chance(recipeList.getSuccessRate()))
      {
        L2ItemInstance createdItem = ItemTable.getInstance().createItem(rollMW(player, recipeList) ? recipeList.getFoundation() : recipeList.getItemId());
        createdItem.setCount(recipeList.getCount());
        employer.getInventory().addItem(createdItem);
        employer.sendPacket(SystemMessage.obtainItems(createdItem));
        if(Config.CRAFT_COUNTER)
        {
          player.incrementCraftCounter((int) recipeList.getItemId(), recipeList.getCount());
        }
        success = 1;
        successCount++;
      }
    }
    if(successCount == 0)
    {
      msgtoemployer = new SystemMessage(SystemMessage.S1_HAS_FAILED_TO_CREATE_S2_AT_THE_PRICE_OF_S3_ADENA);
      msgtoemployer.addString(player.getName());
      msgtoemployer.addItemName(recipeList.getItemId());
      msgtoemployer.addNumber(price);
      msgtomaster = new SystemMessage(SystemMessage.THE_ATTEMPT_TO_CREATE_S2_FOR_S1_AT_THE_PRICE_OF_S3_ADENA_HAS_FAILED);
      msgtomaster.addString(employer.getName());
      msgtomaster.addItemName(recipeList.getItemId());
      msgtomaster.addNumber(price);
      player.sendPacket(msgtomaster);
      employer.sendPacket(msgtoemployer);
    }
    else if(recipeList.getCount() > 1 || successCount > 1)
    {
      msgtoemployer = new SystemMessage(SystemMessage.S1_CREATED_S2_S3_AT_THE_PRICE_OF_S4_ADENA);
      msgtoemployer.addString(player.getName());
      msgtoemployer.addItemName(recipeList.getItemId());
      msgtoemployer.addNumber(recipeList.getCount() * successCount);
      msgtoemployer.addNumber(price);
      msgtomaster = new SystemMessage(SystemMessage.S2_S3_HAVE_BEEN_SOLD_TO_S1_FOR_S4_ADENA);
      msgtomaster.addString(employer.getName());
      msgtomaster.addItemName(recipeList.getItemId());
      msgtomaster.addNumber(recipeList.getCount() * successCount);
      msgtomaster.addNumber(price);
      player.sendPacket(msgtomaster);
      employer.sendPacket(msgtoemployer);
    }
    else
    {
      msgtoemployer = new SystemMessage(SystemMessage.S1_CREATED_S2_AFTER_RECEIVING_S3_ADENA);
      msgtoemployer.addString(player.getName());
      msgtoemployer.addItemName(recipeList.getItemId());
      msgtoemployer.addNumber(price);
      msgtomaster = new SystemMessage(SystemMessage.S2_IS_SOLD_TO_S1_AT_THE_PRICE_OF_S3_ADENA);
      msgtomaster.addString(employer.getName());
      msgtomaster.addItemName(recipeList.getItemId());
      msgtomaster.addNumber(price);
      player.sendPacket(msgtomaster);
      employer.sendPacket(msgtoemployer);
    }
    if(Config.ALT_GAME_EXP_FOR_CRAFT)
    {
      player.addExpAndSp((long) (recipeList.getExp() * Config.RATE_XP), (long) (recipeList.getSp() * Config.RATE_SP), true, false);
    }
    player.sendStatusUpdate(false, StatusUpdate.CUR_LOAD, StatusUpdate.CUR_MP);
    employer.sendChanges();
    employer.sendStatusUpdate(false, StatusUpdate.CUR_LOAD);
    employer.sendPacket(new RecipeShopItemInfo(player.getObjectId(), recipeListId, price, success, employer));
  }
View Full Code Here

TOP

Related Classes of l2p.gameserver.serverpackets.RecipeShopItemInfo

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.