Beispiel #1
0
  /**
   * Starts the participation of the TvTEvent<br>
   * 1. Get L2NpcTemplate by Config.TVT_EVENT_PARTICIPATION_NPC_ID<br>
   * 2. Try to spawn a new npc of it<br>
   * <br>
   *
   * @return boolean: true if success, otherwise false<br>
   */
  public static boolean startParticipation() {
    try {
      _npcSpawn = new L2Spawn(Config.TVT_EVENT_PARTICIPATION_NPC_ID);

      _npcSpawn.setX(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[0]);
      _npcSpawn.setY(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[1]);
      _npcSpawn.setZ(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[2]);
      _npcSpawn.setAmount(1);
      _npcSpawn.setHeading(Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES[3]);
      _npcSpawn.setRespawnDelay(1);
      // later no need to delete spawn from db, we don't store it (false)
      SpawnTable.getInstance().addNewSpawn(_npcSpawn, false);
      _npcSpawn.init();
      _lastNpcSpawn = _npcSpawn.getLastSpawn();
      _lastNpcSpawn.setCurrentHp(_lastNpcSpawn.getMaxHp());
      _lastNpcSpawn.setTitle("TvT Event Participation");
      _lastNpcSpawn.isAggressive();
      _lastNpcSpawn.decayMe();
      _lastNpcSpawn.spawnMe(
          _npcSpawn.getLastSpawn().getX(),
          _npcSpawn.getLastSpawn().getY(),
          _npcSpawn.getLastSpawn().getZ());
      _lastNpcSpawn.broadcastPacket(new MagicSkillUse(_lastNpcSpawn, _lastNpcSpawn, 1034, 1, 1, 1));
    } catch (Exception e) {
      _log.log(
          Level.WARNING,
          "TvTEventEngine[TvTEvent.startParticipation()]: exception: " + e.getMessage(),
          e);
      return false;
    }

    setState(EventState.PARTICIPATING);
    EventDispatcher.getInstance().notifyEventAsync(new OnTvTEventRegistrationStart());
    return true;
  }
 @Override
 public String onSpawn(L2Npc npc) {
   switch (npc.getId()) {
     case WITCH_ATHREA:
       {
         if (npc.isScriptValue(50301)) {
           startQuestTimer("DESPAWN_WITCH_ATHREA", 5000, npc, null);
           npc.broadcastPacket(new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.WAR_AND_DEATH));
         }
         break;
       }
     case WITCH_KALIS:
       {
         if (npc.isScriptValue(50302)) {
           startQuestTimer("DESPAWN_WITCH_KALIS", 5000, npc, null);
           npc.broadcastPacket(
               new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.AMBITION_AND_POWER));
         }
         break;
       }
     case IMPERIAL_COFFER:
       {
         startQuestTimer("DESPAWN_IMPERIAL_COFFER", 180000, npc, null);
         npc.broadcastPacket(
             new NpcSay(
                 npc,
                 ChatType.NPC_GENERAL,
                 NpcStringId
                     .CURSE_OF_THE_GODS_ON_THE_ONE_THAT_DEFILES_THE_PROPERTY_OF_THE_EMPIRE));
         break;
       }
     case BLITZ_WYRM:
       {
         startQuestTimer("DESPAWN_BLITZ_WYRM", 180000, npc, null);
         break;
       }
   }
   return super.onSpawn(npc);
 }
  @Override
  public String onAttack(L2Npc npc, L2PcInstance attacker, int damage, boolean isSummon) {
    final QuestState qs = getQuestState(attacker, false);
    if ((qs != null) && qs.isCond(2)) {
      if (isSummon) {
        final NpcData data = NPC_DATA.get(npc.getId());
        if ((qs.getMemoState() % data.memoStateMod) < data.memoStateValue) {
          final L2Summon pet = attacker.getPet();
          if ((pet != null) && (pet.getControlObjectId() == qs.getInt("fluteObjectId"))) {
            final int hits = qs.getInt("hits") + 1;
            qs.set("hits", hits);

            if (hits < data.minHits) {
              if ((npc.getId() == TREE_OF_ABYSS) && (getRandom(100) < 2)) {
                npc.setTarget(attacker);
                npc.doCast(DRYAD_ROOT.getSkill());
              }
            } else if (getRandom(100) < 2) {
              if (hasQuestItems(attacker, FAIRY_LEAF)) {
                npc.broadcastPacket(
                    new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.GIVE_ME_A_FAIRY_LEAF));
                takeItems(attacker, FAIRY_LEAF, 1);
                qs.setMemoState(qs.getMemoState() + data.memoStateValue);
                qs.unset("hits");
                playSound(attacker, QuestSound.ITEMSOUND_QUEST_MIDDLE);

                if (qs.getMemoState() == 15) {
                  qs.setCond(3);
                }
              }
            }
          }
        } else {
          switch (getRandom(3)) {
            case 0:
              npc.broadcastPacket(
                  new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.WHY_DO_YOU_BOTHER_ME_AGAIN));
              break;
            case 1:
              npc.broadcastPacket(new NpcSay(npc, ChatType.NPC_GENERAL, data.message));
              break;
            case 2:
              npc.broadcastPacket(
                  new NpcSay(
                      npc,
                      ChatType.NPC_GENERAL,
                      NpcStringId.LEAVE_NOW_BEFORE_YOU_INCUR_THE_WRATH_OF_THE_GUARDIAN_GHOST));
              break;
          }
        }
      } else if (getRandom(100) < 30) {
        npc.setTarget(attacker);
        npc.doCast(VICIOUS_POISON.getSkill());
      }
    } else if ((npc.getCurrentHp() < (npc.getMaxHp() * 0.67)) && (getRandom(100) < 30)) {
      npc.setTarget(attacker);
      npc.doCast(VICIOUS_POISON.getSkill());
    }

    return super.onAttack(npc, attacker, damage, isSummon);
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    final QuestState st = getQuestState(player, true);

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

    if (npc.getId() == KANEMIKA) {
      switch (st.getState()) {
        case State.COMPLETED:
          if (!st.isNowAvailable()) {
            htmltext = "32650-03.html";
            break;
          }
          st.setState(State.CREATED);
        case State.CREATED:
          htmltext = (player.getLevel() >= MIN_LEVEL) ? "32650-01.htm" : "32650-02.htm";
          break;
        case State.STARTED:
          if (st.isCond(1)) {
            htmltext =
                (!st.hasQuestItems(EVIDENCE_OF_MIGRATION)) ? "32650-08.html" : "32650-09.html";
          } else {
            st.giveAdena(
                65000, true); // Glory days reward: 6 886 980 exp, 8 116 410 sp, 371 400 Adena
            st.exitQuest(QuestType.DAILY, true);
            htmltext = "32650-10.html";
          }
          break;
      }
    } else if (st.isCond(1)) {
      if (npc.isBusy()) {
        return null;
      }

      if (getRandom(100) < 66) {
        st.giveItems(EVIDENCE_OF_MIGRATION, 1);
        st.playSound(QuestSound.ITEMSOUND_QUEST_ITEMGET);
        npc.getAI()
            .setIntention(
                CtrlIntention.AI_INTENTION_MOVE_TO,
                new Location(npc.getX() + 100, npc.getY() + 100, npc.getZ(), 0));
        npc.setBusy(true);

        startQuestTimer("despawn", 3000, npc, player);

        if (st.getQuestItemsCount(EVIDENCE_OF_MIGRATION) == 10) {
          st.setCond(2, true);
        }
        htmltext = "32651-01.html";
      } else {
        if (getRandom(100) < 50) {
          npc.broadcastPacket(
              new NpcSay(
                  npc.getObjectId(), ChatType.NPC_GENERAL, npc.getId(), NpcStringId.GRUNT_OH));
        } else {
          npc.broadcastPacket(
              new NpcSay(
                  npc.getObjectId(),
                  ChatType.NPC_GENERAL,
                  npc.getId(),
                  NpcStringId.GRUNT_WHAT_S_WRONG_WITH_ME));
        }
        npc.deleteMe();
        htmltext = null;

        final L2Attackable monster =
            (L2Attackable)
                addSpawn(
                    WARRIOR_MON,
                    npc.getX(),
                    npc.getY(),
                    npc.getZ(),
                    npc.getHeading(),
                    true,
                    600000);
        monster.setRunning();
        monster.addDamageHate(player, 0, 999);
        monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
        showOnScreenMsg(
            player,
            NpcStringId
                .THE_GRAVE_ROBBER_WARRIOR_HAS_BEEN_FILLED_WITH_DARK_ENERGY_AND_IS_ATTACKING_YOU,
            5,
            5000);
      }
    }

    return htmltext;
  }
