Beispiel #1
0
  private static void teleportToCharacter(L2PcInstance activeChar, L2PcInstance target) {
    if (target.getObjectId() == activeChar.getObjectId())
      activeChar.sendPacket(SystemMessageId.CANNOT_USE_ON_YOURSELF);
    else {
      int x = target.getX();
      int y = target.getY();
      int z = target.getZ();

      activeChar.getAI().setIntention(CtrlIntention.IDLE);
      activeChar.teleToLocation(x, y, z, 0);
      activeChar.sendMessage("You have teleported to " + target.getName() + ".");
    }
  }
Beispiel #2
0
  private static void auditAction(String fullCommand, L2PcInstance activeChar, String target) {
    if (!Config.GMAUDIT) return;

    String[] command = fullCommand.split(" ");

    GMAudit.auditGMAction(
        activeChar.getName() + " [" + activeChar.getObjectId() + "]",
        command[0],
        (target.equals("") ? "no-target" : target),
        (command.length > 2 ? command[2] : ""));
  }
Beispiel #3
0
  @Override
  public void handleChat(int type, L2PcInstance activeChar, String target, String text) {
    if (!FloodProtectors.performAction(activeChar.getClient(), Action.TRADE_CHAT)) return;

    final CreatureSay cs =
        new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
    final int region = MapRegionTable.getMapRegion(activeChar.getX(), activeChar.getY());

    for (L2PcInstance player : L2World.getInstance().getPlayers()) {
      if (!BlockList.isBlocked(player, activeChar)
          && region == MapRegionTable.getMapRegion(player.getX(), player.getY()))
        player.sendPacket(cs);
    }
  }
  @Override
  protected void runImpl() {
    final L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

    final L2PcInstance partner = player.getActiveRequester();
    if (partner == null || L2World.getInstance().getPlayer(partner.getObjectId()) == null) {
      // Partner hasn't be found, cancel the invitation
      player.sendPacket(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
      player.setActiveRequester(null);
      return;
    }

    // If answer is positive, join the requester's PartyRoom.
    if (_answer == 1 && !partner.isRequestExpired()) {
      PartyMatchRoom _room = PartyMatchRoomList.getInstance().getRoom(partner.getPartyRoom());
      if (_room == null) return;

      if ((player.getLevel() >= _room.getMinLvl()) && (player.getLevel() <= _room.getMaxLvl())) {
        // Remove from waiting list
        PartyMatchWaitingList.getInstance().removePlayer(player);

        player.setPartyRoom(partner.getPartyRoom());

        player.sendPacket(new PartyMatchDetail(player, _room));
        player.sendPacket(new ExPartyRoomMember(player, _room, 0));

        for (L2PcInstance _member : _room.getPartyMembers()) {
          if (_member == null) continue;

          _member.sendPacket(new ExManagePartyRoomMember(player, _room, 0));
          _member.sendPacket(
              SystemMessage.getSystemMessage(SystemMessageId.S1_ENTERED_PARTY_ROOM)
                  .addPcName(player));
        }
        _room.addMember(player);

        // Info Broadcast
        player.broadcastUserInfo();
      } else player.sendPacket(SystemMessageId.CANT_ENTER_PARTY_ROOM);
    }
    // Else, send a message to requester.
    else partner.sendPacket(SystemMessageId.PARTY_MATCHING_REQUEST_NO_RESPONSE);

    // reset transaction timers
    player.setActiveRequester(null);
    partner.onTransactionResponse();
  }
  /**
   * Define the Soul Crystal and try to stage it. Checks for quest enabled, crystal(s) in inventory,
   * required usage of crystal, mob's ability to level crystal and mob vs player level gap.
   *
   * @param player : The player to make checks on.
   * @param mob : The mob to make checks on.
   * @param npcInfo : The mob's leveling informations.
   * @param chance : Input variable used to determine keep/stage/break of the crystal.
   * @return Returns true only, when crystal is staged or broken (aka any type of crystal change is
   *     made), else returns false.
   */
  private void tryToStageCrystal(
      L2PcInstance player, L2Attackable mob, LevelingInfo npcInfo, int chance) {
    SoulCrystalData crystalData = null;
    ItemInstance crystalItem = null;

    // Iterate through player's inventory to find crystal(s).
    for (ItemInstance item : player.getInventory().getItems()) {
      SoulCrystalData data = SoulCrystalsTable.getSoulCrystalInfos().get(item.getItemId());
      if (data == null) continue;

      // More crystals found.
      if (crystalData != null) {
        // Leveling requires soul crystal being used?
        if (npcInfo.skillRequired()) {
          // Absorb list contains killer and his AbsorbInfo is registered.
          final AbsorbInfo ai = mob.getAbsorbInfo(player.getObjectId());
          if (ai != null && ai.isRegistered())
            player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_FAILED_RESONATION);
        } else player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_FAILED_RESONATION);

        return;
      }

      crystalData = data;
      crystalItem = item;
    }

    // No crystal found, return without any notification.
    if (crystalData == null || crystalItem == null) return;

    // Leveling requires soul crystal being used?
    if (npcInfo.skillRequired()) {
      // Absorb list doesn't contain killer or his AbsorbInfo is not registered.
      final AbsorbInfo ai = mob.getAbsorbInfo(player.getObjectId());
      if (ai == null || !ai.isRegistered()) return;

      // Check if Absorb list contains valid crystal and whether it was used properly.
      if (!ai.isValid(crystalItem.getObjectId())) {
        player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_REFUSED);
        return;
      }
    }

    // Check, if npc stages this type of crystal.
    if (!npcInfo.isInLevelList(crystalData.getLevel())) {
      player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_REFUSED);
      return;
    }

    // Check level difference limitation, dark blue monsters does not stage.
    if (player.getLevel() - mob.getLevel() > 8) {
      player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_REFUSED);
      return;
    }

    // Lucky, crystal successfully stages.
    if (chance < npcInfo.getChanceStage()) exchangeCrystal(player, crystalData, true);
    // Bad luck, crystal accidentally breaks.
    else if (chance < (npcInfo.getChanceStage() + npcInfo.getChanceBreak()))
      exchangeCrystal(player, crystalData, false);
    // Bad luck, crystal doesn't stage.
    else player.sendPacket(SystemMessageId.SOUL_CRYSTAL_ABSORBING_FAILED);
  }
  private void adminModifyCharacter(L2PcInstance activeChar, String modifications) {
    L2Object target = activeChar.getTarget();

    if (!(target instanceof L2PcInstance)) return;

    L2PcInstance player = (L2PcInstance) target;
    StringTokenizer st = new StringTokenizer(modifications);

    if (st.countTokens() != 6) {
      editCharacter(player);
      return;
    }

    String hp = st.nextToken();
    String mp = st.nextToken();
    String cp = st.nextToken();
    String pvpflag = st.nextToken();
    String pvpkills = st.nextToken();
    String pkkills = st.nextToken();

    int hpval = Integer.parseInt(hp);
    int mpval = Integer.parseInt(mp);
    int cpval = Integer.parseInt(cp);
    int pvpflagval = Integer.parseInt(pvpflag);
    int pvpkillsval = Integer.parseInt(pvpkills);
    int pkkillsval = Integer.parseInt(pkkills);

    // Common character information
    L2CoreMessage cm = new L2CoreMessage(MessageTable.Messages[30]);
    cm.addNumber(hpval);
    cm.addNumber(mpval);
    cm.addNumber(cpval);
    cm.addNumber(pvpflagval);
    cm.addNumber(pvpkillsval);
    cm.addNumber(pkkillsval);
    cm.sendMessage(player);
    player.setCurrentHp(hpval);
    player.setCurrentMp(mpval);
    player.setCurrentCp(cpval);
    player.setPvpFlag(pvpflagval);
    player.setPvpKills(pvpkillsval);
    player.setPkKills(pkkillsval);

    // Save the changed parameters to the database.
    player.store();

    StatusUpdate su = new StatusUpdate(player.getObjectId());
    su.addAttribute(StatusUpdate.CUR_HP, hpval);
    su.addAttribute(StatusUpdate.MAX_HP, player.getMaxHp());
    su.addAttribute(StatusUpdate.CUR_MP, mpval);
    su.addAttribute(StatusUpdate.MAX_MP, player.getMaxMp());
    su.addAttribute(StatusUpdate.CUR_CP, cpval);
    su.addAttribute(StatusUpdate.MAX_CP, player.getMaxCp());
    player.sendPacket(su);

    // Admin information
    cm = new L2CoreMessage(MessageTable.Messages[70]);
    cm.addString(player.getName());
    cm.addNumber(hpval);
    cm.addNumber(mpval);
    cm.addNumber(cpval);
    cm.addNumber(pvpflagval);
    cm.addNumber(pvpkillsval);
    cm.addNumber(pkkillsval);
    cm.sendMessage(activeChar);

    if (Config.DEBUG)
      _log.fine(
          "[GM]"
              + activeChar.getName()
              + " changed stats of "
              + player.getName()
              + ". "
              + " HP: "
              + hpval
              + " MP: "
              + mpval
              + " CP: "
              + cpval
              + " PvP: "
              + pvpflagval
              + " / "
              + pvpkillsval);

    showCharacterInfo(activeChar, null); // Back to start

    player.broadcastPacket(new CharInfo(player));
    player.sendPacket(new UserInfo(player));
    player.broadcastPacket(new ExBrExtraUserInfo(player));
    player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
    player.decayMe();
    player.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  }
  @Override
  protected void runImpl() {
    if (!FloodProtectors.performAction(getClient(), Action.SERVER_BYPASS)) return;

    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (_command.isEmpty()) {
      _log.info(activeChar.getName() + " sent an empty requestBypass packet.");
      activeChar.logout();
      return;
    }

    try {
      if (_command.startsWith("admin_")) {
        String command = _command.split(" ")[0];

        IAdminCommandHandler ach =
            AdminCommandHandler.getInstance().getAdminCommandHandler(command);
        if (ach == null) {
          if (activeChar.isGM())
            activeChar.sendMessage("The command " + command.substring(6) + " doesn't exist.");

          _log.warning("No handler registered for admin command '" + command + "'");
          return;
        }

        if (!AdminCommandAccessRights.getInstance()
            .hasAccess(command, activeChar.getAccessLevel())) {
          activeChar.sendMessage("You don't have the access rights to use this command.");
          _log.warning(
              activeChar.getName()
                  + " tried to use admin command "
                  + command
                  + " without proper Access Level.");
          return;
        }

        if (Config.GMAUDIT)
          GMAudit.auditGMAction(
              activeChar.getName() + " [" + activeChar.getObjectId() + "]",
              _command,
              (activeChar.getTarget() != null ? activeChar.getTarget().getName() : "no-target"));

        ach.useAdminCommand(_command, activeChar);
      } else if (_command.startsWith("player_help ")) {
        playerHelp(activeChar, _command.substring(12));
      } else if (_command.startsWith("npc_")) {
        if (!activeChar.validateBypass(_command)) return;

        int endOfId = _command.indexOf('_', 5);
        String id;
        if (endOfId > 0) id = _command.substring(4, endOfId);
        else id = _command.substring(4);

        try {
          final L2Object object = L2World.getInstance().getObject(Integer.parseInt(id));

          if (object != null
              && object instanceof L2Npc
              && endOfId > 0
              && ((L2Npc) object).canInteract(activeChar))
            ((L2Npc) object).onBypassFeedback(activeChar, _command.substring(endOfId + 1));

          activeChar.sendPacket(ActionFailed.STATIC_PACKET);
        } catch (NumberFormatException nfe) {
        }
      }
      // Navigate throught Manor windows
      else if (_command.startsWith("manor_menu_select?")) {
        L2Object object = activeChar.getTarget();
        if (object instanceof L2Npc) ((L2Npc) object).onBypassFeedback(activeChar, _command);
      } else if (_command.startsWith("bbs_")
          || _command.startsWith("_bbs")
          || _command.startsWith("_friend")
          || _command.startsWith("_mail")
          || _command.startsWith("_block")) {
        CommunityBoard.getInstance().handleCommands(getClient(), _command);
      } else if (_command.startsWith("Quest ")) {
        if (!activeChar.validateBypass(_command)) return;

        String[] str = _command.substring(6).trim().split(" ", 2);
        if (str.length == 1) activeChar.processQuestEvent(str[0], "");
        else activeChar.processQuestEvent(str[0], str[1]);
      } else if (_command.startsWith("_match")) {
        String params = _command.substring(_command.indexOf("?") + 1);
        StringTokenizer st = new StringTokenizer(params, "&");
        int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
        int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
        int heroid = Hero.getInstance().getHeroByClass(heroclass);
        if (heroid > 0) Hero.getInstance().showHeroFights(activeChar, heroclass, heroid, heropage);
      } else if (_command.startsWith("_diary")) {
        String params = _command.substring(_command.indexOf("?") + 1);
        StringTokenizer st = new StringTokenizer(params, "&");
        int heroclass = Integer.parseInt(st.nextToken().split("=")[1]);
        int heropage = Integer.parseInt(st.nextToken().split("=")[1]);
        int heroid = Hero.getInstance().getHeroByClass(heroclass);
        if (heroid > 0) Hero.getInstance().showHeroDiary(activeChar, heroclass, heroid, heropage);
      } else if (_command.startsWith("arenachange")) // change
      {
        final boolean isManager =
            activeChar.getCurrentFolkNPC() instanceof L2OlympiadManagerInstance;
        if (!isManager) {
          // Without npc, command can be used only in observer mode on arena
          if (!activeChar.inObserverMode()
              || activeChar.isInOlympiadMode()
              || activeChar.getOlympiadGameId() < 0) return;
        }

        if (OlympiadManager.getInstance().isRegisteredInComp(activeChar)) {
          activeChar.sendPacket(
              SystemMessageId
                  .WHILE_YOU_ARE_ON_THE_WAITING_LIST_YOU_ARE_NOT_ALLOWED_TO_WATCH_THE_GAME);
          return;
        }

        final int arenaId = Integer.parseInt(_command.substring(12).trim());
        activeChar.enterOlympiadObserverMode(arenaId);
      }
    } catch (Exception e) {
      _log.log(Level.WARNING, "Bad RequestBypassToServer: ", e);
    }
  }
