Beispiel #1
0
  @Override
  public boolean useUserCommand(int id, Player player) {
    if (!player.isClanLeader()) {
      player.sendPacket(SystemMsg.ONLY_THE_CLAN_LEADER_MAY_ISSUE_COMMANDS);
      return false;
    }

    Castle castle = player.getCastle();
    if (castle == null) return false;

    if (castle.getSiegeEvent().isInProgress())
      if (!player.isNoble()) {
        player.sendPacket(
            SystemMsg
                .ONLY_A_CLAN_LEADER_THAT_IS_A_NOBLESSE_CAN_VIEW_THE_SIEGE_WAR_STATUS_WINDOW_DURING_A_SIEGE_WAR);
        return false;
      }

    NpcHtmlMessage msg = new NpcHtmlMessage(5);
    msg.setFile("siege_status.htm");
    msg.replace("%name%", player.getName());
    msg.replace("%kills%", String.valueOf(0));
    msg.replace("%deaths%", String.valueOf(0));
    msg.replace("%type%", String.valueOf(0));

    player.sendPacket(msg);
    return true;
  }
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) return;

    if (player.getEnchantScroll() != null) {
      Log.add(
          "Player "
              + player.getName()
              + " trying to use enchant exploit[Warehouse], ban this player!",
          "illegal-actions");
      player.setEnchantScroll(null);
      return;
    }

    if (command.startsWith("WithdrawP")) {
      int val = Integer.parseInt(command.substring(10));
      if (val == 99) {
        NpcHtmlMessage html = new NpcHtmlMessage(player, this);
        html.setFile("warehouse/personal.htm");
        html.replace("%npcname%", getName());
        player.sendPacket(html);
      } else WarehouseFunctions.showRetrieveWindow(player, val);
    } else if (command.equals("DepositP")) WarehouseFunctions.showDepositWindow(player);
    else if (command.startsWith("WithdrawC")) {
      int val = Integer.parseInt(command.substring(10));
      if (val == 99) {
        NpcHtmlMessage html = new NpcHtmlMessage(player, this);
        html.setFile("warehouse/clan.htm");
        html.replace("%npcname%", getName());
        player.sendPacket(html);
      } else WarehouseFunctions.showWithdrawWindowClan(player, val);
    } else if (command.equals("DepositC")) WarehouseFunctions.showDepositWindowClan(player);
    else super.onBypassFeedback(player, command);
  }
  @Override
  protected void runImpl() {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    if (PetitionManager.getInstance().isPlayerInConsultation(activeChar)) {
      if (activeChar.isGM()) PetitionManager.getInstance().endActivePetition(activeChar);
      else activeChar.sendPacket(new SystemMessage(SystemMessage.PETITION_UNDER_PROCESS));
    } else if (PetitionManager.getInstance().isPlayerPetitionPending(activeChar)) {
      if (PetitionManager.getInstance().cancelActivePetition(activeChar)) {
        int numRemaining =
            Config.MAX_PETITIONS_PER_PLAYER
                - PetitionManager.getInstance().getPlayerTotalPetitionCount(activeChar);

        activeChar.sendPacket(
            new SystemMessage(
                    SystemMessage.THE_PETITION_WAS_CANCELED_YOU_MAY_SUBMIT_S1_MORE_PETITIONS_TODAY)
                .addString(String.valueOf(numRemaining)));

        // Notify all GMs that the player's pending petition has been cancelled.
        String msgContent = activeChar.getName() + " has canceled a pending petition.";
        GmListTable.broadcastToGMs(
            new Say2(activeChar.getObjectId(), ChatType.HERO_VOICE, "Petition System", msgContent));
      } else
        activeChar.sendPacket(
            new SystemMessage(SystemMessage.FAILED_TO_CANCEL_PETITION_PLEASE_TRY_AGAIN_LATER));
    } else
      activeChar.sendPacket(new SystemMessage(SystemMessage.YOU_HAVE_NOT_SUBMITTED_A_PETITION));
  }
