actual freya branch

This commit is contained in:
2026-09-12 15:41:31 +00:00
parent 8049e0a882
commit 68c1cd27d4
3510 changed files with 336689 additions and 302906 deletions
@@ -0,0 +1,80 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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
*/
public abstract class L2SpawnZone extends L2ZoneType
{
private List<Location> _spawnLocs = null;
private List<Location> _chaoticSpawnLocs = null;
public L2SpawnZone(int id)
{
super(id);
}
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 addChaoticSpawn(int x, int y, int z)
{
if (_chaoticSpawnLocs == null)
{
_chaoticSpawnLocs = new ArrayList<>();
}
_chaoticSpawnLocs.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 getChaoticSpawnLoc()
{
if (_chaoticSpawnLocs != null)
{
return _chaoticSpawnLocs.get(Rnd.get(_chaoticSpawnLocs.size()));
}
return getSpawnLoc();
}
}
@@ -0,0 +1,55 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone;
import com.l2jserver.gameserver.idfactory.IdFactory;
import com.l2jserver.gameserver.instancemanager.ZoneManager;
import com.l2jserver.gameserver.model.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);
}
}
@@ -0,0 +1,490 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone;
import java.util.Map;
import java.util.logging.Logger;
import javolution.util.FastList;
import javolution.util.FastMap;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Object.InstanceType;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
/**
* Abstract base class for any zone type Handles basic operations
* @author durgus
*/
public abstract class L2ZoneType
{
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 _minLvl;
private int _maxLvl;
private int[] _race;
private int[] _class;
private char _classType;
private Map<Quest.QuestEventType, FastList<Quest>> _questEvents;
private InstanceType _target = InstanceType.L2Character; // default all chars
protected L2ZoneType(int id)
{
_id = id;
_characterList = new FastMap<Integer, L2Character>().shared();
_minLvl = 0;
_maxLvl = 0xFF;
_classType = 0;
_race = null;
_class = null;
}
/**
* @return Returns the id.
*/
public int getId()
{
return _id;
}
/**
* Setup new parameters for this zone
* @param type
* @param value
*/
public void setParameter(String name, String value)
{
_checkAffected = true;
// Zone name
if (name.equals("name"))
{
_name = 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
{
_log.info(getClass().getSimpleName() + ": Unknown parameter - " + name + " in zone: " + getId());
}
}
/**
* Checks if the given character is affected by this zone
* @param character
* @return
*/
private boolean isAffected(L2Character character)
{
// Check lvl
if ((character.getLevel() < _minLvl) || (character.getLevel() > _maxLvl))
{
return false;
}
// check obj class
if (!character.isInstanceType(_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 (((L2PcInstance) 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
* @param zone
* @return
*/
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;
}
/**
* Checks if the given coordinates are within zone's plane
* @param x
* @param y
*/
public boolean isInsideZone(int x, int y)
{
return _zone.isInsideZone(x, y, _zone.getHighZ());
}
/**
* Checks if the given coordinates are within the zone
* @param x
* @param y
* @param z
*/
public boolean isInsideZone(int x, int y, int z)
{
return _zone.isInsideZone(x, y, z);
}
/**
* Checks if the given object is inside the zone.
* @param object
*/
public boolean isInsideZone(L2Object object)
{
return isInsideZone(object.getX(), object.getY(), object.getZ());
}
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.getX(), character.getY(), character.getZ()))
{
// Was the character not yet inside this zone?
if (!_characterList.containsKey(character.getObjectId()))
{
FastList<Quest> quests = getQuestByEvent(Quest.QuestEventType.ON_ENTER_ZONE);
if (quests != null)
{
for (Quest quest : quests)
{
quest.notifyEnterZone(character, this);
}
}
_characterList.put(character.getObjectId(), character);
onEnter(character);
}
}
else
{
// Was the character inside this zone?
if (_characterList.containsKey(character.getObjectId()))
{
FastList<Quest> quests = getQuestByEvent(Quest.QuestEventType.ON_EXIT_ZONE);
if (quests != null)
{
for (Quest quest : quests)
{
quest.notifyExitZone(character, this);
}
}
_characterList.remove(character.getObjectId());
onExit(character);
}
}
}
/**
* Force fully removes a character from the zone Should use during teleport / logoff
* @param character
*/
public void removeCharacter(L2Character character)
{
if (_characterList.containsKey(character.getObjectId()))
{
FastList<Quest> quests = getQuestByEvent(Quest.QuestEventType.ON_EXIT_ZONE);
if (quests != null)
{
for (Quest quest : quests)
{
quest.notifyExitZone(character, this);
}
}
_characterList.remove(character.getObjectId());
onExit(character);
}
}
/**
* Will scan the zones char list for the character
* @param character
* @return
*/
public boolean isCharacterInZone(L2Character character)
{
return _characterList.containsKey(character.getObjectId());
}
protected abstract void onEnter(L2Character character);
protected abstract void onExit(L2Character character);
public abstract void onDieInside(L2Character character);
public abstract void onReviveInside(L2Character character);
public FastMap<Integer, L2Character> getCharactersInside()
{
return _characterList;
}
public void addQuestEvent(Quest.QuestEventType EventType, Quest q)
{
if (_questEvents == null)
{
_questEvents = new FastMap<>();
}
FastList<Quest> questByEvents = _questEvents.get(EventType);
if (questByEvents == null)
{
questByEvents = new FastList<>();
}
if (!questByEvents.contains(q))
{
questByEvents.add(q);
}
_questEvents.put(EventType, questByEvents);
}
public FastList<Quest> getQuestByEvent(Quest.QuestEventType EventType)
{
if (_questEvents == null)
{
return null;
}
return _questEvents.get(EventType);
}
/**
* Broadcasts packet to all players inside the zone
*/
public void broadcastPacket(L2GameServerPacket packet)
{
if (_characterList.isEmpty())
{
return;
}
for (L2Character character : _characterList.values())
{
if ((character != null) && (character instanceof L2PcInstance))
{
character.sendPacket(packet);
}
}
}
public InstanceType getTargetType()
{
return _target;
}
public void setTargetType(InstanceType type)
{
_target = type;
_checkAffected = true;
}
@Override
public String toString()
{
return getClass().getSimpleName() + "[" + _id + "]";
}
public void visualizeZone(int z)
{
getZone().visualizeZone(z);
}
}
@@ -0,0 +1,199 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.form;
import com.l2jserver.gameserver.model.zone.L2ZoneForm;
/**
* A primitive rectangular zone
* @author durgus
*/
public class ZoneCuboid extends L2ZoneForm
{
private int _x1, _x2, _y1, _y2, _z1, _z2;
public ZoneCuboid(int x1, int x2, int y1, int y2, int z1, int z2)
{
_x1 = x1;
_x2 = x2;
if (_x1 > _x2) // switch them if alignment is wrong
{
_x1 = x2;
_x2 = x1;
}
_y1 = y1;
_y2 = y2;
if (_y1 > _y2) // switch them if alignment is wrong
{
_y1 = y2;
_y2 = y1;
}
_z1 = z1;
_z2 = z2;
if (_z1 > _z2) // switch them if alignment is wrong
{
_z1 = z2;
_z2 = z1;
}
}
@Override
public boolean isInsideZone(int x, int y, int z)
{
if ((x < _x1) || (x > _x2) || (y < _y1) || (y > _y2) || (z < _z1) || (z > _z2))
{
return false;
}
return true;
}
@Override
public boolean intersectsRectangle(int ax1, int ax2, int ay1, int ay2)
{
// Check if any point inside this rectangle
if (isInsideZone(ax1, ay1, (_z2 - 1)))
{
return true;
}
if (isInsideZone(ax1, ay2, (_z2 - 1)))
{
return true;
}
if (isInsideZone(ax2, ay1, (_z2 - 1)))
{
return true;
}
if (isInsideZone(ax2, ay2, (_z2 - 1)))
{
return true;
}
// Check if any point from this rectangle is inside the other one
if ((_x1 > ax1) && (_x1 < ax2) && (_y1 > ay1) && (_y1 < ay2))
{
return true;
}
if ((_x1 > ax1) && (_x1 < ax2) && (_y2 > ay1) && (_y2 < ay2))
{
return true;
}
if ((_x2 > ax1) && (_x2 < ax2) && (_y1 > ay1) && (_y1 < ay2))
{
return true;
}
if ((_x2 > ax1) && (_x2 < ax2) && (_y2 > ay1) && (_y2 < ay2))
{
return true;
}
// Horizontal lines may intersect vertical lines
if (lineSegmentsIntersect(_x1, _y1, _x2, _y1, ax1, ay1, ax1, ay2))
{
return true;
}
if (lineSegmentsIntersect(_x1, _y1, _x2, _y1, ax2, ay1, ax2, ay2))
{
return true;
}
if (lineSegmentsIntersect(_x1, _y2, _x2, _y2, ax1, ay1, ax1, ay2))
{
return true;
}
if (lineSegmentsIntersect(_x1, _y2, _x2, _y2, ax2, ay1, ax2, ay2))
{
return true;
}
// Vertical lines may intersect horizontal lines
if (lineSegmentsIntersect(_x1, _y1, _x1, _y2, ax1, ay1, ax2, ay1))
{
return true;
}
if (lineSegmentsIntersect(_x1, _y1, _x1, _y2, ax1, ay2, ax2, ay2))
{
return true;
}
if (lineSegmentsIntersect(_x2, _y1, _x2, _y2, ax1, ay1, ax2, ay1))
{
return true;
}
if (lineSegmentsIntersect(_x2, _y1, _x2, _y2, ax1, ay2, ax2, ay2))
{
return true;
}
return false;
}
@Override
public double getDistanceToZone(int x, int y)
{
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, 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)
{
// x1->x2
for (int x = _x1; x < _x2; x = x + STEP)
{
dropDebugItem(57, 1, x, _y1, z);
dropDebugItem(57, 1, x, _y2, z);
}
// y1->y2
for (int y = _y1; y < _y2; y = y + STEP)
{
dropDebugItem(57, 1, _x1, y, z);
dropDebugItem(57, 1, _x2, y, z);
}
}
}
@@ -0,0 +1,134 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.form;
import com.l2jserver.gameserver.model.zone.L2ZoneForm;
/**
* 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(57, 1, _x + x, _y + y, z);
}
}
}
@@ -0,0 +1,161 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.form;
import com.l2jserver.gameserver.model.zone.L2ZoneForm;
/**
* A not so primitive npoly zone
* @author durgus
*/
public class ZoneNPoly extends L2ZoneForm
{
private final int[] _x;
private final int[] _y;
private final int _z1;
private final int _z2;
public ZoneNPoly(int[] x, int[] y, int z1, int z2)
{
_x = x;
_y = y;
_z1 = z1;
_z2 = z2;
}
@Override
public boolean isInsideZone(int x, int y, int z)
{
if ((z < _z1) || (z > _z2))
{
return false;
}
boolean inside = false;
for (int i = 0, j = _x.length - 1; i < _x.length; j = i++)
{
if ((((_y[i] <= y) && (y < _y[j])) || ((_y[j] <= y) && (y < _y[i]))) && (x < ((((_x[j] - _x[i]) * (y - _y[i])) / (_y[j] - _y[i])) + _x[i])))
{
inside = !inside;
}
}
return inside;
}
@Override
public boolean intersectsRectangle(int ax1, int ax2, int ay1, int ay2)
{
int tX, tY, uX, uY;
// First check if a point of the polygon lies inside the rectangle
if ((_x[0] > ax1) && (_x[0] < ax2) && (_y[0] > ay1) && (_y[0] < ay2))
{
return true;
}
// Or a point of the rectangle inside the polygon
if (isInsideZone(ax1, ay1, (_z2 - 1)))
{
return true;
}
// If the first point wasn't inside the rectangle it might still have any line crossing any side
// of the rectangle
// Check every possible line of the polygon for a collision with any of the rectangles side
for (int i = 0; i < _y.length; i++)
{
tX = _x[i];
tY = _y[i];
uX = _x[(i + 1) % _x.length];
uY = _y[(i + 1) % _x.length];
// Check if this line intersects any of the four sites of the rectangle
if (lineSegmentsIntersect(tX, tY, uX, uY, ax1, ay1, ax1, ay2))
{
return true;
}
if (lineSegmentsIntersect(tX, tY, uX, uY, ax1, ay1, ax2, ay1))
{
return true;
}
if (lineSegmentsIntersect(tX, tY, uX, uY, ax2, ay2, ax1, ay2))
{
return true;
}
if (lineSegmentsIntersect(tX, tY, uX, uY, ax2, ay2, ax2, ay1))
{
return true;
}
}
return false;
}
@Override
public double getDistanceToZone(int x, int y)
{
double test, shortestDist = Math.pow(_x[0] - x, 2) + Math.pow(_y[0] - y, 2);
for (int i = 1; i < _y.length; 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)
{
for (int i = 0; i < _x.length; 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(57, 1, (int) (_x[i] + (k * vx)), (int) (_y[i] + (k * vy)), z);
}
}
}
}
@@ -0,0 +1,78 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.skills.AbnormalEffect;
/**
* L2AbnormalZone zones give entering players abnormal effects Default effect is big head
* @author durgus
*/
public class L2AbnormalZone extends L2ZoneType
{
private int abnormal = AbnormalEffect.BIG_HEAD.getMask();
private int special = 0;
public L2AbnormalZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("AbnormalMask"))
{
abnormal = Integer.parseInt(value);
}
else if (name.equals("SpecialMask"))
{
special = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
character.startAbnormalEffect(abnormal);
character.startSpecialEffect(special);
}
@Override
protected void onExit(L2Character character)
{
character.stopAbnormalEffect(abnormal);
character.stopSpecialEffect(special);
}
@Override
public void onDieInside(L2Character character)
{
onExit(character);
}
@Override
public void onReviveInside(L2Character character)
{
onEnter(character);
}
}
@@ -0,0 +1,74 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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.L2SpawnZone;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* An arena
* @author durgus
*/
public class L2ArenaZone extends L2SpawnZone
{
public L2ArenaZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(L2Character.ZONE_PVP, true);
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, true);
if (character instanceof L2PcInstance)
{
if (!character.isInsideZone(L2Character.ZONE_PVP))
{
((L2PcInstance) character).sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENTERED_COMBAT_ZONE));
}
}
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(L2Character.ZONE_PVP, false);
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, false);
if (character instanceof L2PcInstance)
{
if (!character.isInsideZone(L2Character.ZONE_PVP))
{
((L2PcInstance) character).sendPacket(SystemMessage.getSystemMessage(SystemMessageId.LEFT_COMBAT_ZONE));
}
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
}
@@ -0,0 +1,439 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import java.util.Map;
import javolution.util.FastMap;
import com.l2jserver.gameserver.GameServer;
import com.l2jserver.gameserver.datatables.MapRegionTable;
import com.l2jserver.gameserver.instancemanager.GrandBossManager;
import com.l2jserver.gameserver.model.actor.L2Attackable;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.util.L2FastList;
/**
* @author DaRkRaGe
*/
public class L2BossZone extends L2ZoneType
{
private int _timeInvade;
private boolean _enabled = true; // default value, unless overridden by xml...
// 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 FastMap<Integer, Long> _playerAllowedReEntryTimes;
// 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 L2FastList<Integer> _playersAllowed;
private int[] _oustLoc =
{
0,
0,
0
};
protected L2FastList<L2Character> _raidList = new L2FastList<>();
public L2BossZone(int id)
{
super(id);
_playerAllowedReEntryTimes = new FastMap<>();
_playersAllowed = new L2FastList<>();
_oustLoc = new int[3];
GrandBossManager.getInstance().addZone(this);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("InvadeTime"))
{
_timeInvade = Integer.parseInt(value);
}
else if (name.equals("EnabledByDefault"))
{
_enabled = Boolean.parseBoolean(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);
}
}
@Override
/**
* Boss zones have special behaviors for player characters. Players are
* automatically teleported out when the attempt to enter these zones,
* except if the time at which they enter the zone is prior to the entry
* expiration time set for that player. Entry expiration times are set by
* any one of the following: 1) A player logs out while in a zone
* (Expiration gets set to logoutTime + _timeInvade) 2) An external source
* (such as a quest or AI of NPC) set up the player for entry.
*
* There exists one more case in which the player will be allowed to enter.
* That is if the server recently rebooted (boot-up time more recent than
* currentTime - _timeInvade) AND the player was in the zone prior to reboot.
*/
protected void onEnter(L2Character character)
{
if (_enabled)
{
if (character instanceof L2PcInstance)
{
final L2PcInstance player = (L2PcInstance) character;
player.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, true);
if (player.isGM())
{
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 (_playersAllowed.contains(player.getObjectId()))
{
// Get the information about this player's last logout-exit from
// this zone.
final Long expirationTime = _playerAllowedReEntryTimes.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
_playerAllowedReEntryTimes.remove(player.getObjectId());
if (expirationTime.longValue() > System.currentTimeMillis())
{
return;
}
}
_playersAllowed.remove(_playersAllowed.indexOf(player.getObjectId()));
}
// teleport out all players who attempt "illegal" (re-)entry
if ((_oustLoc[0] != 0) && (_oustLoc[1] != 0) && (_oustLoc[2] != 0))
{
player.teleToLocation(_oustLoc[0], _oustLoc[1], _oustLoc[2]);
}
else
{
player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
}
}
else if (character instanceof L2Summon)
{
final L2PcInstance player = ((L2Summon) character).getOwner();
if (player != null)
{
if (_playersAllowed.contains(player.getObjectId()) || player.isGM())
{
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(MapRegionTable.TeleportWhereType.Town);
}
}
((L2Summon) character).unSummon(player);
}
}
}
@Override
protected void onExit(L2Character character)
{
if (_enabled)
{
if (character instanceof L2PcInstance)
{
final L2PcInstance player = (L2PcInstance) character;
player.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, false);
if (player.isGM())
{
return;
}
// if the player just got disconnected/logged out, store the dc
// time so that
// decisions can be made later about allowing or not the player
// to log into the zone
if (!player.isOnline() && _playersAllowed.contains(player.getObjectId()))
{
// mark the time that the player left the zone
_playerAllowedReEntryTimes.put(player.getObjectId(), System.currentTimeMillis() + _timeInvade);
}
else
{
if (_playersAllowed.contains(player.getObjectId()))
{
_playersAllowed.remove(_playersAllowed.indexOf(player.getObjectId()));
}
_playerAllowedReEntryTimes.remove(player.getObjectId());
}
}
if (character instanceof L2Playable)
{
if ((getCharactersInside() != null) && !getCharactersInside().isEmpty())
{
_raidList.clear();
int count = 0;
for (L2Character obj : getCharactersInside().values())
{
if (obj == null)
{
continue;
}
if (obj instanceof L2Playable)
{
count++;
}
else if ((obj instanceof L2Attackable) && obj.isRaid())
{
_raidList.add(obj);
}
}
// if inside zone isnt any player, force all boss instance return to its spawn points
if ((count == 0) && !_raidList.isEmpty())
{
for (int i = 0; i < _raidList.size(); i++)
{
L2Attackable raid = (L2Attackable) _raidList.get(i);
if ((raid == null) || (raid.getSpawn() == null) || raid.isDead())
{
continue;
}
if (!raid.isInsideRadius(raid.getSpawn().getLocx(), raid.getSpawn().getLocy(), 150, false))
{
raid.returnHome();
}
}
}
}
}
}
if ((character instanceof L2Attackable) && character.isRaid() && !character.isDead())
{
((L2Attackable) character).returnHome();
}
}
public void setZoneEnabled(boolean flag)
{
if (_enabled != flag)
{
oustAllPlayers();
}
_enabled = flag;
}
public int getTimeInvade()
{
return _timeInvade;
}
public void setAllowedPlayers(L2FastList<Integer> players)
{
if (players != null)
{
_playersAllowed = players;
}
}
public L2FastList<Integer> getAllowedPlayers()
{
return _playersAllowed;
}
public boolean isPlayerAllowed(L2PcInstance player)
{
if (player.isGM())
{
return true;
}
else if (_playersAllowed.contains(player.getObjectId()))
{
return true;
}
else
{
if ((_oustLoc[0] != 0) && (_oustLoc[1] != 0) && (_oustLoc[2] != 0))
{
player.teleToLocation(_oustLoc[0], _oustLoc[1], _oustLoc[2]);
}
else
{
player.teleToLocation(MapRegionTable.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 x
* @param y
* @param z
*/
public void movePlayersTo(int x, int y, int z)
{
if (_characterList.isEmpty())
{
return;
}
for (L2Character character : _characterList.values())
{
if (character instanceof L2PcInstance)
{
L2PcInstance player = (L2PcInstance) character;
if (player.isOnline())
{
player.teleToLocation(x, y, z);
}
}
}
}
/**
* Occasionally, all players need to be sent out of the zone (for example, if the players are just running around without fighting for too long, or if all players die, etc). This call sends all online players to town and marks offline players to be teleported (by clearing their relog expiration
* times) when they log back in (no real need for off-line teleport).
*/
public void oustAllPlayers()
{
if (_characterList.isEmpty())
{
return;
}
for (L2Character character : _characterList.values())
{
if (character instanceof L2PcInstance)
{
L2PcInstance player = (L2PcInstance) character;
if (player.isOnline())
{
if ((_oustLoc[0] != 0) && (_oustLoc[1] != 0) && (_oustLoc[2] != 0))
{
player.teleToLocation(_oustLoc[0], _oustLoc[1], _oustLoc[2]);
}
else
{
player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
}
}
}
}
_playerAllowedReEntryTimes.clear();
_playersAllowed.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.isGM())
{
if (!_playersAllowed.contains(player.getObjectId()))
{
_playersAllowed.add(player.getObjectId());
}
_playerAllowedReEntryTimes.put(player.getObjectId(), System.currentTimeMillis() + (durationInSec * 1000));
}
}
public void removePlayer(L2PcInstance player)
{
if (!player.isGM())
{
_playersAllowed.remove(Integer.valueOf(player.getObjectId()));
_playerAllowedReEntryTimes.remove(player.getObjectId());
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
public void updateKnownList(L2Npc npc)
{
if ((_characterList == null) || _characterList.isEmpty())
{
return;
}
Map<Integer, L2PcInstance> npcKnownPlayers = npc.getKnownList().getKnownPlayers();
for (L2Character character : _characterList.values())
{
if (character == null)
{
continue;
}
if (character instanceof L2PcInstance)
{
L2PcInstance player = (L2PcInstance) character;
if (player.isOnline())
{
npcKnownPlayers.put(player.getObjectId(), player);
}
}
}
return;
}
}
@@ -0,0 +1,154 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import javolution.util.FastList;
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.util.Rnd;
/**
* A castle teleporter zone used for Mass Gatekeepers
* @author Kerberos
*/
public class L2CastleTeleportZone extends L2ZoneType
{
private final int[] _spawnLoc;
private int _castleId;
public L2CastleTeleportZone(int id)
{
super(id);
_spawnLoc = new int[5];
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("castleId"))
{
_castleId = Integer.parseInt(value);
}
else if (name.equals("spawnMinX"))
{
_spawnLoc[0] = Integer.parseInt(value);
}
else if (name.equals("spawnMaxX"))
{
_spawnLoc[1] = Integer.parseInt(value);
}
else if (name.equals("spawnMinY"))
{
_spawnLoc[2] = Integer.parseInt(value);
}
else if (name.equals("spawnMaxY"))
{
_spawnLoc[3] = Integer.parseInt(value);
}
else if (name.equals("spawnZ"))
{
_spawnLoc[4] = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, true);
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, false);
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
/**
* Returns all players within this zone
* @return
*/
public FastList<L2PcInstance> getAllPlayers()
{
FastList<L2PcInstance> players = new FastList<>();
for (L2Character temp : _characterList.values())
{
if (temp instanceof L2PcInstance)
{
players.add((L2PcInstance) temp);
}
}
return players;
}
public void oustAllPlayers()
{
if (_characterList == null)
{
return;
}
if (_characterList.isEmpty())
{
return;
}
for (L2Character character : _characterList.values())
{
if (character == null)
{
continue;
}
if (character instanceof L2PcInstance)
{
L2PcInstance player = (L2PcInstance) character;
if (player.isOnline())
{
player.teleToLocation(Rnd.get(_spawnLoc[0], _spawnLoc[1]), Rnd.get(_spawnLoc[2], _spawnLoc[3]), _spawnLoc[4]);
}
}
}
}
public int getCastleId()
{
return _castleId;
}
/**
* Get the spawn locations
* @return
*/
public int[] getSpawn()
{
return _spawnLoc;
}
}
@@ -0,0 +1,113 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.datatables.MapRegionTable;
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.L2SpawnZone;
/**
* A castle zone
* @author durgus
*/
public class L2CastleZone extends L2SpawnZone
{
private int _castleId;
private Castle _castle = null;
public L2CastleZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("castleId"))
{
_castleId = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (getCastle() != null)
{
character.setInsideZone(L2Character.ZONE_CASTLE, true);
}
}
@Override
protected void onExit(L2Character character)
{
if (getCastle() != null)
{
character.setInsideZone(L2Character.ZONE_CASTLE, false);
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
/**
* Removes all foreigners from the castle
* @param owningClanId
*/
public void banishForeigners(int owningClanId)
{
for (L2Character temp : _characterList.values())
{
if (!(temp instanceof L2PcInstance))
{
continue;
}
if (((L2PcInstance) temp).getClanId() == owningClanId)
{
continue;
}
((L2PcInstance) temp).teleToLocation(MapRegionTable.TeleportWhereType.Town);
}
}
public int getCastleId()
{
return _castleId;
}
private final Castle getCastle()
{
if (_castle == null)
{
_castle = CastleManager.getInstance().getCastleById(_castleId);
}
return _castle;
}
}
@@ -0,0 +1,123 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.datatables.MapRegionTable;
import com.l2jserver.gameserver.instancemanager.ClanHallManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.entity.ClanHall;
import com.l2jserver.gameserver.model.zone.L2SpawnZone;
import com.l2jserver.gameserver.network.serverpackets.AgitDecoInfo;
/**
* A clan hall zone
* @author durgus
*/
public class L2ClanHallZone extends L2SpawnZone
{
private int _clanHallId;
public L2ClanHallZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("clanHallId"))
{
_clanHallId = Integer.parseInt(value);
// Register self to the correct clan hall
ClanHallManager.getInstance().getClanHallById(_clanHallId).setZone(this);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (character instanceof L2PcInstance)
{
// Set as in clan hall
character.setInsideZone(L2Character.ZONE_CLANHALL, true);
ClanHall clanHall = ClanHallManager.getInstance().getClanHallById(_clanHallId);
if (clanHall == null)
{
return;
}
// Send decoration packet
AgitDecoInfo deco = new AgitDecoInfo(clanHall);
((L2PcInstance) character).sendPacket(deco);
}
}
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2PcInstance)
{
// Unset clanhall zone
character.setInsideZone(L2Character.ZONE_CLANHALL, false);
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
/**
* Removes all foreigners from the clan hall
* @param owningClanId
*/
public void banishForeigners(int owningClanId)
{
for (L2Character temp : _characterList.values())
{
if (!(temp instanceof L2PcInstance))
{
continue;
}
if (((L2PcInstance) temp).getClanId() == owningClanId)
{
continue;
}
((L2PcInstance) temp).teleToLocation(MapRegionTable.TeleportWhereType.Town);
}
}
/**
* @return the clanHallId
*/
public int getClanHallId()
{
return _clanHallId;
}
}
@@ -0,0 +1,93 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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.L2SpawnZone;
/**
* @author UnAfraid
*/
public class L2ConditionZone extends L2SpawnZone
{
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 instanceof L2PcInstance)
{
if (NO_BOOKMARK)
{
character.setInsideZone(L2Character.ZONE_NOBOOKMARK, true);
}
if (NO_ITEM_DROP)
{
character.setInsideZone(L2Character.ZONE_NOITEMDROP, true);
}
}
}
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2PcInstance)
{
if (NO_BOOKMARK)
{
character.setInsideZone(L2Character.ZONE_NOBOOKMARK, false);
}
if (NO_ITEM_DROP)
{
character.setInsideZone(L2Character.ZONE_NOITEMDROP, false);
}
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
}
@@ -0,0 +1,225 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import java.util.Collection;
import java.util.concurrent.Future;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.gameserver.model.L2Object.InstanceType;
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.skills.Stats;
/**
* A damage zone
* @author durgus
*/
public class L2DamageZone extends L2ZoneType
{
private int _damageHPPerSec;
private int _damageMPPerSec;
private Future<?> _task;
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
}
@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 ((_task == null) && ((_damageHPPerSec != 0) || (_damageMPPerSec != 0)))
{
L2PcInstance player = character.getActingPlayer();
if (getCastle() != null)
{
if (!(getCastle().getSiege().getIsInProgress() && (player != null) && (player.getSiegeState() != 2)))
{
return;
}
}
synchronized (this)
{
if (_task == null)
{
_task = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new ApplyDamage(this), _startTask, _reuseTask);
}
}
}
}
@Override
protected void onExit(L2Character character)
{
if (_characterList.isEmpty() && (_task != null))
{
stopTask();
}
}
protected Collection<L2Character> getCharacterList()
{
return _characterList.values();
}
protected int getHPDamagePerSecond()
{
return _damageHPPerSec;
}
protected int getMPDamagePerSecond()
{
return _damageMPPerSec;
}
protected void stopTask()
{
if (_task != null)
{
_task.cancel(false);
_task = null;
}
}
protected Castle getCastle()
{
if ((_castleId > 0) && (_castle == null))
{
_castle = CastleManager.getInstance().getCastleById(_castleId);
}
return _castle;
}
class ApplyDamage implements Runnable
{
private final L2DamageZone _dmgZone;
private final Castle _castle;
ApplyDamage(L2DamageZone zone)
{
_dmgZone = zone;
_castle = zone.getCastle();
}
@Override
public void run()
{
boolean siege = false;
if (_castle != null)
{
siege = _castle.getSiege().getIsInProgress();
// castle zones active only during siege
if (!siege)
{
_dmgZone.stopTask();
return;
}
}
for (L2Character temp : _dmgZone.getCharacterList())
{
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);
}
}
}
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
}
@@ -0,0 +1,64 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
/**
* 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 instanceof L2Playable)
{
character.setInsideZone(L2Character.ZONE_MONSTERTRACK, true);
character.setInsideZone(L2Character.ZONE_PEACE, true);
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, true);
}
}
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2Playable)
{
character.setInsideZone(L2Character.ZONE_MONSTERTRACK, false);
character.setInsideZone(L2Character.ZONE_PEACE, false);
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, false);
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
}
@@ -0,0 +1,127 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import java.util.concurrent.Future;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.L2WorldRegion;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
/**
* 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 Future<?> _task;
private final L2Skill _skill;
protected void setTask(Future<?> task)
{
_task = task;
}
public L2DynamicZone(L2WorldRegion region, L2Character owner, L2Skill skill)
{
super(-1);
_region = region;
_owner = owner;
_skill = skill;
Runnable r = () -> remove();
setTask(ThreadPoolManager.getInstance().scheduleGeneral(r, skill.getBuffDuration()));
}
@Override
protected void onEnter(L2Character character)
{
try
{
if (character instanceof L2PcInstance)
{
((L2PcInstance) character).sendMessage("You have entered a temporary zone!");
}
_skill.getEffects(_owner, character);
}
catch (NullPointerException e)
{
}
}
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2PcInstance)
{
((L2PcInstance) character).sendMessage("You have left a temporary zone!");
}
if (character == _owner)
{
remove();
return;
}
character.stopSkillEffects(_skill.getId());
}
protected void remove()
{
if (_task == null)
{
return;
}
_task.cancel(false);
_task = null;
_region.removeZone(this);
for (L2Character member : _characterList.values())
{
try
{
member.stopSkillEffects(_skill.getId());
}
catch (NullPointerException e)
{
}
}
_owner.stopSkillEffects(_skill.getId());
}
@Override
public void onDieInside(L2Character character)
{
if (character == _owner)
{
remove();
}
else
{
character.stopSkillEffects(_skill.getId());
}
}
@Override
public void onReviveInside(L2Character character)
{
_skill.getEffects(_owner, character);
}
}
@@ -0,0 +1,294 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import java.util.Collection;
import java.util.Map.Entry;
import java.util.concurrent.Future;
import javolution.util.FastMap;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.model.L2Object.InstanceType;
import com.l2jserver.gameserver.model.L2Skill;
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.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;
private boolean _enabled;
protected boolean _bypassConditions;
private boolean _isShowDangerIcon;
private Future<?> _task;
protected FastMap<Integer, Integer> _skills;
public L2EffectZone(int id)
{
super(id);
_chance = 100;
_initialDelay = 0;
_reuse = 30000;
_enabled = true;
setTargetType(InstanceType.L2Playable); // default only playabale
_bypassConditions = false;
_isShowDangerIcon = true;
}
@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("default_enabled"))
{
_enabled = Boolean.parseBoolean(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 (_task == null)
{
synchronized (this)
{
if (_task == null)
{
_task = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new ApplySkill(), _initialDelay, _reuse);
}
}
}
}
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_ALTERED, true);
if (_isShowDangerIcon)
{
character.setInsideZone(L2Character.ZONE_DANGERAREA, true);
character.sendPacket(new EtcStatusUpdate((L2PcInstance) character));
}
}
}
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_ALTERED, false);
if (_isShowDangerIcon)
{
character.setInsideZone(L2Character.ZONE_DANGERAREA, false);
if (!character.isInsideZone(L2Character.ZONE_DANGERAREA))
{
character.sendPacket(new EtcStatusUpdate((L2PcInstance) character));
}
}
}
if (_characterList.isEmpty() && (_task != null))
{
_task.cancel(true);
_task = null;
}
}
protected L2Skill getSkill(int skillId, int skillLvl)
{
return SkillTable.getInstance().getInfo(skillId, skillLvl);
}
public boolean isEnabled()
{
return _enabled;
}
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);
// _log.info("Zone: "+this+" adding skill: "+skillId+" lvl: "+skillLvL);
}
public void removeSkill(int skillId)
{
if (_skills != null)
{
_skills.remove(skillId);
}
}
public void clearSkills()
{
if (_skills != null)
{
_skills.clear();
}
}
public void setZoneEnabled(boolean val)
{
_enabled = val;
}
public int getSkillLevel(int skillId)
{
if ((_skills == null) || !_skills.containsKey(skillId))
{
return 0;
}
return _skills.get(skillId);
}
protected Collection<L2Character> getCharacterList()
{
return _characterList.values();
}
class ApplySkill implements Runnable
{
ApplySkill()
{
if (_skills == null)
{
throw new IllegalStateException("No skills defined.");
}
}
@Override
public void run()
{
if (isEnabled())
{
for (L2Character temp : getCharacterList())
{
if ((temp != null) && !temp.isDead())
{
if (Rnd.get(100) < getChance())
{
for (Entry<Integer, Integer> e : _skills.entrySet())
{
L2Skill skill = getSkill(e.getKey(), e.getValue());
if ((skill != null) && (_bypassConditions || skill.checkCondition(temp, temp, false)))
{
if (temp.getFirstEffect(e.getKey()) == null)
{
skill.getEffects(temp, temp);
}
}
}
}
}
}
}
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
}
@@ -0,0 +1,58 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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)
{
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(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();
}
}
@@ -0,0 +1,102 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.datatables.MapRegionTable;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2SpawnZone;
/**
* A castle zone
* @author durgus
*/
public class L2FortZone extends L2SpawnZone
{
private int _fortId;
public L2FortZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("fortId"))
{
_fortId = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(L2Character.ZONE_FORT, true);
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(L2Character.ZONE_FORT, false);
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
public void updateZoneStatusForCharactersInside()
{
}
/**
* Removes all foreigners from the fort
* @param owningClan
*/
public void banishForeigners(L2Clan owningClan)
{
for (L2Character temp : _characterList.values())
{
if (!(temp instanceof L2PcInstance))
{
continue;
}
if (((L2PcInstance) temp).getClan() == owningClan)
{
continue;
}
((L2PcInstance) temp).teleToLocation(MapRegionTable.TeleportWhereType.Town); // TODO: shouldnt be town, its outside of fort
}
}
public int getFortId()
{
return _fortId;
}
}
@@ -0,0 +1,105 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import com.l2jserver.Config;
import com.l2jserver.gameserver.ThreadPoolManager;
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.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* A jail zone
* @author durgus
*/
public class L2JailZone extends L2ZoneType
{
public L2JailZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_JAIL, true);
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, true);
if (Config.JAIL_IS_PVP)
{
character.setInsideZone(L2Character.ZONE_PVP, true);
((L2PcInstance) character).sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENTERED_COMBAT_ZONE));
}
if (Config.JAIL_DISABLE_TRANSACTION)
{
character.setInsideZone(L2Character.ZONE_NOSTORE, true);
}
}
}
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_JAIL, false);
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, false);
if (Config.JAIL_IS_PVP)
{
character.setInsideZone(L2Character.ZONE_PVP, false);
((L2PcInstance) character).sendPacket(SystemMessage.getSystemMessage(SystemMessageId.LEFT_COMBAT_ZONE));
}
if (((L2PcInstance) character).isInJail())
{
// when a player wants to exit jail even if he is still jailed, teleport him back to jail
ThreadPoolManager.getInstance().scheduleGeneral(new BackToJail(character), 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(L2Character.ZONE_NOSTORE, false);
}
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
static class BackToJail implements Runnable
{
private final L2PcInstance _activeChar;
BackToJail(L2Character character)
{
_activeChar = (L2PcInstance) character;
}
@Override
public void run()
{
_activeChar.teleToLocation(-114356, -249645, -2984); // Jail
}
}
}
@@ -0,0 +1,65 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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;
/**
* A landing zone
* @author Kerberos
*/
public class L2LandingZone extends L2ZoneType
{
public L2LandingZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_LANDING, true);
}
}
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_LANDING, false);
}
}
/**
* @see com.l2jserver.gameserver.model.zone.L2ZoneType#onDieInside(com.l2jserver.gameserver.model.actor.L2Character)
*/
@Override
public void onDieInside(L2Character character)
{
}
/**
* @see com.l2jserver.gameserver.model.zone.L2ZoneType#onReviveInside(com.l2jserver.gameserver.model.actor.L2Character)
*/
@Override
public void onReviveInside(L2Character character)
{
}
}
@@ -0,0 +1,118 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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.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.valueOf(value);
}
else if (name.equals("leaveMsgId"))
{
_leaveMsg = Integer.valueOf(value);
}
else if (name.equals("MpRegenBonus"))
{
_mpRegen = Integer.valueOf(value);
}
else if (name.equals("HpRegenBonus"))
{
_hpRegen = Integer.valueOf(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (character instanceof L2PcInstance)
{
L2PcInstance player = (L2PcInstance) character;
player.setInsideZone(L2Character.ZONE_MOTHERTREE, true);
if (_enterMsg != 0)
{
player.sendPacket(SystemMessage.getSystemMessage(_enterMsg));
}
}
}
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2PcInstance)
{
L2PcInstance player = (L2PcInstance) character;
player.setInsideZone(L2Character.ZONE_MOTHERTREE, false);
if (_leaveMsg != 0)
{
player.sendPacket(SystemMessage.getSystemMessage(_leaveMsg));
}
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
/**
* @return the _mpRegen
*/
public int getMpRegenBonus()
{
return _mpRegen;
}
/**
* @return the _hpRegen
*/
public int getHpRegenBonus()
{
return _hpRegen;
}
}
@@ -0,0 +1,59 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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;
/**
* Zone where 'Build Headquarters' is not allowed.
* @author Gnat
*/
public class L2NoHqZone extends L2ZoneType
{
public L2NoHqZone(final int id)
{
super(id);
}
@Override
protected void onEnter(final L2Character character)
{
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_NOHQ, true);
}
}
@Override
protected void onExit(final L2Character character)
{
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_NOHQ, false);
}
}
@Override
public void onDieInside(final L2Character character)
{
}
@Override
public void onReviveInside(final L2Character character)
{
}
}
@@ -0,0 +1,89 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* A no landing zone
* @author durgus
*/
public class L2NoLandingZone extends L2ZoneType
{
private int dismountDelay = 5;
public L2NoLandingZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_NOLANDING, true);
if (((L2PcInstance) character).getMountType() == 2)
{
character.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.AREA_CANNOT_BE_ENTERED_WHILE_MOUNTED_WYVERN));
((L2PcInstance) character).enteredNoLanding(dismountDelay);
}
}
}
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_NOLANDING, false);
if (((L2PcInstance) character).getMountType() == 2)
{
((L2PcInstance) character).exitedNoLanding();
}
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
/*
* (non-Javadoc)
* @see com.l2jserver.gameserver.model.zone.L2ZoneType#setParameter(java.lang.String, java.lang.String)
*/
@Override
public void setParameter(String name, String value)
{
if (name.equals("dismountDelay"))
{
dismountDelay = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
}
@@ -0,0 +1,59 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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;
/**
* 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 instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_NOSTORE, true);
}
}
@Override
protected void onExit(final L2Character character)
{
if (character instanceof L2PcInstance)
{
character.setInsideZone(L2Character.ZONE_NOSTORE, false);
}
}
@Override
public void onDieInside(final L2Character character)
{
}
@Override
public void onReviveInside(final L2Character character)
{
}
}
@@ -0,0 +1,54 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
/**
* 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(L2Character.ZONE_NOSUMMONFRIEND, true);
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, false);
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
}
@@ -0,0 +1,287 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import java.util.ArrayList;
import java.util.List;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.datatables.MapRegionTable;
import com.l2jserver.gameserver.model.L2Spawn;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.L2Summon;
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.L2SpawnZone;
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 L2SpawnZone
{
private final List<L2DoorInstance> _doors;
private final List<L2Spawn> _buffers;
OlympiadGameTask _task = null;
public L2OlympiadStadiumZone(int id)
{
super(id);
_buffers = new ArrayList<>(2);
_doors = new ArrayList<>(2);
}
public final void registerTask(OlympiadGameTask task)
{
_task = task;
}
public final void openDoors()
{
for (L2DoorInstance door : _doors)
{
if ((door != null) && !door.getOpen())
{
door.openMe();
}
}
}
public final void closeDoors()
{
for (L2DoorInstance door : _doors)
{
if ((door != null) && door.getOpen())
{
door.closeMe();
}
}
}
public final void spawnBuffers()
{
for (L2Spawn spawn : _buffers)
{
spawn.startRespawn();
spawn.respawnNpc(spawn.getLastSpawn());
spawn.stopRespawn();
}
}
public final void deleteBuffers()
{
for (L2Spawn spawn : _buffers)
{
if (spawn.getLastSpawn().isVisible())
{
spawn.getLastSpawn().deleteMe();
}
}
}
public final void broadcastStatusUpdate(L2PcInstance player)
{
final ExOlympiadUserInfo packet = new ExOlympiadUserInfo(player);
for (L2Character character : _characterList.values())
{
if (character instanceof L2PcInstance)
{
if (((L2PcInstance) character).inObserverMode() || (((L2PcInstance) character).getOlympiadSide() != player.getOlympiadSide()))
{
character.sendPacket(packet);
}
}
}
}
public final void broadcastPacketToObservers(L2GameServerPacket packet)
{
for (L2Character character : _characterList.values())
{
if ((character instanceof L2PcInstance) && ((L2PcInstance) character).inObserverMode())
{
character.sendPacket(packet);
}
}
}
@Override
protected final void onEnter(L2Character character)
{
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, true);
if (_task != null)
{
if (_task.isBattleStarted())
{
character.setInsideZone(L2Character.ZONE_PVP, true);
if (character instanceof L2PcInstance)
{
character.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENTERED_COMBAT_ZONE));
_task.getGame().sendOlympiadInfo(character);
}
}
}
if (character instanceof L2Playable)
{
final L2PcInstance player = character.getActingPlayer();
if (player != null)
{
// only participants, observers and GMs allowed
if (!player.isGM() && !player.isInOlympiadMode() && !player.inObserverMode())
{
ThreadPoolManager.getInstance().executeTask(new KickPlayer(player));
}
}
}
else if (character instanceof L2OlympiadManagerInstance)
{
final L2Spawn spawn = ((L2OlympiadManagerInstance) character).getSpawn();
if ((spawn != null) && !_buffers.contains(spawn))
{
_buffers.add(spawn);
spawn.stopRespawn();
character.deleteMe();
}
}
else if (character instanceof L2DoorInstance)
{
for (L2DoorInstance door : _doors)
{
if (door.getDoorId() == ((L2DoorInstance) character).getDoorId())
{
_doors.remove(door);
break;
}
}
_doors.add((L2DoorInstance) character);
}
}
@Override
protected final void onExit(L2Character character)
{
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, false);
if (_task != null)
{
if (_task.isBattleStarted())
{
character.setInsideZone(L2Character.ZONE_PVP, false);
if (character instanceof L2PcInstance)
{
character.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.LEFT_COMBAT_ZONE));
character.sendPacket(ExOlympiadMatchEnd.STATIC_PACKET);
}
}
}
if (character instanceof L2DoorInstance)
{
_doors.remove(character);
}
}
public final void updateZoneStatusForCharactersInside()
{
if (_task == null)
{
return;
}
final boolean battleStarted = _task.isBattleStarted();
final SystemMessage sm;
if (battleStarted)
{
sm = SystemMessage.getSystemMessage(SystemMessageId.ENTERED_COMBAT_ZONE);
}
else
{
sm = SystemMessage.getSystemMessage(SystemMessageId.LEFT_COMBAT_ZONE);
}
for (L2Character character : _characterList.values())
{
if (character == null)
{
continue;
}
if (battleStarted)
{
character.setInsideZone(L2Character.ZONE_PVP, true);
if (character instanceof L2PcInstance)
{
character.sendPacket(sm);
}
}
else
{
character.setInsideZone(L2Character.ZONE_PVP, false);
if (character instanceof L2PcInstance)
{
character.sendPacket(sm);
character.sendPacket(ExOlympiadMatchEnd.STATIC_PACKET);
}
}
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
private static final class KickPlayer implements Runnable
{
private L2PcInstance _player;
public KickPlayer(L2PcInstance player)
{
_player = player;
}
@Override
public void run()
{
if (_player != null)
{
final L2Summon summon = _player.getPet();
if (summon != null)
{
summon.unSummon(_player);
}
_player.teleToLocation(MapRegionTable.TeleportWhereType.Town);
_player = null;
}
}
}
}
@@ -0,0 +1,59 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
/**
* A peaceful zone
* @author durgus
*/
public class L2PeaceZone extends L2ZoneType
{
public L2PeaceZone(int id)
{
super(id);
}
@Override
protected void onEnter(L2Character character)
{
character.setInsideZone(L2Character.ZONE_PEACE, true);
if ((character instanceof L2PcInstance) && ((L2PcInstance) character).isCombatFlagEquipped() && TerritoryWarManager.getInstance().isTWInProgress())
{
TerritoryWarManager.getInstance().dropCombatFlag(((L2PcInstance) character), false, true);
}
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(L2Character.ZONE_PEACE, false);
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
}
@@ -0,0 +1,53 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
/**
* 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(L2Character.ZONE_SCRIPT, true);
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(L2Character.ZONE_SCRIPT, false);
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
}
@@ -0,0 +1,313 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import javolution.util.FastList;
import com.l2jserver.Config;
import com.l2jserver.gameserver.datatables.MapRegionTable;
import com.l2jserver.gameserver.datatables.SkillTable;
import com.l2jserver.gameserver.instancemanager.FortManager;
import com.l2jserver.gameserver.instancemanager.FortSiegeManager;
import com.l2jserver.gameserver.model.L2Clan;
import com.l2jserver.gameserver.model.L2Effect;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.actor.instance.L2SiegeSummonInstance;
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.zone.L2ZoneType;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
/**
* A siege zone
* @author durgus
*/
public class L2SiegeZone extends L2ZoneType
{
private int _siegableId = -1;
private Siegable _siege = null;
private boolean _isActiveSiege = false;
private static final int DISMOUNT_DELAY = 5;
public L2SiegeZone(int id)
{
super(id);
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("castleId"))
{
if (_siegableId != -1)
{
throw new IllegalArgumentException("Siege object already defined!");
}
_siegableId = Integer.parseInt(value);
}
else if (name.equals("fortId"))
{
if (_siegableId != -1)
{
throw new IllegalArgumentException("Siege object already defined!");
}
_siegableId = Integer.parseInt(value);
}
else if (name.equals("clanHallId"))
{
if (_siegableId != -1)
{
throw new IllegalArgumentException("Siege object already defined!");
}
_siegableId = Integer.parseInt(value);
// TODO clan hall siege
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (_isActiveSiege)
{
character.setInsideZone(L2Character.ZONE_PVP, true);
character.setInsideZone(L2Character.ZONE_SIEGE, true);
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, true);
if (character instanceof L2PcInstance)
{
if (((L2PcInstance) character).isRegisteredOnThisSiegeField(_siegableId))
{
((L2PcInstance) character).setIsInSiege(true); // in siege
if (_siege.giveFame())
{
((L2PcInstance) character).startFameTask(_siege.getFameFrequency() * 1000, _siege.getFameAmount());
}
}
((L2PcInstance) character).sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ENTERED_COMBAT_ZONE));
if (!Config.ALLOW_WYVERN_DURING_SIEGE && (((L2PcInstance) character).getMountType() == 2))
{
character.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.AREA_CANNOT_BE_ENTERED_WHILE_MOUNTED_WYVERN));
((L2PcInstance) character).enteredNoLanding(DISMOUNT_DELAY);
}
}
}
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(L2Character.ZONE_PVP, false);
character.setInsideZone(L2Character.ZONE_SIEGE, false);
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, false);
if (_isActiveSiege)
{
if (character instanceof L2PcInstance)
{
((L2PcInstance) character).sendPacket(SystemMessage.getSystemMessage(SystemMessageId.LEFT_COMBAT_ZONE));
if (((L2PcInstance) character).getMountType() == 2)
{
((L2PcInstance) character).exitedNoLanding();
}
// Set pvp flag
if (((L2PcInstance) character).getPvpFlag() == 0)
{
((L2PcInstance) character).startPvPFlag();
}
}
}
if (character instanceof L2PcInstance)
{
L2PcInstance activeChar = (L2PcInstance) character;
activeChar.stopFameTask();
activeChar.setIsInSiege(false);
if ((_siege instanceof FortSiege) && (activeChar.getInventory().getItemByItemId(9819) != null))
{
// drop combat flag
Fort fort = FortManager.getInstance().getFortById(_siegableId);
if (fort != null)
{
FortSiegeManager.getInstance().dropCombatFlag(activeChar, fort.getFortId());
}
else
{
int slot = activeChar.getInventory().getSlotFromItem(activeChar.getInventory().getItemByItemId(9819));
activeChar.getInventory().unEquipItemInBodySlot(slot);
activeChar.destroyItem("CombatFlag", activeChar.getInventory().getItemByItemId(9819), null, true);
}
}
}
if (character instanceof L2SiegeSummonInstance)
{
((L2SiegeSummonInstance) character).unSummon(((L2SiegeSummonInstance) character).getOwner());
}
}
@Override
public void onDieInside(L2Character character)
{
if (_isActiveSiege)
{
// debuff participants only if they die inside siege zone
if ((character instanceof L2PcInstance) && ((L2PcInstance) character).isRegisteredOnThisSiegeField(_siegableId))
{
int lvl = 1;
final L2Effect e = character.getFirstEffect(5660);
if (e != null)
{
lvl = Math.min(lvl + e.getLevel(), 5);
}
final L2Skill skill = SkillTable.getInstance().getInfo(5660, lvl);
if (skill != null)
{
skill.getEffects(character, character);
}
}
}
}
@Override
public void onReviveInside(L2Character character)
{
}
public void updateZoneStatusForCharactersInside()
{
if (_isActiveSiege)
{
for (L2Character character : _characterList.values())
{
if (character != null)
{
onEnter(character);
}
}
}
else
{
for (L2Character character : _characterList.values())
{
if (character == null)
{
continue;
}
character.setInsideZone(L2Character.ZONE_PVP, false);
character.setInsideZone(L2Character.ZONE_SIEGE, false);
character.setInsideZone(L2Character.ZONE_NOSUMMONFRIEND, false);
if (character instanceof L2PcInstance)
{
((L2PcInstance) character).sendPacket(SystemMessage.getSystemMessage(SystemMessageId.LEFT_COMBAT_ZONE));
((L2PcInstance) character).stopFameTask();
if (((L2PcInstance) character).getMountType() == 2)
{
((L2PcInstance) character).exitedNoLanding();
}
}
if (character instanceof L2SiegeSummonInstance)
{
((L2SiegeSummonInstance) character).unSummon(((L2SiegeSummonInstance) character).getOwner());
}
}
}
}
/**
* Sends a message to all players in this zone
* @param message
*/
public void announceToPlayers(String message)
{
for (L2Character temp : _characterList.values())
{
if (temp instanceof L2PcInstance)
{
((L2PcInstance) temp).sendMessage(message);
}
}
}
/**
* Returns all players within this zone
* @return
*/
public FastList<L2PcInstance> getAllPlayers()
{
FastList<L2PcInstance> players = new FastList<>();
for (L2Character temp : _characterList.values())
{
if (temp instanceof L2PcInstance)
{
players.add((L2PcInstance) temp);
}
}
return players;
}
public int getSiegeObjectId()
{
return _siegableId;
}
public boolean isActive()
{
return _isActiveSiege;
}
public void setIsActive(boolean val)
{
_isActiveSiege = val;
}
public void setSiegeInstance(Siegable siege)
{
_siege = siege;
}
/**
* Removes all foreigners from the zone
* @param owningClan
*/
public void banishForeigners(L2Clan owningClan)
{
for (L2Character temp : _characterList.values())
{
if (!(temp instanceof L2PcInstance))
{
continue;
}
if ((((L2PcInstance) temp).getClan() == owningClan) || ((L2PcInstance) temp).isGM())
{
continue;
}
((L2PcInstance) temp).teleToLocation(MapRegionTable.TeleportWhereType.Town);
}
}
}
@@ -0,0 +1,128 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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;
/**
* another type of zone where your speed is changed
* @author kerberos
*/
public class L2SwampZone extends L2ZoneType
{
private int _move_bonus;
private int _castleId;
private Castle _castle;
public L2SwampZone(int id)
{
super(id);
// Setup default speed reduce (in %)
_move_bonus = -50;
// no castle by default
_castleId = 0;
_castle = null;
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("move_bonus"))
{
_move_bonus = Integer.parseInt(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().getIsInProgress() || !getCastle().getSiege().isTrapsActive())
{
return;
}
// defenders not affected
final L2PcInstance player = character.getActingPlayer();
if ((player != null) && player.isInSiege() && (player.getSiegeState() == 2))
{
return;
}
}
character.setInsideZone(L2Character.ZONE_SWAMP, true);
if (character instanceof L2PcInstance)
{
((L2PcInstance) character).broadcastUserInfo();
}
}
@Override
protected void onExit(L2Character character)
{
// don't broadcast info if not needed
if (character.isInsideZone(L2Character.ZONE_SWAMP))
{
character.setInsideZone(L2Character.ZONE_SWAMP, false);
if (character instanceof L2PcInstance)
{
((L2PcInstance) character).broadcastUserInfo();
}
}
}
public int getMoveBonus()
{
return _move_bonus;
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
}
@@ -0,0 +1,135 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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.L2SpawnZone;
/**
* A Town zone
* @author durgus
*/
public class L2TownZone extends L2SpawnZone
{
private int _townId;
private int _taxById;
private boolean _isPeaceZone;
public L2TownZone(int id)
{
super(id);
_taxById = 0;
// Default not peace zone
_isPeaceZone = false;
}
@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 if (name.equals("isPeaceZone"))
{
_isPeaceZone = Boolean.parseBoolean(value);
}
else
{
super.setParameter(name, value);
}
}
@Override
protected void onEnter(L2Character character)
{
if (character instanceof L2PcInstance)
{
// 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 ((((L2PcInstance) character).getSiegeState() != 0) && (Config.ZONE_TOWN == 1))
{
return;
}
// ((L2PcInstance)character).sendMessage("You entered "+_townName);
}
if (_isPeaceZone && (Config.ZONE_TOWN != 2))
{
character.setInsideZone(L2Character.ZONE_PEACE, true);
}
character.setInsideZone(L2Character.ZONE_TOWN, true);
}
@Override
protected void onExit(L2Character character)
{
// TODO: there should be no exit if there was possibly no enter
if (_isPeaceZone)
{
character.setInsideZone(L2Character.ZONE_PEACE, false);
}
character.setInsideZone(L2Character.ZONE_TOWN, false);
// if (character instanceof L2PcInstance)
// ((L2PcInstance)character).sendMessage("You left "+_townName);
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
/**
* 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;
}
public final boolean isPeaceZone()
{
return _isPeaceZone;
}
}
@@ -0,0 +1,123 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.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.network.serverpackets.AbstractNpcInfo;
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(L2Character.ZONE_WATER, true);
if (character instanceof L2PcInstance)
{
if (((L2PcInstance) character).isTransformed() && !((L2PcInstance) character).isCursedWeaponEquipped())
{
character.stopTransformation(true);
// ((L2PcInstance) character).untransform();
}
// TODO: update to only send speed status when that packet is known
else
{
((L2PcInstance) character).broadcastUserInfo();
}
}
else if (character instanceof L2Npc)
{
Collection<L2PcInstance> plrs = character.getKnownList().getKnownPlayers().values();
// synchronized (character.getKnownList().getKnownPlayers())
{
for (L2PcInstance player : plrs)
{
if (character.getRunSpeed() == 0)
{
player.sendPacket(new ServerObjectInfo((L2Npc) character, player));
}
else
{
player.sendPacket(new AbstractNpcInfo.NpcInfo((L2Npc) character, player));
}
}
}
}
/*
* if (character instanceof L2PcInstance) { ((L2PcInstance)character).sendMessage("You entered water!"); }
*/
}
@Override
protected void onExit(L2Character character)
{
character.setInsideZone(L2Character.ZONE_WATER, false);
/*
* if (character instanceof L2PcInstance) { ((L2PcInstance)character).sendMessage("You exited water!"); }
*/
// TODO: update to only send speed status when that packet is known
if (character instanceof L2PcInstance)
{
((L2PcInstance) character).broadcastUserInfo();
}
else if (character instanceof L2Npc)
{
Collection<L2PcInstance> plrs = character.getKnownList().getKnownPlayers().values();
// synchronized (character.getKnownList().getKnownPlayers())
{
for (L2PcInstance player : plrs)
{
if (character.getRunSpeed() == 0)
{
player.sendPacket(new ServerObjectInfo((L2Npc) character, player));
}
else
{
player.sendPacket(new AbstractNpcInfo.NpcInfo((L2Npc) character, player));
}
}
}
}
}
@Override
public void onDieInside(L2Character character)
{
}
@Override
public void onReviveInside(L2Character character)
{
}
public int getWaterZ()
{
return getZone().getHighZ();
}
}