Added Sayune.

This commit is contained in:
mobius
2015-01-03 10:55:42 +00:00
parent 44ee984365
commit 7e473d3efd
16 changed files with 1301 additions and 3 deletions

View File

@@ -118,6 +118,7 @@ import com.l2jserver.gameserver.instancemanager.GrandBossManager;
import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.instancemanager.ItemAuctionManager;
import com.l2jserver.gameserver.instancemanager.ItemsOnGroundManager;
import com.l2jserver.gameserver.instancemanager.JumpManager;
import com.l2jserver.gameserver.instancemanager.MailManager;
import com.l2jserver.gameserver.instancemanager.MapRegionManager;
import com.l2jserver.gameserver.instancemanager.MentorManager;
@@ -307,6 +308,7 @@ public class GameServer
BoatManager.getInstance();
AirShipManager.getInstance();
ShuttleData.getInstance();
JumpManager.getInstance();
GraciaSeedsManager.getInstance();
try

View File

@@ -0,0 +1,251 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.instancemanager;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.l2jserver.Config;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.zone.L2ZoneType;
import com.l2jserver.gameserver.model.zone.ZoneId;
import com.l2jserver.gameserver.model.zone.type.L2JumpZone;
import com.l2jserver.gameserver.network.serverpackets.ExFlyMove;
import com.l2jserver.gameserver.network.serverpackets.FlyToLocation;
import com.l2jserver.gameserver.network.serverpackets.FlyToLocation.FlyType;
/**
* JumpManager
* @author ALF
*/
public class JumpManager
{
private static final Logger _log = Logger.getLogger(JumpManager.class.getName());
private final Map<Integer, Track> _tracks = new HashMap<>();
public class Track extends HashMap<Integer, JumpWay>
{
private static final long serialVersionUID = 1L;
public int x = 0;
public int y = 0;
public int z = 0;
}
public class JumpWay extends ArrayList<JumpNode>
{
private static final long serialVersionUID = 1L;
}
public class JumpNode
{
private final int _x;
private final int _y;
private final int _z;
private final int _next;
public JumpNode(int x, int y, int z, int next)
{
_x = x;
_y = y;
_z = z;
_next = next;
}
public int getX()
{
return _x;
}
public int getY()
{
return _y;
}
public int getZ()
{
return _z;
}
public int getNext()
{
return _next;
}
}
protected JumpManager()
{
load();
}
public void load()
{
_tracks.clear();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);
factory.setIgnoringComments(true);
File file = new File(Config.DATAPACK_ROOT, "data/JumpTrack.xml");
Document doc = null;
if (file.exists())
{
try
{
doc = factory.newDocumentBuilder().parse(file);
}
catch (Exception e)
{
_log.log(Level.WARNING, "Could not parse JumpTrack.xml file: " + e.getMessage(), e);
return;
}
Node root = doc.getFirstChild();
for (Node t = root.getFirstChild(); t != null; t = t.getNextSibling())
{
if (t.getNodeName().equals("track"))
{
Track track = new Track();
int trackId = Integer.parseInt(t.getAttributes().getNamedItem("trackId").getNodeValue());
try
{
track.x = Integer.parseInt(t.getAttributes().getNamedItem("ToX").getNodeValue());
track.y = Integer.parseInt(t.getAttributes().getNamedItem("ToY").getNodeValue());
track.z = Integer.parseInt(t.getAttributes().getNamedItem("ToZ").getNodeValue());
}
catch (Exception e)
{
_log.info("track id:" + trackId + " missing tox toy toz");
}
for (Node w = t.getFirstChild(); w != null; w = w.getNextSibling())
{
if (w.getNodeName().equals("way"))
{
JumpWay jw = new JumpWay();
int wayId = Integer.parseInt(w.getAttributes().getNamedItem("id").getNodeValue());
for (Node j = w.getFirstChild(); j != null; j = j.getNextSibling())
{
if (j.getNodeName().equals("jumpLoc"))
{
NamedNodeMap attrs = j.getAttributes();
int next = Integer.parseInt(attrs.getNamedItem("next").getNodeValue());
int x = Integer.parseInt(attrs.getNamedItem("x").getNodeValue());
int y = Integer.parseInt(attrs.getNamedItem("y").getNodeValue());
int z = Integer.parseInt(attrs.getNamedItem("z").getNodeValue());
jw.add(new JumpNode(x, y, z, next));
}
}
track.put(wayId, jw);
}
}
_tracks.put(trackId, track);
}
}
}
_log.info(getClass().getSimpleName() + ": Loaded " + _tracks.size() + " Jump Routes.");
}
public int getTrackId(L2PcInstance player)
{
for (L2ZoneType zone : L2World.getInstance().getRegion(player.getX(), player.getY()).getZones())
{
if (zone.isCharacterInZone(player) && (zone instanceof L2JumpZone))
{
return ((L2JumpZone) zone).getTrackId();
}
}
return -1;
}
public Track getTrack(int trackId)
{
return _tracks.get(trackId);
}
public JumpWay getJumpWay(int trackId, int wayId)
{
Track t = _tracks.get(trackId);
if (t != null)
{
return t.get(wayId);
}
return null;
}
public void StartJump(L2PcInstance player)
{
if (!player.isInsideZone(ZoneId.JUMP))
{
return;
}
player.setJumpTrackId(getTrackId(player));
if (player.getJumpTrackId() == -1)
{
return;
}
JumpWay jw = getJumpWay(player.getJumpTrackId(), 0);
if (jw == null)
{
return;
}
Track t = getTrack(player.getJumpTrackId());
if (!((t.x == 0) && (t.y == 0) && (t.z == 0)))
{
player.broadcastPacket(new FlyToLocation(player, t.x, t.y, t.z, FlyType.DUMMY));
player.setXYZ(t.x, t.y, t.z);
}
player.sendPacket(new ExFlyMove(player.getObjectId(), player.getJumpTrackId(), jw));
}
public void NextJump(L2PcInstance player, int nextId)
{
if (player.getJumpTrackId() == -1)
{
return;
}
JumpWay jw = getJumpWay(player.getJumpTrackId(), nextId);
if (jw == null)
{
player.enableAllSkills(); // unlock player skills
return;
}
player.sendPacket(new ExFlyMove(player.getObjectId(), player.getJumpTrackId(), jw));
JumpNode n = jw.get(0);
player.setXYZ(n.getX(), n.getY(), n.getZ());
}
public static final JumpManager getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final JumpManager _instance = new JumpManager();
}
}

