Exemplo n.º 1
0
  @Override
  public String onSpawn(L2Npc npc) {
    for (L2PcInstance target : npc.getKnownList().getKnownType(L2PcInstance.class)) {
      if (!target.isDead()
          && GeoData.getInstance().canSeeTarget(npc, target)
          && Util.checkIfInRange(npc.getAggroRange(), npc, target, true)) {
        if (target.getActiveWeaponInstance() != null
            && !npc.isInCombat()
            && npc.getTarget() == null) {
          npc.setTarget(target);
          npc.broadcastNpcSay(
              ((target.getAppearance().getSex()) ? "Sister " : "Brother ")
                  + target.getName()
                  + ", move your weapon away!");

          switch (npc.getNpcId()) {
            case 22124:
            case 22126:
            case 22127:
              npc.doCast(SkillTable.getInstance().getInfo(4589, 8));
              break;

            default:
              attack(((L2Attackable) npc), target);
              break;
          }
        }
      }
    }
    return super.onSpawn(npc);
  }
Exemplo n.º 2
0
  @Override
  protected void runImpl() {
    final L2PcInstance activeChar = getClient().getActiveChar();
    if (activeChar == null) return;

    // You cannot do anything while fishing
    if (activeChar.isFishing()) {
      activeChar.sendPacket(SystemMessageId.CANNOT_DO_WHILE_FISHING_3);
      return;
    }

    // check if the actionId is allowed
    if (_actionId < 2 || _actionId > 13) {
      Util.handleIllegalPlayerAction(
          activeChar,
          activeChar.getName()
              + " of account "
              + activeChar.getAccountName()
              + " requested an internal Social Action.",
          Config.DEFAULT_PUNISH);
      return;
    }

    if (!activeChar.isInStoreMode()
        && activeChar.getActiveRequester() == null
        && !activeChar.isAlikeDead()
        && (!activeChar.isAllSkillsDisabled() || activeChar.isInDuel())
        && activeChar.getAI().getIntention() == CtrlIntention.IDLE) {
      if (Config.DEBUG) _log.fine("Social Action: " + _actionId);

      activeChar.broadcastPacket(new SocialAction(activeChar, _actionId));
    }
  }
