Pailaka Injured Dragon and other quest related changes.
Adapted from: L2jUnity free files.
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -487,6 +488,24 @@ public final class ZoneManager implements IGameXmlReader
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get zone by name.
|
||||
* @param name the zone name
|
||||
* @return the zone by name
|
||||
*/
|
||||
public L2ZoneType getZoneByName(String name)
|
||||
{
|
||||
for (Map<Integer, ? extends L2ZoneType> map : _classZones.values())
|
||||
{
|
||||
final Optional<? extends L2ZoneType> zoneType = map.values().stream().filter(z -> (z.getName() != null) && z.getName().equals(name)).findAny();
|
||||
if (zoneType.isPresent())
|
||||
{
|
||||
return zoneType.get();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get zone by ID and zone class.
|
||||
* @param <T> the generic type
|
||||
@@ -500,6 +519,24 @@ public final class ZoneManager implements IGameXmlReader
|
||||
return (T) _classZones.get(zoneType).get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get zone by name.
|
||||
* @param <T> the generic type
|
||||
* @param name the zone name
|
||||
* @param zoneType the zone type
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends L2ZoneType> T getZoneByName(String name, Class<T> zoneType)
|
||||
{
|
||||
final Optional<? extends L2ZoneType> zone = _classZones.get(zoneType).values().stream().filter(z -> (z.getName() != null) && z.getName().equals(name)).findAny();
|
||||
if (zone.isPresent())
|
||||
{
|
||||
return (T) zone.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all zones from where the object is located.
|
||||
* @param locational the locational
|
||||
|
@@ -34,6 +34,7 @@ import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.ListenersContainer;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureZoneEnter;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureZoneExit;
|
||||
import com.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import com.l2jmobius.gameserver.model.interfaces.ILocational;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
|
||||
|
||||
@@ -47,6 +48,7 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
|
||||
private final int _id;
|
||||
protected L2ZoneForm _zone;
|
||||
protected List<L2ZoneForm> _blockedZone;
|
||||
protected Map<Integer, L2Character> _characterList = new ConcurrentHashMap<>();
|
||||
|
||||
/** Parameters to affect specific characters */
|
||||
@@ -61,6 +63,8 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
private boolean _allowStore;
|
||||
protected boolean _enabled;
|
||||
private AbstractZoneSettings _settings;
|
||||
private int _instanceTemplateId;
|
||||
private Map<Integer, Boolean> _enabledInInstance;
|
||||
|
||||
protected L2ZoneType(int id)
|
||||
{
|
||||
@@ -181,6 +185,10 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
{
|
||||
_enabled = Boolean.parseBoolean(value);
|
||||
}
|
||||
else if (name.equals("instanceId"))
|
||||
{
|
||||
_instanceTemplateId = Integer.parseInt(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.info(getClass().getSimpleName() + ": Unknown parameter - " + name + " in zone: " + getId());
|
||||
@@ -193,6 +201,24 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
*/
|
||||
private boolean isAffected(L2Character character)
|
||||
{
|
||||
// Check instance
|
||||
final Instance world = character.getInstanceWorld();
|
||||
if (world != null)
|
||||
{
|
||||
if (world.getTemplateId() != getInstanceTemplateId())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!isEnabled(character.getInstanceId()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (getInstanceTemplateId() > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check lvl
|
||||
if ((character.getLevel() < _minLvl) || (character.getLevel() > _maxLvl))
|
||||
{
|
||||
@@ -288,6 +314,20 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
return _zone;
|
||||
}
|
||||
|
||||
public void setBlockedZones(List<L2ZoneForm> blockedZones)
|
||||
{
|
||||
if (_blockedZone != null)
|
||||
{
|
||||
throw new IllegalStateException("Blocked zone already set");
|
||||
}
|
||||
_blockedZone = blockedZones;
|
||||
}
|
||||
|
||||
public List<L2ZoneForm> getBlockedZones()
|
||||
{
|
||||
return _blockedZone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the zone name.
|
||||
* @param name
|
||||
@@ -306,6 +346,29 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
return _name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given coordinates are within the zone, ignores instanceId check
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return
|
||||
*/
|
||||
public boolean isInsideZone(int x, int y, int z)
|
||||
{
|
||||
return _zone.isInsideZone(x, y, z) && !isInsideBannedZone(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return {@code true} if this location is within banned zone boundaries, {@code false} otherwise
|
||||
*/
|
||||
public boolean isInsideBannedZone(int x, int y, int z)
|
||||
{
|
||||
return (_blockedZone != null) && _blockedZone.stream().allMatch(zone -> !zone.isInsideZone(x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given coordinates are within zone's plane
|
||||
* @param x
|
||||
@@ -314,7 +377,7 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
*/
|
||||
public boolean isInsideZone(int x, int y)
|
||||
{
|
||||
return _zone.isInsideZone(x, y, _zone.getHighZ());
|
||||
return isInsideZone(x, y, _zone.getHighZ());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,19 +387,7 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
*/
|
||||
public boolean isInsideZone(ILocational loc)
|
||||
{
|
||||
return _zone.isInsideZone(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given coordinates are within the zone, ignores instanceId check
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return
|
||||
*/
|
||||
public boolean isInsideZone(int x, int y, int z)
|
||||
{
|
||||
return _zone.isInsideZone(x, y, z);
|
||||
return isInsideZone(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -361,27 +412,22 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
|
||||
public void revalidateInZone(L2Character character)
|
||||
{
|
||||
// If the character can't be affected by this zone return
|
||||
if (_checkAffected)
|
||||
{
|
||||
if (!isAffected(character))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If the object is inside the zone...
|
||||
if (isInsideZone(character))
|
||||
{
|
||||
// Was the character not yet inside this zone?
|
||||
if (!_characterList.containsKey(character.getObjectId()))
|
||||
// If the character can't be affected by this zone return
|
||||
if (_checkAffected)
|
||||
{
|
||||
if (!isAffected(character))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (_characterList.putIfAbsent(character.getObjectId(), character) == null)
|
||||
{
|
||||
// Notify to scripts.
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureZoneEnter(character, this), this);
|
||||
|
||||
// Register player.
|
||||
_characterList.put(character.getObjectId(), character);
|
||||
|
||||
// Notify Zone implementation.
|
||||
onEnter(character);
|
||||
}
|
||||
@@ -516,6 +562,11 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
return _allowStore;
|
||||
}
|
||||
|
||||
public int getInstanceTemplateId()
|
||||
{
|
||||
return _instanceTemplateId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@@ -537,6 +588,32 @@ public abstract class L2ZoneType extends ListenersContainer
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean state, int instanceId)
|
||||
{
|
||||
if (_enabledInInstance == null)
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (_enabledInInstance == null)
|
||||
{
|
||||
_enabledInInstance = new ConcurrentHashMap<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_enabledInInstance.put(instanceId, state);
|
||||
}
|
||||
|
||||
public boolean isEnabled(int instanceId)
|
||||
{
|
||||
if (_enabledInInstance != null)
|
||||
{
|
||||
return _enabledInInstance.getOrDefault(instanceId, isEnabled());
|
||||
}
|
||||
|
||||
return isEnabled();
|
||||
}
|
||||
|
||||
public void oustAllPlayers()
|
||||
{
|
||||
//@formatter:off
|
||||
|
@@ -45,7 +45,6 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
|
||||
private final List<L2DoorInstance> _doors = new ArrayList<>(2);
|
||||
private final List<L2Spawn> _buffers = new ArrayList<>(2);
|
||||
private final List<Location> _spectatorLocations = new ArrayList<>(1);
|
||||
private int _instanceTemplate = 0;
|
||||
|
||||
public L2OlympiadStadiumZone(int id)
|
||||
{
|
||||
@@ -102,19 +101,6 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(String name, String value)
|
||||
{
|
||||
if (name.equals("instanceTemplate"))
|
||||
{
|
||||
_instanceTemplate = Integer.parseInt(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
super.setParameter(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
public final void registerTask(OlympiadGameTask task)
|
||||
{
|
||||
getSettings().setTask(task);
|
||||
@@ -211,13 +197,4 @@ public class L2OlympiadStadiumZone extends L2ZoneRespawn
|
||||
{
|
||||
return _spectatorLocations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns zone instanceTemplate
|
||||
* @return
|
||||
*/
|
||||
public int getInstanceTemplateId()
|
||||
{
|
||||
return _instanceTemplate;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.zone.type;
|
||||
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class L2TeleportZone extends L2ZoneType
|
||||
{
|
||||
private int _x = -1;
|
||||
private int _y = -1;
|
||||
private int _z = -1;
|
||||
|
||||
public L2TeleportZone(int id)
|
||||
{
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(String name, String value)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "oustX":
|
||||
{
|
||||
_x = Integer.parseInt(value);
|
||||
break;
|
||||
}
|
||||
case "oustY":
|
||||
{
|
||||
_y = Integer.parseInt(value);
|
||||
break;
|
||||
}
|
||||
case "oustZ":
|
||||
{
|
||||
_z = Integer.parseInt(value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
super.setParameter(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onEnter(L2Character character)
|
||||
{
|
||||
character.teleToLocation(new Location(_x, _y, _z));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExit(L2Character character)
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user