コード例 #1
0
  /** Handle chat type 'all' */
  @Override
  public void handleChat(int type, L2PcInstance activeChar, String params, String text) {
    boolean vcd_used = false;
    if (text.startsWith(".")) {
      StringTokenizer st = new StringTokenizer(text);
      IVoicedCommandHandler vch;
      String command = "";

      if (st.countTokens() > 1) {
        command = st.nextToken().substring(1);
        params = text.substring(command.length() + 2);
        vch = VoicedCommandHandler.getInstance().getHandler(command);
      } else {
        command = text.substring(1);
        if (Config.DEBUG) {
          _log.info("Command: " + command);
        }
        vch = VoicedCommandHandler.getInstance().getHandler(command);
      }
      if (vch != null) {
        vch.useVoicedCommand(command, activeChar, params);
        vcd_used = true;
      } else {
        if (Config.DEBUG) {
          _log.warning("No handler registered for bypass '" + command + "'");
        }
        vcd_used = false;
      }
    }
    if (!vcd_used) {
      if (activeChar.isChatBanned() && Util.contains(Config.BAN_CHAT_CHANNELS, type)) {
        activeChar.sendPacket(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED);
        return;
      }

      /**
       * Match the character "." literally (Exactly 1 time) Match any character that is NOT a .
       * character. Between one and unlimited times as possible, giving back as needed (greedy)
       */
      if (text.matches("\\.{1}[^\\.]+")) {
        activeChar.sendPacket(SystemMessageId.INCORRECT_SYNTAX);
      } else {
        CreatureSay cs =
            new CreatureSay(
                activeChar.getObjectId(), type, activeChar.getAppearance().getVisibleName(), text);
        Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
        for (L2PcInstance player : plrs) {
          if ((player != null)
              && activeChar.isInsideRadius(player, 1250, false, true)
              && !BlockList.isBlocked(player, activeChar)) {
            player.sendPacket(cs);
          }
        }

        activeChar.sendPacket(cs);
      }
    }
  }
コード例 #2
0
  @Override
  public String onAttack(
      L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon, Skill skill) {
    final L2Playable playable = (isSummon) ? attacker.getSummon() : attacker;
    final int longRangeGuardRate = npc.getTemplate().getParameters().getInt("LongRangeGuardRate");
    final double distance = Util.calculateDistance(npc, playable, true, false);

    if (npc.isAffectedBySkill(ULTIMATE_DEFENSE.getSkillId()) && (distance <= MIN_DISTANCE)) {
      npc.stopSkillEffects(true, ULTIMATE_DEFENSE.getSkillId());
    } else if ((distance > MIN_DISTANCE)
        && !npc.isSkillDisabled(ULTIMATE_DEFENSE.getSkillId())
        && !((skill != null) && Util.contains(NOT_ALLOWED_SKILLS, skill.getId()))
        && (getRandom(100) < longRangeGuardRate)) {
      npc.setTarget(npc);
      npc.doCast(ULTIMATE_DEFENSE.getSkill());
    }
    return super.onAttack(npc, attacker, damage, isSummon, skill);
  }
コード例 #3
0
  /**
   * Handle chat type 'partymatchroom'
   *
   * @see net.sf.l2j.gameserver.handler.IChatHandler#handleChat(int,
   *     net.sf.l2j.gameserver.model.actor.instance.L2PcInstance, java.lang.String)
   */
  public void handleChat(int type, L2PcInstance activeChar, String target, String text) {
    if (activeChar.isInPartyMatchRoom()) {
      PartyMatchRoom _room = PartyMatchRoomList.getInstance().getPlayerRoom(activeChar);
      if (_room != null) {
        if (activeChar.isChatBanned() && Util.contains(Config.BAN_CHAT_CHANNELS, type)) {
          activeChar.sendPacket(
              SystemMessage.getSystemMessage(SystemMessageId.CHATTING_IS_CURRENTLY_PROHIBITED));
          return;
        }

        CreatureSay cs =
            new CreatureSay(activeChar.getObjectId(), type, activeChar.getName(), text);
        for (L2PcInstance _member : _room.getPartyMembers()) {
          _member.sendPacket(cs);
        }
      }
    }
  }
