コード例 #1
0
  @Override
  public String onSeeCreature(L2Npc npc, L2Character creature, boolean isSummon) {
    if (!zone.isInsideZone(creature) || (creature.isNpc() && (creature.getId() == BAIUM_STONE))) {
      return super.onSeeCreature(npc, creature, isSummon);
    }

    if (creature.isPlayer() && !creature.isDead() && (_standbyPlayer == null)) {
      _standbyPlayer = (L2PcInstance) creature;
    }

    if (creature.isInCategory(CategoryType.CLERIC_GROUP)) {
      if (npc.getCurrentHp() < (npc.getMaxHp() * 0.25)) {
        refreshAiParams(creature, npc, 10000);
      } else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.5)) {
        refreshAiParams(creature, npc, 10000, 6000);
      } else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.75)) {
        refreshAiParams(creature, npc, 10000, 3000);
      } else {
        refreshAiParams(creature, npc, 10000, 2000);
      }
    } else {
      refreshAiParams(creature, npc, 10000, 1000);
    }
    manageSkills(npc);
    return super.onSeeCreature(npc, creature, isSummon);
  }
コード例 #2
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    switch (event) {
      case "31862-04.html":
        {
          return event;
        }
      case "enter":
        {
          String htmltext = null;
          if (getStatus() == DEAD) {
            htmltext = "31862-03.html";
          } else if (getStatus() == IN_FIGHT) {
            htmltext = "31862-02.html";
          } else if (!hasQuestItems(player, FABRIC)) {
            htmltext = "31862-01.html";
          } else {
            takeItems(player, FABRIC, 1);
            player.teleToLocation(TELEPORT_IN_LOC);
          }
          return htmltext;
        }
      case "teleportOut":
        {
          final Location destination = TELEPORT_OUT_LOC[getRandom(TELEPORT_OUT_LOC.length)];
          player.teleToLocation(
              destination.getX() + getRandom(100),
              destination.getY() + getRandom(100),
              destination.getZ());
          break;
        }
      case "wakeUp":
        {
          if (getStatus() == ALIVE) {
            npc.deleteMe();
            setStatus(IN_FIGHT);
            _baium = (L2GrandBossInstance) addSpawn(BAIUM, BAIUM_LOC, false, 0);
            _baium.disableCoreAI(true);
            addBoss(_baium);
            _lastAttack = System.currentTimeMillis();
            startQuestTimer("WAKEUP_ACTION", 50, _baium, null);
            startQuestTimer("MANAGE_EARTHQUAKE", 2000, _baium, null);
            startQuestTimer("CHECK_ATTACK", 60000, _baium, null);
          }
          break;
        }
      case "WAKEUP_ACTION":
        {
          if (npc != null) {
            zone.broadcastPacket(new SocialAction(_baium.getObjectId(), 2));
          }
          break;
        }
      case "MANAGE_EARTHQUAKE":
        {
          if (npc != null) {
            zone.broadcastPacket(new Earthquake(npc.getX(), npc.getY(), npc.getZ(), 40, 10));
            zone.broadcastPacket(new PlaySound("BS02_A"));
            startQuestTimer("SOCIAL_ACTION", 8000, npc, player);
          }
          break;
        }
      case "SOCIAL_ACTION":
        {
          if (npc != null) {
            zone.broadcastPacket(new SocialAction(npc.getObjectId(), 3));
            startQuestTimer("PLAYER_PORT", 6000, npc, player);
          }
          break;
        }
      case "PLAYER_PORT":
        {
          if (npc != null) {
            if ((player != null) && player.isInsideRadius(npc, 16000, true, false)) {
              player.teleToLocation(BAIUM_GIFT_LOC);
              startQuestTimer("PLAYER_KILL", 3000, npc, player);
            } else if ((_standbyPlayer != null)
                && _standbyPlayer.isInsideRadius(npc, 16000, true, false)) {
              _standbyPlayer.teleToLocation(BAIUM_GIFT_LOC);
              startQuestTimer("PLAYER_KILL", 3000, npc, _standbyPlayer);
            }
          }
          break;
        }
      case "PLAYER_KILL":
        {
          if ((player != null) && player.isInsideRadius(npc, 16000, true, false)) {
            zone.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
            broadcastNpcSay(
                npc,
                Say2.NPC_ALL,
                player.getName()
                    + ", How dare you wake me! Now you shall die!"); // TODO: replace with
                                                                     // NpcStringId when are done
                                                                     // core support
            npc.setTarget(player);
            npc.doCast(BAIUM_PRESENT.getSkill());
          }

          for (L2PcInstance players : zone.getPlayersInside()) {
            if (players.isHero()) {
              zone.broadcastPacket(
                  new ExShowScreenMessage(
                      NpcStringId
                          .NOT_EVEN_THE_GODS_THEMSELVES_COULD_TOUCH_ME_BUT_YOU_S1_YOU_DARE_CHALLENGE_ME_IGNORANT_MORTAL,
                      2,
                      4000,
                      players.getName()));
              break;
            }
          }
          startQuestTimer("SPAWN_ARCHANGEL", 8000, npc, null);
          break;
        }
      case "SPAWN_ARCHANGEL":
        {
          _baium.disableCoreAI(false);

          for (Location loc : ARCHANGEL_LOC) {
            final L2Npc archangel = addSpawn(ARCHANGEL, loc, false, 0, true);
            startQuestTimer("SELECT_TARGET", 5000, archangel, null);
          }

          if ((player != null) && !player.isDead()) {
            attackPlayer((L2Attackable) npc, player);
          } else if ((_standbyPlayer != null) && !_standbyPlayer.isDead()) {
            attackPlayer((L2Attackable) npc, _standbyPlayer);
          } else {
            for (L2Character characters : npc.getKnownList().getKnownCharactersInRadius(2000)) {
              if ((characters != null)
                  && characters.isPlayer()
                  && zone.isInsideZone(characters)
                  && !characters.isDead()) {
                attackPlayer((L2Attackable) npc, (L2Playable) characters);
                break;
              }
            }
          }
          break;
        }
      case "SELECT_TARGET":
        {
          if (npc != null) {
            final L2Attackable mob = (L2Attackable) npc;
            final L2Character mostHated = mob.getMostHated();

            if ((_baium == null) || _baium.isDead()) {
              mob.deleteMe();
              break;
            }

            if ((mostHated != null) && mostHated.isPlayer() && zone.isInsideZone(mostHated)) {
              if (mob.getTarget() != mostHated) {
                mob.clearAggroList();
              }
              attackPlayer(mob, (L2Playable) mostHated);
            } else {
              boolean found = false;
              for (L2Character characters : mob.getKnownList().getKnownCharactersInRadius(1000)) {
                if ((characters != null)
                    && characters.isPlayable()
                    && zone.isInsideZone(characters)
                    && !characters.isDead()) {
                  if (mob.getTarget() != characters) {
                    mob.clearAggroList();
                  }
                  attackPlayer(mob, (L2Playable) characters);
                  found = true;
                  break;
                }
              }

              if (!found) {
                if (mob.isInsideRadius(_baium, 40, true, false)) {
                  if (mob.getTarget() != _baium) {
                    mob.clearAggroList();
                  }
                  mob.setIsRunning(true);
                  mob.addDamageHate(_baium, 0, 999);
                  mob.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, _baium);
                } else {
                  mob.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, _baium);
                }
              }
            }
            startQuestTimer("SELECT_TARGET", 5000, npc, null);
          }
          break;
        }
      case "CHECK_ATTACK":
        {
          if ((npc != null) && ((_lastAttack + 1800000) < System.currentTimeMillis())) {
            notifyEvent("CLEAR_ZONE", null, null);
            addSpawn(BAIUM_STONE, BAIUM_LOC, false, 0);
            setStatus(ALIVE);
          } else if (npc != null) {
            if (((_lastAttack + 300000) < System.currentTimeMillis())
                && (npc.getCurrentHp() < (npc.getMaxHp() * 0.75))) {
              npc.setTarget(npc);
              npc.doCast(HEAL_OF_BAIUM.getSkill());
            }
            startQuestTimer("CHECK_ATTACK", 60000, npc, null);
          }
          break;
        }
      case "CLEAR_STATUS":
        {
          setStatus(ALIVE);
          addSpawn(BAIUM_STONE, BAIUM_LOC, false, 0);
          break;
        }
      case "CLEAR_ZONE":
        {
          for (L2Character charInside : zone.getCharactersInside()) {
            if (charInside != null) {
              if (charInside.isNpc()) {
                charInside.deleteMe();
              } else if (charInside.isPlayer()) {
                notifyEvent("teleportOut", null, (L2PcInstance) charInside);
              }
            }
          }
          break;
        }
      case "RESPAWN_BAIUM":
        {
          if (getStatus() == DEAD) {
            setRespawn(0);
            cancelQuestTimer("CLEAR_STATUS", null, null);
            notifyEvent("CLEAR_STATUS", null, null);
          } else {
            player.sendMessage(
                getClass().getSimpleName() + ": You cant respawn Baium while Baium is alive!");
          }
          break;
        }
      case "ABORT_FIGHT":
        {
          if (getStatus() == IN_FIGHT) {
            _baium = null;
            notifyEvent("CLEAR_ZONE", null, null);
            notifyEvent("CLEAR_STATUS", null, null);
            player.sendMessage(getClass().getSimpleName() + ": Aborting fight!");
          } else {
            player.sendMessage(getClass().getSimpleName() + ": You cant abort attack right now!");
          }
          cancelQuestTimers("CHECK_ATTACK");
          cancelQuestTimers("SELECT_TARGET");
          break;
        }
      case "DESPAWN_MINIONS":
        {
          if (getStatus() == IN_FIGHT) {
            for (L2Character charInside : zone.getCharactersInside()) {
              if ((charInside != null) && charInside.isNpc() && (charInside.getId() == ARCHANGEL)) {
                charInside.deleteMe();
              }
            }
            if (player != null) {
              player.sendMessage(getClass().getSimpleName() + ": All archangels has been deleted!");
            }
          } else if (player != null) {
            player.sendMessage(
                getClass().getSimpleName() + ": You cant despawn archangels right now!");
          }
          break;
        }
      case "MANAGE_SKILLS":
        {
          if (npc != null) {
            manageSkills(npc);
          }
          break;
        }
    }
    return super.onAdvEvent(event, npc, player);
  }