Beispiel #5
0
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    if ((event == null) || event.isEmpty()) {
      _log.warning("MC_Show: Null/Empty event for npc " + npc + " and player " + player + "!");
      return null;
    }

    if (event.equalsIgnoreCase("Start")) {
      IS_STARTED = true;
      addSpawn(MC, -56698, -56430, -2008, 32768, false, 0);
    } else if ((npc != null) && IS_STARTED) {
      // TODO switch on event
      if (event.equalsIgnoreCase("6")) {
        autoChat(npc, MESSAGES[6], ChatType.NPC_SHOUT);
        npc.getAI()
            .setIntention(
                CtrlIntention.AI_INTENTION_MOVE_TO, new Location(-56511, -56647, -2008, 36863));
        npc.broadcastPacket(new PlaySound(1, "NS22_F", 0, 0, 0, 0, 0));
        addSpawn(SINGERS[0], -56344, -56328, -2008, 32768, false, 224000);
        addSpawn(SINGERS[1], -56552, -56245, -2008, 36863, false, 224000);
        addSpawn(SINGERS[1], -56546, -56426, -2008, 28672, false, 224000);
        addSpawn(SINGERS[1], -56570, -56473, -2008, 28672, false, 224000);
        addSpawn(SINGERS[1], -56594, -56516, -2008, 28672, false, 224000);
        addSpawn(SINGERS[1], -56580, -56203, -2008, 36863, false, 224000);
        addSpawn(SINGERS[1], -56606, -56157, -2008, 36863, false, 224000);
        startQuestTimer("7", 215000, npc, null);
      } else if (event.equalsIgnoreCase("7")) {
        switch (npc.getId()) {
          case 32433:
            {
              autoChat(npc, MESSAGES[7], ChatType.NPC_SHOUT);
              npc.getAI()
                  .setIntention(
                      CtrlIntention.AI_INTENTION_MOVE_TO,
                      new Location(-56698, -56430, -2008, 32768));
              startQuestTimer("8", 12000, npc, null);
              break;
            }
          default:
            {
              cancelQuestTimer("social1", npc, null);
              npc.getAI()
                  .setIntention(
                      CtrlIntention.AI_INTENTION_MOVE_TO,
                      new Location(-56594, -56064, -2008, 32768));
              break;
            }
        }
      } else if (event.equalsIgnoreCase("10")) {
        npc.getAI()
            .setIntention(
                CtrlIntention.AI_INTENTION_MOVE_TO, new Location(-56483, -56665, -2034, 32768));
        npc.broadcastPacket(new PlaySound(1, "TP05_F", 0, 0, 0, 0, 0));
        startQuestTimer(
            "npc1_1", 3000, addSpawn(CIRCUS[0], -56495, -56375, -2008, 32768, false, 101000), null);
        startQuestTimer(
            "npc2_1", 3000, addSpawn(CIRCUS[0], -56491, -56289, -2008, 32768, false, 101000), null);
        startQuestTimer(
            "npc3_1", 3000, addSpawn(CIRCUS[1], -56502, -56246, -2008, 32768, false, 101000), null);
        startQuestTimer(
            "npc4_1", 3000, addSpawn(CIRCUS[1], -56496, -56429, -2008, 32768, false, 101000), null);
        startQuestTimer(
            "npc5_1", 3500, addSpawn(CIRCUS[2], -56505, -56334, -2008, 32768, false, 101000), null);
        startQuestTimer(
            "npc6_1", 4000, addSpawn(CIRCUS[3], -56545, -56427, -2008, 32768, false, 101000), null);
        startQuestTimer(
            "npc7_1", 4000, addSpawn(CIRCUS[3], -56552, -56248, -2008, 32768, false, 101000), null);
        startQuestTimer(
            "npc8_1", 3000, addSpawn(CIRCUS[4], -56493, -56473, -2008, 32768, false, 101000), null);
        startQuestTimer(
            "npc9_1", 3000, addSpawn(CIRCUS[4], -56504, -56201, -2008, 32768, false, 101000), null);
        startQuestTimer("11", 100000, npc, null);
      } else if (event.equalsIgnoreCase("11")) {
        switch (npc.getId()) {
          case 32433:
            {
              autoChat(npc, MESSAGES[11], ChatType.NPC_SHOUT);
              npc.getAI()
                  .setIntention(
                      CtrlIntention.AI_INTENTION_MOVE_TO,
                      new Location(-56698, -56430, -2008, 32768));
              startQuestTimer("12", 5000, npc, null);
              break;
            }
          default:
            {
              npc.getAI()
                  .setIntention(
                      CtrlIntention.AI_INTENTION_MOVE_TO,
                      new Location(-56343, -56330, -2008, 32768));
              break;
            }
        }
      } else if (event.equalsIgnoreCase("14")) {
        startQuestTimer(
            "social1",
            2000,
            addSpawn(INDIVIDUALS[0], -56700, -56385, -2008, 32768, false, 49000),
            null);
        startQuestTimer("15", 7000, npc, null);
      } else if (event.equalsIgnoreCase("17")) {
        autoChat(npc, MESSAGES[16], ChatType.NPC_SHOUT);
        startQuestTimer(
            "social1",
            2000,
            addSpawn(INDIVIDUALS[1], -56700, -56340, -2008, 32768, false, 32000),
            null);
        startQuestTimer("18", 9000, npc, null);
      } else if (event.equalsIgnoreCase("20")) {
        startQuestTimer(
            "social1",
            2000,
            addSpawn(INDIVIDUALS[2], -56703, -56296, -2008, 32768, false, 13000),
            null);
        startQuestTimer("21", 8000, npc, null);
      } else if (event.equalsIgnoreCase("23")) {
        npc.getAI()
            .setIntention(
                CtrlIntention.AI_INTENTION_MOVE_TO, new Location(-56702, -56340, -2008, 32768));
        startQuestTimer("24", 2800, npc, null);
        addSpawn(SHOWSTUFF[0], -56672, -56406, -2000, 32768, false, 20900);
        addSpawn(SHOWSTUFF[1], -56648, -56368, -2000, 32768, false, 20900);
        addSpawn(SHOWSTUFF[2], -56608, -56338, -2000, 32768, false, 20900);
        addSpawn(SHOWSTUFF[3], -56652, -56307, -2000, 32768, false, 20900);
        addSpawn(SHOWSTUFF[4], -56672, -56272, -2000, 32768, false, 20900);
      } else if (event.equalsIgnoreCase("28")) {
        autoChat(npc, MESSAGES[23], ChatType.NPC_GENERAL);
        startQuestTimer("social1", 1, npc, null);
      } else if (event.equalsIgnoreCase("29")) {
        npc.getAI()
            .setIntention(
                CtrlIntention.AI_INTENTION_MOVE_TO, new Location(-56730, -56340, -2008, 32768));
        startQuestTimer("clean_npc", 4100, npc, null);
        startQuestTimer("timer_check", 60000, null, null, true);
      } else if (event.equalsIgnoreCase("social1")) {
        npc.broadcastSocialAction(1);
      } else if (event.equalsIgnoreCase("clean_npc")) {
        IS_STARTED = false;
        npc.deleteMe();
      } else {
        if (TALKS.containsKey(event)) {
          final ShoutInfo si = TALKS.get(event);
          if (si != null) {
            autoChat(npc, si.getNpcStringId(), ChatType.NPC_SHOUT);
            startQuestTimer(si.getNextEvent(), si.getTime(), npc, null);
          }
        } else if (WALKS.containsKey(event)) {
          final WalkInfo wi = WALKS.get(event);
          if (wi != null) {
            npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, wi.getCharPos());
            startQuestTimer(wi.getNextEvent(), wi.getTime(), npc, null);
          }
        }
      }
    }
    return null;
  }
