// If in Monster Derby Track
if (player.isInsideZone(L2Character.ZONE_MONSTERTRACK))
return new Location(12661, 181687, -3560);
Castle castle = null;
ClanHall clanhall = null;
if (player.getClan() != null)
{
// If teleport to clan hall
if (teleportWhere == TeleportWhereType.ClanHall)
{
clanhall = ClanHallManager.getInstance().getClanHallByOwner(player.getClan());
if (clanhall != null)
{
L2ClanHallZone zone = clanhall.getZone();
if (zone != null)
{
return zone.getSpawn();
}
}
}
// If teleport to castle
if (teleportWhere == TeleportWhereType.Castle) castle = CastleManager.getInstance().getCastleByOwner(player.getClan());
// Check if player is on castle ground
if (castle == null) castle = CastleManager.getInstance().getCastle(player);
if (castle != null && castle.getCastleId() > 0)
{
// If Teleporting to castle or
// If is on caslte with siege and player's clan is defender
if (teleportWhere == TeleportWhereType.Castle || (teleportWhere == TeleportWhereType.Castle && castle.getSiege().getIsInProgress() && castle.getSiege().getDefenderClan(player.getClan()) != null))
{
coord = castle.getZone().getSpawn();
return new Location(coord[0], coord[1], coord[2]);
}
if (teleportWhere == TeleportWhereType.SiegeFlag && castle.getSiege().getIsInProgress())
{
// Check if player's clan is attacker
List<L2NpcInstance> flags = castle.getSiege().getFlag(player.getClan());
if (flags != null && !flags.isEmpty())
{
// Spawn to flag - Need more work to get player to the nearest flag
L2NpcInstance flag = flags.get(0);
return new Location(flag.getX(), flag.getY(), flag.getZ());