Beispiel #4
0
  public Object setStateAndNotSave(int state) {
    Player player = getPlayer();
    if (player == null) {
      return null;
    }

    _state = state;

    if (getQuest().isVisible(player) && isStarted()) {
      player.sendPacket(new ExShowQuestMark(getQuest().getQuestIntId()));
    }

    player.sendPacket(new QuestList(player));
    return state;
  }
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) return;

    UndergroundColiseumEvent coliseumEvent =
        EventHolder.getInstance().getEvent(EventType.MAIN_EVENT, _coliseumId);

    if (command.equals("register")) {
      Party party = player.getParty();
      if (party == null) showChatWindow(player, "events/kerthang_manager008.htm");
      else if (party.getPartyLeader() != player)
        showChatWindow(player, "events/kerthang_manager004.htm");
      else
        for (Player $player : party)
          if ($player.getLevel() < coliseumEvent.getMinLevel()
              || $player.getLevel() > coliseumEvent.getMaxLevel()) {
            showChatWindow(player, "events/kerthang_manager011.htm", "%name%", $player.getName());
            return;
          }
    } else if (command.equals("viewTeams")) {

      List<Player> reg = coliseumEvent.getRegisteredPlayers();

      NpcHtmlMessage msg = new NpcHtmlMessage(player, this);
      msg.setFile("events/kerthang_manager003.htm");
      for (int i = 0; i < 5; i++) {
        Player $player = CollectionUtils.safeGet(reg, i);

        msg.replace("%team" + i + "%", $player == null ? StringUtils.EMPTY : $player.getName());
      }

      player.sendPacket(msg);
    } else super.onBypassFeedback(player, command);
  }
Beispiel #6
0
  public void giveItems(int itemId, long count, Element element, int power) {
    Player player = getPlayer();
    if (player == null) {
      return;
    }

    if (count <= 0) {
      count = 1;
    }

    // Get template of item
    ItemTemplate template = ItemHolder.getInstance().getTemplate(itemId);
    if (template == null) {
      return;
    }

    for (int i = 0; i < count; i++) {
      ItemInstance item = ItemFunctions.createItem(itemId);

      if (element != Element.NONE) {
        item.setAttributeElement(element, power);
      }

      // Add items to player's inventory
      player.getInventory().addItem(item);
    }

    player.sendPacket(SystemMessage2.obtainItems(template.getItemId(), count, 0));
    player.sendChanges();
  }
