Ejemplo n.º 1
0
  /** Talk with captains and using of the escape teleporter */
  @Override
  public final String onTalk(L2Npc npc, L2PcInstance player) {
    QuestState st = player.getQuestState(qn);
    if (st == null) newQuestState(player);
    final int npcId = npc.getNpcId();

    if (npcId == TELEPORTER) {
      final L2Party party = player.getParty();
      // only party leader can talk with escape teleporter
      if (party != null && party.isLeader(player)) {
        final InstanceWorld world = InstanceManager.getInstance().getWorld(npc.getInstanceId());
        if (world instanceof KamaWorld) {
          // party members must be in the instance
          if (world.allowed.contains(player.getObjectId())) {
            Instance inst = InstanceManager.getInstance().getInstance(world.instanceId);

            // teleports entire party away
            for (L2PcInstance partyMember : party.getPartyMembers())
              if (partyMember != null && partyMember.getInstanceId() == world.instanceId)
                teleportPlayer(partyMember, inst.getSpawnLoc(), 0);
          }
        }
      }
    } else return npcId + ".htm";

    return "";
  }
  @Override
  public String onTalk(L2Npc npc, L2PcInstance player) {
    String htmltext = getNoQuestMsg(player);
    QuestState st = player.getQuestState(qn);
    if (st == null) return htmltext;

    if (npc.getNpcId() == JAKAN) {
      switch (st.getState()) {
        case State.CREATED:
          if (player.getLevel() >= 84) htmltext = "32773-1.htm";
          else htmltext = "32773-0.htm";
          break;
        case State.STARTED:
          if (st.getInt("cond") == 1) htmltext = "32773-4.htm";
          else if (st.getInt("cond") == 2) {
            htmltext = "32773-5.htm";
            st.unset("cond");
            st.takeItems(TAG_ID, 1);
            st.giveItems(57, 95200);
            st.addExpAndSp(435024, 50366);
            st.playSound("ItemSound.quest_finish");
            st.exitQuest(false);

            Calendar reDo = Calendar.getInstance();
            reDo.set(Calendar.MINUTE, RESET_MIN);
            if (reDo.get(Calendar.HOUR_OF_DAY) >= RESET_HOUR) reDo.add(Calendar.DATE, 1);
            reDo.set(Calendar.HOUR_OF_DAY, RESET_HOUR);
            st.set("reDoTime", String.valueOf(reDo.getTimeInMillis()));
          }
          break;
        case State.COMPLETED:
          Long reDoTime = Long.parseLong(st.get("reDoTime"));
          if (reDoTime > System.currentTimeMillis()) htmltext = "32773-6.htm";
          else {
            st.setState(State.CREATED);
            if (player.getLevel() >= 84) htmltext = "32773-1.htm";
            else htmltext = "32773-0.htm";
          }
          break;
      }
    } else if (Util.contains(SOLDIER_CORPSES, npc.getNpcId())) {
      if (st.getInt("cond") == 1) htmltext = "corpse-1.htm";
    }
    return htmltext;
  }
Ejemplo n.º 3
0
  /** Only escape teleporters first talk handled */
  @Override
  public final String onFirstTalk(L2Npc npc, L2PcInstance player) {
    if (npc.getNpcId() == TELEPORTER) {
      if (player.isInParty() && player.getParty().isLeader(player)) return "32496.htm";
      else return "32496-no.htm";
    }

    return "";
  }
  @Override
  public String onAdvEvent(String event, L2Npc npc, L2PcInstance player) {
    String htmltext = event;
    QuestState st = player.getQuestState(qn);

    if (st == null) return htmltext;

    if (npc.getNpcId() == JAKAN) {
      if (event.equalsIgnoreCase("32773-3.htm")) {
        st.setState(State.STARTED);
        st.set("cond", "1");
        st.playSound("ItemSound.quest_accept");
      }
    } else if (Util.contains(SOLDIER_CORPSES, npc.getNpcId())) {
      if (st.getInt("cond") == 1) {
        st.giveItems(TAG_ID, 1);
        st.set("cond", "2");
        st.playSound("ItemSound.quest_middle");
        npc.deleteMe();
      } else htmltext = getNoQuestMsg(player);
    }
    return htmltext;
  }
