Пример #1
0
  private void teleportToCharacter(L2PcInstance activeChar, L2Object target) {
    L2PcInstance player = null;

    if (target != null && target.isPlayer) {
      player = (L2PcInstance) target;
    } else {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
      return;
    }

    if (player.getObjectId() == activeChar.getObjectId()) {
      player.sendPacket(new SystemMessage(SystemMessageId.CANNOT_USE_ON_YOURSELF));
    } else {
      int x = player.getX();
      int y = player.getY();
      int z = player.getZ();

      if (player.getInstanceId() != activeChar.getInstanceId()) {
        activeChar.setInstanceId(player.getInstanceId());
        activeChar.sendMessage("Вход в инстанс " + player.getInstanceId() + ".");
      }

      activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
      activeChar.teleToLocation(x, y, z);
    }

    player = null;
  }
Пример #2
0
  private void teleportTo(L2PcInstance activeChar, String Cords) {
    try {
      StringTokenizer st = new StringTokenizer(Cords);
      String x1 = st.nextToken();

      int x = Integer.parseInt(x1);

      String y1 = st.nextToken();

      int y = Integer.parseInt(y1);

      String z1 = st.nextToken();

      int z = Integer.parseInt(z1);

      activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
      activeChar.teleToLocation(x, y, z, false);

      SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
      sm.addString("You have been teleported to " + Cords);
      activeChar.sendPacket(sm);

      sm = null;
      x1 = null;
      y1 = null;
      z1 = null;
      st = null;
    } catch (NoSuchElementException nsee) {
      activeChar.sendMessage("Wrong or no Coordinates given.");
    }
  }
Пример #3
0
  /**
   * @param player
   * @param x
   * @param y
   * @param z
   */
  private void teleportCharacter(L2PcInstance player, int x, int y, int z) {
    if (player != null) {
      // Common character information
      player.sendMessage("Admin is teleporting you.");

      player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
      player.teleToLocation(x, y, z);
    }
  }
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

    ItemContainer warehouse = player.getActiveWarehouse();
    if (warehouse == null) return;

    L2FolkInstance manager = player.getLastFolkNPC();
    if ((manager == null
            || !player.isInsideRadius(manager, L2NpcInstance.INTERACTION_DISTANCE, false, false))
        && !player.isGM()) return;

    if (warehouse instanceof ClanWarehouse && !player.getAccessLevel().allowTransaction()) {
      player.sendMessage("Unsufficient privileges.");
      player.sendPacket(ActionFailed.STATIC_PACKET);
      return;
    }

    if (!FloodProtector.getInstance()
        .tryPerformAction(player.getObjectId(), FloodProtector.PROTECTED_WEREHOUSE)) {
      _log.warn("Player " + player.getName() + " has performed a werehouse action too fast");
      return;
    }

    // Alt game - Karma punishment
    if (!Config.ALT_GAME_KARMA_PLAYER_CAN_USE_WAREHOUSE && player.getKarma() > 0) return;

    if (Config.ALT_MEMBERS_CAN_WITHDRAW_FROM_CLANWH) {
      if (warehouse instanceof ClanWarehouse
          && (player.getClanPrivileges() & L2Clan.CP_CL_VIEW_WAREHOUSE)
              != L2Clan.CP_CL_VIEW_WAREHOUSE) return;
    } else {
      if (warehouse instanceof ClanWarehouse && !player.isClanLeader()) {
        // this msg is for depositing but maybe good to send some msg?
        player.sendPacket(
            new SystemMessage(
                SystemMessageId.ONLY_CLAN_LEADER_CAN_RETRIEVE_ITEMS_FROM_CLAN_WAREHOUSE));
        return;
      }
    }

    int weight = 0;
    int slots = 0;

    for (int i = 0; i < _count; i++) {
      int objectId = _items[i * 2 + 0];
      int count = _items[i * 2 + 1];

      // Calculate needed slots
      L2ItemInstance item = warehouse.getItemByObjectId(objectId);
      if (item == null) {
        continue;
      }
      weight += count * item.getItem().getWeight();
      if (!item.isStackable()) {
        slots += count;
      } else if (player.getInventory().getItemByItemId(item.getItemId()) == null) {
        slots++;
      }
    }

    // Item Max Limit Check
    if (!player.getInventory().validateCapacity(slots)) {
      sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
      return;
    }

    if (player.getActiveEnchantItem() != null) {
      Util.handleIllegalPlayerAction(
          player,
          "Player " + player.getName() + " tried to use enchant exploit!",
          Config.DEFAULT_PUNISH);
      return;
    }

    // Weight limit Check
    if (!player.getInventory().validateWeight(weight)) {
      sendPacket(new SystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
      return;
    }

    // Proceed to the transfer
    InventoryUpdate playerIU = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
    for (int i = 0; i < _count; i++) {
      int objectId = _items[i * 2 + 0];
      int count = _items[i * 2 + 1];

      L2ItemInstance oldItem = warehouse.getItemByObjectId(objectId);
      if (oldItem == null || oldItem.getCount() < count) {
        player.sendMessage("Can't withdraw requested item" + (count > 1 ? "s" : ""));
      }
      L2ItemInstance newItem =
          warehouse.transferItem(
              "Warehouse", objectId, count, player.getInventory(), player, player.getLastFolkNPC());
      if (newItem == null) {
        _log.warn("Error withdrawing a warehouse object for char " + player.getName());
        continue;
      }

      if (playerIU != null) {
        if (newItem.getCount() > count) {
          playerIU.addModifiedItem(newItem);
        } else {
          playerIU.addNewItem(newItem);
        }
      }
    }

    // Send updated item list to the player
    if (playerIU != null) {
      player.sendPacket(playerIU);
    } else {
      player.sendPacket(new ItemList(player, false));
    }

    // Update current load status on player
    StatusUpdate su = new StatusUpdate(player.getObjectId());
    su.addAttribute(StatusUpdate.CUR_LOAD, player.getCurrentLoad());
    player.sendPacket(su);
  }