View File

@@ -900,6 +900,8 @@ public final class L2PcInstance extends L2Playable
private boolean _hasCharmOfCourage = false;
private int _jumpTrackId = 0;
/**
* Create a new L2PcInstance and add it in the characters table of the database.<br>
* <B><U> Actions</U> :</B>
@@ -14419,4 +14421,23 @@ public final class L2PcInstance extends L2Playable
{
getVariables().set("ABILITY_POINTS_USED", points);
}
public boolean isAwaken()
{
if (((getActiveClass() >= 139) && (getActiveClass() <= 181)) || (getActiveClass() >= 188))
{
return true;
}
return false;
}
public int getJumpTrackId()
{
return _jumpTrackId;
}
public void setJumpTrackId(int jumpTrackId)
{
_jumpTrackId = jumpTrackId;
}
}

View File

@@ -46,7 +46,8 @@ public enum ZoneId
ALTERED,
NO_BOOKMARK,
NO_ITEM_DROP,
NO_RESTART;
NO_RESTART,
JUMP;
public static int getZoneCount()
{

View File

@@ -0,0 +1,139 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.model.zone.type;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Future;
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.model.zone.ZoneId;
import com.l2jserver.gameserver.network.serverpackets.ExNotifyFlyMoveStart;
/**
* L2JumpZone zones
* @author ALF (r2max)
*/
public class L2JumpZone extends L2ZoneType
{
private final Map<Integer, Future<?>> _task = new HashMap<>();
private final int _startTask;
private final int _reuseTask;
private int _trackId;
public L2JumpZone(int id)
{
super(id);
_startTask = 10;
_reuseTask = 500;
_trackId = -1;
}
@Override
public void setParameter(String name, String value)
{
if (name.equals("trackId"))
{
_trackId = Integer.parseInt(value);
}
else
{
super.setParameter(name, value);
}
}
public int getTrackId()
{
return _trackId;
}
@Override
protected void onEnter(L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.JUMP, true);
}
if (character instanceof L2PcInstance)
{
L2PcInstance plr = (L2PcInstance) character;
if (!plr.isAwaken() && !Config.FREE_JUMPS_FOR_ALL)
{
return;
}
stopTask(plr);
_task.put(plr.getObjectId(), ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new JumpReq(plr), _startTask, _reuseTask));
}
}
@Override
protected void onExit(L2Character character)
{
if (character.isPlayer())
{
character.setInsideZone(ZoneId.JUMP, false);
}
stopTask(character);
}
@Override
public void onDieInside(L2Character character)
{
onExit(character);
}
@Override
public void onReviveInside(L2Character character)
{
onEnter(character);
}
protected void stopTask(L2Character character)
{
int poid = character.getObjectId();
Future<?> t = _task.get(poid);
_task.remove(poid);
if (t != null)
{
t.cancel(false);
}
}
class JumpReq implements Runnable
{
private final L2PcInstance player;
JumpReq(L2PcInstance pl)
{
player = pl;
}
@Override
public void run()
{
player.sendPacket(new ExNotifyFlyMoveStart());
}
}
}

