This commit is contained in:
mobius
2015-01-01 20:02:50 +00:00
parent eeae660458
commit a6a3718849
17894 changed files with 2818932 additions and 0 deletions

View File

@ -0,0 +1,31 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone;
/**
* Abstract class for Zone settings.
* @author UnAfraid
*/
public abstract class AbstractZoneSettings
{
/**
* Clear the Zone settings.
*/
public abstract void clear();
}

View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone;
import com.l2jserver.gameserver.idfactory.IdFactory;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
/**
* Abstract base class for any zone form
* @author durgus
*/
public abstract class L2ZoneForm
{
protected static final int STEP = 10;
public abstract boolean isInsideZone(int x, int y, int z);
public abstract boolean intersectsRectangle(int x1, int x2, int y1, int y2);
public abstract double getDistanceToZone(int x, int y);
public abstract int getLowZ(); // Support for the ability to extract the z coordinates of zones.
public abstract int getHighZ(); // New fishing patch makes use of that to get the Z for the hook
// landing coordinates.
protected boolean lineSegmentsIntersect(int ax1, int ay1, int ax2, int ay2, int bx1, int by1, int bx2, int by2)
{
return java.awt.geom.Line2D.linesIntersect(ax1, ay1, ax2, ay2, bx1, by1, bx2, by2);
}
public abstract void visualizeZone(int z);
protected final void dropDebugItem(int itemId, int num, int x, int y, int z)
{
L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), itemId);
item.setCount(num);
item.spawnMe(x, y, z + 5);
ZoneManager.getInstance().getDebugItems().add(item);
}
public abstract int[] getRandomPoint();
}

View File

@ -0,0 +1,161 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.util.Rnd;
/**
* Abstract zone with spawn locations
* @author DS, Nyaran (rework 10/07/2011)
*/
public abstract class L2ZoneRespawn extends L2ZoneType
{
private List<Location> _spawnLocs = null;
private List<Location> _otherSpawnLocs = null;
private List<Location> _chaoticSpawnLocs = null;
private List<Location> _banishSpawnLocs = null;
protected L2ZoneRespawn(int id)
{
super(id);
}
public void parseLoc(int x, int y, int z, String type)
{
if ((type == null) || type.isEmpty())
{
addSpawn(x, y, z);
}
else
{
switch (type)
{
case "other":
addOtherSpawn(x, y, z);
break;
case "chaotic":
addChaoticSpawn(x, y, z);
break;
case "banish":
addBanishSpawn(x, y, z);
break;
default:
_log.warning(getClass().getSimpleName() + ": Unknown location type: " + type);
}
}
}
public final void addSpawn(int x, int y, int z)
{
if (_spawnLocs == null)
{
_spawnLocs = new ArrayList<>();
}
_spawnLocs.add(new Location(x, y, z));
}
public final void addOtherSpawn(int x, int y, int z)
{
if (_otherSpawnLocs == null)
{
_otherSpawnLocs = new ArrayList<>();
}
_otherSpawnLocs.add(new Location(x, y, z));
}
public final void addChaoticSpawn(int x, int y, int z)
{
if (_chaoticSpawnLocs == null)
{
_chaoticSpawnLocs = new ArrayList<>();
}
_chaoticSpawnLocs.add(new Location(x, y, z));
}
public final void addBanishSpawn(int x, int y, int z)
{
if (_banishSpawnLocs == null)
{
_banishSpawnLocs = new ArrayList<>();
}
_banishSpawnLocs.add(new Location(x, y, z));
}
public final List<Location> getSpawns()
{
return _spawnLocs;
}
public final Location getSpawnLoc()
{
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
{
return _spawnLocs.get(Rnd.get(_spawnLocs.size()));
}
return _spawnLocs.get(0);
}
public final Location getOtherSpawnLoc()
{
if (_otherSpawnLocs != null)
{
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
{
return _otherSpawnLocs.get(Rnd.get(_otherSpawnLocs.size()));
}
return _otherSpawnLocs.get(0);
}
return getSpawnLoc();
}
public final Location getChaoticSpawnLoc()
{
if (_chaoticSpawnLocs != null)
{
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
{
return _chaoticSpawnLocs.get(Rnd.get(_chaoticSpawnLocs.size()));
}
return _chaoticSpawnLocs.get(0);
}
return getSpawnLoc();
}
public final Location getBanishSpawnLoc()
{
if (_banishSpawnLocs != null)
{
if (Config.RANDOM_RESPAWN_IN_TOWN_ENABLED)
{
return _banishSpawnLocs.get(Rnd.get(_banishSpawnLocs.size()));
}
return _banishSpawnLocs.get(0);
}
return getSpawnLoc();
}
}

View File