Beispiel #6
0
 private void autoChat(L2Npc npc, NpcStringId npcString, ChatType type) {
   npc.broadcastPacket(new NpcSay(npc.getObjectId(), type, npc.getId(), npcString));
 }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    if (event.startsWith("DESPAWN")) {
      npc.deleteMe();
      return super.onAdvEvent(event, npc, player);
    }

    final QuestState qs = getQuestState(player, false);
    if (qs == null) {
      return null;
    }

    String htmltext = null;
    switch (event) {
      case "30760-08.html":
        {
          if (qs.isCreated()) {
            giveItems(player, GUSTAVS_1ST_LETTER, 1);
            qs.startQuest();
            qs.setMemoState(1000);
            htmltext = event;
          }
          break;
        }
      case "30760-12.html":
        {
          giveItems(player, GUSTAVS_2ND_LETTER, 1);
          qs.setMemoState(4000);
          qs.setCond(4);
          htmltext = event;
          break;
        }
      case "30760-16.html":
        {
          giveItems(player, GUSTAVS_3RD_LETTER, 1);
          qs.setMemoState(7000);
          qs.setCond(7);
          htmltext = event;
          break;
        }
      case "30760-20.html":
        {
          if (hasQuestItems(player, SCEPTER_OF_JUDGMENT)) {
            giveItems(player, SEAL_OF_ASPIRATION, 1);
            addExpAndSp(player, 0, 250000);
            qs.exitQuest(false, true);
            htmltext = event;
          }
          break;
        }
      case "30760-22.html":
        {
          qs.setMemoState(10000);
          qs.setCond(12);
          htmltext = event;
          break;
        }
      case "30760-23.html":
        {
          if (hasQuestItems(player, SCEPTER_OF_JUDGMENT)) {
            giveItems(player, SEAL_OF_ASPIRATION, 1);
            addExpAndSp(player, 0, 250000);
            qs.exitQuest(false, true);
            htmltext = event;
          }
          break;
        }
      case "30512-03.html":
        {
          if (hasQuestItems(player, BROOCH_OF_THE_MAGPIE)) {
            takeItems(player, BROOCH_OF_THE_MAGPIE, -1);
            giveItems(player, BLACK_ANVIL_COIN, 1);
          }
          htmltext = event;
          break;
        }
      case "30645-03.html":
        {
          takeItems(player, GUSTAVS_1ST_LETTER, -1);
          qs.setMemoState(2000);
          qs.setCond(2, true);
          htmltext = event;
          break;
        }
      case "30761-02.html":
        {
          if (qs.isMemoState(2000)
              || qs.isMemoState(2011)
              || qs.isMemoState(2010)
              || qs.isMemoState(2001)) {
            giveItems(player, BLITZ_WYRM_EGG, 3);
            qs.setMemoState(qs.getMemoState() + 100);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            startQuestTimer("DESPAWN", 10000, npc, player);
            htmltext = event;
          } else if (qs.isMemoState(2100)
              || qs.isMemoState(2111)
              || qs.isMemoState(2110)
              || qs.isMemoState(2101)) {
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            startQuestTimer("DESPAWN", 10000, npc, player);
            htmltext = "30761-03.html";
          }
          break;
        }
      case "30762-02.html":
        {
          if (qs.isMemoState(2000)
              || qs.isMemoState(2101)
              || qs.isMemoState(2001)
              || qs.isMemoState(2100)) {
            giveItems(player, BLITZ_WYRM_EGG, 3);
            giveItems(player, MIST_DRAKES_EGG, 4);
            qs.setMemoState(qs.getMemoState() + 10);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            startQuestTimer("DESPAWN", 10000, npc, player);
            htmltext = event;
          } else if (qs.isMemoState(2100)
              || qs.isMemoState(2111)
              || qs.isMemoState(2011)
              || qs.isMemoState(2110)) {
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            addAttackPlayerDesire(addSpawn(BLITZ_WYRM, npc, true, 0, false), player);
            startQuestTimer("DESPAWN", 10000, npc, player);
            htmltext = "30762-03.html";
          }
          break;
        }
      case "30763-02.html":
        {
          if (qs.isMemoState(2000)
              || qs.isMemoState(2110)
              || qs.isMemoState(2010)
              || qs.isMemoState(2100)) {
            giveItems(player, BROOCH_OF_THE_MAGPIE, 1);
            giveItems(player, MIST_DRAKES_EGG, 6);
            qs.setMemoState(qs.getMemoState() + 1);
            npc.deleteMe();
            htmltext = event;
          }
          break;
        }
      case "30764-03.html":
        {
          takeItems(player, GUSTAVS_2ND_LETTER, -1);
          qs.setMemoState(5000);
          qs.setCond(5, true);
          htmltext = event;
          break;
        }
      case "30764-06.html":
        {
          takeItems(player, GUSTAVS_2ND_LETTER, -1);
          takeItems(player, BLACK_ANVIL_COIN, -1);
          giveItems(player, RECIPE_SPITEFUL_SOUL_ENERGY, 1);
          qs.setMemoState(5000);
          qs.setCond(5, true);
          htmltext = event;
          break;
        }
      case "30765-04.html":
        {
          takeItems(player, IMPERIAL_KEY, -1);
          giveItems(player, SCEPTER_OF_JUDGMENT, 1);
          qs.setMemoState(8700);
          htmltext = event;
          break;
        }
      case "30766-04.html":
        {
          qs.setMemoState(8100);
          qs.setCond(9, true);
          npc.broadcastPacket(new NpcSay(npc, ChatType.NPC_GENERAL, NpcStringId.BLOOD_AND_HONOR));
          startQuestTimer("SPAWN_WITCH", 5000, npc, player);
          htmltext = event;
          break;
        }
      case "30766-08.html":
        {
          if (hasQuestItems(player, SCEPTER_OF_JUDGMENT)) {
            giveItems(player, SEAL_OF_ASPIRATION, 1);
            addExpAndSp(player, 0, 250000);
            qs.exitQuest(false, true);
            htmltext = event;
          }
          break;
        }
      case "30868-04.html":
        {
          takeItems(player, GUSTAVS_3RD_LETTER, -1);
          qs.setMemoState(8000);
          qs.setCond(8, true);
          htmltext = event;
          break;
        }
      case "30868-10.html":
        {
          qs.setMemoState(9000);
          qs.setCond(11, true);
          htmltext = event;
          break;
        }
      case "30645-06.html":
      case "30760-05.html":
      case "30760-06.html":
      case "30760-07.html":
      case "30760-21.html":
      case "30764-05.html":
      case "30765-02.html":
      case "30765-05a.html":
      case "30766-03.html":
      case "30868-03.html":
      case "30868-06a.html":
        {
          htmltext = event;
          break;
        }
      case "SPAWN_WITCH":
        {
          final L2Npc athrea = addSpawn(WITCH_ATHREA, 160688, 21296, -3714, 0, false, 0);
          athrea.setScriptValue(50301);
          final L2Npc kalis = addSpawn(WITCH_KALIS, 160690, 21176, -3712, 0, false, 0);
          kalis.setScriptValue(50302);
          break;
        }
    }
    return htmltext;
  }