Package lineage2.gameserver.templates.manor

Examples of lineage2.gameserver.templates.manor.CropProcure


   * @param buy long
   * @return CropProcure
   */
  public CropProcure getNewCropProcure(int id, long amount, int type, long price, long buy)
  {
    return new CropProcure(id, amount, type, buy, price);
  }
View Full Code Here


      _cropData[i * 14 + 3] = Manor.getInstance().getRewardItem(cr, 2);
      _cropData[i * 14 + 4] = Manor.getInstance().getCropPuchaseLimit(cr);
      _cropData[i * 14 + 5] = 0; // Looks like not used
      _cropData[i * 14 + 6] = Manor.getInstance().getCropBasicPrice(cr) * 60 / 100;
      _cropData[i * 14 + 7] = Manor.getInstance().getCropBasicPrice(cr) * 10;
      CropProcure cropPr = c.getCrop(cr, CastleManorManager.PERIOD_CURRENT);
      if (cropPr != null)
      {
        _cropData[i * 14 + 8] = cropPr.getStartAmount();
        _cropData[i * 14 + 9] = cropPr.getPrice();
        _cropData[i * 14 + 10] = cropPr.getReward();
      }
      else
      {
        _cropData[i * 14 + 8] = 0;
        _cropData[i * 14 + 9] = 0;
        _cropData[i * 14 + 10] = 0;
      }
      cropPr = c.getCrop(cr, CastleManorManager.PERIOD_NEXT);
      if (cropPr != null)
      {
        _cropData[i * 14 + 11] = cropPr.getStartAmount();
        _cropData[i * 14 + 12] = cropPr.getPrice();
        _cropData[i * 14 + 13] = cropPr.getReward();
      }
      else
      {
        _cropData[i * 14 + 11] = 0;
        _cropData[i * 14 + 12] = 0;
View Full Code Here

        Castle castle = ResidenceHolder.getInstance().getResidence(Castle.class, manorId);
        if (castle == null)
        {
          return;
        }
        CropProcure crop = castle.getCrop(cropId, CastleManorManager.PERIOD_CURRENT);
        if ((crop == null) || (crop.getId() == 0) || (crop.getPrice() == 0))
        {
          return;
        }
        if (count > crop.getAmount())
        {
          return;
        }
        long price = SafeMath.mulAndCheck(count, crop.getPrice());
        long fee = 0;
        if ((currentManorId != 0) && (manorId != currentManorId))
        {
          fee = (price * 5) / 100;
        }
        totalFee = SafeMath.addAndCheck(totalFee, fee);
        int rewardItemId = Manor.getInstance().getRewardItem(cropId, crop.getReward());
        ItemTemplate template = ItemHolder.getInstance().getTemplate(rewardItemId);
        if (template == null)
        {
          return;
        }
        weight = SafeMath.addAndCheck(weight, SafeMath.mulAndCheck(count, template.getWeight()));
        if (!template.isStackable() || (activeChar.getInventory().getItemByItemId(cropId) == null))
        {
          slots++;
        }
      }
    }
    catch (ArithmeticException ae)
    {
      sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_QUANTITY_THAT_CAN_BE_INPUTTED);
      return;
    }
    activeChar.getInventory().writeLock();
    try
    {
      if (!activeChar.getInventory().validateWeight(weight))
      {
        sendPacket(Msg.YOU_HAVE_EXCEEDED_THE_WEIGHT_LIMIT);
        return;
      }
      if (!activeChar.getInventory().validateCapacity(slots))
      {
        sendPacket(Msg.YOUR_INVENTORY_IS_FULL);
        return;
      }
      if (activeChar.getInventory().getAdena() < totalFee)
      {
        activeChar.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
        return;
      }
      for (int i = 0; i < _count; i++)
      {
        int objId = _items[i];
        int cropId = _crop[i];
        int manorId = _manor[i];
        long count = _itemQ[i];
        ItemInstance item = activeChar.getInventory().getItemByObjectId(objId);
        if ((item == null) || (item.getCount() < count) || (item.getItemId() != cropId))
        {
          continue;
        }
        Castle castle = ResidenceHolder.getInstance().getResidence(Castle.class, manorId);
        if (castle == null)
        {
          continue;
        }
        CropProcure crop = castle.getCrop(cropId, CastleManorManager.PERIOD_CURRENT);
        if ((crop == null) || (crop.getId() == 0) || (crop.getPrice() == 0))
        {
          continue;
        }
        if (count > crop.getAmount())
        {
          continue;
        }
        int rewardItemId = Manor.getInstance().getRewardItem(cropId, crop.getReward());
        long sellPrice = count * crop.getPrice();
        long rewardPrice = ItemHolder.getInstance().getTemplate(rewardItemId).getReferencePrice();
        if (rewardPrice == 0)
        {
          continue;
        }
        double reward = (double) sellPrice / rewardPrice;
        long rewardItemCount = (long) reward + (Rnd.nextDouble() <= (reward % 1) ? 1 : 0);
        if (rewardItemCount < 1)
        {
          SystemMessage sm = new SystemMessage(SystemMessage.FAILED_IN_TRADING_S2_OF_CROP_S1);
          sm.addItemName(cropId);
          sm.addNumber(count);
          activeChar.sendPacket(sm);
          continue;
        }
        long fee = 0;
        if ((currentManorId != 0) && (manorId != currentManorId))
        {
          fee = (sellPrice * 5) / 100;
        }
        if (!activeChar.getInventory().destroyItemByObjectId(objId, count))
        {
          continue;
        }
        if (!activeChar.reduceAdena(fee, false))
        {
          SystemMessage sm = new SystemMessage(SystemMessage.FAILED_IN_TRADING_S2_OF_CROP_S1);
          sm.addItemName(cropId);
          sm.addNumber(count);
          activeChar.sendPacket(sm, Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
          continue;
        }
        crop.setAmount(crop.getAmount() - count);
        castle.updateCrop(crop.getId(), crop.getAmount(), CastleManorManager.PERIOD_CURRENT);
        castle.addToTreasuryNoTax(fee, false, false);
        if (activeChar.getInventory().addItem(rewardItemId, rewardItemCount) == null)
        {
          continue;
        }
View Full Code Here

      long sales = _items[(i * 4) + 1];
      long price = _items[(i * 4) + 2];
      int type = (int) _items[(i * 4) + 3];
      if (id > 0)
      {
        CropProcure s = CastleManorManager.getInstance().getNewCropProcure(id, sales, type, price, sales);
        crops.add(s);
      }
    }
    caslte.setCropProcure(crops, CastleManorManager.PERIOD_NEXT);
    caslte.saveCropData(CastleManorManager.PERIOD_NEXT);
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.manor.CropProcure

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.