@ -0,0 +1,600 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import javolution.util.FastMap;
import com.l2jserver.gameserver.enums.InstanceType;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.events.EventDispatcher;
import com.l2jserver.gameserver.model.events.ListenersContainer;
import com.l2jserver.gameserver.model.events.impl.character.OnCreatureZoneEnter;
import com.l2jserver.gameserver.model.events.impl.character.OnCreatureZoneExit;
import com.l2jserver.gameserver.model.interfaces.ILocational;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
/**
* Abstract base class for any zone type handles basic operations.
* @author durgus
*/
public abstract class L2ZoneType extends ListenersContainer
{
protected static final Logger _log = Logger.getLogger(L2ZoneType.class.getName());
private final int _id;
protected L2ZoneForm _zone;
protected FastMap<Integer, L2Character> _characterList;
/** Parameters to affect specific characters */
private boolean _checkAffected = false;
private String _name = null;
private int _instanceId = -1;
private String _instanceTemplate = "";
private int _minLvl;
private int _maxLvl;
private int[] _race;
private int[] _class;
private char _classType;
private InstanceType _target = InstanceType.L2Character; // default all chars
private boolean _allowStore;
private boolean _enabled;
private AbstractZoneSettings _settings;
protected L2ZoneType(int id)
{
_id = id;
_characterList = new FastMap<>();
_characterList.shared();
_minLvl = 0;
_maxLvl = 0xFF;
_classType = 0;
_race = null;
_class = null;
_allowStore = true;
_enabled = true;
}
/**
* @return Returns the id.
*/
public int getId()
{
return _id;
}
/**
* Setup new parameters for this zone
* @param name
* @param value
*/
public void setParameter(String name, String value)
{
_checkAffected = true;
// Zone name
if (name.equals("name"))
{
_name = value;
}
else if (name.equals("instanceId"))
{
_instanceId = Integer.parseInt(value);
}
else if (name.equals("instanceTemplate"))
{
_instanceTemplate = value;
_instanceId = InstanceManager.getInstance().createDynamicInstance(value);
}
// Minimum level
else if (name.equals("affectedLvlMin"))
{
_minLvl = Integer.parseInt(value);
}
// Maximum level
else if (name.equals("affectedLvlMax"))
{
_maxLvl = Integer.parseInt(value);
}
// Affected Races
else if (name.equals("affectedRace"))
{
// Create a new array holding the affected race
if (_race == null)
{
_race = new int[1];
_race[0] = Integer.parseInt(value);
}
else
{
int[] temp = new int[_race.length + 1];
int i = 0;
for (; i < _race.length; i++)
{
temp[i] = _race[i];
}
temp[i] = Integer.parseInt(value);
_race = temp;
}
}
// Affected classes
else if (name.equals("affectedClassId"))
{
// Create a new array holding the affected classIds
if (_class == null)
{
_class = new int[1];
_class[0] = Integer.parseInt(value);
}
else
{
int[] temp = new int[_class.length + 1];
int i = 0;
for (; i < _class.length; i++)
{
temp[i] = _class[i];
}
temp[i] = Integer.parseInt(value);
_class = temp;
}
}
// Affected class type
else if (name.equals("affectedClassType"))
{
if (value.equals("Fighter"))
{
_classType = 1;
}
else
{
_classType = 2;
}
}
else if (name.equals("targetClass"))
{
_target = Enum.valueOf(InstanceType.class, value);
}
else if (name.equals("allowStore"))
{
_allowStore = Boolean.parseBoolean(value);
}
else if (name.equals("default_enabled"))
{
_enabled = Boolean.parseBoolean(value);
}
else
{
_log.info(getClass().getSimpleName() + ": Unknown parameter - " + name + " in zone: " + getId());
}
}
/**
* @param character the player to verify.
* @return {@code true} if the given character is affected by this zone, {@code false} otherwise.
*/
private boolean isAffected(L2Character character)
{
// Check lvl
if ((character.getLevel() < _minLvl) || (character.getLevel() > _maxLvl))
{
return false;
}
// check obj class
if (!character.isInstanceTypes(_target))
{
return false;
}
if (character instanceof L2PcInstance)
{
// Check class type
if (_classType != 0)
{
if (((L2PcInstance) character).isMageClass())
{
if (_classType == 1)
{
return false;
}
}
else if (_classType == 2)
{
return false;
}
}
// Check race
if (_race != null)
{
boolean ok = false;
for (int element : _race)
{
if (character.getRace().ordinal() == element)
{
ok = true;
break;
}
}
if (!ok)
{
return false;
}
}
// Check class
if (_class != null)
{
boolean ok = false;
for (int _clas : _class)
{
if (((L2PcInstance) character).getClassId().ordinal() == _clas)
{
ok = true;
break;
}
}
if (!ok)
{
return false;
}
}
}
return true;
}
/**
* Set the zone for this L2ZoneType Instance
* @param zone
*/
public void setZone(L2ZoneForm zone)
{
if (_zone != null)
{
throw new IllegalStateException("Zone already set");
}
_zone = zone;
}
/**
* Returns this zones zone form.
* @return {@link #_zone}
*/
public L2ZoneForm getZone()
{
return _zone;
}
/**
* Set the zone name.
* @param name
*/
public void setName(String name)
{
_name = name;
}
/**
* Returns zone name
* @return
*/
public String getName()
{
return _name;
}
/**
* Set the zone instanceId.
* @param instanceId
*/
public void setInstanceId(int instanceId)
{
_instanceId = instanceId;
}
/**
* Returns zone instanceId
* @return
*/
public int getInstanceId()
{
return _instanceId;
}
/**
* Returns zone instanceTemplate
* @return
*/
public String getInstanceTemplate()
{
return _instanceTemplate;
}
/**
* Checks if the given coordinates are within zone's plane
* @param x
* @param y
* @return
*/
public boolean isInsideZone(int x, int y)
{
return _zone.isInsideZone(x, y, _zone.getHighZ());
}
/**
* Checks if the given coordinates are within the zone, ignores instanceId check
* @param loc
* @return
*/
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);
}
/**
* Checks if the given coordinates are within the zone and the instanceId used matched the zone's instanceId
* @param x
* @param y
* @param z
* @param instanceId
* @return
*/
public boolean isInsideZone(int x, int y, int z, int instanceId)
{
// It will check if coords are within the zone if the given instanceId or
// the zone's _instanceId are in the multiverse or they match
if ((_instanceId == -1) || (instanceId == -1) || (_instanceId == instanceId))
{
return _zone.isInsideZone(x, y, z);
}
return false;
}
/**
* Checks if the given object is inside the zone.
* @param object
* @return
*/
public boolean isInsideZone(L2Object object)
{
return isInsideZone(object.getX(), object.getY(), object.getZ(), object.getInstanceId());
}
public double getDistanceToZone(int x, int y)
{
return getZone().getDistanceToZone(x, y);
}
public double getDistanceToZone(L2Object object)
{
return getZone().getDistanceToZone(object.getX(), object.getY());
}
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()))
{
// Notify to scripts.
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureZoneEnter(character, this), this);
// Register player.
_characterList.put(character.getObjectId(), character);
// Notify Zone implementation.
onEnter(character);
}
}
else
{
removeCharacter(character);
}
}
/**
* Force fully removes a character from the zone Should use during teleport / logoff
* @param character
*/
public void removeCharacter(L2Character character)
{
// Was the character inside this zone?
if (_characterList.containsKey(character.getObjectId()))
{
// Notify to scripts.
EventDispatcher.getInstance().notifyEventAsync(new OnCreatureZoneExit(character, this), this);
// Unregister player.
_characterList.remove(character.getObjectId());
// Notify Zone implementation.
onExit(character);
}
}
/**
* Will scan the zones char list for the character
* @param character
* @return
*/
public boolean isCharacterInZone(L2Character character)
{
return _characterList.containsKey(character.getObjectId());
}
public AbstractZoneSettings getSettings()
{
return _settings;
}
public void setSettings(AbstractZoneSettings settings)
{
if (_settings != null)
{
_settings.clear();
}
_settings = settings;
}
protected abstract void onEnter(L2Character character);
protected abstract void onExit(L2Character character);
public void onDieInside(L2Character character)
{
}
public void onReviveInside(L2Character character)
{
}
public void onPlayerLoginInside(L2PcInstance player)
{
}
public void onPlayerLogoutInside(L2PcInstance player)
{
}
public Map<Integer, L2Character> getCharacters()
{
return _characterList;
}
public Collection<L2Character> getCharactersInside()
{
return _characterList.values();
}
public List<L2PcInstance> getPlayersInside()
{
List<L2PcInstance> players = new ArrayList<>();
for (L2Character ch : _characterList.values())
{
if ((ch != null) && ch.isPlayer())
{
players.add(ch.getActingPlayer());
}
}
return players;
}
/**
* Broadcasts packet to all players inside the zone
* @param packet
*/
public void broadcastPacket(L2GameServerPacket packet)
{
if (_characterList.isEmpty())
{
return;
}
for (L2Character character : _characterList.values())
{
if ((character != null) && character.isPlayer())
{
character.sendPacket(packet);
}
}
}
public InstanceType getTargetType()
{
return _target;
}
public void setTargetType(InstanceType type)
{
_target = type;
_checkAffected = true;
}
public boolean getAllowStore()
{
return _allowStore;
}
@Override
public String toString()
{
return getClass().getSimpleName() + "[" + _id + "]";
}
public void visualizeZone(int z)
{
getZone().visualizeZone(z);
}
public void setEnabled(boolean state)
{
_enabled = state;
}
public boolean isEnabled()
{
return _enabled;
}
}

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone;
import java.util.concurrent.Future;
/**
* Basic task zone settings implementation.
* @author UnAfraid
*/
public class TaskZoneSettings extends AbstractZoneSettings
{
private Future<?> _task;
/**
* Gets the task.
* @return the task
*/
public Future<?> getTask()
{
return _task;
}
/**
* Sets the task.
* @param task the new task
*/
public void setTask(Future<?> task)
{
_task = task;
}
@Override
public void clear()
{
if (_task != null)
{
_task.cancel(true);
_task = null;
}
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone;
/**
* Zone Ids.
* @author Zoey76
*/
public enum ZoneId
{
PVP,
PEACE,
SIEGE,
MOTHER_TREE,
CLAN_HALL,
LANDING,
NO_LANDING,
WATER,
JAIL,
MONSTER_TRACK,
CASTLE,
SWAMP,
NO_SUMMON_FRIEND,
FORT,
NO_STORE,
TOWN,
SCRIPT,
HQ,
DANGER_AREA,
ALTERED,
NO_BOOKMARK,
NO_ITEM_DROP,
NO_RESTART;
public static int getZoneCount()
{
return values().length;
}
}

View File

@ -0,0 +1,142 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.form;
import java.awt.Rectangle;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.model.zone.L2ZoneForm;
import com.l2jserver.util.Rnd;
/**
* A primitive rectangular zone
* @author durgus
*/
public class ZoneCuboid extends L2ZoneForm
{
private final int _z1, _z2;
Rectangle _r;
public ZoneCuboid(int x1, int x2, int y1, int y2, int z1, int z2)
{
int _x1 = Math.min(x1, x2);
int _x2 = Math.max(x1, x2);
int _y1 = Math.min(y1, y2);
int _y2 = Math.max(y1, y2);
_r = new Rectangle(_x1, _y1, _x2 - _x1, _y2 - _y1);
_z1 = Math.min(z1, z2);
_z2 = Math.max(z1, z2);
}
@Override
public boolean isInsideZone(int x, int y, int z)
{
return (_r.contains(x, y) && (z >= _z1) && (z <= _z2));
}
@Override
public boolean intersectsRectangle(int ax1, int ax2, int ay1, int ay2)
{
return (_r.intersects(Math.min(ax1, ax2), Math.min(ay1, ay2), Math.abs(ax2 - ax1), Math.abs(ay2 - ay1)));
}
@Override
public double getDistanceToZone(int x, int y)
{
int _x1 = _r.x;
int _x2 = _r.x + _r.width;
int _y1 = _r.y;
int _y2 = _r.y + _r.height;
double test, shortestDist = Math.pow(_x1 - x, 2) + Math.pow(_y1 - y, 2);
test = Math.pow(_x1 - x, 2) + Math.pow(_y2 - y, 2);
if (test < shortestDist)
{
shortestDist = test;
}
test = Math.pow(_x2 - x, 2) + Math.pow(_y1 - y, 2);
if (test < shortestDist)
{
shortestDist = test;
}
test = Math.pow(_x2 - x, 2) + Math.pow(_y2 - y, 2);
if (test < shortestDist)
{
shortestDist = test;
}
return Math.sqrt(shortestDist);
}
/*
* getLowZ() / getHighZ() - These two functions were added to cope with the demand of the new fishing algorithms, which are now able to correctly place the hook in the water, thanks to getHighZ(). getLowZ() was added, considering potential future modifications.
*/
@Override
public int getLowZ()
{
return _z1;
}
@Override
public int getHighZ()
{
return _z2;
}
@Override
public void visualizeZone(int z)
{
int _x1 = _r.x;
int _x2 = _r.x + _r.width;
int _y1 = _r.y;
int _y2 = _r.y + _r.height;
// x1->x2
for (int x = _x1; x < _x2; x = x + STEP)
{
dropDebugItem(Inventory.ADENA_ID, 1, x, _y1, z);
dropDebugItem(Inventory.ADENA_ID, 1, x, _y2, z);
}
// y1->y2
for (int y = _y1; y < _y2; y = y + STEP)
{
dropDebugItem(Inventory.ADENA_ID, 1, _x1, y, z);
dropDebugItem(Inventory.ADENA_ID, 1, _x2, y, z);
}
}
@Override
public int[] getRandomPoint()
{
int x = Rnd.get(_r.x, _r.x + _r.width);
int y = Rnd.get(_r.y, _r.y + _r.height);
return new int[]
{
x,
y,
GeoData.getInstance().getHeight(x, y, _z1)
};
}
}

View File

@ -0,0 +1,157 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.form;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.model.zone.L2ZoneForm;
import com.l2jserver.util.Rnd;
/**
* A primitive circular zone
* @author durgus
*/
public class ZoneCylinder extends L2ZoneForm
{
private final int _x, _y, _z1, _z2, _rad, _radS;
public ZoneCylinder(int x, int y, int z1, int z2, int rad)
{
_x = x;
_y = y;
_z1 = z1;
_z2 = z2;
_rad = rad;
_radS = rad * rad;
}
@Override
public boolean isInsideZone(int x, int y, int z)
{
if (((Math.pow(_x - x, 2) + Math.pow(_y - y, 2)) > _radS) || (z < _z1) || (z > _z2))
{
return false;
}
return true;
}
@Override
public boolean intersectsRectangle(int ax1, int ax2, int ay1, int ay2)
{
// Circles point inside the rectangle?
if ((_x > ax1) && (_x < ax2) && (_y > ay1) && (_y < ay2))
{
return true;
}
// Any point of the rectangle intersecting the Circle?
if ((Math.pow(ax1 - _x, 2) + Math.pow(ay1 - _y, 2)) < _radS)
{
return true;
}
if ((Math.pow(ax1 - _x, 2) + Math.pow(ay2 - _y, 2)) < _radS)
{
return true;
}
if ((Math.pow(ax2 - _x, 2) + Math.pow(ay1 - _y, 2)) < _radS)
{
return true;
}
if ((Math.pow(ax2 - _x, 2) + Math.pow(ay2 - _y, 2)) < _radS)
{
return true;
}
// Collision on any side of the rectangle?
if ((_x > ax1) && (_x < ax2))
{
if (Math.abs(_y - ay2) < _rad)
{
return true;
}
if (Math.abs(_y - ay1) < _rad)
{
return true;
}
}
if ((_y > ay1) && (_y < ay2))
{
if (Math.abs(_x - ax2) < _rad)
{
return true;
}
if (Math.abs(_x - ax1) < _rad)
{
return true;
}
}
return false;
}
@Override
public double getDistanceToZone(int x, int y)
{
return (Math.sqrt((Math.pow(_x - x, 2) + Math.pow(_y - y, 2))) - _rad);
}
// getLowZ() / getHighZ() - These two functions were added to cope with the demand of the new fishing algorithms, wich are now able to correctly place the hook in the water, thanks to getHighZ(). getLowZ() was added, considering potential future modifications.
@Override
public int getLowZ()
{
return _z1;
}
@Override
public int getHighZ()
{
return _z2;
}
@Override
public void visualizeZone(int z)
{
int count = (int) ((2 * Math.PI * _rad) / STEP);
double angle = (2 * Math.PI) / count;
for (int i = 0; i < count; i++)
{
int x = (int) (Math.cos(angle * i) * _rad);
int y = (int) (Math.sin(angle * i) * _rad);
dropDebugItem(Inventory.ADENA_ID, 1, _x + x, _y + y, z);
}
}
@Override
public int[] getRandomPoint()
{
double x, y, q, r;
q = Rnd.get() * 2 * Math.PI;
r = Math.sqrt(Rnd.get());
x = (_rad * r * Math.cos(q)) + _x;
y = (_rad * r * Math.sin(q)) + _y;
return new int[]
{
(int) x,
(int) y,
GeoData.getInstance().getHeight((int) x, (int) y, _z1)
};
}
}

View File

@ -0,0 +1,149 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.form;
import java.awt.Polygon;
import com.l2jserver.gameserver.GeoData;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import com.l2jserver.gameserver.model.zone.L2ZoneForm;
import com.l2jserver.util.Rnd;
/**
* A not so primitive npoly zone
* @author durgus
*/
public class ZoneNPoly extends L2ZoneForm
{
private final Polygon _p;
private final int _z1;
private final int _z2;
/**
* @param x
* @param y
* @param z1
* @param z2
*/
public ZoneNPoly(int[] x, int[] y, int z1, int z2)
{
_p = new Polygon(x, y, x.length);
_z1 = Math.min(z1, z2);
_z2 = Math.max(z1, z2);
}
@Override
public boolean isInsideZone(int x, int y, int z)
{
return (_p.contains(x, y) && (z >= _z1) && (z <= _z2));
}
@Override
public boolean intersectsRectangle(int ax1, int ax2, int ay1, int ay2)
{
return (_p.intersects(Math.min(ax1, ax2), Math.min(ay1, ay2), Math.abs(ax2 - ax1), Math.abs(ay2 - ay1)));
}
@Override
public double getDistanceToZone(int x, int y)
{
int[] _x = _p.xpoints;
int[] _y = _p.ypoints;
double test, shortestDist = Math.pow(_x[0] - x, 2) + Math.pow(_y[0] - y, 2);
for (int i = 1; i < _p.npoints; i++)
{
test = Math.pow(_x[i] - x, 2) + Math.pow(_y[i] - y, 2);
if (test < shortestDist)
{
shortestDist = test;
}
}
return Math.sqrt(shortestDist);
}
// getLowZ() / getHighZ() - These two functions were added to cope with the demand of the new fishing algorithms, wich are now able to correctly place the hook in the water, thanks to getHighZ(). getLowZ() was added, considering potential future modifications.
@Override
public int getLowZ()
{
return _z1;
}
@Override
public int getHighZ()
{
return _z2;
}
@Override
public void visualizeZone(int z)
{
int[] _x = _p.xpoints;
int[] _y = _p.ypoints;
for (int i = 0; i < _p.npoints; i++)
{
int nextIndex = i + 1;
// ending point to first one
if (nextIndex == _x.length)
{
nextIndex = 0;
}
int vx = _x[nextIndex] - _x[i];
int vy = _y[nextIndex] - _y[i];
float lenght = (float) Math.sqrt((vx * vx) + (vy * vy));
lenght /= STEP;
for (int o = 1; o <= lenght; o++)
{
float k = o / lenght;
dropDebugItem(Inventory.ADENA_ID, 1, (int) (_x[i] + (k * vx)), (int) (_y[i] + (k * vy)), z);
}
}
}
@Override
public int[] getRandomPoint()
{
int x, y;
int _minX = _p.getBounds().x;
int _maxX = _p.getBounds().x + _p.getBounds().width;
int _minY = _p.getBounds().y;
int _maxY = _p.getBounds().y + _p.getBounds().height;
x = Rnd.get(_minX, _maxX);
y = Rnd.get(_minY, _maxY);
int antiBlocker = 0;
while (!_p.contains(x, y) && (antiBlocker++ < 1000))
{
x = Rnd.get(_minX, _maxX);
y = Rnd.get(_minY, _maxY);
}
return new int[]
{
x,
y,
GeoData.getInstance().getHeight(x, y, _z1)
};
}
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
/**
* A PVP Zone
* @author durgus
*/
public class L2ArenaZone extends L2ZoneType
{
public L2ArenaZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
if (character instanceof L2PcInstance)
{
if (!character.isInsideZone(ZoneId.PVP))
{
character.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
}
}
character.setInsideZone(ZoneId.PVP, true);
}
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2PcInstance)
{
if (!character.isInsideZone(ZoneId.PVP))
{
character.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
}
}
character.setInsideZone(ZoneId.PVP, false);
}
}