View File

@@ -1302,7 +1302,7 @@ public final class L2GamePacketHandler implements IPacketHandler<L2GameClient>,
// @ msg = new RequestExEscapeScene();
break;
case 0x91:
// msg = new RequestFlyMove();
msg = new RequestFlyMove();
break;
case 0x92:
// msg = new RequestSurrenderPledgeWarEX(); (chS)
@@ -1392,7 +1392,7 @@ public final class L2GamePacketHandler implements IPacketHandler<L2GameClient>,
// msg = new RequestFirstPlayStart();
break;
case 0xAD:
// msg = new RequestFlyMoveStart();
msg = new RequestFlyMoveStart();
break;
case 0xAE:
case 0xAF:

View File

@@ -22,10 +22,13 @@ import java.nio.BufferUnderflowException;
import com.l2jserver.Config;
import com.l2jserver.gameserver.ai.CtrlIntention;
import com.l2jserver.gameserver.instancemanager.JumpManager;
import com.l2jserver.gameserver.instancemanager.JumpManager.JumpWay;
import com.l2jserver.gameserver.model.Location;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
import com.l2jserver.gameserver.network.serverpackets.ExFlyMove;
import com.l2jserver.gameserver.network.serverpackets.StopMove;
import com.l2jserver.gameserver.util.Util;
@@ -101,6 +104,26 @@ public class MoveBackwardToLocation extends L2GameClientPacket
if (activeChar.getTeleMode() > 0)
{
// Sayune
if ((activeChar.getTeleMode() == 3) || (activeChar.getTeleMode() == 4))
{
if (activeChar.getTeleMode() == 3)
{
activeChar.setTeleMode(0);
}
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
activeChar.stopMove(null, false);
activeChar.abortAttack();
activeChar.abortCast();
activeChar.setTarget(null);
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
JumpWay jw = JumpManager.getInstance().new JumpWay();
jw.add(JumpManager.getInstance().new JumpNode(_targetX, _targetY, _targetZ, -1));
activeChar.sendPacket(new ExFlyMove(activeChar.getObjectId(), -1, jw));
activeChar.setXYZ(_targetX, _targetY, _targetZ);
return;
}
if (activeChar.getTeleMode() == 1)
{
activeChar.setTeleMode(0);

View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.instancemanager.JumpManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* Format: (ch)d
* @author mrTJO
*/
public final class RequestFlyMove extends L2GameClientPacket
{
private static final String _C__D0_94_REQUESTFLYMOVE = "[C] D0:94 RequestFlyMove";
int _nextPoint;
@Override
protected void readImpl()
{
_nextPoint = readD();
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
JumpManager.getInstance().NextJump(activeChar, _nextPoint);
}
@Override
public String getType()
{
return _C__D0_94_REQUESTFLYMOVE;
}
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.clientpackets;
import com.l2jserver.gameserver.instancemanager.JumpManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
public final class RequestFlyMoveStart extends L2GameClientPacket
{
private static final String _C__D0_AD_REQUESTFLYMOVESTART = "[C] D0:AD RequestFlyMoveStart";
@Override
protected void readImpl()
{
}
@Override
protected void runImpl()
{
final L2PcInstance activeChar = getClient().getActiveChar();
if (activeChar == null)
{
return;
}
if (activeChar.isFlying() || activeChar.isMounted() || activeChar.isFlyingMounted() || activeChar.isInBoat() || activeChar.isInAirShip())
{
return;
}
if (activeChar.isTransformed() || activeChar.isCursedWeaponEquipped() || activeChar.isFishing())
{
return;
}
if (activeChar.isCastingNow() || activeChar.isCastingSimultaneouslyNow() || activeChar.isAttackingNow() || activeChar.isInCombat() || activeChar.isInDuel())
{
return;
}
if (activeChar.isStunned() || activeChar.isParalyzed() || activeChar.isSleeping() || activeChar.isAfraid() || activeChar.isAlikeDead() || activeChar.isFakeDeath())
{
return;
}
if (activeChar.isDead() || activeChar.isOutOfControl() || activeChar.isMovementDisabled())
{
return;
}
if (activeChar.isSitting() || activeChar.isMoving() || activeChar.isTeleporting())
{
return;
}
if (activeChar.isInStoreMode() || activeChar.isInCraftMode() || activeChar.isInOlympiadMode())
{
return;
}
activeChar.disableAllSkills(); // lock player skills
JumpManager.getInstance().StartJump(activeChar);
}
@Override
public String getType()
{
return _C__D0_AD_REQUESTFLYMOVESTART;
}
}

View File

@@ -0,0 +1,75 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.gameserver.instancemanager.JumpManager.JumpNode;
import com.l2jserver.gameserver.instancemanager.JumpManager.JumpWay;
/**
* Created by IntelliJ IDEA. User: Keiichi Date: 27.05.2011 Time: 12:06:19 To change this template use File | Settings | File Templates.
*/
public class ExFlyMove extends L2GameServerPacket
{
final int _objId;
final int _trackId;
final JumpWay _jw;
public ExFlyMove(int objid, int trackId, JumpWay jw)
{
_objId = objid;
_trackId = trackId;
_jw = jw;
}
@Override
protected void writeImpl()
{
if (_jw == null)
{
return;
}
writeC(0xfe);
writeH(0xe8);
writeD(_objId);
if (_jw.size() == 1)
{
writeD(2);
}
else
{
writeD(0);
}
writeD(0);
writeD(_trackId);
writeD(_jw.size());
for (JumpNode n : _jw)
{
writeD(n.getNext());
writeD(0);
writeD(n.getX());
writeD(n.getY());
writeD(n.getZ());
}
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 2004-2015 L2J Server
*
* This file is part of L2J Server.
*
* L2J Server is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* L2J Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.network.serverpackets;
/**
* @author mrTJO
*/
public final class ExNotifyFlyMoveStart extends L2GameServerPacket
{
public ExNotifyFlyMoveStart()
{
}
@Override
protected void writeImpl()
{
writeC(0xFE);
writeH(0x110);
}
}