Core/Movement: properly fix aura interrupts during movement

Port From (https://github.com/TrinityCore/TrinityCore/commit/43a7091e8a86179e195e2bc021133ce751d48d48)
This commit is contained in:
hondacrx
2022-01-06 10:24:20 -05:00
parent 923a993f1e
commit 8c71ecf0b2
4 changed files with 42 additions and 5 deletions
+6
View File
@@ -79,10 +79,16 @@ namespace Framework.Constants
public enum SummonSlot
{
Any = -1,
Pet = 0,
Totem = 1,
Totem2 = 2,
Totem3 = 3,
Totem4 = 4,
MiniPet = 5,
Quest = 6,
Max
}
public enum BaseModType
+13
View File
@@ -43,6 +43,7 @@ namespace Game.Entities
public uint m_movementCounter; //< Incrementing counter used in movement packets
TimeTrackerSmall movesplineTimer;
MovementForces _movementForces;
PositionUpdateInfo _positionUpdateInfo;
protected Unit m_unitMovedByMe; // only ever set for players, and only for direct client control
protected Player m_playerMovingMe; // only set for direct client control (possess effects, vehicles and similar)
@@ -555,4 +556,16 @@ namespace Game.Entities
{
public StringArray name = new(SharedConst.MaxDeclinedNameCases);
}
struct PositionUpdateInfo
{
public bool Relocated;
public bool Turned;
public void Reset()
{
Relocated = false;
Turned = false;
}
}
}
+14 -5
View File
@@ -600,13 +600,8 @@ namespace Game.Entities
Math.Abs(GetPositionY() - y) > 0.001f ||
Math.Abs(GetPositionZ() - z) > 0.001f);
if (turn)
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Turning);
if (relocated)
{
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Moving);
// move and update visible state if need
if (IsTypeId(TypeId.Player))
GetMap().PlayerRelocation(ToPlayer(), x, y, z, orientation);
@@ -618,6 +613,9 @@ namespace Game.Entities
UpdatePositionData();
_positionUpdateInfo.Relocated = relocated;
_positionUpdateInfo.Turned = turn;
bool isInWater = IsInWater();
if (!IsFalling() || isInWater || IsFlying())
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags2.Ground);
@@ -1741,6 +1739,17 @@ namespace Game.Entities
UpdatePosition(loc.X, loc.Y, loc.Z, loc.W);
}
void InterruptMovementBasedAuras()
{
// TODO: Check if orientation transport offset changed instead of only global orientation
if (_positionUpdateInfo.Turned)
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Turning);
if (_positionUpdateInfo.Relocated && !GetVehicle())
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Moving);
}
public void DisableSpline()
{
m_movementInfo.RemoveMovementFlag(MovementFlag.Forward);
+9
View File
@@ -172,6 +172,15 @@ namespace Game.Entities
UpdateSplineMovement(diff);
GetMotionMaster().Update(diff);
// Wait with the aura interrupts until we have updated our movement generators and position
if (IsPlayer())
InterruptMovementBasedAuras();
else if (!MoveSpline.Finalized())
InterruptMovementBasedAuras();
// All position info based actions have been executed, reset info
_positionUpdateInfo.Reset();
if (GetAI() == null && (!IsPlayer() || (IsCharmed() && GetCharmerGUID().IsCreature())))
UpdateCharmAI();