View File

@ -0,0 +1,458 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import java.util.List;
import java.util.Map;
import javolution.util.FastList;
import javolution.util.FastMap;
import com.l2jserver.gameserver.GameServer;
import com.l2jserver.gameserver.instancemanager.GrandBossManager;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.PcCondOverride;
import com.l2jserver.gameserver.model.TeleportWhereType;
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.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.AbstractZoneSettings;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
/**
* @author DaRkRaGe
*/
public class L2BossZone extends L2ZoneType
{
private int _timeInvade;
private int[] _oustLoc =
{
0,
0,
0
};
public final class Settings extends AbstractZoneSettings
{
// track the times that players got disconnected. Players are allowed
// to log back into the zone as long as their log-out was within _timeInvade time...
// <player objectId, expiration time in milliseconds>
private final Map<Integer, Long> _playerAllowedReEntryTimes = new FastMap<>();
// track the players admitted to the zone who should be allowed back in
// after reboot/server downtime (outside of their control), within 30 of server restart
private final List<Integer> _playersAllowed = new FastList<>();
private final List<L2Character> _raidList = new FastList<>();
protected Settings()
{
}
public Map<Integer, Long> getPlayerAllowedReEntryTimes()
{
return _playerAllowedReEntryTimes;
}
public List<Integer> getPlayersAllowed()
{
return _playersAllowed;
}
public List<L2Character> getRaidList()
{
return _raidList;
}
@Override
public void clear()
{
_playerAllowedReEntryTimes.clear();
_playersAllowed.clear();
_raidList.clear();
}
}
public L2BossZone(int id)
{
super(id);
_oustLoc = new int[3];
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
if (settings == null)
{
settings = new Settings();
}
setSettings(settings);
GrandBossManager.getInstance().addZone(this);
}
@Override
public Settings getSettings()
{
return (Settings) super.getSettings();
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("InvadeTime"))
{
_timeInvade = Integer.parseInt(value);
}
else if (name.equals("oustX"))
{
_oustLoc[0] = Integer.parseInt(value);
}
else if (name.equals("oustY"))
{
_oustLoc[1] = Integer.parseInt(value);
}
else if (name.equals("oustZ"))
{
_oustLoc[2] = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
/**
* Boss zones have special behaviors for player characters.<br>
* 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.<br>
* Entry expiration times are set by any one of the following:<br>
* 1) A player logs out while in a zone (Expiration gets set to logoutTime + _timeInvade)<br>
* 2) An external source (such as a quest or AI of NPC) set up the player for entry.<br>
* There exists one more case in which the player will be allowed to enter.<br>
* 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 (isEnabled())
{
if (character.isPlayer())
{
final L2PcInstance player = character.getActingPlayer();
if (player.canOverrideCond(PcCondOverride.ZONE_CONDITIONS))
{
return;
}
// if player has been (previously) cleared by npc/ai for entry and the zone is
// set to receive players (aka not waiting for boss to respawn)
if (getSettings().getPlayersAllowed().contains(player.getObjectId()))
{
// Get the information about this player's last logout-exit from
// this zone.
final Long expirationTime = getSettings().getPlayerAllowedReEntryTimes().get(player.getObjectId());
// with legal entries, do nothing.
if (expirationTime == null) // legal null expirationTime entries
{
long serverStartTime = GameServer.dateTimeServerStarted.getTimeInMillis();
if ((serverStartTime > (System.currentTimeMillis() - _timeInvade)))
{
return;
}
}
else
{
// legal non-null logoutTime entries
getSettings().getPlayerAllowedReEntryTimes().remove(player.getObjectId());
if (expirationTime.longValue() > System.currentTimeMillis())
{
return;
}
}
getSettings().getPlayersAllowed().remove(getSettings().getPlayersAllowed().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(TeleportWhereType.TOWN);
}
}
else if (character.isSummon())
{
final L2PcInstance player = character.getActingPlayer();
if (player != null)
{
if (getSettings().getPlayersAllowed().contains(player.getObjectId()) || player.canOverrideCond(PcCondOverride.ZONE_CONDITIONS))
{
return;
}
// 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(TeleportWhereType.TOWN);
}
}
((L2Summon) character).unSummon(player);
}
}
}
@Override
protected void onExit(L2Character character)
{
if (isEnabled())
{
if (character.isPlayer())
{
final L2PcInstance player = character.getActingPlayer();
if (player.canOverrideCond(PcCondOverride.ZONE_CONDITIONS))
{
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
// to log into the zone
if (!player.isOnline() && getSettings().getPlayersAllowed().contains(player.getObjectId()))
{
// mark the time that the player left the zone
getSettings().getPlayerAllowedReEntryTimes().put(player.getObjectId(), System.currentTimeMillis() + _timeInvade);
}
else
{
if (getSettings().getPlayersAllowed().contains(player.getObjectId()))
{
getSettings().getPlayersAllowed().remove(getSettings().getPlayersAllowed().indexOf(player.getObjectId()));
}
getSettings().getPlayerAllowedReEntryTimes().remove(player.getObjectId());
}
}
if (character.isPlayable())
{
if ((getCharactersInside() != null) && !getCharactersInside().isEmpty())
{
getSettings().getRaidList().clear();
int count = 0;
for (L2Character obj : getCharactersInside())
{
if (obj == null)
{
continue;
}
if (obj.isPlayable())
{
count++;
}
else if (obj.isAttackable() && obj.isRaid())
{
getSettings().getRaidList().add(obj);
}
}
// if inside zone isnt any player, force all boss instance return to its spawn points
if ((count == 0) && !getSettings().getRaidList().isEmpty())
{
for (int i = 0; i < getSettings().getRaidList().size(); i++)
{
L2Attackable raid = (L2Attackable) getSettings().getRaidList().get(i);
if ((raid == null) || (raid.getSpawn() == null) || raid.isDead())
{
continue;
}
if (!raid.isInsideRadius(raid.getSpawn(), 150, false, false))
{
raid.returnHome();
}
}
}
}
}
}
if (character.isAttackable() && character.isRaid() && !character.isDead())
{
((L2Attackable) character).returnHome();
}
}
@Override
public void setEnabled(boolean flag)
{
if (isEnabled() != flag)
{
oustAllPlayers();
}
super.setEnabled(flag);
}
public int getTimeInvade()
{
return _timeInvade;
}
public void setAllowedPlayers(List<Integer> players)
{
if (players != null)
{
getSettings().getPlayersAllowed().clear();
getSettings().getPlayersAllowed().addAll(players);
}
}
public List<Integer> getAllowedPlayers()
{
return getSettings().getPlayersAllowed();
}
public boolean isPlayerAllowed(L2PcInstance player)
{
if (player.canOverrideCond(PcCondOverride.ZONE_CONDITIONS))
{
return true;
}
else if (getSettings().getPlayersAllowed().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(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().
* @param loc
*/
public void movePlayersTo(Location loc)
{
if (_characterList.isEmpty())
{
return;
}
for (L2Character character : getCharactersInside())
{
if ((character != null) && character.isPlayer())
{
L2PcInstance player = character.getActingPlayer();
if (player.isOnline())
{
player.teleToLocation(loc);
}
}
}
}
/**
* 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()
{
if (_characterList.isEmpty())
{
return;
}
for (L2Character character : getCharactersInside())
{
if ((character != null) && character.isPlayer())
{
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(TeleportWhereType.TOWN);
}
}
}
}
getSettings().getPlayerAllowedReEntryTimes().clear();
getSettings().getPlayersAllowed().clear();
}
/**
* 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.
*/
public void allowPlayerEntry(L2PcInstance player, int durationInSec)
{
if (!player.canOverrideCond(PcCondOverride.ZONE_CONDITIONS))
{
if (!getSettings().getPlayersAllowed().contains(player.getObjectId()))
{
getSettings().getPlayersAllowed().add(player.getObjectId());
}
getSettings().getPlayerAllowedReEntryTimes().put(player.getObjectId(), System.currentTimeMillis() + (durationInSec * 1000));
}
}
public void removePlayer(L2PcInstance player)
{
if (!player.canOverrideCond(PcCondOverride.ZONE_CONDITIONS))
{
getSettings().getPlayersAllowed().remove(Integer.valueOf(player.getObjectId()));
getSettings().getPlayerAllowedReEntryTimes().remove(player.getObjectId());
}
}
public void updateKnownList(L2Npc npc)
{
if ((_characterList == null) || _characterList.isEmpty())
{
return;
}
Map<Integer, L2PcInstance> npcKnownPlayers = npc.getKnownList().getKnownPlayers();
for (L2Character character : getCharactersInside())
{
if ((character != null) && character.isPlayer())
{
L2PcInstance player = character.getActingPlayer();
if (player.isOnline())
{
npcKnownPlayers.put(player.getObjectId(), player);
}
}
}
}
}

View File

@ -0,0 +1,60 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* A castle zone
* @author durgus
*/
public final class L2CastleZone extends L2ResidenceZone
{
public L2CastleZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("castleId"))
{
setResidenceId(Integer.parseInt(value));
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(ZoneId.CASTLE, true);
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(ZoneId.CASTLE, false);
}
}