Beispiel #7
0
  private void showTeleportWindow(Player activeChar) {
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);

    StringBuilder replyMSG = new StringBuilder("<html><title>Teleport Menu</title>");
    replyMSG.append("<body>");

    replyMSG.append("<br>");
    replyMSG.append("<center><table>");

    replyMSG.append(
        "<tr><td><button value=\"  \" action=\"bypass -h admin_tele\" width=70 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
    replyMSG.append(
        "<td><button value=\"North\" action=\"bypass -h admin_gonorth\" width=70 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
    replyMSG.append(
        "<td><button value=\"Up\" action=\"bypass -h admin_goup\" width=70 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td></tr>");
    replyMSG.append(
        "<tr><td><button value=\"West\" action=\"bypass -h admin_gowest\" width=70 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
    replyMSG.append(
        "<td><button value=\"  \" action=\"bypass -h admin_tele\" width=70 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
    replyMSG.append(
        "<td><button value=\"East\" action=\"bypass -h admin_goeast\" width=70 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td></tr>");
    replyMSG.append(
        "<tr><td><button value=\"  \" action=\"bypass -h admin_tele\" width=70 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
    replyMSG.append(
        "<td><button value=\"South\" action=\"bypass -h admin_gosouth\" width=70 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
    replyMSG.append(
        "<td><button value=\"Down\" action=\"bypass -h admin_godown\" width=70 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td></tr>");

    replyMSG.append("</table></center>");
    replyMSG.append("</body></html>");

    adminReply.setHtml(replyMSG.toString());
    activeChar.sendPacket(adminReply);
  }
 @Override
 public void showChatWindow(Player player, int val, Object... arg) {
   if (!validateCondition(player)) {
     NpcHtmlMessage html = new NpcHtmlMessage(player, this);
     html.setFile("wyvern/lord_only.htm");
     html.replace("%npcname%", "Wyvern Manager " + getName());
     player.sendPacket(html);
     player.sendActionFailed();
     return;
   }
   NpcHtmlMessage html = new NpcHtmlMessage(player, this);
   html.setFile("wyvern/lord_here.htm");
   html.replace("%Char_name%", String.valueOf(player.getName()));
   html.replace("%npcname%", "Wyvern Manager " + getName());
   player.sendPacket(html);
   player.sendActionFailed();
 }
Beispiel #9
0
 public void showTutorialHTML(String html, int type) {
   Player player = getPlayer();
   if (player == null) {
     return;
   }
   String text = html;
   if (type == 1) {
     text = HtmCache.getInstance().getNotNull("quests/_255_Tutorial/" + html, player);
   }
   player.sendPacket(new TutorialShowHtml(text, type));
 }
Beispiel #10
0
 private void teleportCharacter(Player activeChar, String Cords) {
   GameObject target = activeChar.getTarget();
   if (target == null || !target.isPlayer()) {
     activeChar.sendPacket(Msg.INVALID_TARGET);
     return;
   }
   if (target.getObjectId() == activeChar.getObjectId()) {
     activeChar.sendMessage("You cannot teleport yourself.");
     return;
   }
   teleportTo(activeChar, (Player) target, Cords, activeChar.getReflectionId());
 }
Beispiel #11
0
  public void becomeNoble() {
    Player player = getSelf();
    if (player == null || player.isNoble()) {
      return;
    }

    Olympiad.addNoble(player);
    player.setNoble(true);
    player.updatePledgeClass();
    player.updateNobleSkills();
    player.sendPacket(new SkillList(player));
    player.broadcastUserInfo(true);
  }
Beispiel #12
0
  private void showTeleportCharWindow(Player activeChar) {
    GameObject target = activeChar.getTarget();
    Player player = null;
    if (target.isPlayer()) player = (Player) target;
    else {
      activeChar.sendPacket(Msg.INVALID_TARGET);
      return;
    }
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);

    StringBuilder replyMSG = new StringBuilder("<html><title>Teleport Character</title>");
    replyMSG.append("<body>");
    replyMSG.append("The character you will teleport is " + player.getName() + ".");
    replyMSG.append("<br>");

    replyMSG.append("Co-ordinate x");
    replyMSG.append("<edit var=\"char_cord_x\" width=110>");
    replyMSG.append("Co-ordinate y");
    replyMSG.append("<edit var=\"char_cord_y\" width=110>");
    replyMSG.append("Co-ordinate z");
    replyMSG.append("<edit var=\"char_cord_z\" width=110>");
    replyMSG.append(
        "<button value=\"Teleport\" action=\"bypass -h admin_teleport_character $char_cord_x $char_cord_y $char_cord_z\" width=60 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\">");
    replyMSG.append(
        "<button value=\"Teleport near you\" action=\"bypass -h admin_teleport_character "
            + activeChar.getX()
            + " "
            + activeChar.getY()
            + " "
            + activeChar.getZ()
            + "\" width=115 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\">");
    replyMSG.append(
        "<center><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=15 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
    replyMSG.append("</body></html>");

    adminReply.setHtml(replyMSG.toString());
    activeChar.sendPacket(adminReply);
  }
Beispiel #13
0
  @Override
  public boolean useItem(Playable playable, ItemInstance item, boolean ctrl) {
    if (!playable.isPlayer()) return false;
    Player activeChar = playable.getPlayer();

    if (!activeChar.isQuestContinuationPossible(true)) return false;

    Map<Integer, Long> items = new HashMap<Integer, Long>();
    long count = 0;
    do {
      count++;
      getGroupItem(activeChar, _dropmats, items);
      getGroupItem(activeChar, _dropacc, items);
      getGroupItem(activeChar, _dropevents, items);
      getGroupItem(activeChar, _dropench, items);
    } while (ctrl && item.getCount() > count && activeChar.isQuestContinuationPossible(false));

    activeChar.getInventory().destroyItem(item, count); // FIXME [G1ta0] item-API
    activeChar.sendPacket(SystemMessage2.removeItems(item.getItemId(), count));
    for (Entry<Integer, Long> e : items.entrySet())
      activeChar.sendPacket(SystemMessage2.obtainItems(e.getKey(), e.getValue(), 0));
    return true;
  }
Beispiel #14
0
  public String setCond(int newCond, boolean store) {
    if (newCond == getCond()) {
      return String.valueOf(newCond);
    }

    int oldCond = getInt(VAR_COND);
    _cond = newCond;

    if ((oldCond & 0x80000000) != 0) {
      // уже используется второй формат
      if (newCond > 2) // Если этап меньше 3 то возвращаемся к первому варианту.
      {
        oldCond &= 0x80000001 | ((1 << newCond) - 1);
        newCond = oldCond | (1 << (newCond - 1));
      }
    } else {
      // Второй вариант теперь используется всегда если этап больше 2
      if (newCond > 2) {
        newCond = 0x80000001 | (1 << (newCond - 1)) | ((1 << oldCond) - 1);
      }
    }

    final String sVal = String.valueOf(newCond);
    final String result = set(VAR_COND, sVal, false);
    if (store) {
      Quest.updateQuestVarInDb(this, VAR_COND, sVal);
    }

    final Player player = getPlayer();
    if (player != null) {
      player.sendPacket(new QuestList(player));
      if ((newCond != 0) && getQuest().isVisible(player) && isStarted()) {
        player.sendPacket(new ExShowQuestMark(getQuest().getQuestIntId()));
      }
    }
    return result;
  }
  @Override
  public void onBypassFeedback(Player player, String command) {
    if (!canBypassCheck(player, this)) return;

    StringTokenizer st = new StringTokenizer(command, " ");
    String actualCommand = st.nextToken();
    boolean condition = validateCondition(player);

    if (actualCommand.equalsIgnoreCase("RideHelp")) {
      NpcHtmlMessage html = new NpcHtmlMessage(player, this);
      html.setFile("wyvern/help_ride.htm");
      html.replace("%npcname%", "Wyvern Manager " + getName());
      player.sendPacket(html);
      player.sendActionFailed();
    }
    if (condition) {
      if (actualCommand.equalsIgnoreCase("RideWyvern") && player.isClanLeader())
        if (!player.isRiding() || !PetDataTable.isStrider(player.getMountNpcId())) {
          NpcHtmlMessage html = new NpcHtmlMessage(player, this);
          html.setFile("wyvern/not_ready.htm");
          html.replace("%npcname%", "Wyvern Manager " + getName());
          player.sendPacket(html);
        } else if (player.getInventory().getItemByItemId(1460) == null
            || player.getInventory().getItemByItemId(1460).getCount() < 25) {
          NpcHtmlMessage html = new NpcHtmlMessage(player, this);
          html.setFile("wyvern/havenot_cry.htm");
          html.replace("%npcname%", "Wyvern Manager " + getName());
          player.sendPacket(html);
        } else if (player.getInventory().destroyItemByItemId(1460, 25L)) {
          player.setMount(PetDataTable.WYVERN_ID, player.getMountObjId(), player.getMountLevel());
          NpcHtmlMessage html = new NpcHtmlMessage(player, this);
          html.setFile("wyvern/after_ride.htm");
          html.replace("%npcname%", "Wyvern Manager " + getName());
          player.sendPacket(html);
        }
    } else super.onBypassFeedback(player, command);
  }
Beispiel #16
0
  public void get() {
    Player player = getSelf();

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

    if (player.getSubLevel() < 75) {
      player.sendMessage("You must make sub class level 75 first.");
      return;
    }

    if (player
        .getInventory()
        .destroyItemByItemId(
            Config.SERVICES_NOBLESS_SELL_ITEM, Config.SERVICES_NOBLESS_SELL_PRICE)) {
      makeSubQuests();
      becomeNoble();
    } else if (Config.SERVICES_NOBLESS_SELL_ITEM == 57) {
      player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
    } else {
      player.sendPacket(SystemMsg.INCORRECT_ITEM_COUNT);
    }
  }
Beispiel #17
0
  /**
   * Destroy element used by quest when quest is exited
   *
   * @param repeatable
   * @return QuestState
   */
  public QuestState exitCurrentQuest(boolean repeatable) {
    Player player = getPlayer();
    if (player == null) {
      return this;
    }

    removePlayerOnKillListener();
    // Clean drops
    for (int itemId : _quest.getItems()) {
      // Get [item from] / [presence of the item in] the inventory of the player
      ItemInstance item = player.getInventory().getItemByItemId(itemId);
      if ((item == null) || (itemId == 57)) {
        continue;
      }
      long count = item.getCount();
      // If player has the item in inventory, destroy it (if not gold)
      player.getInventory().destroyItemByItemId(itemId, count);
      player.getWarehouse().destroyItemByItemId(itemId, count); // TODO [G1ta0] analyze this
    }

    // If quest is repeatable, delete quest from list of quest of the player and from database
    // (quest CAN be created again => repeatable)
    if (repeatable) {
      player.removeQuestState(_quest.getName());
      Quest.deleteQuestInDb(this);
      _vars.clear();
    } else { // Otherwise, delete variables for quest and update database (quest CANNOT be created
             // again => not repeatable)
      for (String var : _vars.keySet()) {
        if (var != null) {
          unset(var);
        }
      }
      setState(Quest.COMPLETED);
      Quest.updateQuestInDb(this); // FIXME: оно вроде не нужно?
    }
    if (isCompleted()) {
      // WorldStatisticsManager.getInstance().updateStat(player, CategoryType.QUESTS_COMPLETED,0,
      // 1);
    }
    player.sendPacket(new QuestList(player));
    return this;
  }
Beispiel #18
0
  private static boolean ShowQuestState(QuestState qs, Player activeChar) {
    Map<String, String> vars = qs.getVars();
    int id = qs.getQuest().getQuestIntId();
    String char_name = qs.getPlayer().getName();

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    StringBuilder replyMSG = new StringBuilder("<html><body>");
    replyMSG.append(fmtHEAD.sprintf(new Object[] {qs.getQuest().getClass().getSimpleName(), id}));
    replyMSG.append("<table width=260>");
    replyMSG.append(fmtRow.sprintf(new Object[] {"PLAYER: ", char_name, ""}));
    replyMSG.append(
        fmtRow.sprintf(
            new Object[] {
              "STATE: ",
              qs.getStateName(),
              fmtSetButton.sprintf(new Object[] {id, "STATE", "$new_val", char_name, ""})
            }));
    for (String key : vars.keySet())
      if (!key.equalsIgnoreCase("<state>"))
        replyMSG.append(
            fmtRow.sprintf(
                new Object[] {
                  key + ": ",
                  vars.get(key),
                  fmtSetButton.sprintf(new Object[] {id, "VAR", key, "$new_val", char_name})
                }));
    replyMSG.append(
        fmtRow.sprintf(
            new Object[] {
              "<edit var=\"new_name\" width=50 height=12>",
              "~new var~",
              fmtSetButton.sprintf(new Object[] {id, "VAR", "$new_name", "$new_val", char_name})
            }));
    replyMSG.append("</table>");
    replyMSG.append(fmtFOOT.sprintf(new Object[] {id, char_name, char_name}));
    replyMSG.append("</body></html>");

    adminReply.setHtml(replyMSG.toString());
    activeChar.sendPacket(adminReply);
    vars.clear();
    return true;
  }
  @Override
  protected void runImpl() {
    Player activeChar = getClient().getActiveChar();
    if (activeChar == null) {
      return;
    }
    if (!activeChar.isInMovie()) {
      activeChar.sendActionFailed();
      return;
    }

    SceneMovie movie = SceneMovie.getMovie(activeChar.getMovieId());
    if ((movie == null) || (!movie.isCancellable())) {
      activeChar.sendActionFailed();
      return;
    }

    activeChar.stopQuestMovie();
    activeChar.sendPacket(new ExStopScenePlayerPacket(movie.getId()));
  }
Beispiel #20
0
  private static boolean ShowQuestList(Player targetChar, Player activeChar) {
    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    StringBuilder replyMSG = new StringBuilder("<html><body><table width=260>");
    for (QuestState qs : targetChar.getAllQuestsStates())
      if (qs != null && qs.getQuest().getQuestIntId() != 255)
        replyMSG.append(
            fmtListRow.sprintf(
                new Object[] {
                  qs.getQuest().getQuestIntId(),
                  targetChar.getName(),
                  qs.getQuest().getName(),
                  qs.getStateName()
                }));
    replyMSG.append(fmtListNew.sprintf(new Object[] {targetChar.getName()}));
    replyMSG.append("</table></body></html>");

    adminReply.setHtml(replyMSG.toString());
    activeChar.sendPacket(adminReply);

    return true;
  }
Beispiel #21
0
  /**
   * Удаляет указанные предметы из инвентаря игрока, и обновляет инвентарь
   *
   * @param itemId : id удаляемого предмета
   * @param count : число удаляемых предметов<br>
   *     Если count передать -1, то будут удалены все указанные предметы.
   * @return Количество удаленных предметов
   */
  public long takeItems(int itemId, long count) {
    Player player = getPlayer();
    if (player == null) {
      return 0;
    }

    // Get object item from player's inventory list
    ItemInstance item = player.getInventory().getItemByItemId(itemId);
    if (item == null) {
      return 0;
    }
    // Tests on count value in order not to have negative value
    if ((count < 0) || (count > item.getCount())) {
      count = item.getCount();
    }

    // Destroy the quantity of items wanted
    player.getInventory().destroyItemByItemId(itemId, count);
    // Send message of destruction to client
    player.sendPacket(SystemMessage2.removeItems(itemId, count));

    return count;
  }
Beispiel #22
0
  @Override
  public void showChatWindow(Player player, int val, Object... arg) {
    if (val == 0) {
      String htmlpath = null;
      if (c_ai0 == null && i_quest2 == 0) {
        htmlpath = "event/monastyre/minigame_instructor001.htm";
        c_ai1 = player;
      } else if (c_ai0 == null && i_quest2 == 1) {
        htmlpath = "event/monastyre/minigame_instructor008.htm";
      } else if (c_ai0 == player && i_quest0 == 1 && i_quest1 == 0) {
        htmlpath = "event/monastyre/minigame_instructor002.htm";
      } else if (c_ai0 == player && i_quest0 == 2 && i_quest1 == 0) {
        htmlpath = "event/monastyre/minigame_instructor003.htm";
      } else if (c_ai0 != player) {
        htmlpath = "event/monastyre/minigame_instructor004.htm";
      } else if (c_ai0 == player && i_quest1 == 1) {
        htmlpath = "event/monastyre/minigame_instructor007.htm";
      }

      player.sendPacket(new HtmlMessage(player, this, htmlpath, val));
    } else {
      super.showChatWindow(player, val);
    }
  }
Beispiel #23
0
  public void ride(String[] args) {
    Player player = getSelf();
    NpcInstance npc = getNpc();
    if (player == null || npc == null) return;

    boolean ru = player.isLangRus();
    if (args.length != 3) {
      show(ru ? "Некорректные данные" : "Incorrect input", player, npc);
      return;
    }

    if (!NpcInstance.canBypassCheck(player, npc)) return;

    if (player.getActiveWeaponFlagAttachment() != null) {
      player.sendPacket(Msg.YOU_CANNOT_MOUNT_BECAUSE_YOU_DO_NOT_MEET_THE_REQUIREMENTS);
      return;
    }

    if (player.getTransformation() != 0) {
      show(
          ru
              ? "Вы не можете взять пета в прокат, пока находитесь в режиме трансформации."
              : "Can't ride while in transformation mode.",
          player,
          npc);
      return;
    }

    if (player.getSummonList().size() > 0 || player.isMounted()) {
      player.sendPacket(Msg.YOU_ALREADY_HAVE_A_PET);
      return;
    }

    int npc_id;

    switch (Integer.parseInt(args[0])) {
      case 1:
        npc_id = PetDataTable.WYVERN_ID;
        break;
      case 2:
        npc_id = PetDataTable.STRIDER_WIND_ID;
        break;
      case 3:
        npc_id = PetDataTable.WGREAT_WOLF_ID;
        break;
      case 4:
        npc_id = PetDataTable.WFENRIR_WOLF_ID;
        break;
      default:
        show(ru ? "У меня нет таких питомцев!" : "Unknown pet.", player, npc);
        return;
    }

    if ((npc_id == PetDataTable.WYVERN_ID || npc_id == PetDataTable.STRIDER_WIND_ID)
        && !SiegeUtils.getCanRide()) {
      show(
          ru
              ? "Прокат виверн/страйдеров не работает во время осады."
              : "Can't ride wyvern/strider while Siege in progress.",
          player,
          npc);
      return;
    }

    Integer time = Integer.parseInt(args[1]);
    Long price = Long.parseLong(args[2]);

    if (time > 1800) {
      show(ru ? "Слишком большое время." : "Too long time to ride.", player, npc);
      return;
    }

    if (player.getAdena() < price) {
      player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
      return;
    }

    player.reduceAdena(price, true);

    doLimitedRide(player, npc_id, time);
  }
Beispiel #24
0
 public void doLimitedRide(Player player, Integer npc_id, Integer time) {
   if (!ride(player, npc_id)) return;
   player.sendPacket(new SetupGauge(player, 3, time * 1000));
   executeTask(player, "services.RideHire", "rideOver", new Object[0], time * 1000);
 }
Beispiel #25
0
 /**
  * Send a packet in order to play sound at client terminal
  *
  * @param sound
  */
 public void playSound(String sound) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new PlaySound(sound));
   }
 }
Beispiel #26
0
 public void playTutorialVoice(String voice) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new PlaySound(PlaySound.Type.VOICE, voice, 0, 0, player.getLoc()));
   }
 }
