From 7014a1ebede044fe316cd9f505f81101b9f1ab0e Mon Sep 17 00:00:00 2001 From: MobiusDev <8391001+MobiusDevelopment@users.noreply.github.com> Date: Tue, 15 May 2018 14:15:49 +0000 Subject: [PATCH] Retail flying dismount prohibition. --- .../gameserver/model/actor/L2Character.java | 5 ++ .../model/actor/instance/L2PcInstance.java | 72 +++++++++++++----- .../clientpackets/ValidatePosition.java | 6 +- .../gameserver/model/actor/L2Character.java | 5 ++ .../model/actor/instance/L2PcInstance.java | 72 +++++++++++++----- .../clientpackets/ValidatePosition.java | 6 +- .../gameserver/model/actor/L2Character.java | 5 ++ .../model/actor/instance/L2PcInstance.java | 72 +++++++++++++----- .../clientpackets/ValidatePosition.java | 6 +- .../gameserver/model/actor/L2Character.java | 5 ++ .../model/actor/instance/L2PcInstance.java | 72 +++++++++++++----- .../clientpackets/ValidatePosition.java | 6 +- .../model/actor/instance/L2PcInstance.java | 63 +++++++++++----- .../gameserver/network/SystemMessageId.java | 12 +++ .../clientpackets/ValidatePosition.java | 6 +- .../model/actor/instance/L2PcInstance.java | 74 ++++++++++++++----- .../clientpackets/ValidatePosition.java | 6 +- .../gameserver/model/actor/L2Character.java | 5 ++ .../model/actor/instance/L2PcInstance.java | 72 +++++++++++++----- .../clientpackets/ValidatePosition.java | 6 +- .../gameserver/model/actor/L2Character.java | 5 ++ .../model/actor/instance/L2PcInstance.java | 72 +++++++++++++----- .../clientpackets/ValidatePosition.java | 6 +- .../gameserver/model/actor/L2Character.java | 5 ++ .../model/actor/instance/L2PcInstance.java | 72 +++++++++++++----- .../clientpackets/ValidatePosition.java | 6 +- 26 files changed, 527 insertions(+), 215 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 6e08eb8525..87c5450087 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -467,6 +467,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe public void untransform() { + if (isPlayer() && getActingPlayer().isFlyingMounted() && !getActingPlayer().canDismount()) + { + return; + } + _transform.ifPresent(t -> t.onUntransform(this)); _transform = Optional.empty(); diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index bf8657f2d9..22b3be600c 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -257,6 +257,7 @@ import com.l2jmobius.gameserver.model.variables.AccountVariables; import com.l2jmobius.gameserver.model.variables.PlayerVariables; import com.l2jmobius.gameserver.model.zone.L2ZoneType; import com.l2jmobius.gameserver.model.zone.ZoneId; +import com.l2jmobius.gameserver.model.zone.type.L2WaterZone; import com.l2jmobius.gameserver.network.Disconnection; import com.l2jmobius.gameserver.network.L2GameClient; import com.l2jmobius.gameserver.network.SystemMessageId; @@ -502,8 +503,6 @@ public final class L2PcInstance extends L2Playable private int _mountLevel; /** Store object used to summon the strider you are mounting **/ private int _mountObjectID = 0; - /** Remember if dismounted from Wyvern **/ - private boolean _hasDismountedWyvern = false; private AdminTeleportType _teleportType = AdminTeleportType.NORMAL; @@ -767,7 +766,7 @@ public final class L2PcInstance extends L2Playable // during fall validations will be disabled for 1000 ms. private static final int FALLING_VALIDATION_DELAY = 1000; private volatile long _fallingTimestamp = 0; - private volatile int _fallingDamageSum = 0; + private volatile int _fallingDamage = 0; private Future _fallingDamageTask = null; private int _multiSocialTarget = 0; @@ -6140,16 +6139,18 @@ public final class L2PcInstance extends L2Playable public boolean dismount() { - final boolean wasFlying = isFlying(); + if (!canDismount()) + { + return false; + } + final boolean wasFlying = isFlying(); sendPacket(new SetupGauge(3, 0, 0)); final int petId = _mountNpcId; setMount(0, 0); stopFeed(); - clearPetData(); if (wasFlying) { - _hasDismountedWyvern = true; removeSkill(CommonSkill.WYVERN_BREATH.getSkill()); } broadcastPacket(new Ride(this)); @@ -6160,9 +6161,42 @@ public final class L2PcInstance extends L2Playable return true; } - public boolean hasDismountedWyvern() + public boolean canDismount() { - return _hasDismountedWyvern; + L2WaterZone water = null; + for (L2ZoneType zone : ZoneManager.getInstance().getZones(getX(), getY(), getZ() - 300)) + { + if (zone instanceof L2WaterZone) + { + water = (L2WaterZone) zone; + } + } + if (water == null) + { + if (!isInWater() && (getZ() > 10000)) + { + sendPacket(SystemMessageId.YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_IN_THIS_LOCATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + if ((GeoEngine.getInstance().getHeight(getX(), getY(), getZ()) + 300) < getZ()) + { + sendPacket(SystemMessageId.YOU_CANNOT_DISMOUNT_FROM_THIS_ELEVATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + } + else + { + ThreadPool.schedule(() -> + { + if (isInWater()) + { + broadcastUserInfo(); + } + }, 1500); + } + return true; } public void setUptime(long time) @@ -12678,29 +12712,29 @@ public final class L2PcInstance extends L2Playable return false; } - // TODO: Test on retail. Add or set damage? - _fallingDamageSum += (int) Formulas.calcFallDam(this, deltaZ); + if (_fallingDamage == 0) + { + _fallingDamage = (int) Formulas.calcFallDam(this, deltaZ); + } if (_fallingDamageTask != null) { _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> { - if ((_fallingDamageSum > 0) && !isInvul()) + if ((_fallingDamage > 0) && !isInvul()) { - reduceCurrentHp(Math.min(_fallingDamageSum, getCurrentHp() - 1), this, null, false, true, false, false); + reduceCurrentHp(Math.min(_fallingDamage, getCurrentHp() - 1), this, null, false, true, false, false); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_RECEIVED_S1_FALLING_DAMAGE); - sm.addInt(_fallingDamageSum); + sm.addInt(_fallingDamage); sendPacket(sm); } - _hasDismountedWyvern = false; - _fallingDamageSum = 0; + _fallingDamage = 0; _fallingDamageTask = null; }, 1500); - if (!_hasDismountedWyvern) - { - sendPacket(new ValidateLocation(this)); - } + + // Prevent falling under ground. + sendPacket(new ValidateLocation(this)); setFalling(); diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 59ef5de5ea..622d6d2d7f 100644 --- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -182,11 +182,7 @@ public class ValidatePosition implements IClientIncomingPacket { // if ((_z - activeChar.getClientZ()) < 200 && Math.abs(activeChar.getLastServerPosition().getZ()-realZ) > 70) - if (activeChar.hasDismountedWyvern()) - { - activeChar.setXYZ(_x, _y, _z); - } - else if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) + if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) { activeChar.setXYZ(realX, realY, _z); realZ = _z; diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 6e08eb8525..87c5450087 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -467,6 +467,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe public void untransform() { + if (isPlayer() && getActingPlayer().isFlyingMounted() && !getActingPlayer().canDismount()) + { + return; + } + _transform.ifPresent(t -> t.onUntransform(this)); _transform = Optional.empty(); diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index cb20a0a732..70332e4392 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -259,6 +259,7 @@ import com.l2jmobius.gameserver.model.variables.AccountVariables; import com.l2jmobius.gameserver.model.variables.PlayerVariables; import com.l2jmobius.gameserver.model.zone.L2ZoneType; import com.l2jmobius.gameserver.model.zone.ZoneId; +import com.l2jmobius.gameserver.model.zone.type.L2WaterZone; import com.l2jmobius.gameserver.network.Disconnection; import com.l2jmobius.gameserver.network.L2GameClient; import com.l2jmobius.gameserver.network.SystemMessageId; @@ -504,8 +505,6 @@ public final class L2PcInstance extends L2Playable private int _mountLevel; /** Store object used to summon the strider you are mounting **/ private int _mountObjectID = 0; - /** Remember if dismounted from Wyvern **/ - private boolean _hasDismountedWyvern = false; private AdminTeleportType _teleportType = AdminTeleportType.NORMAL; @@ -769,7 +768,7 @@ public final class L2PcInstance extends L2Playable // during fall validations will be disabled for 1000 ms. private static final int FALLING_VALIDATION_DELAY = 1000; private volatile long _fallingTimestamp = 0; - private volatile int _fallingDamageSum = 0; + private volatile int _fallingDamage = 0; private Future _fallingDamageTask = null; private int _multiSocialTarget = 0; @@ -6146,16 +6145,18 @@ public final class L2PcInstance extends L2Playable public boolean dismount() { - final boolean wasFlying = isFlying(); + if (!canDismount()) + { + return false; + } + final boolean wasFlying = isFlying(); sendPacket(new SetupGauge(3, 0, 0)); final int petId = _mountNpcId; setMount(0, 0); stopFeed(); - clearPetData(); if (wasFlying) { - _hasDismountedWyvern = true; removeSkill(CommonSkill.WYVERN_BREATH.getSkill()); } broadcastPacket(new Ride(this)); @@ -6166,9 +6167,42 @@ public final class L2PcInstance extends L2Playable return true; } - public boolean hasDismountedWyvern() + public boolean canDismount() { - return _hasDismountedWyvern; + L2WaterZone water = null; + for (L2ZoneType zone : ZoneManager.getInstance().getZones(getX(), getY(), getZ() - 300)) + { + if (zone instanceof L2WaterZone) + { + water = (L2WaterZone) zone; + } + } + if (water == null) + { + if (!isInWater() && (getZ() > 10000)) + { + sendPacket(SystemMessageId.YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_IN_THIS_LOCATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + if ((GeoEngine.getInstance().getHeight(getX(), getY(), getZ()) + 300) < getZ()) + { + sendPacket(SystemMessageId.YOU_CANNOT_DISMOUNT_FROM_THIS_ELEVATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + } + else + { + ThreadPool.schedule(() -> + { + if (isInWater()) + { + broadcastUserInfo(); + } + }, 1500); + } + return true; } public void setUptime(long time) @@ -12685,29 +12719,29 @@ public final class L2PcInstance extends L2Playable return false; } - // TODO: Test on retail. Add or set damage? - _fallingDamageSum += (int) Formulas.calcFallDam(this, deltaZ); + if (_fallingDamage == 0) + { + _fallingDamage = (int) Formulas.calcFallDam(this, deltaZ); + } if (_fallingDamageTask != null) { _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> { - if ((_fallingDamageSum > 0) && !isInvul()) + if ((_fallingDamage > 0) && !isInvul()) { - reduceCurrentHp(Math.min(_fallingDamageSum, getCurrentHp() - 1), this, null, false, true, false, false); + reduceCurrentHp(Math.min(_fallingDamage, getCurrentHp() - 1), this, null, false, true, false, false); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_RECEIVED_S1_FALLING_DAMAGE); - sm.addInt(_fallingDamageSum); + sm.addInt(_fallingDamage); sendPacket(sm); } - _hasDismountedWyvern = false; - _fallingDamageSum = 0; + _fallingDamage = 0; _fallingDamageTask = null; }, 1500); - if (!_hasDismountedWyvern) - { - sendPacket(new ValidateLocation(this)); - } + + // Prevent falling under ground. + sendPacket(new ValidateLocation(this)); setFalling(); diff --git a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 59ef5de5ea..622d6d2d7f 100644 --- a/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -182,11 +182,7 @@ public class ValidatePosition implements IClientIncomingPacket { // if ((_z - activeChar.getClientZ()) < 200 && Math.abs(activeChar.getLastServerPosition().getZ()-realZ) > 70) - if (activeChar.hasDismountedWyvern()) - { - activeChar.setXYZ(_x, _y, _z); - } - else if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) + if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) { activeChar.setXYZ(realX, realY, _z); realZ = _z; diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 6e08eb8525..87c5450087 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -467,6 +467,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe public void untransform() { + if (isPlayer() && getActingPlayer().isFlyingMounted() && !getActingPlayer().canDismount()) + { + return; + } + _transform.ifPresent(t -> t.onUntransform(this)); _transform = Optional.empty(); diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 35ece6ed34..66ee5fc565 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -260,6 +260,7 @@ import com.l2jmobius.gameserver.model.variables.AccountVariables; import com.l2jmobius.gameserver.model.variables.PlayerVariables; import com.l2jmobius.gameserver.model.zone.L2ZoneType; import com.l2jmobius.gameserver.model.zone.ZoneId; +import com.l2jmobius.gameserver.model.zone.type.L2WaterZone; import com.l2jmobius.gameserver.network.Disconnection; import com.l2jmobius.gameserver.network.L2GameClient; import com.l2jmobius.gameserver.network.SystemMessageId; @@ -506,8 +507,6 @@ public final class L2PcInstance extends L2Playable private int _mountLevel; /** Store object used to summon the strider you are mounting **/ private int _mountObjectID = 0; - /** Remember if dismounted from Wyvern **/ - private boolean _hasDismountedWyvern = false; private AdminTeleportType _teleportType = AdminTeleportType.NORMAL; @@ -771,7 +770,7 @@ public final class L2PcInstance extends L2Playable // during fall validations will be disabled for 1000 ms. private static final int FALLING_VALIDATION_DELAY = 1000; private volatile long _fallingTimestamp = 0; - private volatile int _fallingDamageSum = 0; + private volatile int _fallingDamage = 0; private Future _fallingDamageTask = null; private int _multiSocialTarget = 0; @@ -6148,16 +6147,18 @@ public final class L2PcInstance extends L2Playable public boolean dismount() { - final boolean wasFlying = isFlying(); + if (!canDismount()) + { + return false; + } + final boolean wasFlying = isFlying(); sendPacket(new SetupGauge(3, 0, 0)); final int petId = _mountNpcId; setMount(0, 0); stopFeed(); - clearPetData(); if (wasFlying) { - _hasDismountedWyvern = true; removeSkill(CommonSkill.WYVERN_BREATH.getSkill()); } broadcastPacket(new Ride(this)); @@ -6168,9 +6169,42 @@ public final class L2PcInstance extends L2Playable return true; } - public boolean hasDismountedWyvern() + public boolean canDismount() { - return _hasDismountedWyvern; + L2WaterZone water = null; + for (L2ZoneType zone : ZoneManager.getInstance().getZones(getX(), getY(), getZ() - 300)) + { + if (zone instanceof L2WaterZone) + { + water = (L2WaterZone) zone; + } + } + if (water == null) + { + if (!isInWater() && (getZ() > 10000)) + { + sendPacket(SystemMessageId.YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_IN_THIS_LOCATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + if ((GeoEngine.getInstance().getHeight(getX(), getY(), getZ()) + 300) < getZ()) + { + sendPacket(SystemMessageId.YOU_CANNOT_DISMOUNT_FROM_THIS_ELEVATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + } + else + { + ThreadPool.schedule(() -> + { + if (isInWater()) + { + broadcastUserInfo(); + } + }, 1500); + } + return true; } public void setUptime(long time) @@ -12695,29 +12729,29 @@ public final class L2PcInstance extends L2Playable return false; } - // TODO: Test on retail. Add or set damage? - _fallingDamageSum += (int) Formulas.calcFallDam(this, deltaZ); + if (_fallingDamage == 0) + { + _fallingDamage = (int) Formulas.calcFallDam(this, deltaZ); + } if (_fallingDamageTask != null) { _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> { - if ((_fallingDamageSum > 0) && !isInvul()) + if ((_fallingDamage > 0) && !isInvul()) { - reduceCurrentHp(Math.min(_fallingDamageSum, getCurrentHp() - 1), this, null, false, true, false, false); + reduceCurrentHp(Math.min(_fallingDamage, getCurrentHp() - 1), this, null, false, true, false, false); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_RECEIVED_S1_FALLING_DAMAGE); - sm.addInt(_fallingDamageSum); + sm.addInt(_fallingDamage); sendPacket(sm); } - _hasDismountedWyvern = false; - _fallingDamageSum = 0; + _fallingDamage = 0; _fallingDamageTask = null; }, 1500); - if (!_hasDismountedWyvern) - { - sendPacket(new ValidateLocation(this)); - } + + // Prevent falling under ground. + sendPacket(new ValidateLocation(this)); setFalling(); diff --git a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 59ef5de5ea..622d6d2d7f 100644 --- a/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -182,11 +182,7 @@ public class ValidatePosition implements IClientIncomingPacket { // if ((_z - activeChar.getClientZ()) < 200 && Math.abs(activeChar.getLastServerPosition().getZ()-realZ) > 70) - if (activeChar.hasDismountedWyvern()) - { - activeChar.setXYZ(_x, _y, _z); - } - else if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) + if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) { activeChar.setXYZ(realX, realY, _z); realZ = _z; diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 6e08eb8525..87c5450087 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -467,6 +467,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe public void untransform() { + if (isPlayer() && getActingPlayer().isFlyingMounted() && !getActingPlayer().canDismount()) + { + return; + } + _transform.ifPresent(t -> t.onUntransform(this)); _transform = Optional.empty(); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index f33d62db17..fa23359d5a 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -263,6 +263,7 @@ import com.l2jmobius.gameserver.model.variables.AccountVariables; import com.l2jmobius.gameserver.model.variables.PlayerVariables; import com.l2jmobius.gameserver.model.zone.L2ZoneType; import com.l2jmobius.gameserver.model.zone.ZoneId; +import com.l2jmobius.gameserver.model.zone.type.L2WaterZone; import com.l2jmobius.gameserver.network.Disconnection; import com.l2jmobius.gameserver.network.L2GameClient; import com.l2jmobius.gameserver.network.SystemMessageId; @@ -511,8 +512,6 @@ public final class L2PcInstance extends L2Playable private int _mountLevel; /** Store object used to summon the strider you are mounting **/ private int _mountObjectID = 0; - /** Remember if dismounted from Wyvern **/ - private boolean _hasDismountedWyvern = false; private AdminTeleportType _teleportType = AdminTeleportType.NORMAL; @@ -778,7 +777,7 @@ public final class L2PcInstance extends L2Playable // during fall validations will be disabled for 1000 ms. private static final int FALLING_VALIDATION_DELAY = 1000; private volatile long _fallingTimestamp = 0; - private volatile int _fallingDamageSum = 0; + private volatile int _fallingDamage = 0; private Future _fallingDamageTask = null; private int _multiSocialTarget = 0; @@ -6145,16 +6144,18 @@ public final class L2PcInstance extends L2Playable public boolean dismount() { - final boolean wasFlying = isFlying(); + if (!canDismount()) + { + return false; + } + final boolean wasFlying = isFlying(); sendPacket(new SetupGauge(3, 0, 0)); final int petId = _mountNpcId; setMount(0, 0); stopFeed(); - clearPetData(); if (wasFlying) { - _hasDismountedWyvern = true; removeSkill(CommonSkill.WYVERN_BREATH.getSkill()); } broadcastPacket(new Ride(this)); @@ -6165,9 +6166,42 @@ public final class L2PcInstance extends L2Playable return true; } - public boolean hasDismountedWyvern() + public boolean canDismount() { - return _hasDismountedWyvern; + L2WaterZone water = null; + for (L2ZoneType zone : ZoneManager.getInstance().getZones(getX(), getY(), getZ() - 300)) + { + if (zone instanceof L2WaterZone) + { + water = (L2WaterZone) zone; + } + } + if (water == null) + { + if (!isInWater() && (getZ() > 10000)) + { + sendPacket(SystemMessageId.YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_IN_THIS_LOCATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + if ((GeoEngine.getInstance().getHeight(getX(), getY(), getZ()) + 300) < getZ()) + { + sendPacket(SystemMessageId.YOU_CANNOT_DISMOUNT_FROM_THIS_ELEVATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + } + else + { + ThreadPool.schedule(() -> + { + if (isInWater()) + { + broadcastUserInfo(); + } + }, 1500); + } + return true; } public void setUptime(long time) @@ -12677,29 +12711,29 @@ public final class L2PcInstance extends L2Playable return false; } - // TODO: Test on retail. Add or set damage? - _fallingDamageSum += (int) Formulas.calcFallDam(this, deltaZ); + if (_fallingDamage == 0) + { + _fallingDamage = (int) Formulas.calcFallDam(this, deltaZ); + } if (_fallingDamageTask != null) { _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> { - if ((_fallingDamageSum > 0) && !isInvul()) + if ((_fallingDamage > 0) && !isInvul()) { - reduceCurrentHp(Math.min(_fallingDamageSum, getCurrentHp() - 1), this, null, false, true, false, false); + reduceCurrentHp(Math.min(_fallingDamage, getCurrentHp() - 1), this, null, false, true, false, false); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_RECEIVED_S1_FALLING_DAMAGE); - sm.addInt(_fallingDamageSum); + sm.addInt(_fallingDamage); sendPacket(sm); } - _hasDismountedWyvern = false; - _fallingDamageSum = 0; + _fallingDamage = 0; _fallingDamageTask = null; }, 1500); - if (!_hasDismountedWyvern) - { - sendPacket(new ValidateLocation(this)); - } + + // Prevent falling under ground. + sendPacket(new ValidateLocation(this)); setFalling(); diff --git a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 59ef5de5ea..622d6d2d7f 100644 --- a/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -182,11 +182,7 @@ public class ValidatePosition implements IClientIncomingPacket { // if ((_z - activeChar.getClientZ()) < 200 && Math.abs(activeChar.getLastServerPosition().getZ()-realZ) > 70) - if (activeChar.hasDismountedWyvern()) - { - activeChar.setXYZ(_x, _y, _z); - } - else if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) + if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) { activeChar.setXYZ(realX, realY, _z); realZ = _z; diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index eb9a4c5874..1055268981 100644 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -82,6 +82,7 @@ import com.l2jmobius.gameserver.instancemanager.CoupleManager; import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager; import com.l2jmobius.gameserver.instancemanager.DimensionalRiftManager; import com.l2jmobius.gameserver.instancemanager.DuelManager; +import com.l2jmobius.gameserver.instancemanager.FishingZoneManager; import com.l2jmobius.gameserver.instancemanager.FortSiegeManager; import com.l2jmobius.gameserver.instancemanager.ItemsOnGroundManager; import com.l2jmobius.gameserver.instancemanager.PlayerCountManager; @@ -541,9 +542,6 @@ public final class L2PcInstance extends L2Playable /** Store object used to summon the strider you are mounting *. */ private int _mountObjectID = 0; - /** Remember if dismounted from Wyvern **/ - private boolean _hasDismountedWyvern = false; - /** The _telemode. */ public int _telemode = 0; @@ -1056,7 +1054,7 @@ public final class L2PcInstance extends L2Playable // during fall validations will be disabled for 1000 ms. private static final int FALLING_VALIDATION_DELAY = 1000; private long _fallingTimestamp = 0; - private volatile int _fallingDamageSum = 0; + private volatile int _fallingDamage = 0; private Future _fallingDamageTask = null; /** Previous coordinate sent to party in ValidatePosition *. */ @@ -17731,11 +17729,15 @@ public final class L2PcInstance extends L2Playable */ public boolean dismount() { + if (!canDismount()) + { + return false; + } + final boolean wasFlying = isFlying(); setMountType(0); if (wasFlying) { - _hasDismountedWyvern = true; removeSkill(SkillTable.getInstance().getInfo(4289, 1)); } Ride dismount = new Ride(getObjectId(), Ride.ACTION_DISMOUNT, 0); @@ -17745,9 +17747,34 @@ public final class L2PcInstance extends L2Playable return true; } - public boolean hasDismountedWyvern() + private boolean canDismount() { - return _hasDismountedWyvern; + if (FishingZoneManager.getInstance().isInsideWaterZone(getX(), getY(), getZ() - 300) == null) + { + if (!isInWater() && (getZ() > 10000)) + { + sendPacket(SystemMessageId.YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_IN_THIS_LOCATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + if ((GeoData.getInstance().getHeight(getX(), getY(), getZ()) + 300) < getZ()) + { + sendPacket(SystemMessageId.YOU_CANNOT_DISMOUNT_FROM_THIS_ELEVATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + } + else + { + ThreadPool.schedule(() -> + { + if (isInWater()) + { + broadcastUserInfo(); + } + }, 1500); + } + return true; } /** @@ -18457,27 +18484,27 @@ public final class L2PcInstance extends L2Playable return false; } - // TODO: Test on retail. Add or set damage? - _fallingDamageSum += (int) Formulas.calcFallDam(this, deltaZ); + if (_fallingDamage == 0) + { + _fallingDamage = (int) Formulas.calcFallDam(this, deltaZ); + } if (_fallingDamageTask != null) { _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> { - if ((_fallingDamageSum > 0) && !isInvul()) + if ((_fallingDamage > 0) && !isInvul()) { - reduceCurrentHp(Math.min(_fallingDamageSum, getCurrentHp() - 1), null, false); - sendPacket(new SystemMessage(SystemMessageId.FALL_DAMAGE_S1).addNumber(_fallingDamageSum)); + reduceCurrentHp(Math.min(_fallingDamage, getCurrentHp() - 1), null, false); + sendPacket(new SystemMessage(SystemMessageId.FALL_DAMAGE_S1).addNumber(_fallingDamage)); } - _hasDismountedWyvern = false; - _fallingDamageSum = 0; + _fallingDamage = 0; _fallingDamageTask = null; }, 1500); - if (!_hasDismountedWyvern) - { - sendPacket(new ValidateLocation(this)); - } + + // Prevent falling under ground. + sendPacket(new ValidateLocation(this)); _fallingTimestamp = System.currentTimeMillis() + FALLING_VALIDATION_DELAY; diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/network/SystemMessageId.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/network/SystemMessageId.java index fe6c24b340..624395dd7c 100644 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/network/SystemMessageId.java +++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/network/SystemMessageId.java @@ -2933,6 +2933,12 @@ public enum SystemMessageId */ WOULD_YOU_LIKE_TO_CLOSE_THE_GATE(1141), + /** + * ID: 1158
+ * Message: You cannot dismount from this elevation. + */ + YOU_CANNOT_DISMOUNT_FROM_THIS_ELEVATION(1158), + /** * ID: 1176
* Message: This is a quest event period. @@ -3365,6 +3371,12 @@ public enum SystemMessageId */ S1_HAS_BECOME_A_PARTY_LEADER(1384), + /** + * ID: 1385
+ * Message: You are not allowed to dismount at this location. + */ + YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_IN_THIS_LOCATION(1385), + /** * ID: 1388
* Message: A party room has been created. diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 247b9608d7..1f9b1c0620 100644 --- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -147,11 +147,7 @@ public final class ValidatePosition extends L2GameClientPacket { // if ((_z - activeChar.getClientZ()) < 200 && Math.abs(activeChar.getLastServerPosition().getZ()-realZ) > 70) - if (activeChar.hasDismountedWyvern()) - { - activeChar.setXYZ(_x, _y, _z); - } - else if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) + if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) { activeChar.setXYZ(realX, realY, _z); realZ = _z; diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 875dedd4bc..f16cc9b7cd 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -251,6 +251,7 @@ import com.l2jmobius.gameserver.model.variables.PlayerVariables; import com.l2jmobius.gameserver.model.zone.L2ZoneType; import com.l2jmobius.gameserver.model.zone.ZoneId; import com.l2jmobius.gameserver.model.zone.type.L2BossZone; +import com.l2jmobius.gameserver.model.zone.type.L2WaterZone; import com.l2jmobius.gameserver.network.Disconnection; import com.l2jmobius.gameserver.network.L2GameClient; import com.l2jmobius.gameserver.network.SystemMessageId; @@ -507,8 +508,6 @@ public final class L2PcInstance extends L2Playable private int _mountLevel; /** Store object used to summon the strider you are mounting **/ private int _mountObjectID = 0; - /** Remember if dismounted from Wyvern **/ - private boolean _hasDismountedWyvern = false; public int _telemode = 0; @@ -796,7 +795,7 @@ public final class L2PcInstance extends L2Playable // during fall validations will be disabled for 1000 ms. private static final int FALLING_VALIDATION_DELAY = 1000; private volatile long _fallingTimestamp = 0; - private volatile int _fallingDamageSum = 0; + private volatile int _fallingDamage = 0; private Future _fallingDamageTask = null; private int _multiSocialTarget = 0; @@ -4665,10 +4664,11 @@ public final class L2PcInstance extends L2Playable @Override public void untransform() { - if (_transformation == null) + if ((_transformation == null) || (isFlyingMounted() && !canDismount())) { return; } + setQueuedSkill(null, false, false); _transformation.onUntransform(this); _transformation = null; @@ -6373,15 +6373,18 @@ public final class L2PcInstance extends L2Playable public boolean dismount() { - final boolean wasFlying = isFlying(); + if (!canDismount()) + { + return false; + } + final boolean wasFlying = isFlying(); sendPacket(new SetupGauge(3, 0, 0)); final int petId = _mountNpcId; setMount(0, 0); stopFeed(); if (wasFlying) { - _hasDismountedWyvern = true; removeSkill(CommonSkill.WYVERN_BREATH.getSkill()); } broadcastPacket(new Ride(this)); @@ -6392,9 +6395,42 @@ public final class L2PcInstance extends L2Playable return true; } - public boolean hasDismountedWyvern() + private boolean canDismount() { - return _hasDismountedWyvern; + L2WaterZone water = null; + for (L2ZoneType zone : ZoneManager.getInstance().getZones(getX(), getY(), getZ() - 300)) + { + if (zone instanceof L2WaterZone) + { + water = (L2WaterZone) zone; + } + } + if (water == null) + { + if (!isInWater() && (getZ() > 10000)) + { + sendPacket(SystemMessageId.YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_IN_THIS_LOCATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + if ((GeoEngine.getInstance().getHeight(getX(), getY(), getZ()) + 300) < getZ()) + { + sendPacket(SystemMessageId.YOU_CANNOT_DISMOUNT_FROM_THIS_ELEVATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + } + else + { + ThreadPool.schedule(() -> + { + if (isInWater()) + { + broadcastUserInfo(); + } + }, 1500); + } + return true; } public void setUptime(long time) @@ -13520,29 +13556,29 @@ public final class L2PcInstance extends L2Playable return false; } - // TODO: Test on retail. Add or set damage? - _fallingDamageSum += (int) Formulas.calcFallDam(this, deltaZ); + if (_fallingDamage == 0) + { + _fallingDamage = (int) Formulas.calcFallDam(this, deltaZ); + } if (_fallingDamageTask != null) { _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> { - if ((_fallingDamageSum > 0) && !isInvul()) + if ((_fallingDamage > 0) && !isInvul()) { - reduceCurrentHp(Math.min(_fallingDamageSum, getCurrentHp() - 1), null, false, true, null); + reduceCurrentHp(Math.min(_fallingDamage, getCurrentHp() - 1), null, false, true, null); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_RECEIVED_S1_FALLING_DAMAGE); - sm.addInt(_fallingDamageSum); + sm.addInt(_fallingDamage); sendPacket(sm); } - _hasDismountedWyvern = false; - _fallingDamageSum = 0; + _fallingDamage = 0; _fallingDamageTask = null; }, 1500); - if (!_hasDismountedWyvern) - { - sendPacket(new ValidateLocation(this)); - } + + // Prevent falling under ground. + sendPacket(new ValidateLocation(this)); setFalling(); diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 43c3b66f4a..d56e2c606a 100644 --- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -182,11 +182,7 @@ public class ValidatePosition implements IClientIncomingPacket { // if ((_z - activeChar.getClientZ()) < 200 && Math.abs(activeChar.getLastServerPosition().getZ()-realZ) > 70) - if (activeChar.hasDismountedWyvern()) - { - activeChar.setXYZ(_x, _y, _z); - } - else if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) + if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) { activeChar.setXYZ(realX, realY, _z); realZ = _z; diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 6e08eb8525..87c5450087 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -467,6 +467,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe public void untransform() { + if (isPlayer() && getActingPlayer().isFlyingMounted() && !getActingPlayer().canDismount()) + { + return; + } + _transform.ifPresent(t -> t.onUntransform(this)); _transform = Optional.empty(); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 44e74aa60f..498a63a2c9 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -259,6 +259,7 @@ import com.l2jmobius.gameserver.model.variables.AccountVariables; import com.l2jmobius.gameserver.model.variables.PlayerVariables; import com.l2jmobius.gameserver.model.zone.L2ZoneType; import com.l2jmobius.gameserver.model.zone.ZoneId; +import com.l2jmobius.gameserver.model.zone.type.L2WaterZone; import com.l2jmobius.gameserver.network.Disconnection; import com.l2jmobius.gameserver.network.L2GameClient; import com.l2jmobius.gameserver.network.SystemMessageId; @@ -501,8 +502,6 @@ public final class L2PcInstance extends L2Playable private int _mountLevel; /** Store object used to summon the strider you are mounting **/ private int _mountObjectID = 0; - /** Remember if dismounted from Wyvern **/ - private boolean _hasDismountedWyvern = false; private AdminTeleportType _teleportType = AdminTeleportType.NORMAL; @@ -765,7 +764,7 @@ public final class L2PcInstance extends L2Playable // during fall validations will be disabled for 1000 ms. private static final int FALLING_VALIDATION_DELAY = 1000; private volatile long _fallingTimestamp = 0; - private volatile int _fallingDamageSum = 0; + private volatile int _fallingDamage = 0; private Future _fallingDamageTask = null; private int _multiSocialTarget = 0; @@ -6112,16 +6111,18 @@ public final class L2PcInstance extends L2Playable public boolean dismount() { - final boolean wasFlying = isFlying(); + if (!canDismount()) + { + return false; + } + final boolean wasFlying = isFlying(); sendPacket(new SetupGauge(3, 0, 0)); final int petId = _mountNpcId; setMount(0, 0); stopFeed(); - clearPetData(); if (wasFlying) { - _hasDismountedWyvern = true; removeSkill(CommonSkill.WYVERN_BREATH.getSkill()); } broadcastPacket(new Ride(this)); @@ -6132,9 +6133,42 @@ public final class L2PcInstance extends L2Playable return true; } - public boolean hasDismountedWyvern() + public boolean canDismount() { - return _hasDismountedWyvern; + L2WaterZone water = null; + for (L2ZoneType zone : ZoneManager.getInstance().getZones(getX(), getY(), getZ() - 300)) + { + if (zone instanceof L2WaterZone) + { + water = (L2WaterZone) zone; + } + } + if (water == null) + { + if (!isInWater() && (getZ() > 10000)) + { + sendPacket(SystemMessageId.YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_IN_THIS_LOCATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + if ((GeoEngine.getInstance().getHeight(getX(), getY(), getZ()) + 300) < getZ()) + { + sendPacket(SystemMessageId.YOU_CANNOT_DISMOUNT_FROM_THIS_ELEVATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + } + else + { + ThreadPool.schedule(() -> + { + if (isInWater()) + { + broadcastUserInfo(); + } + }, 1500); + } + return true; } public void setUptime(long time) @@ -12526,29 +12560,29 @@ public final class L2PcInstance extends L2Playable return false; } - // TODO: Test on retail. Add or set damage? - _fallingDamageSum += (int) Formulas.calcFallDam(this, deltaZ); + if (_fallingDamage == 0) + { + _fallingDamage = (int) Formulas.calcFallDam(this, deltaZ); + } if (_fallingDamageTask != null) { _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> { - if ((_fallingDamageSum > 0) && !isInvul()) + if ((_fallingDamage > 0) && !isInvul()) { - reduceCurrentHp(Math.min(_fallingDamageSum, getCurrentHp() - 1), this, null, false, true, false, false); + reduceCurrentHp(Math.min(_fallingDamage, getCurrentHp() - 1), this, null, false, true, false, false); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_RECEIVED_S1_FALLING_DAMAGE); - sm.addInt(_fallingDamageSum); + sm.addInt(_fallingDamage); sendPacket(sm); } - _hasDismountedWyvern = false; - _fallingDamageSum = 0; + _fallingDamage = 0; _fallingDamageTask = null; }, 1500); - if (!_hasDismountedWyvern) - { - sendPacket(new ValidateLocation(this)); - } + + // Prevent falling under ground. + sendPacket(new ValidateLocation(this)); setFalling(); diff --git a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 59ef5de5ea..622d6d2d7f 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -182,11 +182,7 @@ public class ValidatePosition implements IClientIncomingPacket { // if ((_z - activeChar.getClientZ()) < 200 && Math.abs(activeChar.getLastServerPosition().getZ()-realZ) > 70) - if (activeChar.hasDismountedWyvern()) - { - activeChar.setXYZ(_x, _y, _z); - } - else if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) + if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) { activeChar.setXYZ(realX, realY, _z); realZ = _z; diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 6e08eb8525..87c5450087 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -467,6 +467,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe public void untransform() { + if (isPlayer() && getActingPlayer().isFlyingMounted() && !getActingPlayer().canDismount()) + { + return; + } + _transform.ifPresent(t -> t.onUntransform(this)); _transform = Optional.empty(); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index 382af44204..5692138494 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -259,6 +259,7 @@ import com.l2jmobius.gameserver.model.variables.AccountVariables; import com.l2jmobius.gameserver.model.variables.PlayerVariables; import com.l2jmobius.gameserver.model.zone.L2ZoneType; import com.l2jmobius.gameserver.model.zone.ZoneId; +import com.l2jmobius.gameserver.model.zone.type.L2WaterZone; import com.l2jmobius.gameserver.network.Disconnection; import com.l2jmobius.gameserver.network.L2GameClient; import com.l2jmobius.gameserver.network.SystemMessageId; @@ -501,8 +502,6 @@ public final class L2PcInstance extends L2Playable private int _mountLevel; /** Store object used to summon the strider you are mounting **/ private int _mountObjectID = 0; - /** Remember if dismounted from Wyvern **/ - private boolean _hasDismountedWyvern = false; private AdminTeleportType _teleportType = AdminTeleportType.NORMAL; @@ -765,7 +764,7 @@ public final class L2PcInstance extends L2Playable // during fall validations will be disabled for 1000 ms. private static final int FALLING_VALIDATION_DELAY = 1000; private volatile long _fallingTimestamp = 0; - private volatile int _fallingDamageSum = 0; + private volatile int _fallingDamage = 0; private Future _fallingDamageTask = null; private int _multiSocialTarget = 0; @@ -6112,16 +6111,18 @@ public final class L2PcInstance extends L2Playable public boolean dismount() { - final boolean wasFlying = isFlying(); + if (!canDismount()) + { + return false; + } + final boolean wasFlying = isFlying(); sendPacket(new SetupGauge(3, 0, 0)); final int petId = _mountNpcId; setMount(0, 0); stopFeed(); - clearPetData(); if (wasFlying) { - _hasDismountedWyvern = true; removeSkill(CommonSkill.WYVERN_BREATH.getSkill()); } broadcastPacket(new Ride(this)); @@ -6132,9 +6133,42 @@ public final class L2PcInstance extends L2Playable return true; } - public boolean hasDismountedWyvern() + public boolean canDismount() { - return _hasDismountedWyvern; + L2WaterZone water = null; + for (L2ZoneType zone : ZoneManager.getInstance().getZones(getX(), getY(), getZ() - 300)) + { + if (zone instanceof L2WaterZone) + { + water = (L2WaterZone) zone; + } + } + if (water == null) + { + if (!isInWater() && (getZ() > 10000)) + { + sendPacket(SystemMessageId.YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_IN_THIS_LOCATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + if ((GeoEngine.getInstance().getHeight(getX(), getY(), getZ()) + 300) < getZ()) + { + sendPacket(SystemMessageId.YOU_CANNOT_DISMOUNT_FROM_THIS_ELEVATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + } + else + { + ThreadPool.schedule(() -> + { + if (isInWater()) + { + broadcastUserInfo(); + } + }, 1500); + } + return true; } public void setUptime(long time) @@ -12526,29 +12560,29 @@ public final class L2PcInstance extends L2Playable return false; } - // TODO: Test on retail. Add or set damage? - _fallingDamageSum += (int) Formulas.calcFallDam(this, deltaZ); + if (_fallingDamage == 0) + { + _fallingDamage = (int) Formulas.calcFallDam(this, deltaZ); + } if (_fallingDamageTask != null) { _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> { - if ((_fallingDamageSum > 0) && !isInvul()) + if ((_fallingDamage > 0) && !isInvul()) { - reduceCurrentHp(Math.min(_fallingDamageSum, getCurrentHp() - 1), this, null, false, true, false, false); + reduceCurrentHp(Math.min(_fallingDamage, getCurrentHp() - 1), this, null, false, true, false, false); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_RECEIVED_S1_FALLING_DAMAGE); - sm.addInt(_fallingDamageSum); + sm.addInt(_fallingDamage); sendPacket(sm); } - _hasDismountedWyvern = false; - _fallingDamageSum = 0; + _fallingDamage = 0; _fallingDamageTask = null; }, 1500); - if (!_hasDismountedWyvern) - { - sendPacket(new ValidateLocation(this)); - } + + // Prevent falling under ground. + sendPacket(new ValidateLocation(this)); setFalling(); diff --git a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 59ef5de5ea..622d6d2d7f 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -182,11 +182,7 @@ public class ValidatePosition implements IClientIncomingPacket { // if ((_z - activeChar.getClientZ()) < 200 && Math.abs(activeChar.getLastServerPosition().getZ()-realZ) > 70) - if (activeChar.hasDismountedWyvern()) - { - activeChar.setXYZ(_x, _y, _z); - } - else if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) + if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) { activeChar.setXYZ(realX, realY, _z); realZ = _z; diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/L2Character.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/L2Character.java index 6e08eb8525..87c5450087 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/L2Character.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/L2Character.java @@ -467,6 +467,11 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe public void untransform() { + if (isPlayer() && getActingPlayer().isFlyingMounted() && !getActingPlayer().canDismount()) + { + return; + } + _transform.ifPresent(t -> t.onUntransform(this)); _transform = Optional.empty(); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java index d034391ca4..e5535f18d2 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/model/actor/instance/L2PcInstance.java @@ -259,6 +259,7 @@ import com.l2jmobius.gameserver.model.variables.AccountVariables; import com.l2jmobius.gameserver.model.variables.PlayerVariables; import com.l2jmobius.gameserver.model.zone.L2ZoneType; import com.l2jmobius.gameserver.model.zone.ZoneId; +import com.l2jmobius.gameserver.model.zone.type.L2WaterZone; import com.l2jmobius.gameserver.network.Disconnection; import com.l2jmobius.gameserver.network.L2GameClient; import com.l2jmobius.gameserver.network.SystemMessageId; @@ -501,8 +502,6 @@ public final class L2PcInstance extends L2Playable private int _mountLevel; /** Store object used to summon the strider you are mounting **/ private int _mountObjectID = 0; - /** Remember if dismounted from Wyvern **/ - private boolean _hasDismountedWyvern = false; private AdminTeleportType _teleportType = AdminTeleportType.NORMAL; @@ -765,7 +764,7 @@ public final class L2PcInstance extends L2Playable // during fall validations will be disabled for 1000 ms. private static final int FALLING_VALIDATION_DELAY = 1000; private volatile long _fallingTimestamp = 0; - private volatile int _fallingDamageSum = 0; + private volatile int _fallingDamage = 0; private Future _fallingDamageTask = null; private int _multiSocialTarget = 0; @@ -6114,16 +6113,18 @@ public final class L2PcInstance extends L2Playable public boolean dismount() { - final boolean wasFlying = isFlying(); + if (!canDismount()) + { + return false; + } + final boolean wasFlying = isFlying(); sendPacket(new SetupGauge(3, 0, 0)); final int petId = _mountNpcId; setMount(0, 0); stopFeed(); - clearPetData(); if (wasFlying) { - _hasDismountedWyvern = true; removeSkill(CommonSkill.WYVERN_BREATH.getSkill()); } broadcastPacket(new Ride(this)); @@ -6134,9 +6135,42 @@ public final class L2PcInstance extends L2Playable return true; } - public boolean hasDismountedWyvern() + public boolean canDismount() { - return _hasDismountedWyvern; + L2WaterZone water = null; + for (L2ZoneType zone : ZoneManager.getInstance().getZones(getX(), getY(), getZ() - 300)) + { + if (zone instanceof L2WaterZone) + { + water = (L2WaterZone) zone; + } + } + if (water == null) + { + if (!isInWater() && (getZ() > 10000)) + { + sendPacket(SystemMessageId.YOU_ARE_NOT_ALLOWED_TO_DISMOUNT_IN_THIS_LOCATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + if ((GeoEngine.getInstance().getHeight(getX(), getY(), getZ()) + 300) < getZ()) + { + sendPacket(SystemMessageId.YOU_CANNOT_DISMOUNT_FROM_THIS_ELEVATION); + sendPacket(ActionFailed.STATIC_PACKET); + return false; + } + } + else + { + ThreadPool.schedule(() -> + { + if (isInWater()) + { + broadcastUserInfo(); + } + }, 1500); + } + return true; } public void setUptime(long time) @@ -12528,29 +12562,29 @@ public final class L2PcInstance extends L2Playable return false; } - // TODO: Test on retail. Add or set damage? - _fallingDamageSum += (int) Formulas.calcFallDam(this, deltaZ); + if (_fallingDamage == 0) + { + _fallingDamage = (int) Formulas.calcFallDam(this, deltaZ); + } if (_fallingDamageTask != null) { _fallingDamageTask.cancel(true); } _fallingDamageTask = ThreadPool.schedule(() -> { - if ((_fallingDamageSum > 0) && !isInvul()) + if ((_fallingDamage > 0) && !isInvul()) { - reduceCurrentHp(Math.min(_fallingDamageSum, getCurrentHp() - 1), this, null, false, true, false, false); + reduceCurrentHp(Math.min(_fallingDamage, getCurrentHp() - 1), this, null, false, true, false, false); final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_RECEIVED_S1_FALLING_DAMAGE); - sm.addInt(_fallingDamageSum); + sm.addInt(_fallingDamage); sendPacket(sm); } - _hasDismountedWyvern = false; - _fallingDamageSum = 0; + _fallingDamage = 0; _fallingDamageTask = null; }, 1500); - if (!_hasDismountedWyvern) - { - sendPacket(new ValidateLocation(this)); - } + + // Prevent falling under ground. + sendPacket(new ValidateLocation(this)); setFalling(); diff --git a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java index 59ef5de5ea..622d6d2d7f 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java +++ b/L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/network/clientpackets/ValidatePosition.java @@ -182,11 +182,7 @@ public class ValidatePosition implements IClientIncomingPacket { // if ((_z - activeChar.getClientZ()) < 200 && Math.abs(activeChar.getLastServerPosition().getZ()-realZ) > 70) - if (activeChar.hasDismountedWyvern()) - { - activeChar.setXYZ(_x, _y, _z); - } - else if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) + if ((Math.abs(dz) > 200) && (Math.abs(dz) < 1500) && (Math.abs(_z - activeChar.getClientZ()) < 800)) { activeChar.setXYZ(realX, realY, _z); realZ = _z;