View File

@ -0,0 +1,91 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.instancemanager.ClanHallManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.entity.ClanHall;
import com.l2jserver.gameserver.model.entity.clanhall.AuctionableHall;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.serverpackets.AgitDecoInfo;
/**
* A clan hall zone
* @author durgus
*/
public class L2ClanHallZone extends L2ResidenceZone
{
public L2ClanHallZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("clanHallId"))
{
setResidenceId(Integer.parseInt(value));
// Register self to the correct clan hall
ClanHall hall = ClanHallManager.getInstance().getClanHallById(getResidenceId());
if (hall == null)
{
_log.warning("L2ClanHallZone: Clan hall with id " + getResidenceId() + " does not exist!");
}
else
{
hall.setZone(this);
}
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (character.isPlayer())
{
// Set as in clan hall
character.setInsideZone(ZoneId.CLAN_HALL, true);
AuctionableHall clanHall = ClanHallManager.getInstance().getAuctionableHallById(getResidenceId());
if (clanHall == null)
{
return;
}
// Send decoration packet
AgitDecoInfo deco = new AgitDecoInfo(clanHall);
character.sendPacket(deco);
}
}
@Override
protected void onExit(L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.CLAN_HALL, false);
}
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* @author UnAfraid
*/
public class L2ConditionZone extends L2ZoneType
{
private boolean NO_ITEM_DROP = false;
private boolean NO_BOOKMARK = false;
public L2ConditionZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equalsIgnoreCase("NoBookmark"))
{
NO_BOOKMARK = Boolean.parseBoolean(value);
}
else if (name.equalsIgnoreCase("NoItemDrop"))
{
NO_ITEM_DROP = Boolean.parseBoolean(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (character.isPlayer())
{
if (NO_BOOKMARK)
{
character.setInsideZone(ZoneId.NO_BOOKMARK, true);
}
if (NO_ITEM_DROP)
{
character.setInsideZone(ZoneId.NO_ITEM_DROP, true);
}
}
}
@Override
protected void onExit(L2Character character)
{
if (character.isPlayer())
{
if (NO_BOOKMARK)
{
character.setInsideZone(ZoneId.NO_BOOKMARK, false);
}
if (NO_ITEM_DROP)
{
character.setInsideZone(ZoneId.NO_ITEM_DROP, false);
}
}
}
}

View File