Beispiel #27
0
 public void onTutorialClientEvent(int number) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new TutorialEnableClientEvent(number));
   }
 }
Beispiel #28
0
  @SuppressWarnings("rawtypes")
  @Override
  public boolean useAdminCommand(
      Enum comm, String[] wordList, String fullString, Player activeChar) {
    Commands command = (Commands) comm;

    if (!activeChar.getPlayerAccess().CanTeleport) return false;

    switch (command) {
      case admin_show_moves:
        activeChar.sendPacket(new NpcHtmlMessage(5).setFile("admin/teleports.htm"));
        break;
      case admin_show_moves_other:
        activeChar.sendPacket(new NpcHtmlMessage(5).setFile("admin/tele/other.htm"));
        break;
      case admin_show_teleport:
        showTeleportCharWindow(activeChar);
        break;
      case admin_teleport_to_character:
        teleportToCharacter(activeChar, activeChar.getTarget());
        break;
      case admin_teleport_to:
      case admin_teleportto:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleportto charName");
          return false;
        }
        String chaName = Util.joinStrings(" ", wordList, 1);
        Player cha = GameObjectsStorage.getPlayer(chaName);
        if (cha == null) {
          activeChar.sendMessage("Player '" + chaName + "' not found in world");
          return false;
        }
        teleportToCharacter(activeChar, cha);
        break;
      case admin_move_to:
      case admin_moveto:
      case admin_teleport:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleport x y z [ref]");
          return false;
        }
        teleportTo(
            activeChar,
            activeChar,
            Util.joinStrings(" ", wordList, 1, 3),
            ArrayUtils.valid(wordList, 4) != null && !ArrayUtils.valid(wordList, 4).isEmpty()
                ? Integer.parseInt(wordList[4])
                : 0);
        break;
      case admin_walk:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //walk x y z");
          return false;
        }
        try {
          activeChar.moveToLocation(Location.parseLoc(Util.joinStrings(" ", wordList, 1)), 0, true);
        } catch (IllegalArgumentException e) {
          activeChar.sendMessage("USAGE: //walk x y z");
          return false;
        }
        break;
      case admin_gonorth:
      case admin_gosouth:
      case admin_goeast:
      case admin_gowest:
      case admin_goup:
      case admin_godown:
        int val = wordList.length < 2 ? 150 : Integer.parseInt(wordList[1]);
        int x = activeChar.getX();
        int y = activeChar.getY();
        int z = activeChar.getZ();
        if (command == Commands.admin_goup) z += val;
        else if (command == Commands.admin_godown) z -= val;
        else if (command == Commands.admin_goeast) x += val;
        else if (command == Commands.admin_gowest) x -= val;
        else if (command == Commands.admin_gosouth) y += val;
        else if (command == Commands.admin_gonorth) y -= val;

        activeChar.teleToLocation(x, y, z);
        showTeleportWindow(activeChar);
        break;
      case admin_tele:
        showTeleportWindow(activeChar);
        break;
      case admin_teleto:
      case admin_tele_to:
      case admin_instant_move:
        if (wordList.length > 1 && wordList[1].equalsIgnoreCase("r")) activeChar.setTeleMode(2);
        else if (wordList.length > 1 && wordList[1].equalsIgnoreCase("end"))
          activeChar.setTeleMode(0);
        else activeChar.setTeleMode(1);
        break;
      case admin_tonpc:
      case admin_to_npc:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //tonpc npcId|npcName");
          return false;
        }
        String npcName = Util.joinStrings(" ", wordList, 1);
        NpcInstance npc;
        try {
          if ((npc = GameObjectsStorage.getByNpcId(Integer.parseInt(npcName))) != null) {
            teleportToCharacter(activeChar, npc);
            return true;
          }
        } catch (Exception e) {
        }
        if ((npc = GameObjectsStorage.getNpc(npcName)) != null) {
          teleportToCharacter(activeChar, npc);
          return true;
        }
        activeChar.sendMessage("Npc " + npcName + " not found");
        break;
      case admin_toobject:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //toobject objectId");
          return false;
        }
        Integer target = Integer.parseInt(wordList[1]);
        GameObject obj;
        if ((obj = GameObjectsStorage.findObject(target)) != null) {
          teleportToCharacter(activeChar, obj);
          return true;
        }
        activeChar.sendMessage("Object " + target + " not found");
        break;
      default:
        break;
    }

    if (!activeChar.getPlayerAccess().CanEditChar) return false;

    switch (command) {
      case admin_teleport_character:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleport_character x y z");
          return false;
        }
        teleportCharacter(activeChar, Util.joinStrings(" ", wordList, 1));
        showTeleportCharWindow(activeChar);
        break;
      case admin_recall:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //recall charName");
          return false;
        }
        String targetName = Util.joinStrings(" ", wordList, 1);
        Player recall_player = GameObjectsStorage.getPlayer(targetName);
        if (recall_player != null) {
          teleportTo(activeChar, recall_player, activeChar.getLoc(), activeChar.getReflectionId());
          return true;
        }
        int obj_id = CharacterDAO.getInstance().getObjectIdByName(targetName);
        if (obj_id > 0) {
          teleportCharacter_offline(obj_id, activeChar.getLoc());
          activeChar.sendMessage(targetName + " is offline. Offline teleport used...");
        } else activeChar.sendMessage("->" + targetName + "<- is incorrect.");
        break;
      case admin_setref:
        {
          if (wordList.length < 2) {
            activeChar.sendMessage("Usage: //setref <reflection>");
            return false;
          }

          int ref_id = Integer.parseInt(wordList[1]);
          if (ref_id != 0 && ReflectionManager.getInstance().get(ref_id) == null) {
            activeChar.sendMessage("Reflection <" + ref_id + "> not found.");
            return false;
          }

          GameObject target = activeChar;
          GameObject obj = activeChar.getTarget();
          if (obj != null) target = obj;

          target.setReflection(ref_id);
          target.decayMe();
          target.spawnMe();
          break;
        }
      case admin_getref:
        if (wordList.length < 2) {
          activeChar.sendMessage("Usage: //getref <char_name>");
          return false;
        }
        Player cha = GameObjectsStorage.getPlayer(wordList[1]);
        if (cha == null) {
          activeChar.sendMessage("Player '" + wordList[1] + "' not found in world");
          return false;
        }
        activeChar.sendMessage(
            "Player '"
                + wordList[1]
                + "' in reflection: "
                + activeChar.getReflectionId()
                + ", name: "
                + activeChar.getReflection().getName());
        break;
      default:
        break;
    }

    if (!activeChar.getPlayerAccess().CanEditNPC) return false;

    switch (command) {
      case admin_recall_npc:
        recallNPC(activeChar);
        break;
      default:
        break;
    }

    return true;
  }
Beispiel #29
0
 public void showQuestionMark(int number) {
   Player player = getPlayer();
   if (player != null) {
     player.sendPacket(new TutorialShowQuestionMark(number));
   }
 }
Beispiel #30
0
 public void showTutorialHTML(String html) {
   Player player = getPlayer();
   if (player == null) return;
   String text = HtmCache.getInstance().getNotNull("quests/_255_Tutorial/" + html, player);
   player.sendPacket(new TutorialShowHtml(TutorialShowHtml.TYPE_HTML, text));
 }