Ejemplo n.º 5
0
  @Override
  public String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
    L2PcInstance partyMember = getRandomPartyMember(player, "1");
    if (partyMember == null) return null;
    final QuestState st = partyMember.getQuestState(qn);
    int chance = Rnd.get(1000);
    boolean giveItem = false;

    switch (npc.getNpcId()) {
      case 22771: // Tanta Lizardman Berserker
        if (chance < 159) giveItem = true;
        break;
      case 22770: // Tanta Lizardman Soldier
        if (chance < 123) giveItem = true;
        break;
      case 22774: // Tanta Lizardman Summoner
        if (chance < 261) giveItem = true;
        break;
      case 22769: // Tanta Lizardman Warrior
        if (chance < 689) giveItem = true;
        break;
      case 22772: // Tanta Lizardman Archer
        if (chance < 739) giveItem = true;
        break;
      case 22768: // Tanta Lizardman Scout
        if (chance < 509) giveItem = true;
        break;
      case 22773: // Tanta Lizardman Magician
        if (chance < 737) giveItem = true;
        break;
    }

    if (giveItem) {
      st.giveItems(VialOfTantaBlood, 1);
      st.playSound("ItemSound.quest_itemget");
    }
    return null;
  }
  @Override
  public final String onKill(L2Npc npc, L2PcInstance player, boolean isPet) {
    L2PcInstance pl = null;
    switch (npc.getNpcId()) {
      case DEMON_PRINCE:
        pl = getRandomPartyMember(player, "rewarded_prince", "1");
        if (pl != null) {
          final QuestState st = pl.getQuestState(qn);
          st.giveItems(BLUEPRINT_PRINCE, 1);
          st.set("rewarded_prince", "2");

          if (st.hasQuestItems(BLUEPRINT_RANKU)) {
            st.playSound("ItemSound.quest_middle");
            st.set("cond", "2");
          } else {
            st.playSound("ItemSound.quest_itemget");
          }
        }
        break;
      case RANKU:
        pl = getRandomPartyMember(player, "rewarded_ranku", "1");
        if (pl != null) {
          final QuestState st = pl.getQuestState(qn);
          st.giveItems(BLUEPRINT_RANKU, 1);
          st.set("rewarded_ranku", "2");

          if (st.getQuestItemsCount(BLUEPRINT_PRINCE) > 0) {
            st.playSound("ItemSound.quest_middle");
            st.set("cond", "2");
          } else {
            st.playSound("ItemSound.quest_itemget");
          }
        }
        break;
    }
    return null;
  }
Ejemplo n.º 7
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.º 8
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;
  }