@ -0,0 +1,221 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.enums.InstanceType;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.stats.Stats;
import com.l2jserver.gameserver.model.zone.AbstractZoneSettings;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.TaskZoneSettings;
/**
* A damage zone
* @author durgus
*/
public class L2DamageZone extends L2ZoneType
{
private int _damageHPPerSec;
private int _damageMPPerSec;
private int _castleId;
private Castle _castle;
private int _startTask;
private int _reuseTask;
public L2DamageZone(int id)
{
super(id);
// Setup default damage
_damageHPPerSec = 200;
_damageMPPerSec = 0;
// Setup default start / reuse time
_startTask = 10;
_reuseTask = 5000;
// no castle by default
_castleId = 0;
_castle = null;
setTargetType(InstanceType.L2Playable); // default only playabale
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
if (settings == null)
{
settings = new TaskZoneSettings();
}
setSettings(settings);
}
@Override
public TaskZoneSettings getSettings()
{
return (TaskZoneSettings) super.getSettings();
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("dmgHPSec"))
{
_damageHPPerSec = Integer.parseInt(value);
}
else if (name.equals("dmgMPSec"))
{
_damageMPPerSec = Integer.parseInt(value);
}
else if (name.equals("castleId"))
{
_castleId = Integer.parseInt(value);
}
else if (name.equalsIgnoreCase("initialDelay"))
{
_startTask = Integer.parseInt(value);
}
else if (name.equalsIgnoreCase("reuse"))
{
_reuseTask = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if ((getSettings().getTask() == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
{
L2PcInstance player = character.getActingPlayer();
if (getCastle() != null) // Castle zone
{
if (!(getCastle().getSiege().isInProgress() && (player != null) && (player.getSiegeState() != 2))) // Siege and no defender
{
return;
}
}
synchronized (this)
{
if (getSettings().getTask() == null)
{
getSettings().setTask(ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask));
}
}
}
}
@Override
protected void onExit(L2Character character)
{
if (_characterList.isEmpty() && (getSettings().getTask() != null))
{
getSettings().clear();
}
}
protected int getHPDamagePerSecond()
{
return _damageHPPerSec;
}
protected int getMPDamagePerSecond()
{
return _damageMPPerSec;
}
protected Castle getCastle()
{
if ((_castleId > 0) && (_castle == null))
{
_castle = CastleManager.getInstance().getCastleById(_castleId);
}
return _castle;
}
private final class ApplyDamage implements Runnable
{
private final L2DamageZone _dmgZone;
private final Castle _castle;
protected ApplyDamage(L2DamageZone zone)
{
_dmgZone = zone;
_castle = zone.getCastle();
}
@Override
public void run()
{
if (!isEnabled())
{
return;
}
boolean siege = false;
if (_castle != null)
{
siege = _castle.getSiege().isInProgress();
// castle zones active only during siege
if (!siege)
{
_dmgZone.getSettings().clear();
return;
}
}
for (L2Character temp : _dmgZone.getCharactersInside())
{
if ((temp != null) && !temp.isDead())
{
if (siege)
{
// during siege defenders not affected
final L2PcInstance player = temp.getActingPlayer();
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
{
continue;
}
}
double multiplier = 1 + (temp.calcStat(Stats.DAMAGE_ZONE_VULN, 0, null, null) / 100);
if (getHPDamagePerSecond() != 0)
{
temp.reduceCurrentHp(_dmgZone.getHPDamagePerSecond() * multiplier, null, null);
}
if (getMPDamagePerSecond() != 0)
{
temp.reduceCurrentMp(_dmgZone.getMPDamagePerSecond() * multiplier);
}
}
}
}
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* The Monster Derby Track Zone
* @author durgus
*/
public class L2DerbyTrackZone extends L2ZoneType
{
public L2DerbyTrackZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
if (character.isPlayable())
{
character.setInsideZone(ZoneId.MONSTER_TRACK, true);
}
}
@Override
protected void onExit(L2Character character)
{
if (character.isPlayable())
{
character.setInsideZone(ZoneId.MONSTER_TRACK, false);
}
}
}

View File

@ -0,0 +1,128 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.L2WorldRegion;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.zone.AbstractZoneSettings;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.TaskZoneSettings;
/**
* A dynamic zone? Maybe use this for interlude skills like protection field :>
* @author durgus
*/
public class L2DynamicZone extends L2ZoneType
{
private final L2WorldRegion _region;
private final L2Character _owner;
private final Skill _skill;
public L2DynamicZone(L2WorldRegion region, L2Character owner, Skill skill)
{
super(-1);
_region = region;
_owner = owner;
_skill = skill;
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
if (settings == null)
{
settings = new TaskZoneSettings();
}
setSettings(settings);
getSettings().setTask(ThreadPoolManager.getInstance().scheduleGeneral(() -> remove(), skill.getAbnormalTime() * 1000));
}
@Override
public TaskZoneSettings getSettings()
{
return (TaskZoneSettings) super.getSettings();
}
@Override
protected void onEnter(L2Character character)
{
if (character.isPlayer())
{
character.sendMessage("You have entered a temporary zone!");
}
if (_owner != null)
{
_skill.applyEffects(_owner, character);
}
}
@Override
protected void onExit(L2Character character)
{
if (character.isPlayer())
{
character.sendMessage("You have left a temporary zone!"); // TODO: Custom message?
}
if (character == _owner)
{
remove();
return;
}
character.stopSkillEffects(true, _skill.getId());
}
protected void remove()
{
if ((getSettings().getTask() == null) || (_skill == null))
{
return;
}
getSettings().getTask().cancel(false);
_region.removeZone(this);
for (L2Character member : getCharactersInside())
{
member.stopSkillEffects(true, _skill.getId());
}
_owner.stopSkillEffects(true, _skill.getId());
}
@Override
public void onDieInside(L2Character character)
{
if (character == _owner)
{
remove();
}
else
{
character.stopSkillEffects(true, _skill.getId());
}
}
@Override
public void onReviveInside(L2Character character)
{
_skill.applyEffects(_owner, character);
}
}

View File

@ -0,0 +1,277 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import java.util.Map.Entry;
import javolution.util.FastMap;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.datatables.SkillData;
import com.l2jserver.gameserver.enums.InstanceType;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.zone.AbstractZoneSettings;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.TaskZoneSettings;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.serverpackets.EtcStatusUpdate;
import com.l2jserver.util.Rnd;
import com.l2jserver.util.StringUtil;
/**
* another type of damage zone with skills
* @author kerberos
*/
public class L2EffectZone extends L2ZoneType
{
private int _chance;
private int _initialDelay;
private int _reuse;
protected boolean _bypassConditions;
private boolean _isShowDangerIcon;
protected volatile FastMap<Integer, Integer> _skills;
public L2EffectZone(int id)
{
super(id);
_chance = 100;
_initialDelay = 0;
_reuse = 30000;
setTargetType(InstanceType.L2Playable); // default only playabale
_bypassConditions = false;
_isShowDangerIcon = true;
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
if (settings == null)
{
settings = new TaskZoneSettings();
}
setSettings(settings);
}
@Override
public TaskZoneSettings getSettings()
{
return (TaskZoneSettings) super.getSettings();
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("chance"))
{
_chance = Integer.parseInt(value);
}
else if (name.equals("initialDelay"))
{
_initialDelay = Integer.parseInt(value);
}
else if (name.equals("reuse"))
{
_reuse = Integer.parseInt(value);
}
else if (name.equals("bypassSkillConditions"))
{
_bypassConditions = Boolean.parseBoolean(value);
}
else if (name.equals("maxDynamicSkillCount"))
{
_skills = new FastMap<Integer, Integer>(Integer.parseInt(value)).shared();
}
else if (name.equals("skillIdLvl"))
{
String[] propertySplit = value.split(";");
_skills = new FastMap<>(propertySplit.length);
for (String skill : propertySplit)
{
String[] skillSplit = skill.split("-");
if (skillSplit.length != 2)
{
_log.warning(StringUtil.concat(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"", skill, "\""));
}
else
{
try
{
_skills.put(Integer.parseInt(skillSplit[0]), Integer.parseInt(skillSplit[1]));
}
catch (NumberFormatException nfe)
{
if (!skill.isEmpty())
{
_log.warning(StringUtil.concat(getClass().getSimpleName() + ": invalid config property -> skillsIdLvl \"", skillSplit[0], "\"", skillSplit[1]));
}
}
}
}
}
else if (name.equals("showDangerIcon"))
{
_isShowDangerIcon = Boolean.parseBoolean(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (_skills != null)
{
if (getSettings().getTask() == null)
{
synchronized (this)
{
if (getSettings().getTask() == null)
{
getSettings().setTask(ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new ApplySkill(), _initialDelay, _reuse));
}
}
}
}
if (character.isPlayer())
{
character.setInsideZone(ZoneId.ALTERED, true);
if (_isShowDangerIcon)
{
character.setInsideZone(ZoneId.DANGER_AREA, true);
character.sendPacket(new EtcStatusUpdate(character.getActingPlayer()));
}
}
}
@Override
protected void onExit(L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.ALTERED, false);
if (_isShowDangerIcon)
{
character.setInsideZone(ZoneId.DANGER_AREA, false);
if (!character.isInsideZone(ZoneId.DANGER_AREA))
{
character.sendPacket(new EtcStatusUpdate(character.getActingPlayer()));
}
}
}
if (_characterList.isEmpty() && (getSettings().getTask() != null))
{
getSettings().clear();
}
}
protected Skill getSkill(int skillId, int skillLvl)
{
return SkillData.getInstance().getSkill(skillId, skillLvl);
}
public int getChance()
{
return _chance;
}
public void addSkill(int skillId, int skillLvL)
{
if (skillLvL < 1) // remove skill
{
removeSkill(skillId);
return;
}
if (_skills == null)
{
synchronized (this)
{
if (_skills == null)
{
_skills = new FastMap<Integer, Integer>(3).shared();
}
}
}
_skills.put(skillId, skillLvL);
}
public void removeSkill(int skillId)
{
if (_skills != null)
{
_skills.remove(skillId);
}
}
public void clearSkills()
{
if (_skills != null)
{
_skills.clear();
}
}
public int getSkillLevel(int skillId)
{
if ((_skills == null) || !_skills.containsKey(skillId))
{
return 0;
}
return _skills.get(skillId);
}
private final class ApplySkill implements Runnable
{
protected ApplySkill()
{
if (_skills == null)
{
throw new IllegalStateException("No skills defined.");
}
}
@Override
public void run()
{
if (isEnabled())
{
for (L2Character temp : getCharactersInside())
{
if ((temp != null) && !temp.isDead())
{
if (Rnd.get(100) < getChance())
{
for (Entry<Integer, Integer> e : _skills.entrySet())
{
Skill skill = getSkill(e.getKey(), e.getValue());
if ((skill != null) && (_bypassConditions || skill.checkCondition(temp, temp, false)))
{
if (!temp.isAffectedBySkill(e.getKey()))
{
skill.applyEffects(temp, temp);
}
}
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
/**
* A fishing zone
* @author durgus
*/
public class L2FishingZone extends L2ZoneType
{
public L2FishingZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
}
@Override
protected void onExit(L2Character character)
{
}
/*
* getWaterZ() this added function returns the Z value for the water surface. In effect this simply returns the upper Z value of the zone. This required some modification of L2ZoneForm, and zone form extentions.
*/
public int getWaterZ()
{
return getZone().getHighZ();
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* A castle zone
* @author durgus
*/
public final class L2FortZone extends L2ResidenceZone
{
public L2FortZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("fortId"))
{
setResidenceId(Integer.parseInt(value));
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(ZoneId.FORT, true);
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(ZoneId.FORT, false);
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* Zone where 'Build Headquarters' is allowed.
* @author Gnacik
*/
public class L2HqZone extends L2ZoneType
{
public L2HqZone(final int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if ("castleId".equals(name))
{
// TODO
}
else if ("fortId".equals(name))
{
// TODO
}
else if ("clanHallId".equals(name))
{
// TODO
}
else if ("territoryId".equals(name))
{
// TODO
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(final L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.HQ, true);
}
}
@Override
protected void onExit(final L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.HQ, false);
}
}
}

View File

@ -0,0 +1,101 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.Config;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.tasks.player.TeleportTask;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
/**
* A jail zone
* @author durgus
*/
public class L2JailZone extends L2ZoneType
{
private static final Location JAIL_IN_LOC = new Location(-114356, -249645, -2984);
private static final Location JAIL_OUT_LOC = new Location(17836, 170178, -3507);
public L2JailZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.JAIL, true);
character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, true);
if (Config.JAIL_IS_PVP)
{
character.setInsideZone(ZoneId.PVP, true);
character.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
}
if (Config.JAIL_DISABLE_TRANSACTION)
{
character.setInsideZone(ZoneId.NO_STORE, true);
}
}
}
@Override
protected void onExit(L2Character character)
{
if (character.isPlayer())
{
final L2PcInstance player = character.getActingPlayer();
player.setInsideZone(ZoneId.JAIL, false);
player.setInsideZone(ZoneId.NO_SUMMON_FRIEND, false);
if (Config.JAIL_IS_PVP)
{
character.setInsideZone(ZoneId.PVP, false);
character.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
}
if (player.isJailed())
{
// when a player wants to exit jail even if he is still jailed, teleport him back to jail
ThreadPoolManager.getInstance().scheduleGeneral(new TeleportTask(player, JAIL_IN_LOC), 2000);
character.sendMessage("You cannot cheat your way out of here. You must wait until your jail time is over.");
}
if (Config.JAIL_DISABLE_TRANSACTION)
{
character.setInsideZone(ZoneId.NO_STORE, false);
}
}
}
public static Location getLocationIn()
{
return JAIL_IN_LOC;
}
public static Location getLocationOut()
{
return JAIL_OUT_LOC;
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* A landing zone
* @author Kerberos
*/
public class L2LandingZone extends L2ZoneType
{
public L2LandingZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.LANDING, true);
}
}
@Override
protected void onExit(L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.LANDING, false);
}
}
}

View File

@ -0,0 +1,111 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* A mother-trees zone Basic type zone for Hp, MP regen
* @author durgus
*/
public class L2MotherTreeZone extends L2ZoneType
{
private int _enterMsg;
private int _leaveMsg;
private int _mpRegen;
private int _hpRegen;
public L2MotherTreeZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("enterMsgId"))
{
_enterMsg = Integer.parseInt(value);
}
else if (name.equals("leaveMsgId"))
{
_leaveMsg = Integer.parseInt(value);
}
else if (name.equals("MpRegenBonus"))
{
_mpRegen = Integer.parseInt(value);
}
else if (name.equals("HpRegenBonus"))
{
_hpRegen = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (character.isPlayer())
{
L2PcInstance player = character.getActingPlayer();
character.setInsideZone(ZoneId.MOTHER_TREE, true);
if (_enterMsg != 0)
{
player.sendPacket(SystemMessage.getSystemMessage(_enterMsg));
}
}
}
@Override
protected void onExit(L2Character character)
{
if (character.isPlayer())
{
L2PcInstance player = character.getActingPlayer();
player.setInsideZone(ZoneId.MOTHER_TREE, false);
if (_leaveMsg != 0)
{
player.sendPacket(SystemMessage.getSystemMessage(_leaveMsg));
}
}
}
/**
* @return the _mpRegen
*/
public int getMpRegenBonus()
{
return _mpRegen;
}
/**
* @return the _hpRegen
*/
public int getHpRegenBonus()
{
return _hpRegen;
}
}