Beispiel #8
0
  @Override
  public boolean useAdminCommand(String command, L2PcInstance activeChar) {
    if (command.equals("admin_forge")) showMainPage(activeChar);
    else if (command.startsWith("admin_forge2")) {
      try {
        StringTokenizer st = new StringTokenizer(command);
        st.nextToken();
        String format = st.nextToken();
        showPage2(activeChar, format);
      } catch (Exception ex) {
        activeChar.sendMessage("Usage: //forge2 format");
      }
    } else if (command.startsWith("admin_forge3")) {
      try {
        StringTokenizer st = new StringTokenizer(command);
        st.nextToken();
        String format = st.nextToken();
        boolean broadcast = false;

        if (format.toLowerCase().equals("broadcast")) {
          format = st.nextToken();
          broadcast = true;
        }

        AdminForgePacket sp = new AdminForgePacket();
        for (int i = 0; i < format.length(); i++) {
          String val = st.nextToken();
          if (val.toLowerCase().equals("$objid")) {
            val = String.valueOf(activeChar.getObjectId());
          } else if (val.toLowerCase().equals("$tobjid")) {
            val = String.valueOf(activeChar.getTarget().getObjectId());
          } else if (val.toLowerCase().equals("$bobjid")) {
            if (activeChar.getBoat() != null) {
              val = String.valueOf(activeChar.getBoat().getObjectId());
            }
          } else if (val.toLowerCase().equals("$clanid")) {
            val = String.valueOf(activeChar.getCharId());
          } else if (val.toLowerCase().equals("$allyid")) {
            val = String.valueOf(activeChar.getAllyId());
          } else if (val.toLowerCase().equals("$tclanid")) {
            val = String.valueOf(((L2PcInstance) activeChar.getTarget()).getCharId());
          } else if (val.toLowerCase().equals("$tallyid")) {
            val = String.valueOf(((L2PcInstance) activeChar.getTarget()).getAllyId());
          } else if (val.toLowerCase().equals("$x")) {
            val = String.valueOf(activeChar.getX());
          } else if (val.toLowerCase().equals("$y")) {
            val = String.valueOf(activeChar.getY());
          } else if (val.toLowerCase().equals("$z")) {
            val = String.valueOf(activeChar.getZ());
          } else if (val.toLowerCase().equals("$heading")) {
            val = String.valueOf(activeChar.getHeading());
          } else if (val.toLowerCase().equals("$tx")) {
            val = String.valueOf(activeChar.getTarget().getX());
          } else if (val.toLowerCase().equals("$ty")) {
            val = String.valueOf(activeChar.getTarget().getY());
          } else if (val.toLowerCase().equals("$tz")) {
            val = String.valueOf(activeChar.getTarget().getZ());
          } else if (val.toLowerCase().equals("$theading")) {
            val = String.valueOf(((L2PcInstance) activeChar.getTarget()).getHeading());
          }

          sp.addPart(format.getBytes()[i], val);
        }

        if (broadcast) activeChar.broadcastPacket(sp);
        else activeChar.sendPacket(sp);

        showPage3(activeChar, format, command);
      } catch (Exception ex) {
        activeChar.sendMessage("Usage: //forge or //forge2 format");
      }
    }
    return true;
  }
