Updated zone check method.
This commit is contained in:
parent
332b5b2e23
commit
db9a123081
@ -152,7 +152,7 @@ public abstract class L2ZoneRespawn extends L2ZoneType
|
|||||||
return getSpawnLoc();
|
return getSpawnLoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Location getBanishSpawnLoc()
|
public Location getBanishSpawnLoc()
|
||||||
{
|
{
|
||||||
if (_banishSpawnLocs != null)
|
if (_banishSpawnLocs != null)
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ public abstract class L2ZoneType extends ListenersContainer
|
|||||||
|
|
||||||
private final int _id;
|
private final int _id;
|
||||||
protected L2ZoneForm _zone;
|
protected L2ZoneForm _zone;
|
||||||
protected Map<Integer, L2Character> _characterList;
|
protected Map<Integer, L2Character> _characterList = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/** Parameters to affect specific characters */
|
/** Parameters to affect specific characters */
|
||||||
private boolean _checkAffected = false;
|
private boolean _checkAffected = false;
|
||||||
@ -66,7 +66,6 @@ public abstract class L2ZoneType extends ListenersContainer
|
|||||||
protected L2ZoneType(int id)
|
protected L2ZoneType(int id)
|
||||||
{
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
_characterList = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
_minLvl = 0;
|
_minLvl = 0;
|
||||||
_maxLvl = 0xFF;
|
_maxLvl = 0xFF;
|
||||||
@ -359,7 +358,7 @@ public abstract class L2ZoneType extends ListenersContainer
|
|||||||
*/
|
*/
|
||||||
public boolean isInsideZone(int x, int y)
|
public boolean isInsideZone(int x, int y)
|
||||||
{
|
{
|
||||||
return _zone.isInsideZone(x, y, _zone.getHighZ());
|
return isInsideZone(x, y, _zone.getHighZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,7 +368,7 @@ public abstract class L2ZoneType extends ListenersContainer
|
|||||||
*/
|
*/
|
||||||
public boolean isInsideZone(ILocational loc)
|
public boolean isInsideZone(ILocational loc)
|
||||||
{
|
{
|
||||||
return _zone.isInsideZone(loc.getX(), loc.getY(), loc.getZ());
|
return isInsideZone(loc.getX(), loc.getY(), loc.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -396,24 +395,19 @@ public abstract class L2ZoneType extends ListenersContainer
|
|||||||
|
|
||||||
public void revalidateInZone(L2Character character)
|
public void revalidateInZone(L2Character character)
|
||||||
{
|
{
|
||||||
// If the character can't be affected by this zone return
|
|
||||||
if (_checkAffected && !isAffected(character))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the object is inside the zone...
|
// If the object is inside the zone...
|
||||||
if (isInsideZone(character))
|
if (isInsideZone(character))
|
||||||
{
|
{
|
||||||
// Was the character not yet inside this zone?
|
// If the character can't be affected by this zone return
|
||||||
if (!_characterList.containsKey(character.getObjectId()))
|
if (_checkAffected && !isAffected(character))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_characterList.putIfAbsent(character.getObjectId(), character) == null)
|
||||||
{
|
{
|
||||||
// Notify to scripts.
|
// Notify to scripts.
|
||||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureZoneEnter(character, this), this);
|
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureZoneEnter(character, this), this);
|
||||||
|
|
||||||
// Register player.
|
|
||||||
_characterList.put(character.getObjectId(), character);
|
|
||||||
|
|
||||||
// Notify Zone implementation.
|
// Notify Zone implementation.
|
||||||
onEnter(character);
|
onEnter(character);
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,10 @@ public class TaskZoneSettings extends AbstractZoneSettings
|
|||||||
@Override
|
@Override
|
||||||
public void clear()
|
public void clear()
|
||||||
{
|
{
|
||||||
if (_task == null)
|
if (_task != null)
|
||||||
{
|
{
|
||||||
return;
|
_task.cancel(true);
|
||||||
|
_task = null;
|
||||||
}
|
}
|
||||||
_task.cancel(true);
|
|
||||||
_task = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,10 @@ public class L2ArenaZone extends L2ZoneType
|
|||||||
{
|
{
|
||||||
if (character instanceof L2PcInstance)
|
if (character instanceof L2PcInstance)
|
||||||
{
|
{
|
||||||
character.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
|
if (!character.isInsideZone(ZoneId.PVP))
|
||||||
|
{
|
||||||
|
character.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
character.setInsideZone(ZoneId.PVP, true);
|
character.setInsideZone(ZoneId.PVP, true);
|
||||||
@ -47,9 +50,12 @@ public class L2ArenaZone extends L2ZoneType
|
|||||||
@Override
|
@Override
|
||||||
protected void onExit(L2Character character)
|
protected void onExit(L2Character character)
|
||||||
{
|
{
|
||||||
if ((character instanceof L2PcInstance) && !character.isInsideZone(ZoneId.PVP))
|
if (character instanceof L2PcInstance)
|
||||||
{
|
{
|
||||||
character.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
|
if (!character.isInsideZone(ZoneId.PVP))
|
||||||
|
{
|
||||||
|
character.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
character.setInsideZone(ZoneId.PVP, false);
|
character.setInsideZone(ZoneId.PVP, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user