コード例 #4
0
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = "";
    QuestState st = getQuestState(player, true);

    int npcId = npc.getId();
    if (Util.contains(TOWN_DAWN, npcId)) {
      st.setState(State.STARTED);
      int i = 0;
      for (int dawn : TELEPORTERS) {
        if (dawn == npcId) {
          break;
        }
        i++;
      }
      st.set("id", Integer.toString(i));
      playSound(player, QuestSound.ITEMSOUND_QUEST_ACCEPT);
      player.teleToLocation(new Location(-80157, 111344, -4901));
      player.setIsIn7sDungeon(true);
    }
    if (Util.contains(TOWN_DUSK, npcId)) {
      st.setState(State.STARTED);
      int i = 0;
      for (int dusk : TELEPORTERS) {
        if (dusk == npcId) {
          break;
        }
        i++;
      }
      st.set("id", Integer.toString(i));
      playSound(player, QuestSound.ITEMSOUND_QUEST_ACCEPT);
      player.teleToLocation(new Location(-81261, 86531, -5157));
      player.setIsIn7sDungeon(true);
    } else if ((npcId >= 31494) && (npcId <= 31507)) {
      if (player.getLevel() < 20) {
        htmltext = "1.htm";
        st.exitQuest(true);
      } else if (player.getAllActiveQuests().length > 23) {
        htmltext = "1a.htm";
        st.exitQuest(true);
      } else if (!hasQuestItems(player, DIMENSIONAL_FRAGMENT)) {
        htmltext = "3.htm";
      } else {
        st.setState(State.CREATED);
        htmltext = "4.htm";
      }
    } else if (((npcId >= 31095) && (npcId <= 31111)) || ((npcId >= 31114) && (npcId <= 31126))) {
      int playerLevel = player.getLevel();
      if (playerLevel < 20) {
        htmltext = "ziggurat_lowlevel.htm";
        st.exitQuest(true);
      } else if (player.getAllActiveQuests().length > 40) {
        player.sendPacket(SystemMessageId.TOO_MANY_QUESTS);
        st.exitQuest(true);
      } else if (!hasQuestItems(player, DIMENSIONAL_FRAGMENT)) {
        htmltext = "ziggurat_nofrag.htm";
        st.exitQuest(true);
      } else if ((playerLevel >= 20) && (playerLevel < 30) && (player.getAdena() < 2000)) {
        htmltext = "ziggurat_noadena.htm";
        st.exitQuest(true);
      } else if ((playerLevel >= 30) && (playerLevel < 40) && (player.getAdena() < 4500)) {
        htmltext = "ziggurat_noadena.htm";
        st.exitQuest(true);
      } else if ((playerLevel >= 40) && (playerLevel < 50) && (player.getAdena() < 8000)) {
        htmltext = "ziggurat_noadena.htm";
        st.exitQuest(true);
      } else if ((playerLevel >= 50) && (playerLevel < 60) && (player.getAdena() < 12500)) {
        htmltext = "ziggurat_noadena.htm";
        st.exitQuest(true);
      } else if ((playerLevel >= 60) && (playerLevel < 70) && (player.getAdena() < 18000)) {
        htmltext = "ziggurat_noadena.htm";
        st.exitQuest(true);
      } else if ((playerLevel >= 70) && (player.getAdena() < 24500)) {
        htmltext = "ziggurat_noadena.htm";
        st.exitQuest(true);
      } else {
        htmltext = "ziggurat.htm";
      }
    }
    return htmltext;
  }
コード例 #5
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = "";
    QuestState st = getQuestState(player, false);

    if (st == null) {
      return null;
    }

    final int npcId = npc.getId();
    if (event.equalsIgnoreCase("Return")) {
      if (Util.contains(TEMPLE_PRIEST, npcId) && (st.getState() == State.STARTED)) {
        player.teleToLocation(RETURN_LOCS[st.getInt("id")]);
        player.setIsIn7sDungeon(false);
        st.exitQuest(true);
      } else if (Util.contains(RIFT_POSTERS, npcId) && (st.getState() == State.STARTED)) {
        player.teleToLocation(RETURN_LOCS[st.getInt("id")]);
        htmltext = "rift_back.htm";
        st.exitQuest(true);
      }
    } else if (event.equalsIgnoreCase("Festival")) {
      int id = st.getInt("id");
      if (Util.contains(TOWN_DAWN, id)) {
        player.teleToLocation(new Location(-80157, 111344, -4901));
        player.setIsIn7sDungeon(true);
      } else if (Util.contains(TOWN_DUSK, id)) {
        player.teleToLocation(new Location(-81261, 86531, -5157));
        player.setIsIn7sDungeon(true);
      } else {
        htmltext = "oracle1.htm";
      }
    } else if (event.equalsIgnoreCase("Dimensional")) {
      htmltext = "oracle.htm";
      player.teleToLocation(new Location(-114755, -179466, -6752));
    } else if (event.equalsIgnoreCase("5.htm")) {
      int id = st.getInt("id");
      if (id > -1) {
        htmltext = "5a.htm";
      }
      int i = 0;
      for (int id1 : TELEPORTERS) {
        if (id1 == npcId) {
          break;
        }
        i++;
      }
      st.set("id", Integer.toString(i));
      st.setState(State.STARTED);
      player.teleToLocation(new Location(-114755, -179466, -6752));
    } else if (event.equalsIgnoreCase("6.htm")) {
      htmltext = "6.htm";
      st.exitQuest(true);
    } else if (event.equalsIgnoreCase("zigurratDimensional")) {
      int playerLevel = player.getLevel();
      if ((playerLevel >= 20) && (playerLevel < 30)) {
        takeItems(player, Inventory.ADENA_ID, 2000);
      } else if ((playerLevel >= 30) && (playerLevel < 40)) {
        takeItems(player, Inventory.ADENA_ID, 4500);
      } else if ((playerLevel >= 40) && (playerLevel < 50)) {
        takeItems(player, Inventory.ADENA_ID, 8000);
      } else if ((playerLevel >= 50) && (playerLevel < 60)) {
        takeItems(player, Inventory.ADENA_ID, 12500);
      } else if ((playerLevel >= 60) && (playerLevel < 70)) {
        takeItems(player, Inventory.ADENA_ID, 18000);
      } else if (playerLevel >= 70) {
        takeItems(player, Inventory.ADENA_ID, 24500);
      }
      int i = 0;
      for (int ziggurat : TELEPORTERS) {
        if (ziggurat == npcId) {
          break;
        }
        i++;
      }
      st.set("id", Integer.toString(i));
      st.setState(State.STARTED);
      playSound(player, QuestSound.ITEMSOUND_QUEST_ACCEPT);
      htmltext = "ziggurat_rift.htm";
      player.teleToLocation(new Location(-114755, -179466, -6752));
    }
    return htmltext;
  }