Пример #5
0
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    if (!super.useAdminCommand(command, activeChar)) {
      return false;
    }

    if (command.equals("admin_teleto")) {
      activeChar.setTeleMode(1);
    }

    if (command.equals("admin_teleto r")) {
      activeChar.setTeleMode(2);
    }

    if (command.equals("admin_teleto end")) {
      activeChar.setTeleMode(0);
    }

    if (command.equals("admin_show_moves")) {
      com.l2scoria.gameserver.handler.admin.impl.HelpPage.showHelpPage(activeChar, "teleports.htm");
    }

    if (command.equals("admin_show_moves_other")) {
      com.l2scoria.gameserver.handler.admin.impl.HelpPage.showHelpPage(
          activeChar, "tele/other.html");
    } else if (command.equals("admin_show_teleport")) {
      showTeleportCharWindow(activeChar);
    } else if (command.equals("admin_recall_npc")) {
      recallNPC(activeChar);
    } else if (command.equals("admin_teleport_to_character")) {
      teleportToCharacter(activeChar, activeChar.getTarget());
    } else if (command.startsWith("admin_walk")) {
      try {
        String val = command.substring(11);
        StringTokenizer st = new StringTokenizer(val);
        String x1 = st.nextToken();

        int x = Integer.parseInt(x1);

        String y1 = st.nextToken();

        int y = Integer.parseInt(y1);

        String z1 = st.nextToken();

        int z = Integer.parseInt(z1);

        L2CharPosition pos = new L2CharPosition(x, y, z, 0);
        activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, pos);

        pos = null;
        x1 = null;
        y1 = null;
        z1 = null;
        st = null;
      } catch (Exception e) {
        if (Config.DEBUG) {
          _log.info("admin_walk: " + e);
        }
      }
    } else if (command.startsWith("admin_move_to")) {
      try {
        String val = command.substring(14);
        teleportTo(activeChar, val);

        val = null;
      } catch (StringIndexOutOfBoundsException e) {
        // Case of empty or missing coordinates
        com.l2scoria.gameserver.handler.admin.impl.HelpPage.showHelpPage(
            activeChar, "teleports.htm");
      }
    } else if (command.startsWith("admin_teleport_character")) {
      try {
        String val = command.substring(25);

        if (activeChar.getAccessLevel().isGm()) {
          teleportCharacter(activeChar, val);
        }

        val = null;
      } catch (StringIndexOutOfBoundsException e) {
        // Case of empty coordinates
        activeChar.sendMessage("Wrong or no Coordinates given.");
        showTeleportCharWindow(activeChar); // back to character teleport
      }
    } else if (command.startsWith("admin_teleportto ")) {
      try {
        String targetName = command.substring(17);
        L2PcInstance player = L2World.getInstance().getPlayer(targetName);
        teleportToCharacter(activeChar, player);
        targetName = null;
        player = null;
      } catch (StringIndexOutOfBoundsException e) {
        // ignore
      }
    } else if (command.startsWith("admin_recall ")) {
      try {
        String targetName = command.substring(13);
        L2PcInstance player = L2World.getInstance().getPlayer(targetName);

        if (activeChar.getAccessLevel().isGm()) {
          teleportCharacter(player, activeChar.getX(), activeChar.getY(), activeChar.getZ());
        }

        player = null;
      } catch (StringIndexOutOfBoundsException e) {
        // ignore
      }
    } else if (command.startsWith("admin_sendhome ")) {
      try {
        String targetName = command.substring(15);
        L2PcInstance player = L2World.getInstance().getPlayer(targetName);
        player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
        targetName = null;
        player = null;
      } catch (StringIndexOutOfBoundsException e) {
        // ignore
      }
    } else if (command.equals("admin_tele")) {
      showTeleportWindow(activeChar);
    } else if (command.startsWith("admin_go")) {
      int intVal = 150;
      int x = activeChar.getX(), y = activeChar.getY(), z = activeChar.getZ();

      try {
        String val = command.substring(8);
        StringTokenizer st = new StringTokenizer(val);
        String dir = st.nextToken();

        if (st.hasMoreTokens()) {
          intVal = Integer.parseInt(st.nextToken());
        }

        if (dir.equals("east")) {
          x += intVal;
        } else if (dir.equals("west")) {
          x -= intVal;
        } else if (dir.equals("north")) {
          y -= intVal;
        } else if (dir.equals("south")) {
          y += intVal;
        } else if (dir.equals("up")) {
          z += intVal;
        } else if (dir.equals("down")) {
          z -= intVal;
        }

        activeChar.teleToLocation(x, y, z, false);
        showTeleportWindow(activeChar);

        dir = null;
        st = null;
        val = null;
      } catch (Exception e) {
        activeChar.sendMessage("Usage: //go<north|south|east|west|up|down> [offset] (default 150)");
      }
    }

    return true;
  }