View File

@ -0,0 +1,79 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.enums.MountType;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
/**
* A no landing zone
* @author durgus
*/
public class L2NoLandingZone extends L2ZoneType
{
private int dismountDelay = 5;
public L2NoLandingZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("dismountDelay"))
{
dismountDelay = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.NO_LANDING, true);
if (character.getActingPlayer().getMountType() == MountType.WYVERN)
{
character.sendPacket(SystemMessageId.THIS_AREA_CANNOT_BE_ENTERED_WHILE_MOUNTED_ATOP_OF_A_WYVERN_YOU_WILL_BE_DISMOUNTED_FROM_YOUR_WYVERN_IF_YOU_DO_NOT_LEAVE);
character.getActingPlayer().enteredNoLanding(dismountDelay);
}
}
}
@Override
protected void onExit(L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.NO_LANDING, false);
if (character.getActingPlayer().getMountType() == MountType.WYVERN)
{
character.getActingPlayer().exitedNoLanding();
}
}
}
}

View File

@ -0,0 +1,129 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.GameServer;
import com.l2jserver.gameserver.model.TeleportWhereType;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* A simple no restart zone
* @author GKR
*/
public class L2NoRestartZone extends L2ZoneType
{
private int _restartAllowedTime = 0;
private int _restartTime = 0;
private boolean _enabled = true;
public L2NoRestartZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equalsIgnoreCase("default_enabled"))
{
_enabled = Boolean.parseBoolean(value);
}
else if (name.equalsIgnoreCase("restartAllowedTime"))
{
_restartAllowedTime = Integer.parseInt(value) * 1000;
}
else if (name.equalsIgnoreCase("restartTime"))
{
_restartTime = Integer.parseInt(value) * 1000;
}
else if (name.equalsIgnoreCase("instanceId"))
{
// Do nothing.
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (!_enabled)
{
return;
}
if (character.isPlayer())
{
character.setInsideZone(ZoneId.NO_RESTART, true);
}
}
@Override
protected void onExit(L2Character character)
{
if (!_enabled)
{
return;
}
if (character.isPlayer())
{
character.setInsideZone(ZoneId.NO_RESTART, false);
}
}
@Override
public void onPlayerLoginInside(L2PcInstance player)
{
if (!_enabled)
{
return;
}
if (((System.currentTimeMillis() - player.getLastAccess()) > getRestartTime()) && ((System.currentTimeMillis() - GameServer.dateTimeServerStarted.getTimeInMillis()) > getRestartAllowedTime()))
{
player.teleToLocation(TeleportWhereType.TOWN);
}
}
public int getRestartAllowedTime()
{
return _restartAllowedTime;
}
public void setRestartAllowedTime(int time)
{
_restartAllowedTime = time;
}
public int getRestartTime()
{
return _restartTime;
}
public void setRestartTime(int time)
{
_restartTime = time;
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* Zone where store is not allowed.
* @author fordfrog
*/
public class L2NoStoreZone extends L2ZoneType
{
public L2NoStoreZone(final int id)
{
super(id);
}
@Override
protected void onEnter(final L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.NO_STORE, true);
}
}
@Override
protected void onExit(final L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.NO_STORE, false);
}
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* A simple no summon zone
* @author JIV
*/
public class L2NoSummonFriendZone extends L2ZoneType
{
public L2NoSummonFriendZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, true);
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, false);
}
}

View File

@ -0,0 +1,314 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.PcCondOverride;
import com.l2jserver.gameserver.model.TeleportWhereType;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jserver.gameserver.model.actor.instance.L2OlympiadManagerInstance;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.olympiad.OlympiadGameTask;
import com.l2jserver.gameserver.model.zone.AbstractZoneSettings;
import com.l2jserver.gameserver.model.zone.L2ZoneRespawn;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExOlympiadMatchEnd;
import com.l2jserver.gameserver.network.serverpackets.ExOlympiadUserInfo;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* An olympiad stadium
* @author durgus, DS
*/
public class L2OlympiadStadiumZone extends L2ZoneRespawn
{
private List<Location> _spectatorLocations;
public L2OlympiadStadiumZone(int id)
{
super(id);
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
if (settings == null)
{
settings = new Settings();
}
setSettings(settings);
}
public final class Settings extends AbstractZoneSettings
{
private OlympiadGameTask _task = null;
protected Settings()
{
}
public OlympiadGameTask getOlympiadTask()
{
return _task;
}
protected void setTask(OlympiadGameTask task)
{
_task = task;
}
@Override
public void clear()
{
_task = null;
}
}
@Override
public Settings getSettings()
{
return (Settings) super.getSettings();
}
public final void registerTask(OlympiadGameTask task)
{
getSettings().setTask(task);
}
public final void openDoors()
{
for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getInstanceId()).getDoors())
{
if ((door != null) && !door.getOpen())
{
door.openMe();
}
}
}
public final void closeDoors()
{
for (L2DoorInstance door : InstanceManager.getInstance().getInstance(getInstanceId()).getDoors())
{
if ((door != null) && door.getOpen())
{
door.closeMe();
}
}
}
public final void spawnBuffers()
{
for (L2Npc buffer : InstanceManager.getInstance().getInstance(getInstanceId()).getNpcs())
{
if ((buffer instanceof L2OlympiadManagerInstance) && !buffer.isVisible())
{
buffer.spawnMe();
}
}
}
public final void deleteBuffers()
{
for (L2Npc buffer : InstanceManager.getInstance().getInstance(getInstanceId()).getNpcs())
{
if ((buffer instanceof L2OlympiadManagerInstance) && buffer.isVisible())
{
buffer.decayMe();
}
}
}
public final void broadcastStatusUpdate(L2PcInstance player)
{
final ExOlympiadUserInfo packet = new ExOlympiadUserInfo(player);
for (L2PcInstance target : getPlayersInside())
{
if ((target != null) && (target.inObserverMode() || (target.getOlympiadSide() != player.getOlympiadSide())))
{
target.sendPacket(packet);
}
}
}
public final void broadcastPacketToObservers(L2GameServerPacket packet)
{
for (L2Character character : getCharactersInside())
{
if ((character != null) && character.isPlayer() && character.getActingPlayer().inObserverMode())
{
character.sendPacket(packet);
}
}
}
@Override
protected final void onEnter(L2Character character)
{
if (getSettings().getOlympiadTask() != null)
{
if (getSettings().getOlympiadTask().isBattleStarted())
{
character.setInsideZone(ZoneId.PVP, true);
if (character.isPlayer())
{
character.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
getSettings().getOlympiadTask().getGame().sendOlympiadInfo(character);
}
}
}
if (character.isPlayable())
{
final L2PcInstance player = character.getActingPlayer();
if (player != null)
{
// only participants, observers and GMs allowed
if (!player.canOverrideCond(PcCondOverride.ZONE_CONDITIONS) && !player.isInOlympiadMode() && !player.inObserverMode())
{
ThreadPoolManager.getInstance().executeGeneral(new KickPlayer(player));
}
else
{
// check for pet
if (player.hasPet())
{
player.getSummon().unSummon(player);
}
}
}
}
}
@Override
protected final void onExit(L2Character character)
{
if (getSettings().getOlympiadTask() != null)
{
if (getSettings().getOlympiadTask().isBattleStarted())
{
character.setInsideZone(ZoneId.PVP, false);
if (character.isPlayer())
{
character.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
character.sendPacket(ExOlympiadMatchEnd.STATIC_PACKET);
}
}
}
}
public final void updateZoneStatusForCharactersInside()
{
if (getSettings().getOlympiadTask() == null)
{
return;
}
final boolean battleStarted = getSettings().getOlympiadTask().isBattleStarted();
final SystemMessage sm;
if (battleStarted)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
}
else
{
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
}
for (L2Character character : getCharactersInside())
{
if (character == null)
{
continue;
}
if (battleStarted)
{
character.setInsideZone(ZoneId.PVP, true);
if (character.isPlayer())
{
character.sendPacket(sm);
}
}
else
{
character.setInsideZone(ZoneId.PVP, false);
if (character.isPlayer())
{
character.sendPacket(sm);
character.sendPacket(ExOlympiadMatchEnd.STATIC_PACKET);
}
}
}
}
private static final class KickPlayer implements Runnable
{
private L2PcInstance _player;
public KickPlayer(L2PcInstance player)
{
_player = player;
}
@Override
public void run()
{
if (_player != null)
{
if (_player.hasSummon())
{
_player.getSummon().unSummon(_player);
}
_player.teleToLocation(TeleportWhereType.TOWN);
_player.setInstanceId(0);
_player = null;
}
}
}
@Override
public void parseLoc(int x, int y, int z, String type)
{
if ((type != null) && type.equals("spectatorSpawn"))
{
if (_spectatorLocations == null)
{
_spectatorLocations = new ArrayList<>();
}
_spectatorLocations.add(new Location(x, y, z));
}
else
{
super.parseLoc(x, y, z, type);
}
}
public List<Location> getSpectatorSpawns()
{
return _spectatorLocations;
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* A Peace Zone
* @author durgus
*/
public class L2PeaceZone extends L2ZoneType
{
public L2PeaceZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
if (character.isPlayer())
{
L2PcInstance player = character.getActingPlayer();
// PVP possible during siege, now for siege participants only
// Could also check if this town is in siege, or if any siege is going on
if ((player.getSiegeState() != 0) && (Config.PEACE_ZONE_MODE == 1))
{
return;
}
}
if (Config.PEACE_ZONE_MODE != 2)
{
character.setInsideZone(ZoneId.PEACE, true);
}
if (!getAllowStore())
{
character.setInsideZone(ZoneId.NO_STORE, true);
}
}
@Override
protected void onExit(L2Character character)
{
if (Config.PEACE_ZONE_MODE != 2)
{
character.setInsideZone(ZoneId.PEACE, false);
}
if (!getAllowStore())
{
character.setInsideZone(ZoneId.NO_STORE, false);
}
}
}