Exemplo n.º 3
0
 /**
  * @param activeChar
  * @param player
  */
 private void gatherCharacterInfo(L2PcInstance activeChar, L2PcInstance player, String filename) {
   String ip = "N/A";
   String account = "N/A";
   try {
     String clientInfo = player.getClient().toString();
     account =
         clientInfo.substring(clientInfo.indexOf("Account: ") + 9, clientInfo.indexOf(" - IP: "));
     ip = clientInfo.substring(clientInfo.indexOf(" - IP: ") + 7, clientInfo.lastIndexOf("]"));
   } catch (Exception e) {
   }
   NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
   adminReply.setFile("data/html/admin/" + filename);
   adminReply.replace("%name%", player.getName());
   adminReply.replace("%level%", String.valueOf(player.getLevel()));
   adminReply.replace(
       "%clan%", String.valueOf(ClanTable.getInstance().getClan(player.getClanId())));
   adminReply.replace("%xp%", String.valueOf(player.getExp()));
   adminReply.replace("%sp%", String.valueOf(player.getSp()));
   adminReply.replace("%class%", player.getTemplate().className);
   adminReply.replace("%ordinal%", String.valueOf(player.getClassId().ordinal()));
   adminReply.replace("%classid%", String.valueOf(player.getClassId()));
   adminReply.replace("%x%", String.valueOf(player.getX()));
   adminReply.replace("%y%", String.valueOf(player.getY()));
   adminReply.replace("%z%", String.valueOf(player.getZ()));
   adminReply.replace("%currenthp%", String.valueOf((int) player.getCurrentHp()));
   adminReply.replace("%maxhp%", String.valueOf(player.getMaxHp()));
   adminReply.replace("%karma%", String.valueOf(player.getKarma()));
   adminReply.replace("%currentmp%", String.valueOf((int) player.getCurrentMp()));
   adminReply.replace("%maxmp%", String.valueOf(player.getMaxMp()));
   adminReply.replace("%pvpflag%", String.valueOf(player.getPvpFlag()));
   adminReply.replace("%currentcp%", String.valueOf((int) player.getCurrentCp()));
   adminReply.replace("%maxcp%", String.valueOf(player.getMaxCp()));
   adminReply.replace("%pvpkills%", String.valueOf(player.getPvpKills()));
   adminReply.replace("%pkkills%", String.valueOf(player.getPkKills()));
   adminReply.replace("%currentload%", String.valueOf(player.getCurrentLoad()));
   adminReply.replace("%maxload%", String.valueOf(player.getMaxLoad()));
   adminReply.replace(
       "%percent%",
       String.valueOf(
           Util.roundTo(
               ((float) player.getCurrentLoad() / (float) player.getMaxLoad()) * 100, 2)));
   adminReply.replace("%patk%", String.valueOf(player.getPAtk(null)));
   adminReply.replace("%matk%", String.valueOf(player.getMAtk(null, null)));
   adminReply.replace("%pdef%", String.valueOf(player.getPDef(null)));
   adminReply.replace("%mdef%", String.valueOf(player.getMDef(null, null)));
   adminReply.replace("%accuracy%", String.valueOf(player.getAccuracy()));
   adminReply.replace("%evasion%", String.valueOf(player.getEvasionRate(null)));
   adminReply.replace("%critical%", String.valueOf(player.getCriticalHit(null, null)));
   adminReply.replace("%runspeed%", String.valueOf(player.getRunSpeed()));
   adminReply.replace("%patkspd%", String.valueOf(player.getPAtkSpd()));
   adminReply.replace("%matkspd%", String.valueOf(player.getMAtkSpd()));
   adminReply.replace("%access%", String.valueOf(player.getAccessLevel().getLevel()));
   adminReply.replace("%account%", account);
   adminReply.replace("%ip%", ip);
   activeChar.sendPacket(adminReply);
 }
Exemplo n.º 4
0
  /**
   * Return the number of players in a defined radius.<br>
   * Dead players aren't counted, invisible ones is the boolean parameter.
   *
   * @param range : the radius.
   * @param npc : the object to make the test on.
   * @param invisible : true counts invisible characters.
   * @return the number of targets found.
   */
  public static int getPlayersCountInRadius(int range, L2Character npc, boolean invisible) {
    int count = 0;
    for (L2PcInstance player : npc.getKnownList().getKnownType(L2PcInstance.class)) {
      if (player.isDead()) continue;

      if (!invisible && player.getAppearance().getInvisible()) continue;

      if (Util.checkIfInRange(range, npc, player, true)) count++;
    }
    return count;
  }
Exemplo n.º 5
0
  public PrimevalIsle() {
    super("ai/group");

    for (L2Spawn npc : SpawnTable.getInstance().getSpawnTable())
      if (Util.contains(MOBIDS, npc.getNpcId())
          && npc.getLastSpawn() != null
          && npc.getLastSpawn() instanceof L2Attackable)
        ((L2Attackable) npc.getLastSpawn()).seeThroughSilentMove(true);

    registerMobs(SPRIGANTS, EventType.ON_AGGRO, EventType.ON_KILL);
    addAttackId(ANCIENT_EGG);
    addSpawnId(MOBIDS);
  }
