Fixed losing target with instant teleport.

This commit is contained in:
MobiusDevelopment
2021-04-06 22:05:56 +00:00
parent b5318b1f40
commit 7e112206dc
251 changed files with 1254 additions and 1156 deletions

View File

@@ -26,6 +26,7 @@ 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;
/**
@@ -72,6 +73,7 @@ public class Blink extends AbstractEffect
effected.broadcastPacket(new FlyToLocation(effected, destination, FlyType.DUMMY));
effected.abortAttack();
effected.abortCast();
effected.teleToLocationInstant(destination);
effected.setXYZ(destination);
effected.broadcastPacket(new ValidateLocation(effected));
}
}

View File

@@ -24,6 +24,7 @@ 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.
@@ -91,6 +92,7 @@ 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));
info.getEffector().teleToLocationInstant(destination);
info.getEffector().setXYZ(destination);
info.getEffector().broadcastPacket(new ValidateLocation(info.getEffector()));
}
}

View File

@@ -27,6 +27,7 @@ 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;
/**
@@ -86,6 +87,7 @@ public class TeleportToTarget extends AbstractEffect
creature.broadcastPacket(new FlyToLocation(creature, loc.getX(), loc.getY(), loc.getZ(), FlyType.DUMMY));
creature.abortAttack();
creature.abortCast();
creature.teleToLocationInstant(loc);
creature.setXYZ(loc);
creature.broadcastPacket(new ValidateLocation(creature));
}
}

View File

@@ -25,6 +25,7 @@ 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.
@@ -94,6 +95,7 @@ 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));
info.getEffected().teleToLocationInstant(destination);
info.getEffected().setXYZ(destination);
info.getEffected().broadcastPacket(new ValidateLocation(info.getEffected()));
}
}

View File

@@ -680,55 +680,56 @@ 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, boolean instant)
public void teleToLocation(int xValue, int yValue, int zValue, int headingValue, int instanceId, int randomOffset)
{
int x = xValue;
int y = yValue;
int z = zValue;
int heading = headingValue;
setInstanceId(instanceId);
// Prepare creature for teleport.
if (_isPendingRevive)
{
doRevive();
}
// Abort any client actions, casting and remove target.
stopMove(null);
abortAttack();
abortCast();
setTarget(null);
setTeleporting(true);
setTarget(null);
getAI().setIntention(AI_INTENTION_ACTIVE);
// Remove the object from its old location.
decayMe();
// Adjust position a bit.
if (Config.OFFSET_ON_TELEPORT_ENABLED && (randomOffset > 0))
{
x += Rnd.get(-randomOffset, randomOffset);
y += Rnd.get(-randomOffset, randomOffset);
}
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, instant));
// Send teleport packet where needed.
broadcastPacket(new TeleportToLocation(this, x, y, z, heading));
// remove the object from its old location
decayMe();
// Change instance id.
setInstanceId(instanceId);
// Set the x,y,z position of the WorldObject and if necessary modify its _worldRegion
// Set the x,y,z position of the WorldObject and if necessary modify its _worldRegion.
setXYZ(x, y, z);
// temporary fix for heading on teleports
// Also adjust heading.
if (heading != 0)
{
setHeading(heading);
}
// allow recall of the detached characters
// Allow recall of the detached characters.
if (!isPlayer() || ((getActingPlayer().getClient() != null) && getActingPlayer().getClient().isDetached()))
{
onTeleported();
@@ -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, false);
teleToLocation(x, y, z, heading, instanceId, (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0);
}
public void teleToLocation(int x, int y, int z, int heading, int instanceId)
{
teleToLocation(x, y, z, heading, instanceId, 0, false);
teleToLocation(x, y, z, heading, instanceId, 0);
}
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, false);
teleToLocation(x, y, z, heading, -1, (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0);
}
public void teleToLocation(int x, int y, int z, int heading)
{
teleToLocation(x, y, z, heading, -1, 0, false);
teleToLocation(x, y, z, heading, -1, 0);
}
public void teleToLocation(int x, int y, int z, boolean randomOffset)
{
teleToLocation(x, y, z, 0, -1, (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0, false);
teleToLocation(x, y, z, 0, -1, (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0);
}
public void teleToLocation(int x, int y, int z)
{
teleToLocation(x, y, z, 0, -1, 0, false);
teleToLocation(x, y, z, 0, -1, 0);
}
public void teleToLocation(ILocational loc, int randomOffset)
{
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), randomOffset, false);
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), randomOffset);
}
public void teleToLocation(ILocational loc, int instanceId, int randomOffset)
{
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), instanceId, randomOffset, false);
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), instanceId, randomOffset);
}
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, false);
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), (randomOffset) ? Config.MAX_OFFSET_ON_TELEPORT : 0);
}
public void teleToLocation(ILocational loc)
{
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), 0, false);
teleToLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getHeading(), loc.getInstanceId(), 0);
}
public void teleToLocation(TeleportWhereType teleportWhere)
@@ -792,16 +793,6 @@ 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(), false));
sendPacket(new TeleportToLocation(this, getX(), getY(), getZ(), getHeading()));
}
@Override

View File

@@ -121,10 +121,6 @@ public class ValidatePosition implements IClientIncomingPacket
player.stopMove(null);
}
}
else
{
player.setXYZ(_x, _y, _z);
}
player.sendPacket(new ValidateLocation(player));
}

View File

@@ -27,16 +27,14 @@ 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, boolean instant)
public TeleportToLocation(WorldObject obj, int x, int y, int z, int heading)
{
_targetObjId = obj.getObjectId();
_x = x;
_y = y;
_z = z;
_heading = heading;
_instant = instant;
}
@Override
@@ -48,7 +46,7 @@ public class TeleportToLocation implements IClientOutgoingPacket
packet.writeD(_x);
packet.writeD(_y);
packet.writeD(_z);
packet.writeD(_instant ? 0x01 : 0x00);
packet.writeD(0x00); // Fade 0, Instant 1.
packet.writeD(_heading);
return true;
}