View File

@ -0,0 +1,97 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import java.util.concurrent.ScheduledFuture;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.util.Rnd;
/**
* Teleport residence zone for clan hall sieges
* @author BiggBoss
*/
public class L2ResidenceHallTeleportZone extends L2ResidenceTeleportZone
{
private int _id;
private ScheduledFuture<?> _teleTask;
/**
* @param id
*/
public L2ResidenceHallTeleportZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("residenceZoneId"))
{
_id = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
public int getResidenceZoneId()
{
return _id;
}
public synchronized void checkTeleporTask()
{
if ((_teleTask == null) || _teleTask.isDone())
{
_teleTask = ThreadPoolManager.getInstance().scheduleGeneral(new TeleportTask(), 30000);
}
}
protected class TeleportTask implements Runnable
{
@Override
public void run()
{
int index = 0;
if (getSpawns().size() > 1)
{
index = Rnd.get(getSpawns().size());
}
final Location loc = getSpawns().get(index);
if (loc == null)
{
throw new NullPointerException();
}
for (L2PcInstance pc : getPlayersInside())
{
if (pc != null)
{
pc.teleToLocation(loc, false);
}
}
}
}
}

View File

@ -0,0 +1,79 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneRespawn;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* based on Kerberos work for custom L2CastleTeleportZone
* @author Nyaran
*/
public class L2ResidenceTeleportZone extends L2ZoneRespawn
{
private int _residenceId;
public L2ResidenceTeleportZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("residenceId"))
{
_residenceId = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, true); // FIXME: Custom ?
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, false); // FIXME: Custom ?
}
public void oustAllPlayers()
{
for (L2PcInstance player : getPlayersInside())
{
if ((player != null) && player.isOnline())
{
player.teleToLocation(getSpawnLoc(), 200);
}
}
}
public int getResidenceId()
{
return _residenceId;
}
}

View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneRespawn;
/**
* @author xban1x
*/
public abstract class L2ResidenceZone extends L2ZoneRespawn
{
private int _residenceId;
protected L2ResidenceZone(int id)
{
super(id);
}
public void banishForeigners(int owningClanId)
{
for (L2PcInstance temp : getPlayersInside())
{
if ((owningClanId != 0) && (temp.getClanId() == owningClanId))
{
continue;
}
temp.teleToLocation(getBanishSpawnLoc(), true);
}
}
protected void setResidenceId(int residenceId)
{
_residenceId = residenceId;
}
public int getResidenceId()
{
return _residenceId;
}
}

View File

@ -0,0 +1,66 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import java.util.HashMap;
import java.util.Map;
import com.l2jserver.gameserver.enums.Race;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
/**
* Respawn zone implementation.
* @author Nyaran
*/
public class L2RespawnZone extends L2ZoneType
{
private final Map<Race, String> _raceRespawnPoint = new HashMap<>();
public L2RespawnZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
}
@Override
protected void onExit(L2Character character)
{
}
public void addRaceRespawnPoint(String race, String point)
{
_raceRespawnPoint.put(Race.valueOf(race), point);
}
public Map<Race, String> getAllRespawnPoints()
{
return _raceRespawnPoint;
}
public String getRespawnPoint(L2PcInstance activeChar)
{
return _raceRespawnPoint.get(activeChar.getRace());
}
}

View File