Exemplo n.º 6
0
  public void updateStatus(L2RaidBossInstance boss, boolean isBossDead) {
    if (!_storedInfo.containsKey(boss.getNpcId())) return;

    final StatsSet info = _storedInfo.get(boss.getNpcId());

    if (isBossDead) {
      boss.setRaidStatus(StatusEnum.DEAD);

      // getRespawnMinDelay() is used as fixed timer, while getRespawnMaxDelay() is used as random
      // timer.
      final int respawnDelay =
          boss.getSpawn().getRespawnMinDelay()
              + Rnd.get(
                  -boss.getSpawn().getRespawnMaxDelay(), boss.getSpawn().getRespawnMaxDelay());
      final long respawnTime = Calendar.getInstance().getTimeInMillis() + (respawnDelay * 3600000);

      info.set("currentHP", boss.getMaxHp());
      info.set("currentMP", boss.getMaxMp());
      info.set("respawnTime", respawnTime);

      if (!_schedules.containsKey(boss.getNpcId())) {
        final Calendar time = Calendar.getInstance();
        time.setTimeInMillis(respawnTime);
        _log.info(
            "RaidBoss: "
                + boss.getName()
                + " - "
                + Util.formatDate(time.getTime(), "d MMM yyyy HH:mm")
                + " ("
                + respawnDelay
                + "h).");

        _schedules.put(
            boss.getNpcId(),
            ThreadPoolManager.getInstance()
                .scheduleGeneral(new spawnSchedule(boss.getNpcId()), respawnDelay * 3600000));
        updateDb();
      }
    } else {
      boss.setRaidStatus(StatusEnum.ALIVE);

      info.set("currentHP", boss.getCurrentHp());
      info.set("currentMP", boss.getCurrentMp());
      info.set("respawnTime", 0L);
    }

    _storedInfo.put(boss.getNpcId(), info);
  }
Exemplo n.º 7
0
  /**
   * Under that barbarian name, return the number of players in front, back and sides of the npc.
   * <br>
   * Dead players aren't counted, invisible ones is the boolean parameter.
   *
   * @param range : the radius.
   * @param npc : the object to make the test on.
   * @param invisible : true counts invisible characters.
   * @return an array composed of front, back and side targets number.
   */
  public static int[] getPlayersCountInPositions(int range, L2Character npc, boolean invisible) {
    int frontCount = 0;
    int backCount = 0;
    int sideCount = 0;

    for (L2PcInstance player : npc.getKnownList().getKnownType(L2PcInstance.class)) {
      if (player.isDead()) continue;

      if (!invisible && player.getAppearance().getInvisible()) continue;

      if (!Util.checkIfInRange(range, npc, player, true)) continue;

      if (player.isInFrontOf(npc)) frontCount++;
      else if (player.isBehind(npc)) backCount++;
      else sideCount++;
    }

    int[] array = {frontCount, backCount, sideCount};
    return array;
  }
Exemplo n.º 8
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = event;
    QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    if (event.equalsIgnoreCase("32017-03.htm")) {
      st.setState(STATE_STARTED);
      st.set("cond", "1");
      st.playSound(QuestState.SOUND_ACCEPT);
    } else if (Util.isDigit(event)) {
      htmltext = "32017-07.htm";
      st.takeItems(CURSED_GRAVE_GOODS, -1);

      final int reward[] = REWARDS[Integer.parseInt(event)];
      st.giveItems(reward[0], reward[1]);

      st.playSound(QuestState.SOUND_FINISH);
      st.exitQuest(true);
    }

    return htmltext;
  }
Exemplo n.º 9
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg();
    QuestState st = player.getQuestState(getName());
    if (st == null) return htmltext;

    if (Util.isDigit(event)) {
      final int eventId = Integer.parseInt(event);
      if (eventId >= 0 && eventId <= 7) {
        if (st.getQuestItemsCount(HORN) >= BUFF[eventId - 1][2]) {
          st.takeItems(HORN, BUFF[eventId - 1][2]);
          npc.setTarget(player);
          npc.doCast(SkillTable.getInstance().getInfo(BUFF[eventId - 1][0], BUFF[eventId - 1][1]));
          npc.setCurrentHpMp(npc.getMaxHp(), npc.getMaxMp());
          htmltext = "31372-4.htm";
        }
      }
    } else if (event.equals("Withdraw")) {
      if (player.getWarehouse().getSize() == 0) htmltext = "31374-0.htm";
      else {
        player.sendPacket(ActionFailed.STATIC_PACKET);
        player.setActiveWarehouse(player.getWarehouse());
        player.sendPacket(new WareHouseWithdrawalList(player, 1));
      }
    } else if (event.equals("Teleport")) {
      switch (player.getAllianceWithVarkaKetra()) {
        case 4:
          htmltext = "31376-4.htm";
          break;
        case 5:
          htmltext = "31376-5.htm";
          break;
      }
    }

    return htmltext;
  }