コード例 #1
0
ファイル: Observation.java プロジェクト: GT-Games/Lineage-II
 private static final void doObserve(
     final L2PcInstance player, final L2Npc npc, final Location pos, final long cost) {
   if (player.reduceAdena("Broadcast", cost, npc, true)) {
     // enter mode
     player.enterObserverMode(pos);
     player.sendPacket(new ItemList(player, false));
   }
   player.sendPacket(ActionFailed.STATIC_PACKET);
 }
コード例 #2
0
ファイル: Banking.java プロジェクト: Stmol/L2J_DataPack
 @Override
 public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params) {
   if (command.equals("bank")) {
     activeChar.sendMessage(
         ".deposit ("
             + Config.BANKING_SYSTEM_ADENA
             + " Adena = "
             + Config.BANKING_SYSTEM_GOLDBARS
             + " Goldbar) / .withdraw ("
             + Config.BANKING_SYSTEM_GOLDBARS
             + " Goldbar = "
             + Config.BANKING_SYSTEM_ADENA
             + " Adena)");
   } else if (command.equals("deposit")) {
     if (activeChar.getInventory().getInventoryItemCount(57, 0) >= Config.BANKING_SYSTEM_ADENA) {
       if (!activeChar.reduceAdena("Goldbar", Config.BANKING_SYSTEM_ADENA, activeChar, false)) {
         return false;
       }
       activeChar
           .getInventory()
           .addItem("Goldbar", 3470, Config.BANKING_SYSTEM_GOLDBARS, activeChar, null);
       activeChar.getInventory().updateDatabase();
       activeChar.sendMessage(
           "Thank you, you now have "
               + Config.BANKING_SYSTEM_GOLDBARS
               + " Goldbar(s), and "
               + Config.BANKING_SYSTEM_ADENA
               + " less adena.");
     } else {
       activeChar.sendMessage(
           "You do not have enough Adena to convert to Goldbar(s), you need "
               + Config.BANKING_SYSTEM_ADENA
               + " Adena.");
     }
   } else if (command.equals("withdraw")) {
     if (activeChar.getInventory().getInventoryItemCount(3470, 0)
         >= Config.BANKING_SYSTEM_GOLDBARS) {
       if (!activeChar.destroyItemByItemId(
           "Adena", 3470, Config.BANKING_SYSTEM_GOLDBARS, activeChar, false)) {
         return false;
       }
       activeChar.getInventory().addAdena("Adena", Config.BANKING_SYSTEM_ADENA, activeChar, null);
       activeChar.getInventory().updateDatabase();
       activeChar.sendMessage(
           "Thank you, you now have "
               + Config.BANKING_SYSTEM_ADENA
               + " Adena, and "
               + Config.BANKING_SYSTEM_GOLDBARS
               + " less Goldbar(s).");
     } else {
       activeChar.sendMessage(
           "You do not have any Goldbars to turn into " + Config.BANKING_SYSTEM_ADENA + " Adena.");
     }
   }
   return true;
 }
コード例 #3
0
  private static final void doObserve(L2PcInstance player, L2Npc npc, String val) {
    StringTokenizer st = new StringTokenizer(val);
    long cost = Long.parseLong(st.nextToken());
    int x = Integer.parseInt(st.nextToken());
    int y = Integer.parseInt(st.nextToken());
    int z = Integer.parseInt(st.nextToken());

    if (player.reduceAdena("Broadcast", cost, npc, true)) {
      // enter mode
      player.enterObserverMode(x, y, z);
      player.sendPacket(new ItemList(player, false));
    }
    player.sendPacket(ActionFailed.STATIC_PACKET);
  }