@ -0,0 +1,47 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* A scripted zone... Creation of such a zone should require somekind of jython script reference which can handle onEnter() / onExit()
* @author durgus
*/
public class L2ScriptZone extends L2ZoneType
{
public L2ScriptZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(ZoneId.SCRIPT, true);
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(ZoneId.SCRIPT, false);
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author BiggBoss
*/
public final class L2SiegableHallZone extends L2ClanHallZone
{
private List<Location> _challengerLocations;
public L2SiegableHallZone(int id)
{
super(id);
}
@Override
public void parseLoc(int x, int y, int z, String type)
{
if ((type != null) && type.equals("challenger"))
{
if (_challengerLocations == null)
{
_challengerLocations = new ArrayList<>();
}
_challengerLocations.add(new Location(x, y, z));
}
else
{
super.parseLoc(x, y, z, type);
}
}
public List<Location> getChallengerSpawns()
{
return _challengerLocations;
}
public void banishNonSiegeParticipants()
{
for (L2PcInstance player : getPlayersInside())
{
if ((player != null) && player.isInHideoutSiege())
{
player.teleToLocation(getBanishSpawnLoc(), true);
}
}
}
}

View File

@ -0,0 +1,352 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.SkillData;
import com.l2jserver.gameserver.enums.MountType;
import com.l2jserver.gameserver.instancemanager.CHSiegeManager;
import com.l2jserver.gameserver.instancemanager.FortManager;
import com.l2jserver.gameserver.instancemanager.FortSiegeManager;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.TeleportWhereType;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Fort;
import com.l2jserver.gameserver.model.entity.FortSiege;
import com.l2jserver.gameserver.model.entity.Siegable;
import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
import com.l2jserver.gameserver.model.skills.BuffInfo;
import com.l2jserver.gameserver.model.skills.Skill;
import com.l2jserver.gameserver.model.zone.AbstractZoneSettings;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.SystemMessageId;
/**
* A siege zone
* @author durgus
*/
public class L2SiegeZone extends L2ZoneType
{
private static final int DISMOUNT_DELAY = 5;
public L2SiegeZone(int id)
{
super(id);
AbstractZoneSettings settings = ZoneManager.getSettings(getName());
if (settings == null)
{
settings = new Settings();
}
setSettings(settings);
}
public final class Settings extends AbstractZoneSettings
{
private int _siegableId = -1;
private Siegable _siege = null;
private boolean _isActiveSiege = false;
protected Settings()
{
}
public int getSiegeableId()
{
return _siegableId;
}
protected void setSiegeableId(int id)
{
_siegableId = id;
}
public Siegable getSiege()
{
return _siege;
}
public void setSiege(Siegable s)
{
_siege = s;
}
public boolean isActiveSiege()
{
return _isActiveSiege;
}
public void setActiveSiege(boolean val)
{
_isActiveSiege = val;
}
@Override
public void clear()
{
_siegableId = -1;
_siege = null;
_isActiveSiege = false;
}
}
@Override
public Settings getSettings()
{
return (Settings) super.getSettings();
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("castleId"))
{
if (getSettings().getSiegeableId() != -1)
{
throw new IllegalArgumentException("Siege object already defined!");
}
getSettings().setSiegeableId(Integer.parseInt(value));
}
else if (name.equals("fortId"))
{
if (getSettings().getSiegeableId() != -1)
{
throw new IllegalArgumentException("Siege object already defined!");
}
getSettings().setSiegeableId(Integer.parseInt(value));
}
else if (name.equals("clanHallId"))
{
if (getSettings().getSiegeableId() != -1)
{
throw new IllegalArgumentException("Siege object already defined!");
}
getSettings().setSiegeableId(Integer.parseInt(value));
SiegableHall hall = CHSiegeManager.getInstance().getConquerableHalls().get(getSettings().getSiegeableId());
if (hall == null)
{
_log.warning("L2SiegeZone: Siegable clan hall with id " + value + " does not exist!");
}
else
{
hall.setSiegeZone(this);
}
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (getSettings().isActiveSiege())
{
character.setInsideZone(ZoneId.PVP, true);
character.setInsideZone(ZoneId.SIEGE, true);
character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, true); // FIXME: Custom ?
if (character.isPlayer())
{
L2PcInstance plyer = character.getActingPlayer();
if (plyer.isRegisteredOnThisSiegeField(getSettings().getSiegeableId()))
{
plyer.setIsInSiege(true); // in siege
if (getSettings().getSiege().giveFame() && (getSettings().getSiege().getFameFrequency() > 0))
{
plyer.startFameTask(getSettings().getSiege().getFameFrequency() * 1000, getSettings().getSiege().getFameAmount());
}
}
character.sendPacket(SystemMessageId.YOU_HAVE_ENTERED_A_COMBAT_ZONE);
if (!Config.ALLOW_WYVERN_DURING_SIEGE && (plyer.getMountType() == MountType.WYVERN))
{
plyer.sendPacket(SystemMessageId.THIS_AREA_CANNOT_BE_ENTERED_WHILE_MOUNTED_ATOP_OF_A_WYVERN_YOU_WILL_BE_DISMOUNTED_FROM_YOUR_WYVERN_IF_YOU_DO_NOT_LEAVE);
plyer.enteredNoLanding(DISMOUNT_DELAY);
}
}
}
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(ZoneId.PVP, false);
character.setInsideZone(ZoneId.SIEGE, false);
character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, false); // FIXME: Custom ?
if (getSettings().isActiveSiege())
{
if (character.isPlayer())
{
L2PcInstance player = character.getActingPlayer();
character.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
if (player.getMountType() == MountType.WYVERN)
{
player.exitedNoLanding();
}
// Set pvp flag
if (player.getPvpFlag() == 0)
{
player.startPvPFlag();
}
}
}
if (character.isPlayer())
{
L2PcInstance activeChar = character.getActingPlayer();
activeChar.stopFameTask();
activeChar.setIsInSiege(false);
if ((getSettings().getSiege() instanceof FortSiege) && (activeChar.getInventory().getItemByItemId(9819) != null))
{
// drop combat flag
Fort fort = FortManager.getInstance().getFortById(getSettings().getSiegeableId());
if (fort != null)
{
FortSiegeManager.getInstance().dropCombatFlag(activeChar, fort.getResidenceId());
}
else
{
int slot = activeChar.getInventory().getSlotFromItem(activeChar.getInventory().getItemByItemId(9819));
activeChar.getInventory().unEquipItemInBodySlot(slot);
activeChar.destroyItem("CombatFlag", activeChar.getInventory().getItemByItemId(9819), null, true);
}
}
}
}
@Override
public void onDieInside(L2Character character)
{
if (getSettings().isActiveSiege())
{
// debuff participants only if they die inside siege zone
if (character.isPlayer() && character.getActingPlayer().isRegisteredOnThisSiegeField(getSettings().getSiegeableId()))
{
int lvl = 1;
final BuffInfo info = character.getEffectList().getBuffInfoBySkillId(5660);
if (info != null)
{
lvl = Math.min(lvl + info.getSkill().getLevel(), 5);
}
final Skill skill = SkillData.getInstance().getSkill(5660, lvl);
if (skill != null)
{
skill.applyEffects(character, character);
}
}
}
}
public void updateZoneStatusForCharactersInside()
{
if (getSettings().isActiveSiege())
{
for (L2Character character : getCharactersInside())
{
if (character != null)
{
onEnter(character);
}
}
}
else
{
L2PcInstance player;
for (L2Character character : getCharactersInside())
{
if (character == null)
{
continue;
}
character.setInsideZone(ZoneId.PVP, false);
character.setInsideZone(ZoneId.SIEGE, false);
character.setInsideZone(ZoneId.NO_SUMMON_FRIEND, false);
if (character.isPlayer())
{
player = character.getActingPlayer();
character.sendPacket(SystemMessageId.YOU_HAVE_LEFT_A_COMBAT_ZONE);
player.stopFameTask();
if (player.getMountType() == MountType.WYVERN)
{
player.exitedNoLanding();
}
}
}
}
}
/**
* Sends a message to all players in this zone
* @param message
*/
public void announceToPlayers(String message)
{
for (L2PcInstance player : getPlayersInside())
{
if (player != null)
{
player.sendMessage(message);
}
}
}
public int getSiegeObjectId()
{
return getSettings().getSiegeableId();
}
public boolean isActive()
{
return getSettings().isActiveSiege();
}
public void setIsActive(boolean val)
{
getSettings().setActiveSiege(val);
}
public void setSiegeInstance(Siegable siege)
{
getSettings().setSiege(siege);
}
/**
* Removes all foreigners from the zone
* @param owningClanId
*/
public void banishForeigners(int owningClanId)
{
TeleportWhereType type = TeleportWhereType.TOWN;
for (L2PcInstance temp : getPlayersInside())
{
if (temp.getClanId() == owningClanId)
{
continue;
}
temp.teleToLocation(type);
}
}
}

View File

@ -0,0 +1,122 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.Castle;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* another type of zone where your speed is changed
* @author kerberos
*/
public class L2SwampZone extends L2ZoneType
{
private double _move_bonus;
private int _castleId;
private Castle _castle;
public L2SwampZone(int id)
{
super(id);
// Setup default speed reduce (in %)
_move_bonus = 0.5;
// no castle by default
_castleId = 0;
_castle = null;
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("move_bonus"))
{
_move_bonus = Double.parseDouble(value);
}
else if (name.equals("castleId"))
{
_castleId = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
private Castle getCastle()
{
if ((_castleId > 0) && (_castle == null))
{
_castle = CastleManager.getInstance().getCastleById(_castleId);
}
return _castle;
}
@Override
protected void onEnter(L2Character character)
{
if (getCastle() != null)
{
// castle zones active only during siege
if (!getCastle().getSiege().isInProgress() || !isEnabled())
{
return;
}
// defenders not affected
final L2PcInstance player = character.getActingPlayer();
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
{
return;
}
}
character.setInsideZone(ZoneId.SWAMP, true);
if (character.isPlayer())
{
character.getActingPlayer().broadcastUserInfo();
}
}
@Override
protected void onExit(L2Character character)
{
// don't broadcast info if not needed
if (character.isInsideZone(ZoneId.SWAMP))
{
character.setInsideZone(ZoneId.SWAMP, false);
if (character.isPlayer())
{
character.getActingPlayer().broadcastUserInfo();
}
}
}
public double getMoveBonus()
{
return _move_bonus;
}
}

View File

@ -0,0 +1,87 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
/**
* A Town zone
* @author durgus
*/
public class L2TownZone extends L2ZoneType
{
private int _townId;
private int _taxById;
public L2TownZone(int id)
{
super(id);
_taxById = 0;
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("townId"))
{
_townId = Integer.parseInt(value);
}
else if (name.equals("taxById"))
{
_taxById = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(ZoneId.TOWN, true);
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(ZoneId.TOWN, false);
}
/**
* Returns this zones town id (if any)
* @return
*/
public int getTownId()
{
return _townId;
}
/**
* Returns this town zones castle id
* @return
*/
public final int getTaxById()
{
return _taxById;
}
}

View File

@ -0,0 +1,105 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import java.util.Collection;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.network.serverpackets.NpcInfo;
import com.l2jserver.gameserver.network.serverpackets.ServerObjectInfo;
public class L2WaterZone extends L2ZoneType
{
public L2WaterZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(ZoneId.WATER, true);
// TODO: update to only send speed status when that packet is known
if (character.isPlayer())
{
L2PcInstance player = character.getActingPlayer();
if (player.isTransformed() && !player.getTransformation().canSwim())
{
character.stopTransformation(true);
}
else
{
player.broadcastUserInfo();
}
}
else if (character.isNpc())
{
Collection<L2PcInstance> plrs = character.getKnownList().getKnownPlayers().values();
for (L2PcInstance player : plrs)
{
if (character.getRunSpeed() == 0)
{
player.sendPacket(new ServerObjectInfo((L2Npc) character, player));
}
else
{
player.sendPacket(new NpcInfo((L2Npc) character));
}
}
}
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(ZoneId.WATER, false);
// TODO: update to only send speed status when that packet is known
if (character.isPlayer())
{
character.getActingPlayer().broadcastUserInfo();
}
else if (character.isNpc())
{
Collection<L2PcInstance> plrs = character.getKnownList().getKnownPlayers().values();
for (L2PcInstance player : plrs)
{
if (character.getRunSpeed() == 0)
{
player.sendPacket(new ServerObjectInfo((L2Npc) character, player));
}
else
{
player.sendPacket(new NpcInfo((L2Npc) character));
}
}
}
}
public int getWaterZ()
{
return getZone().getHighZ();
}
}

View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2004-2014 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server 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.
*
* L2J Server 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.l2jserver.gameserver.model.zone.type;
import java.util.List;
import com.l2jserver.gameserver.model.zone.L2ZoneForm;
/**
* Just dummy zone, needs only for geometry calculations
* @author GKR
*/
public class NpcSpawnTerritory
{
private final String _name;
private final L2ZoneForm _territory;
@SuppressWarnings("unused")
private List<L2ZoneForm> _bannedTerritories; // TODO: Implement it
public NpcSpawnTerritory(String name, L2ZoneForm territory)
{
_name = name;
_territory = territory;
}
public String getName()
{
return _name;
}
public int[] getRandomPoint()
{
return _territory.getRandomPoint();
}
public boolean isInsideZone(int x, int y, int z)
{
return _territory.isInsideZone(x, y, z);
}
public void visualizeZone(int z)
{
_territory.visualizeZone(z);
}
}