|
@@ -24,7 +24,6 @@ import com.l2jserver.gameserver.instancemanager.MapRegionManager;
|
|
|
import com.l2jserver.gameserver.model.actor.L2Attackable;
|
|
|
import com.l2jserver.gameserver.model.actor.L2Character;
|
|
|
import com.l2jserver.gameserver.model.actor.L2Npc;
|
|
|
-import com.l2jserver.gameserver.model.actor.L2Playable;
|
|
|
import com.l2jserver.gameserver.model.actor.L2Summon;
|
|
|
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
|
|
import com.l2jserver.gameserver.model.zone.L2ZoneType;
|
|
@@ -48,7 +47,14 @@ public class L2BossZone extends L2ZoneType
|
|
|
// after reboot/server downtime (outside of their control), within 30
|
|
|
// of server restart
|
|
|
private L2FastList<Integer> _playersAllowed;
|
|
|
- private int[] _oustLoc = { 0, 0, 0 };
|
|
|
+
|
|
|
+ private int[] _oustLoc =
|
|
|
+ {
|
|
|
+ 0,
|
|
|
+ 0,
|
|
|
+ 0
|
|
|
+ };
|
|
|
+
|
|
|
protected L2FastList<L2Character> _raidList = new L2FastList<L2Character>();
|
|
|
|
|
|
public L2BossZone(int id)
|
|
@@ -89,27 +95,22 @@ public class L2BossZone extends L2ZoneType
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
/**
|
|
|
- * Boss zones have special behaviors for player characters. Players are
|
|
|
- * automatically teleported out when the attempt to enter these zones,
|
|
|
- * except if the time at which they enter the zone is prior to the entry
|
|
|
- * expiration time set for that player. Entry expiration times are set by
|
|
|
- * any one of the following: 1) A player logs out while in a zone
|
|
|
- * (Expiration gets set to logoutTime + _timeInvade) 2) An external source
|
|
|
- * (such as a quest or AI of NPC) set up the player for entry.
|
|
|
- *
|
|
|
- * There exists one more case in which the player will be allowed to enter.
|
|
|
- * That is if the server recently rebooted (boot-up time more recent than
|
|
|
- * currentTime - _timeInvade) AND the player was in the zone prior to reboot.
|
|
|
+ * Boss zones have special behaviors for player characters.
|
|
|
+ * Players are automatically teleported out when the attempt to enter these zones, except if the time at which they enter the zone is prior to the entry expiration time set for that player.
|
|
|
+ * Entry expiration times are set by any one of the following:
|
|
|
+ * 1) A player logs out while in a zone (Expiration gets set to logoutTime + _timeInvade)
|
|
|
+ * 2) An external source (such as a quest or AI of NPC) set up the player for entry. There exists one more case in which the player will be allowed to enter.
|
|
|
+ * That is if the server recently rebooted (boot-up time more recent than currentTime - _timeInvade) AND the player was in the zone prior to reboot.
|
|
|
*/
|
|
|
+ @Override
|
|
|
protected void onEnter(L2Character character)
|
|
|
{
|
|
|
if (_enabled)
|
|
|
{
|
|
|
- if (character instanceof L2PcInstance)
|
|
|
+ if (character.isPlayer())
|
|
|
{
|
|
|
- final L2PcInstance player = (L2PcInstance)character;
|
|
|
+ final L2PcInstance player = character.getActingPlayer();
|
|
|
if (player.isGM())
|
|
|
return;
|
|
|
// if player has been (previously) cleared by npc/ai for entry and the zone is
|
|
@@ -125,26 +126,34 @@ public class L2BossZone extends L2ZoneType
|
|
|
{
|
|
|
long serverStartTime = GameServer.dateTimeServerStarted.getTimeInMillis();
|
|
|
if ((serverStartTime > (System.currentTimeMillis() - _timeInvade)))
|
|
|
+ {
|
|
|
return;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// legal non-null logoutTime entries
|
|
|
_playerAllowedReEntryTimes.remove(player.getObjectId());
|
|
|
if (expirationTime.longValue() > System.currentTimeMillis())
|
|
|
+ {
|
|
|
return;
|
|
|
+ }
|
|
|
}
|
|
|
_playersAllowed.remove(_playersAllowed.indexOf(player.getObjectId()));
|
|
|
}
|
|
|
// teleport out all players who attempt "illegal" (re-)entry
|
|
|
if (_oustLoc[0] != 0 && _oustLoc[1] != 0 && _oustLoc[2] != 0)
|
|
|
+ {
|
|
|
player.teleToLocation(_oustLoc[0], _oustLoc[1], _oustLoc[2]);
|
|
|
+ }
|
|
|
else
|
|
|
+ {
|
|
|
player.teleToLocation(MapRegionManager.TeleportWhereType.Town);
|
|
|
+ }
|
|
|
}
|
|
|
- else if (character instanceof L2Summon)
|
|
|
+ else if (character.isSummon())
|
|
|
{
|
|
|
- final L2PcInstance player = ((L2Summon)character).getOwner();
|
|
|
+ final L2PcInstance player = character.getActingPlayer();
|
|
|
if (player != null)
|
|
|
{
|
|
|
if (_playersAllowed.contains(player.getObjectId()) || player.isGM())
|
|
@@ -153,11 +162,15 @@ public class L2BossZone extends L2ZoneType
|
|
|
// remove summon and teleport out owner
|
|
|
// who attempt "illegal" (re-)entry
|
|
|
if (_oustLoc[0] != 0 && _oustLoc[1] != 0 && _oustLoc[2] != 0)
|
|
|
+ {
|
|
|
player.teleToLocation(_oustLoc[0], _oustLoc[1], _oustLoc[2]);
|
|
|
+ }
|
|
|
else
|
|
|
+ {
|
|
|
player.teleToLocation(MapRegionManager.TeleportWhereType.Town);
|
|
|
+ }
|
|
|
}
|
|
|
- ((L2Summon)character).unSummon(player);
|
|
|
+ ((L2Summon) character).unSummon(player);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -167,11 +180,12 @@ public class L2BossZone extends L2ZoneType
|
|
|
{
|
|
|
if (_enabled)
|
|
|
{
|
|
|
- if (character instanceof L2PcInstance)
|
|
|
+ if (character.isPlayer())
|
|
|
{
|
|
|
- final L2PcInstance player = (L2PcInstance) character;
|
|
|
+ final L2PcInstance player = character.getActingPlayer();
|
|
|
if (player.isGM())
|
|
|
return;
|
|
|
+
|
|
|
// if the player just got disconnected/logged out, store the dc
|
|
|
// time so that
|
|
|
// decisions can be made later about allowing or not the player
|
|
@@ -184,11 +198,13 @@ public class L2BossZone extends L2ZoneType
|
|
|
else
|
|
|
{
|
|
|
if (_playersAllowed.contains(player.getObjectId()))
|
|
|
+ {
|
|
|
_playersAllowed.remove(_playersAllowed.indexOf(player.getObjectId()));
|
|
|
+ }
|
|
|
_playerAllowedReEntryTimes.remove(player.getObjectId());
|
|
|
}
|
|
|
}
|
|
|
- if (character instanceof L2Playable)
|
|
|
+ if (character.isPlayable())
|
|
|
{
|
|
|
if (getCharactersInside() != null && !getCharactersInside().isEmpty())
|
|
|
{
|
|
@@ -197,10 +213,14 @@ public class L2BossZone extends L2ZoneType
|
|
|
for (L2Character obj : getCharactersInsideArray())
|
|
|
{
|
|
|
if (obj == null)
|
|
|
+ {
|
|
|
continue;
|
|
|
- if (obj instanceof L2Playable)
|
|
|
+ }
|
|
|
+ if (obj.isPlayable())
|
|
|
+ {
|
|
|
count++;
|
|
|
- else if (obj instanceof L2Attackable && obj.isRaid())
|
|
|
+ }
|
|
|
+ else if (obj.isL2Attackable() && obj.isRaid())
|
|
|
{
|
|
|
_raidList.add(obj);
|
|
|
}
|
|
@@ -220,7 +240,7 @@ public class L2BossZone extends L2ZoneType
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (character instanceof L2Attackable && character.isRaid() && !character.isDead())
|
|
|
+ if (character.isL2Attackable() && character.isRaid() && !character.isDead())
|
|
|
{
|
|
|
((L2Attackable) character).returnHome();
|
|
|
}
|
|
@@ -253,29 +273,33 @@ public class L2BossZone extends L2ZoneType
|
|
|
public boolean isPlayerAllowed(L2PcInstance player)
|
|
|
{
|
|
|
if (player.isGM())
|
|
|
+ {
|
|
|
return true;
|
|
|
+ }
|
|
|
else if (_playersAllowed.contains(player.getObjectId()))
|
|
|
+ {
|
|
|
return true;
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
if (_oustLoc[0] != 0 && _oustLoc[1] != 0 && _oustLoc[2] != 0)
|
|
|
+ {
|
|
|
player.teleToLocation(_oustLoc[0], _oustLoc[1], _oustLoc[2]);
|
|
|
+ }
|
|
|
else
|
|
|
+ {
|
|
|
player.teleToLocation(MapRegionManager.TeleportWhereType.Town);
|
|
|
+ }
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Some GrandBosses send all players in zone to a specific part of the zone,
|
|
|
- * rather than just removing them all. If this is the case, this command should
|
|
|
- * be used. If this is no the case, then use oustAllPlayers().
|
|
|
- *
|
|
|
+ * Some GrandBosses send all players in zone to a specific part of the zone, rather than just removing them all. If this is the case, this command should be used. If this is no the case, then use oustAllPlayers().
|
|
|
* @param x
|
|
|
* @param y
|
|
|
* @param z
|
|
|
*/
|
|
|
-
|
|
|
public void movePlayersTo(int x, int y, int z)
|
|
|
{
|
|
|
if (_characterList.isEmpty())
|
|
@@ -283,22 +307,20 @@ public class L2BossZone extends L2ZoneType
|
|
|
|
|
|
for (L2Character character : getCharactersInsideArray())
|
|
|
{
|
|
|
- if (character instanceof L2PcInstance)
|
|
|
+ if (character != null && character.isPlayer())
|
|
|
{
|
|
|
- L2PcInstance player = (L2PcInstance) character;
|
|
|
+ L2PcInstance player = character.getActingPlayer();
|
|
|
if (player.isOnline())
|
|
|
+ {
|
|
|
player.teleToLocation(x, y, z);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Occasionally, all players need to be sent out of the zone (for example,
|
|
|
- * if the players are just running around without fighting for too long, or
|
|
|
- * if all players die, etc). This call sends all online players to town and
|
|
|
- * marks offline players to be teleported (by clearing their relog
|
|
|
- * expiration times) when they log back in (no real need for off-line
|
|
|
- * teleport).
|
|
|
+ * Occasionally, all players need to be sent out of the zone (for example, if the players are just running around without fighting for too long, or if all players die, etc). This call sends all online players to town and marks offline players to be teleported (by clearing their relog expiration
|
|
|
+ * times) when they log back in (no real need for off-line teleport).
|
|
|
*/
|
|
|
public void oustAllPlayers()
|
|
|
{
|
|
@@ -307,15 +329,19 @@ public class L2BossZone extends L2ZoneType
|
|
|
|
|
|
for (L2Character character : getCharactersInsideArray())
|
|
|
{
|
|
|
- if (character instanceof L2PcInstance)
|
|
|
+ if (character != null && character.isPlayer())
|
|
|
{
|
|
|
- L2PcInstance player = (L2PcInstance) character;
|
|
|
+ L2PcInstance player = character.getActingPlayer();
|
|
|
if (player.isOnline())
|
|
|
{
|
|
|
if (_oustLoc[0] != 0 && _oustLoc[1] != 0 && _oustLoc[2] != 0)
|
|
|
+ {
|
|
|
player.teleToLocation(_oustLoc[0], _oustLoc[1], _oustLoc[2]);
|
|
|
+ }
|
|
|
else
|
|
|
+ {
|
|
|
player.teleToLocation(MapRegionManager.TeleportWhereType.Town);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -324,10 +350,7 @@ public class L2BossZone extends L2ZoneType
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * This function is to be used by external sources, such as quests and AI
|
|
|
- * in order to allow a player for entry into the zone for some time. Naturally
|
|
|
- * if the player does not enter within the allowed time, he/she will be
|
|
|
- * teleported out again...
|
|
|
+ * This function is to be used by external sources, such as quests and AI in order to allow a player for entry into the zone for some time. Naturally if the player does not enter within the allowed time, he/she will be teleported out again...
|
|
|
* @param player reference to the player we wish to allow
|
|
|
* @param durationInSec amount of time in seconds during which entry is valid.
|
|
|
*/
|
|
@@ -336,14 +359,16 @@ public class L2BossZone extends L2ZoneType
|
|
|
if (!player.isGM())
|
|
|
{
|
|
|
if (!_playersAllowed.contains(player.getObjectId()))
|
|
|
+ {
|
|
|
_playersAllowed.add(player.getObjectId());
|
|
|
+ }
|
|
|
_playerAllowedReEntryTimes.put(player.getObjectId(), System.currentTimeMillis() + durationInSec * 1000);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void removePlayer(L2PcInstance player)
|
|
|
{
|
|
|
- if(!player.isGM())
|
|
|
+ if (!player.isGM())
|
|
|
{
|
|
|
_playersAllowed.remove(Integer.valueOf(player.getObjectId()));
|
|
|
_playerAllowedReEntryTimes.remove(player.getObjectId());
|
|
@@ -368,18 +393,14 @@ public class L2BossZone extends L2ZoneType
|
|
|
Map<Integer, L2PcInstance> npcKnownPlayers = npc.getKnownList().getKnownPlayers();
|
|
|
for (L2Character character : getCharactersInsideArray())
|
|
|
{
|
|
|
- if (character == null)
|
|
|
- continue;
|
|
|
- if (character instanceof L2PcInstance)
|
|
|
+ if (character != null && character.isPlayer())
|
|
|
{
|
|
|
- L2PcInstance player = (L2PcInstance) character;
|
|
|
+ L2PcInstance player = character.getActingPlayer();
|
|
|
if (player.isOnline())
|
|
|
+ {
|
|
|
npcKnownPlayers.put(player.getObjectId(), player);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- return;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|