Beispiel #9
0
  public void activate(L2PcInstance player, ItemInstance item) {
    // if the player is mounted, attempt to unmount first and pick it if successful.
    if (player.isMounted() && !player.dismount()) {
      player.sendPacket(
          SystemMessage.getSystemMessage(SystemMessageId.FAILED_TO_PICKUP_S1)
              .addItemName(item.getItemId()));
      item.setDestroyProtected(true);
      player.dropItem("InvDrop", item, null, true);
      return;
    }

    _isActivated = true;

    // Hold player data.
    _player = player;
    _playerId = _player.getObjectId();
    _playerKarma = _player.getKarma();
    _playerPkKills = _player.getPkKills();

    _item = item;

    // Generate a random number for next stage.
    _numberBeforeNextStage =
        Rnd.get((int) Math.round(_stageKills * 0.5), (int) Math.round(_stageKills * 1.5));

    // Renew hungry time.
    _hungryTime = _durationLost * 60;

    // Activate the daily timer.
    _dailyTimerTask =
        ThreadPoolManager.getInstance()
            .scheduleGeneralAtFixedRate(new DailyTimerTask(), 60000L, 60000L);

    // Cancel the "1h dropped CW" timer.
    cancelDropTimerTask();

    insertData();

    // Change player stats
    _player.setCursedWeaponEquippedId(_itemId);
    _player.setKarma(9999999);
    _player.setPkKills(0);

    if (_player.isInParty()) _player.getParty().removePartyMember(_player, MessageType.Expelled);

    // Disable active toggles
    for (L2Effect effect : _player.getAllEffects()) {
      if (effect.getSkill().isToggle()) effect.exit();
    }

    // Add CW skills
    giveDemonicSkills();

    // Equip the weapon
    _player.useEquippableItem(_item, true);

    // Fully heal player
    _player.setCurrentHpMp(_player.getMaxHp(), _player.getMaxMp());
    _player.setCurrentCp(_player.getMaxCp());

    // Refresh player stats
    _player.broadcastUserInfo();

    // _player.broadcastPacket(new SocialAction(_player, 17));
    Broadcast.toAllOnlinePlayers(
        SystemMessage.getSystemMessage(
                SystemMessageId.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION)
            .addZoneName(_player.getX(), _player.getY(), _player.getZ())
            .addItemName(_item.getItemId()));
  }
