Addition of instant teleporting methods.

This commit is contained in:
MobiusDevelopment
2021-04-04 16:41:22 +00:00
parent a0996ae9a8
commit 8b1e96454a
253 changed files with 861 additions and 1085 deletions

View File

@@ -26,7 +26,6 @@ import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.serverpackets.FlyToLocation;
import org.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
import org.l2jmobius.gameserver.util.Util;
/**
@@ -73,7 +72,6 @@ public class Blink extends AbstractEffect
effected.broadcastPacket(new FlyToLocation(effected, destination, FlyType.DUMMY));
effected.abortAttack();
effected.abortCast();
effected.setXYZ(destination);
effected.broadcastPacket(new ValidateLocation(effected));
effected.teleToLocationInstant(destination);
}
}

View File

@@ -24,7 +24,6 @@ import org.l2jmobius.gameserver.model.effects.AbstractEffect;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.serverpackets.FlyToLocation;
import org.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
/**
* Enemy Charge effect implementation.
@@ -92,9 +91,6 @@ public class EnemyCharge extends AbstractEffect
final int z = info.getEffected().getZ();
final Location destination = GeoEngine.getInstance().getValidLocation(info.getEffector().getX(), info.getEffector().getY(), info.getEffector().getZ(), x, y, z, info.getEffector().getInstanceId());
info.getEffector().broadcastPacket(new FlyToLocation(info.getEffector(), destination, FlyType.CHARGE));
// maybe is need force set X,Y,Z
info.getEffector().setXYZ(destination);
info.getEffector().broadcastPacket(new ValidateLocation(info.getEffector()));
info.getEffector().teleToLocationInstant(destination);
}
}

View File

@@ -27,7 +27,6 @@ import org.l2jmobius.gameserver.model.effects.EffectType;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.serverpackets.FlyToLocation;
import org.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
import org.l2jmobius.gameserver.util.Util;
/**
@@ -87,7 +86,6 @@ public class TeleportToTarget extends AbstractEffect
creature.broadcastPacket(new FlyToLocation(creature, loc.getX(), loc.getY(), loc.getZ(), FlyType.DUMMY));
creature.abortAttack();
creature.abortCast();
creature.setXYZ(loc);
creature.broadcastPacket(new ValidateLocation(creature));
creature.teleToLocationInstant(loc);
}
}

View File

@@ -25,7 +25,6 @@ import org.l2jmobius.gameserver.model.effects.EffectFlag;
import org.l2jmobius.gameserver.model.skills.BuffInfo;
import org.l2jmobius.gameserver.network.serverpackets.FlyToLocation;
import org.l2jmobius.gameserver.network.serverpackets.FlyToLocation.FlyType;
import org.l2jmobius.gameserver.network.serverpackets.ValidateLocation;
/**
* Throw Up effect implementation.
@@ -95,8 +94,6 @@ public class ThrowUp extends AbstractEffect
final int z = info.getEffected().getZ();
final Location destination = GeoEngine.getInstance().getValidLocation(info.getEffected().getX(), info.getEffected().getY(), info.getEffected().getZ(), x, y, z, info.getEffected().getInstanceId());
info.getEffected().broadcastPacket(new FlyToLocation(info.getEffected(), destination, FlyType.THROW_UP));
// TODO: Review.
info.getEffected().setXYZ(destination);
info.getEffected().broadcastPacket(new ValidateLocation(info.getEffected()));
info.getEffected().teleToLocationInstant(destination);
}
}

View File

@@ -627,13 +627,13 @@ public class Duel
final Location spawn1 = spawns.get(Rnd.get(spawns.size() / 2));
for (PlayerInstance temp : _playerA.getParty().getMembers())
{
temp.teleToLocation(spawn1.getX(), spawn1.getY(), spawn1.getZ(), 0, _duelInstanceId, 0);
temp.teleToLocation(spawn1.getX(), spawn1.getY(), spawn1.getZ(), 0, _duelInstanceId, 0, false);
}
final Location spawn2 = spawns.get(Rnd.get(spawns.size() / 2, spawns.size()));
for (PlayerInstance temp : _playerB.getParty().getMembers())
{
temp.teleToLocation(spawn2.getX(), spawn2.getY(), spawn2.getZ(), 0, _duelInstanceId, 0);
temp.teleToLocation(spawn2.getX(), spawn2.getY(), spawn2.getZ(), 0, _duelInstanceId, 0, false);
}
}

View File

@@ -681,8 +681,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
* @param headingValue
* @param instanceId
* @param randomOffset
* @param instant
*/
public void teleToLocation(int xValue, int yValue, int zValue, int headingValue, int instanceId, int randomOffset)
public void teleToLocation(int xValue, int yValue, int zValue, int headingValue, int instanceId, int randomOffset, boolean instant)
{
int x = xValue;
int y = yValue;
@@ -714,7 +715,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
z += 5;
// Send a Server->Client packet TeleportToLocationt to the Creature AND to all PlayerInstance in the _KnownPlayers of the Creature
broadcastPacket(new TeleportToLocation(this, x, y, z, heading));
broadcastPacket(new TeleportToLocation(this, x, y, z, heading, instant));
// remove the object from its old location
decayMe();
@@ -739,52 +740,52 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
public void teleToLocation(int x, int y, int z, int heading, int instanceId, boolean randomOffset)
{
teleToLocation(x, y, z, heading, instanceId, (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0);
teleToLocation(x, y, z, heading, instanceId, (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0, false);
}
public void teleToLocation(int x, int y, int z, int heading, int instanceId)
{
teleToLocation(x, y, z, heading, instanceId, 0);
teleToLocation(x, y, z, heading, instanceId, 0, false);
}
public void teleToLocation(int x, int y, int z, int heading, boolean randomOffset)
{
teleToLocation(x, y, z, heading, -1, (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0);
teleToLocation(x, y, z, heading, -1, (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0, false);
}
public void teleToLocation(int x, int y, int z, int heading)
{
teleToLocation(x, y, z, heading, -1, 0);
teleToLocation(x, y, z, heading, -1, 0, false);
}
public void teleToLocation(int x, int y, int z, boolean randomOffset)
{
teleToLocation(x, y, z, 0, -1, (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0);
teleToLocation(x, y, z, 0, -1, (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0, false);
}
public void teleToLocation(int x, int y, int z)
{
teleToLocation(x, y, z, 0, -1, 0);
teleToLocation(x, y, z, 0, -1, 0, false);
}
public void teleToLocation(ILocational loc, int randomOffset)
{
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), randomOffset);
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), randomOffset, false);
}
public void teleToLocation(ILocational loc, int instanceId, int randomOffset)
{
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), instanceId, randomOffset);
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), instanceId, randomOffset, false);
}
public void teleToLocation(ILocational loc, boolean randomOffset)
{
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0);
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0, false);
}
public void teleToLocation(ILocational loc)
{
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), 0);
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), 0, false);
}
public void teleToLocation(TeleportWhereType teleportWhere)
@@ -792,6 +793,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
teleToLocation(MapRegionManager.getInstance().getTeleToLocation(this, teleportWhere), true);
}
public void teleToLocationInstant(ILocational loc)
{
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), getHeading() /* Use the current heading */, getInstanceId(), 0, true);
}
public void teleToLocationInstant(int x, int y, int z)
{
teleToLocation(x, y, z, getHeading(), getInstanceId(), 0, true);
}
private boolean canUseRangeWeapon()
{
if (isTransformed())

View File

@@ -902,7 +902,7 @@ public abstract class Summon extends Playable
public synchronized void onTeleported()
{
super.onTeleported();
sendPacket(new TeleportToLocation(this, getX(), getY(), getZ(), getHeading()));
sendPacket(new TeleportToLocation(this, getX(), getY(), getZ(), getHeading(), false));
}
@Override

View File

@@ -27,26 +27,29 @@ public class TeleportToLocation implements IClientOutgoingPacket
private final int _y;
private final int _z;
private final int _heading;
private final boolean _instant;
public TeleportToLocation(WorldObject obj, int x, int y, int z, int heading)
public TeleportToLocation(WorldObject obj, int x, int y, int z, int heading, boolean instant)
{
_targetObjId = obj.getObjectId();
_x = x;
_y = y;
_z = z;
_heading = heading;
_instant = instant;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.TELEPORT_TO_LOCATION.writeId(packet);
packet.writeD(_targetObjId);
packet.writeD(_x);
packet.writeD(_y);
packet.writeD(_z);
packet.writeD(0x00); // isValidation ??
packet.writeD(_heading); // nYaw
packet.writeD(_instant ? 0x01 : 0x00);
packet.writeD(_heading);
return true;
}
}