Пример #6
0
  private void recallNPC(L2PcInstance activeChar) {
    L2Object obj = activeChar.getTarget();

    if (obj != null && obj.isNpc) {
      L2NpcInstance target = (L2NpcInstance) obj;

      int monsterTemplate = target.getTemplate().npcId;

      L2NpcTemplate template1 = NpcTable.getInstance().getTemplate(monsterTemplate);

      if (template1 == null) {
        activeChar.sendMessage("Incorrect monster template.");
        _log.warn("ERROR: NPC " + target.getObjectId() + " has a 'null' template.");
        return;
      }

      L2Spawn spawn = target.getSpawn();

      if (spawn == null) {
        activeChar.sendMessage("Incorrect monster spawn.");
        _log.warn("ERROR: NPC " + target.getObjectId() + " has a 'null' spawn.");
        return;
      }

      int respawnTime = spawn.getRespawnDelay();

      target.deleteMe();
      spawn.stopRespawn();
      SpawnTable.getInstance().deleteSpawn(spawn, true);

      try {
        // L2MonsterInstance mob = new L2MonsterInstance(monsterTemplate, template1);

        spawn = new L2Spawn(template1);
        spawn.setLocx(activeChar.getX());
        spawn.setLocy(activeChar.getY());
        spawn.setLocz(activeChar.getZ());
        spawn.setAmount(1);
        spawn.setHeading(activeChar.getHeading());
        spawn.setRespawnDelay(respawnTime);
        SpawnTable.getInstance().addNewSpawn(spawn, true);
        spawn.init();

        SystemMessage sm = new SystemMessage(SystemMessageId.S1_S2);
        sm.addString("Created " + template1.name + " on " + target.getObjectId() + ".");
        activeChar.sendPacket(sm);
        sm = null;

        if (Config.DEBUG) {
          _log.info(
              "Spawn at X=" + spawn.getLocx() + " Y=" + spawn.getLocy() + " Z=" + spawn.getLocz());
          _log.warn(
              "GM: "
                  + activeChar.getName()
                  + "("
                  + activeChar.getObjectId()
                  + ") moved NPC "
                  + target.getObjectId());
        }

        spawn = null;
        template1 = null;
        target = null;
      } catch (Exception e) {
        activeChar.sendMessage("Target is not in game.");
      }
    } else {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
    }

    obj = null;
  }
Пример #7
0
  @Override
  protected void runImpl() {
    L2PcInstance player = getClient().getActiveChar();
    if (player == null || !(player.getPet().isPet)) return;

    // Alt game - Karma punishment
    if (!Config.ALT_GAME_KARMA_PLAYER_CAN_TRADE && player.getKarma() > 0) return;

    if (player.getPrivateStoreType() != 0) {
      player.sendMessage("Cannot exchange items while trading");
      return;
    }

    if (player.isCastingNow()) {
      return;
    }

    if (player.getActiveEnchantItem() != null) {
      Util.handleIllegalPlayerAction(
          player,
          "Player " + player.getName() + " Tried To Use Enchant Exploit! Ban This Player",
          Config.DEFAULT_PUNISH);
      return;
    }

    if (player.InventoryMoreLimit()) {
      return;
    }

    // Exploit Fix for Hero weapons Uses pet Inventory to buy New One.
    // [L2Scoria]
    L2ItemInstance item = player.getInventory().getItemByObjectId(_objectId);

    if (item == null) return;

    if (item.isAugmented()) return;

    if (!item.isDropable() || !item.isDestroyable() || !item.isTradeable()) {
      sendPacket(new SystemMessage(SystemMessageId.ITEM_NOT_FOR_PETS));
      return;
    }

    if (item.isTimeLimitedItem()) {
      sendPacket(new SystemMessage(SystemMessageId.ITEM_NOT_FOR_PETS));
      return;
    }

    L2PetInstance pet = (L2PetInstance) player.getPet();

    if (pet.isDead()) {
      sendPacket(new SystemMessage(SystemMessageId.CANNOT_GIVE_ITEMS_TO_DEAD_PET));
      return;
    }

    if (_amount < 0) return;

    if (player.transferItem("Transfer", _objectId, _amount, pet.getInventory(), pet) == null) {
      _log.warn(
          "Invalid item transfer request: " + pet.getName() + "(pet) --> " + player.getName());
    }
  }