Beispiel #10
0
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null || activeChar.isTeleporting() || activeChar.inObserverMode()) return;

    final int realX = activeChar.getX();
    final int realY = activeChar.getY();
    int realZ = activeChar.getZ();

    if (Config.DEVELOPER)
      _log.fine(
          "C(S) pos: "
              + _x
              + "("
              + realX
              + ") "
              + _y
              + "("
              + realY
              + ") "
              + _z
              + "("
              + realZ
              + ") / "
              + _heading
              + "("
              + activeChar.getHeading()
              + ")");

    if (_x == 0 && _y == 0) {
      if (realX != 0) // in this case this seems like a client error
      return;
    }

    int dx, dy, dz;
    double diffSq;

    if (activeChar.isInBoat()) {
      if (Config.COORD_SYNCHRONIZE == 2) {
        dx = _x - activeChar.getInVehiclePosition().getX();
        dy = _y - activeChar.getInVehiclePosition().getY();
        dz = _z - activeChar.getInVehiclePosition().getZ();
        diffSq = (dx * dx + dy * dy);
        if (diffSq > 250000)
          sendPacket(
              new GetOnVehicle(activeChar.getObjectId(), _data, activeChar.getInVehiclePosition()));
      }
      return;
    }

    if (activeChar.isFalling(_z)) return; // disable validations during fall to avoid "jumping"

    dx = _x - realX;
    dy = _y - realY;
    dz = _z - realZ;
    diffSq = (dx * dx + dy * dy);

    if (activeChar.isFlying() || activeChar.isInsideZone(ZoneId.WATER)) {
      activeChar.setXYZ(realX, realY, _z);
      if (diffSq > 90000) // validate packet, may also cause z bounce if close to land
      activeChar.sendPacket(new ValidateLocation(activeChar));
    } else if (diffSq < 360000) // if too large, messes observation
    {
      if (Config.COORD_SYNCHRONIZE == -1) // Only Z coordinate synched to server,
      // mainly used when no geodata but can be used also with geodata
      {
        activeChar.setXYZ(realX, realY, _z);
        return;
      }
      if (Config.COORD_SYNCHRONIZE
          == 1) // Trusting also client x,y coordinates (should not be used with geodata)
      {
        // Heading changed on client = possible obstacle
        if (!activeChar.isMoving() || !activeChar.validateMovementHeading(_heading)) {
          // character is not moving, take coordinates from client
          if (diffSq
              < 2500) // 50*50 - attack won't work fluently if even small differences are corrected
          activeChar.setXYZ(realX, realY, _z);
          else activeChar.setXYZ(_x, _y, _z);
        } else activeChar.setXYZ(realX, realY, _z);

        activeChar.setHeading(_heading);
        return;
      }
      // Sync 2 (or other),
      // intended for geodata. Sends a validation packet to client
      // when too far from server calculated true coordinate.
      // Due to geodata/zone errors, some Z axis checks are made. (maybe a temporary solution)
      // Important: this code part must work together with L2Character.updatePosition
      if (Config.GEODATA > 0 && (diffSq > 250000 || Math.abs(dz) > 200)) {
        if (Math.abs(dz) > 200
            && Math.abs(dz) < 1500
            && Math.abs(_z - activeChar.getClientZ()) < 800) {
          activeChar.setXYZ(realX, realY, _z);
          realZ = _z;
        } else {
          if (Config.DEVELOPER)
            _log.info(activeChar.getName() + ": Synchronizing position Server --> Client");

          activeChar.sendPacket(new ValidateLocation(activeChar));
        }
      }
    }

    activeChar.setClientX(_x);
    activeChar.setClientY(_y);
    activeChar.setClientZ(_z);
    activeChar.setClientHeading(_heading); // No real need to validate heading.
    activeChar.setLastServerPosition(realX, realY, realZ);
  }