Ejemplo n.º 9
0
  public Location getTeleToLocation(L2Character activeChar, TeleportWhereType teleportWhere) {
    int[] coord;

    if (activeChar instanceof L2PcInstance) {
      L2PcInstance player = ((L2PcInstance) activeChar);

      Castle castle = null;
      Fort fort = null;
      ClanHall clanhall = null;

      if (player.getClan() != null
          && !player.isFlyingMounted()
          && !player.isFlying()) // flying players in gracia cant use teleports to aden continent
      {
        // If teleport to clan hall
        if (teleportWhere == TeleportWhereType.ClanHall) {
          clanhall = ClanHallManager.getInstance().getAbstractHallByOwner(player.getClan());
          if (clanhall != null) {
            L2ClanHallZone zone = clanhall.getZone();
            if (zone != null && !player.isFlyingMounted()) {
              if (player.getKarma() > 0) return zone.getChaoticSpawnLoc();
              return zone.getSpawnLoc();
            }
          }
        }

        // If teleport to castle
        if (teleportWhere == TeleportWhereType.Castle) {
          castle = CastleManager.getInstance().getCastleByOwner(player.getClan());
          // Otherwise check if player is on castle or fortress ground
          // and player's clan is defender
          if (castle == null) {
            castle = CastleManager.getInstance().getCastle(player);
            if (!(castle != null
                && castle.getSiege().getIsInProgress()
                && castle.getSiege().getDefenderClan(player.getClan()) != null)) castle = null;
          }

          if (castle != null && castle.getCastleId() > 0) {
            if (player.getKarma() > 0) return castle.getCastleZone().getChaoticSpawnLoc();
            return castle.getCastleZone().getSpawnLoc();
          }
        }

        // If teleport to fortress
        if (teleportWhere == TeleportWhereType.Fortress) {
          fort = FortManager.getInstance().getFortByOwner(player.getClan());
          // Otherwise check if player is on castle or fortress ground
          // and player's clan is defender
          if (fort == null) {
            fort = FortManager.getInstance().getFort(player);
            if (!(fort != null
                && fort.getSiege().getIsInProgress()
                && fort.getOwnerClan() == player.getClan())) fort = null;
          }

          if (fort != null && fort.getFortId() > 0) {
            if (player.getKarma() > 0) return fort.getFortZone().getChaoticSpawnLoc();
            return fort.getFortZone().getSpawnLoc();
          }
        }

        // If teleport to SiegeHQ
        if (teleportWhere == TeleportWhereType.SiegeFlag) {
          castle = CastleManager.getInstance().getCastle(player);
          fort = FortManager.getInstance().getFort(player);
          clanhall =
              ClanHallManager.getInstance()
                  .getNearbyAbstractHall(activeChar.getX(), activeChar.getY(), 10000);
          L2SiegeFlagInstance tw_flag =
              TerritoryWarManager.getInstance().getFlagForClan(player.getClan());
          if (tw_flag != null) return new Location(tw_flag.getX(), tw_flag.getY(), tw_flag.getZ());
          else if (castle != null) {
            if (castle.getSiege().getIsInProgress()) {
              // Check if player's clan is attacker
              List<L2Npc> flags = castle.getSiege().getFlag(player.getClan());
              if (flags != null && !flags.isEmpty()) {
                // Spawn to flag - Need more work to get player to the nearest flag
                L2Npc flag = flags.get(0);
                return new Location(flag.getX(), flag.getY(), flag.getZ());
              }
            }

          } else if (fort != null) {
            if (fort.getSiege().getIsInProgress()) {
              // Check if player's clan is attacker
              List<L2Npc> flags = fort.getSiege().getFlag(player.getClan());
              if (flags != null && !flags.isEmpty()) {
                // Spawn to flag - Need more work to get player to the nearest flag
                L2Npc flag = flags.get(0);
                return new Location(flag.getX(), flag.getY(), flag.getZ());
              }
            }
          } else if (clanhall != null && clanhall.isSiegableHall()) {
            SiegableHall sHall = (SiegableHall) clanhall;
            List<L2Npc> flags = sHall.getSiege().getFlag(player.getClan());
            if (flags != null && !flags.isEmpty()) {
              L2Npc flag = flags.get(0);
              return new Location(flag.getX(), flag.getY(), flag.getZ());
            }
          }
        }
      }

      if (teleportWhere == TeleportWhereType.Castle_banish) {
        castle = CastleManager.getInstance().getCastle(player);
        if (castle != null) return castle.getCastleZone().getBanishSpawnLoc();
      } else if (teleportWhere == TeleportWhereType.Fortress_banish) {
        fort = FortManager.getInstance().getFort(activeChar);
        if (fort != null) return fort.getFortZone().getBanishSpawnLoc();
      } else if (teleportWhere == TeleportWhereType.ClanHall_banish) {
        clanhall = ClanHallManager.getInstance().getClanHall(activeChar);
        if (clanhall != null) return clanhall.getZone().getBanishSpawnLoc();
      }

      // Karma player land out of city
      if (player.getKarma() > 0) {
        try {
          L2RespawnZone zone = ZoneManager.getInstance().getZone(player, L2RespawnZone.class);
          if (zone != null)
            return getRestartRegion(activeChar, zone.getRespawnPoint((L2PcInstance) activeChar))
                .getChaoticSpawnLoc();
          return getMapRegion(activeChar).getChaoticSpawnLoc();
        } catch (Exception e) {
          if (player.isFlyingMounted()) // prevent flying players to teleport outside of gracia
          return _regions.get("union_base_of_kserth").getChaoticSpawnLoc();
          return _regions.get("talking_island_town").getChaoticSpawnLoc();
        }
      }

      // Checking if needed to be respawned in "far" town from the castle;
      castle = CastleManager.getInstance().getCastle(player);
      if (castle != null) {
        if (castle.getSiege().getIsInProgress()) {
          // Check if player's clan is participating
          if ((castle.getSiege().checkIsDefender(player.getClan())
                  || castle.getSiege().checkIsAttacker(player.getClan()))
              && SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE)
                  == SevenSigns.CABAL_DAWN) return castle.getCastleZone().getOtherSpawnLoc();
        }
      }

      // Checking if in an instance
      if (player.getInstanceId() > 0) {
        Instance inst = InstanceManager.getInstance().getInstance(player.getInstanceId());
        if (inst != null) {
          coord = inst.getSpawnLoc();
          if (coord[0] != 0 && coord[1] != 0 && coord[2] != 0)
            return new Location(coord[0], coord[1], coord[2]);
        }
      }
    }

    // Get the nearest town
    try {
      L2RespawnZone zone = ZoneManager.getInstance().getZone(activeChar, L2RespawnZone.class);
      if (zone != null)
        return getRestartRegion(activeChar, zone.getRespawnPoint((L2PcInstance) activeChar))
            .getSpawnLoc();
      return getMapRegion(activeChar).getSpawnLoc();
    } catch (Exception e) {
      // port to the Talking Island if no closest town found
      if (Config.DEBUG)
        _log.log(
            Level.WARNING,
            "Not defined respawn point for coords loc X="
                + activeChar.getX()
                + " Y="
                + activeChar.getY()
                + " Z="
                + activeChar.getZ());
      return _regions.get("talking_island_town").getSpawnLoc();
    }
  }