Esempio n. 1
0
  @Override
  public String onKill(L2NpcInstance npc, L2PcInstance killer, boolean isPet) {
    int npcId = npc.getNpcId();

    Integer status = GrandBossManager.getInstance().getBossStatus(ZAKEN);

    if (npcId == ZAKEN) {
      npc.broadcastPacket(
          new PlaySound(1, "BS02_D", 1, npc.getObjectId(), npc.getX(), npc.getY(), npc.getZ()));

      GrandBossManager.getInstance().setBossStatus(ZAKEN, DEAD);
      // time is 36hour	+/- 17hour
      long respawnTime = (long) (Config.ZAKEN_RESP_FIRST + Rnd.get(Config.ZAKEN_RESP_SECOND));
      startQuestTimer("zaken_unlock", respawnTime, null, null);
      cancelQuestTimer("1001", npc, null);
      cancelQuestTimer("1003", npc, null);
      // also save the respawn time so that the info is maintained past reboots
      StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
      info.set("respawn_time", System.currentTimeMillis() + respawnTime);
      GrandBossManager.getInstance().setStatsSet(ZAKEN, info);
    } else if (status == ALIVE) {
      if (npcId != ZAKEN) {
        startQuestTimer("CreateOnePrivateEx", ((30 + Rnd.get(60)) * 1000), npc, null);
      }
    }
    return super.onKill(npc, killer, isPet);
  }
Esempio n. 2
0
  public Zaken(int questId, String name, String descr) {
    super(questId, name, descr);

    // Zaken doors handling
    ThreadPoolManager.getInstance()
        .scheduleGeneralAtFixedRate(
            new Runnable() {
              public void run() {
                try {
                  if (getTimeHour() == 0) {
                    DoorTable.getInstance().getDoor(21240006).openMe();
                    ThreadPoolManager.getInstance()
                        .scheduleGeneral(
                            new Runnable() {
                              public void run() {
                                try {
                                  DoorTable.getInstance().getDoor(21240006).closeMe();
                                } catch (Throwable e) {
                                  e.printStackTrace();
                                  log.warn("Cannot close door ID: 21240006 " + e);
                                }
                              }
                            },
                            300000L);
                  }
                } catch (Throwable e) {
                  e.printStackTrace();
                  log.warn("Cannot open door ID: 21240006 " + e);
                }
              }
            },
            2000L,
            600000L);

    addEventId(ZAKEN, Quest.QuestEventType.ON_KILL);
    addEventId(ZAKEN, Quest.QuestEventType.ON_ATTACK);
    addEventId(ZAKEN, Quest.QuestEventType.ON_SPELL_FINISHED);
    addEventId(ZAKEN, Quest.QuestEventType.ON_AGGRO_RANGE_ENTER);
    addEventId(ZAKEN, Quest.QuestEventType.ON_FACTION_CALL);

    addEventId(doll_blader_b, Quest.QuestEventType.ON_KILL);
    addEventId(vale_master_b, Quest.QuestEventType.ON_KILL);
    addEventId(pirates_zombie_captain_b, Quest.QuestEventType.ON_KILL);
    addEventId(pirates_zombie_b, Quest.QuestEventType.ON_KILL);

    _Zone = GrandBossManager.getInstance().getZone(55312, 219168, -3223);

    StatsSet info = GrandBossManager.getInstance().getStatsSet(ZAKEN);
    Integer status = GrandBossManager.getInstance().getBossStatus(ZAKEN);
    if (status == DEAD) {
      // load the unlock date and time for zaken from DB
      long temp = info.getLong("respawn_time") - System.currentTimeMillis();
      // if zaken is locked until a certain time, mark it so and start the unlock timer
      // the unlock time has not yet expired.
      if (temp > 0) startQuestTimer("zaken_unlock", temp, null, null);
      else {
        // the time has already expired while the server was offline. Immediately spawn zaken.
        L2GrandBossInstance zaken =
            (L2GrandBossInstance) addSpawn(ZAKEN, 55312, 219168, -3223, 0, false, 0);
        GrandBossManager.getInstance().setBossStatus(ZAKEN, ALIVE);
        spawnBoss(zaken);
      }
    } else {
      int loc_x = info.getInteger("loc_x");
      int loc_y = info.getInteger("loc_y");
      int loc_z = info.getInteger("loc_z");
      int heading = info.getInteger("heading");
      int hp = info.getInteger("currentHP");
      int mp = info.getInteger("currentMP");
      L2GrandBossInstance zaken =
          (L2GrandBossInstance) addSpawn(ZAKEN, loc_x, loc_y, loc_z, heading, false, 0);
      zaken.setCurrentHpMp(hp, mp);
      spawnBoss(zaken);
    }
  }