From 1f21e6893f81719c41f141453ca29613aecfa97a Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 10 May 2022 09:38:14 -0400 Subject: [PATCH] Core/Auras: Implemented SPELL_AURA_DISABLE_INERTIA (506) Port From (https://github.com/TrinityCore/TrinityCore/commit/d945a118db6d2b423a77c419eb8dd7f4732802a2) --- Source/Game/Entities/Player/Player.cs | 6 +++++ Source/Game/Entities/Unit/Unit.Movement.cs | 26 ++++++++++++++++++++++ Source/Game/Spells/Auras/AuraEffect.cs | 18 +++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index 458c5ed17..660fbfadf 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -5749,6 +5749,12 @@ namespace Game.Entities if (HasAura(196055)) //DH DoubleJump setCompoundState.StateChanges.Add(new MoveSetCompoundState.MoveStateChange(ServerOpcodes.MoveEnableDoubleJump, m_movementCounter++)); + if (HasAuraType(AuraType.IgnoreMovementForces)) + setCompoundState.StateChanges.Add(new MoveSetCompoundState.MoveStateChange(ServerOpcodes.MoveSetIgnoreMovementForces, m_movementCounter++)); + + if (HasAuraType(AuraType.DisableInertia)) + setCompoundState.StateChanges.Add(new MoveSetCompoundState.MoveStateChange(ServerOpcodes.MoveDisableInertia, m_movementCounter++)); + if (!setCompoundState.StateChanges.Empty()) { setCompoundState.MoverGUID = GetGUID(); diff --git a/Source/Game/Entities/Unit/Unit.Movement.cs b/Source/Game/Entities/Unit/Unit.Movement.cs index 2bbb3698a..c2af784ad 100644 --- a/Source/Game/Entities/Unit/Unit.Movement.cs +++ b/Source/Game/Entities/Unit/Unit.Movement.cs @@ -395,6 +395,32 @@ namespace Game.Entities return true; } + public bool SetDisableInertia(bool disable) + { + if (disable == HasExtraUnitMovementFlag2(MovementFlags3.DisableInertia)) + return false; + + if (disable) + AddExtraUnitMovementFlag2(MovementFlags3.DisableInertia); + else + RemoveExtraUnitMovementFlag2(MovementFlags3.DisableInertia); + + Player playerMover = GetUnitBeingMoved()?.ToPlayer(); + if (playerMover != null) + { + MoveSetFlag packet = new(disable ? ServerOpcodes.MoveDisableInertia : ServerOpcodes.MoveEnableInertia); + packet.MoverGUID = GetGUID(); + packet.SequenceIndex = m_movementCounter++; + playerMover.SendPacket(packet); + + MoveUpdate moveUpdate = new(); + moveUpdate.Status = m_movementInfo; + SendMessageToSet(moveUpdate, playerMover); + } + + return true; + } + public void JumpTo(float speedXY, float speedZ, float angle, Position dest = null) { if (dest != null) diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index d1c252887..d23b2abae 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -2303,6 +2303,24 @@ namespace Game.Spells target.SetIgnoreMovementForces(apply); } + [AuraEffectHandler(AuraType.IgnoreMovementForces)] + void HandleDisableInertia(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) + { + if (!mode.HasFlag(AuraEffectHandleModes.SendForClientMask)) + return; + + Unit target = aurApp.GetTarget(); + + if (!apply) + { + // do not remove unit flag if there are more than this auraEffect of that kind on unit on unit + if (target.HasAuraType(GetAuraType())) + return; + } + + target.SetDisableInertia(apply); + } + /****************************/ /*** THREAT ***/ /****************************/