コード例 #4
0
  @Override
  protected void runImpl() {
    if (_items == null) {
      return;
    }

    // Get the current player and return if null
    L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }

    if (!getClient().getFloodProtectors().getTransaction().tryPerformAction("buy")) {
      activeChar.sendMessage("You are buying too fast.");
      return;
    }

    // If Alternate rule Karma punishment is set to true, forbid Wear to player with Karma
    if (!Config.ALT_GAME_KARMA_PLAYER_CAN_SHOP && (activeChar.getKarma() > 0)) {
      return;
    }

    // Check current target of the player and the INTERACTION_DISTANCE
    L2Object target = activeChar.getTarget();
    if (!activeChar.isGM()
        && ((target == null // No target (i.e. GM Shop)
            )
            || !((target instanceof L2MerchantInstance)) // Target not a merchant
            || !activeChar.isInsideRadius(
                target, L2Npc.INTERACTION_DISTANCE, false, false) // Distance is too far
        )) {
      return;
    }

    if ((_count < 1) || (_listId >= 4000000)) {
      sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    // Get the current merchant targeted by the player
    final L2MerchantInstance merchant =
        (target instanceof L2MerchantInstance) ? (L2MerchantInstance) target : null;
    if (merchant == null) {
      _log.warning(getClass().getName() + " Null merchant!");
      return;
    }

    final L2BuyList buyList = BuyListData.getInstance().getBuyList(_listId);
    if (buyList == null) {
      Util.handleIllegalPlayerAction(
          activeChar,
          "Warning!! Character "
              + activeChar.getName()
              + " of account "
              + activeChar.getAccountName()
              + " sent a false BuyList list_id "
              + _listId,
          Config.DEFAULT_PUNISH);
      return;
    }

    long totalPrice = 0;
    Map<Integer, Integer> itemList = new HashMap<>();

    for (int i = 0; i < _count; i++) {
      int itemId = _items[i];

      final Product product = buyList.getProductByItemId(itemId);
      if (product == null) {
        Util.handleIllegalPlayerAction(
            activeChar,
            "Warning!! Character "
                + activeChar.getName()
                + " of account "
                + activeChar.getAccountName()
                + " sent a false BuyList list_id "
                + _listId
                + " and item_id "
                + itemId,
            Config.DEFAULT_PUNISH);
        return;
      }

      L2Item template = product.getItem();
      if (template == null) {
        continue;
      }

      int slot = Inventory.getPaperdollIndex(template.getBodyPart());
      if (slot < 0) {
        continue;
      }

      if (template instanceof L2Weapon) {
        if (activeChar.getRace().ordinal() == 5) {
          if (template.getItemType() == WeaponType.NONE) {
            continue;
          } else if ((template.getItemType() == WeaponType.RAPIER)
              || (template.getItemType() == WeaponType.CROSSBOW)
              || (template.getItemType() == WeaponType.ANCIENTSWORD)) {
            continue;
          }
        }
      } else if (template instanceof L2Armor) {
        if (activeChar.getRace().ordinal() == 5) {
          if ((template.getItemType() == ArmorType.HEAVY)
              || (template.getItemType() == ArmorType.MAGIC)) {
            continue;
          }
        }
      }

      if (itemList.containsKey(slot)) {
        activeChar.sendPacket(SystemMessageId.YOU_CAN_NOT_TRY_THOSE_ITEMS_ON_AT_THE_SAME_TIME);
        return;
      }

      itemList.put(slot, itemId);
      totalPrice += Config.WEAR_PRICE;
      if (totalPrice > Inventory.MAX_ADENA) {
        Util.handleIllegalPlayerAction(
            activeChar,
            "Warning!! Character "
                + activeChar.getName()
                + " of account "
                + activeChar.getAccountName()
                + " tried to purchase over "
                + Inventory.MAX_ADENA
                + " adena worth of goods.",
            Config.DEFAULT_PUNISH);
        return;
      }
    }

    // Charge buyer and add tax to castle treasury if not owned by npc clan because a Try On is not
    // Free
    if ((totalPrice < 0)
        || !activeChar.reduceAdena("Wear", totalPrice, activeChar.getLastFolkNPC(), true)) {
      activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
      return;
    }

    if (!itemList.isEmpty()) {
      activeChar.sendPacket(new ShopPreviewInfo(itemList));
      // Schedule task
      ThreadPoolManager.getInstance()
          .scheduleGeneral(new RemoveWearItemsTask(activeChar), Config.WEAR_DELAY * 1000);
    }
  }