Ejemplo n.º 1
0
  @Override
  public final String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
    final InstanceWorld tmpWorld = InstanceManager.getInstance().getWorld(npc.getInstanceId());
    if (tmpWorld instanceof KamaWorld) {
      final KamaWorld world = (KamaWorld) tmpWorld;
      final int objectId = npc.getObjectId();

      // first room was spawned ?
      if (world.firstRoom != null) {
        // is shaman killed ?
        if (world.shaman != 0 && world.shaman == objectId) {
          world.shaman = 0;
          // stop respawn of the minions
          for (L2Spawn spawn : world.firstRoom) {
            if (spawn != null) spawn.stopRespawn();
          }
          world.firstRoom.clear();
          world.firstRoom = null;

          if (world.boss != null) {
            final int skillId = FIRST_ROOM[world.index][2];
            final int skillLvl = FIRST_ROOM[world.index][3];
            if (skillId != 0 && skillLvl != 0) {
              final L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
              if (skill != null) skill.getEffects(world.boss, world.boss);
            }
          }

          return super.onKill(npc, player, isPet);
        }
      }

      // second room was spawned ?
      if (world.secondRoom != null) {
        boolean all = true;
        // check for all mobs in the second room
        for (int i = 0; i < world.secondRoom.size(); i++) {
          // found killed now mob
          if (world.secondRoom.get(i) == objectId) world.secondRoom.set(i, 0);
          // found alive mob
          else if (world.secondRoom.get(i) != 0) all = false;
        }
        // all mobs killed ?
        if (all) {
          world.secondRoom.clear();
          world.secondRoom = null;

          if (world.boss != null) {
            final int skillId = SECOND_ROOM[world.index][1];
            final int skillLvl = SECOND_ROOM[world.index][2];
            if (skillId != 0 && skillLvl != 0) {
              final L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
              if (skill != null) skill.getEffects(world.boss, world.boss);
            }
          }

          return super.onKill(npc, player, isPet);
        }
      }

      // miniboss spawned ?
      if (world.miniBoss != 0 && world.miniBoss == objectId) {
        world.miniBoss = 0;

        if (world.boss != null) {
          final int skillId = MINIBOSS[world.index][4];
          final int skillLvl = MINIBOSS[world.index][5];
          if (skillId != 0 && skillLvl != 0) {
            final L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLvl);
            if (skill != null) skill.getEffects(world.boss, world.boss);
          }
        }

        return super.onKill(npc, player, isPet);
      }

      // boss was killed, finish instance
      if (world.boss != null && world.boss == npc) {
        world.boss = null;
        finishInstance(world);
      }
    }
    return super.onKill(npc, player, isPet);
  }
Ejemplo n.º 2
0
  /**
   * Spawn all NPCs in kamaloka
   *
   * @param world instanceWorld
   */
  @SuppressWarnings("all")
  private final void spawnKama(KamaWorld world) {
    int[] npcs;
    int[][] spawns;
    L2Npc npc;
    final int index = world.index;

    // first room
    npcs = FIRST_ROOM[index];
    spawns = FIRST_ROOM_SPAWNS[index];
    if (npcs != null) {
      world.firstRoom = new ArrayList<L2Spawn>(spawns.length - 1);
      int shaman = Rnd.get(spawns.length); // random position for shaman

      for (int i = 0; i < spawns.length; i++) {
        if (i == shaman) {
          // stealth shaman use same npcId as other mobs
          npc =
              addSpawn(
                  STEALTH_SHAMAN ? npcs[1] : npcs[0],
                  spawns[i][0],
                  spawns[i][1],
                  spawns[i][2],
                  0,
                  false,
                  0,
                  false,
                  world.instanceId);
          world.shaman = npc.getObjectId();
        } else {
          npc =
              addSpawn(
                  npcs[1],
                  spawns[i][0],
                  spawns[i][1],
                  spawns[i][2],
                  0,
                  false,
                  0,
                  false,
                  world.instanceId);
          L2Spawn spawn = npc.getSpawn();
          spawn.setRespawnDelay(FIRST_ROOM_RESPAWN_DELAY);
          spawn.setAmount(1);
          spawn.startRespawn();
          world.firstRoom.add(spawn); // store mobs spawns
        }
        npc.setIsNoRndWalk(true);
      }
    }

    // second room
    npcs = SECOND_ROOM[index];
    spawns = SECOND_ROOM_SPAWNS[index];
    if (npcs != null) {
      world.secondRoom = new ArrayList<Integer>(spawns.length);

      for (int i = 0; i < spawns.length; i++) {
        npc =
            addSpawn(
                npcs[0],
                spawns[i][0],
                spawns[i][1],
                spawns[i][2],
                0,
                false,
                0,
                false,
                world.instanceId);
        npc.setIsNoRndWalk(true);
        world.secondRoom.add(npc.getObjectId());
      }
    }

    // miniboss
    if (MINIBOSS[index] != null) {
      npc =
          addSpawn(
              MINIBOSS[index][0],
              MINIBOSS[index][1],
              MINIBOSS[index][2],
              MINIBOSS[index][3],
              0,
              false,
              0,
              false,
              world.instanceId);
      npc.setIsNoRndWalk(true);
      world.miniBoss = npc.getObjectId();
    }

    // escape teleporter
    if (TELEPORTERS[index] != null)
      addSpawn(
          TELEPORTER,
          TELEPORTERS[index][0],
          TELEPORTERS[index][1],
          TELEPORTERS[index][2],
          0,
          false,
          0,
          false,
          world.instanceId);

    // boss
    npc =
        addSpawn(
            BOSS[index][0],
            BOSS[index][1],
            BOSS[index][2],
            BOSS[index][3],
            0,
            false,
            0,
            false,
            world.instanceId);
    ((L2MonsterInstance) npc).setOnKillDelay(100);
    world.boss = npc;
  }