mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
Core/Movement: properly fix aura interrupts during movement (#24068)
We want our movement to be fully updated before even thinking about interrupting anything. The old logic was updating positions, interrupting stuff and afterwards updating movement generators. This way we were ending up with false interrupts.
properly fixes #22908
(cherry picked from commit 02daf1bf3a)
This commit is contained in:
@@ -479,6 +479,12 @@ void Unit::Update(uint32 p_time)
|
||||
UpdateSplineMovement(p_time);
|
||||
i_motionMaster->Update(p_time);
|
||||
|
||||
// Wait with the aura interrupts until we have updated our movement generators and position
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
InterruptMovementBasedAuras();
|
||||
else if (!movespline->Finalized())
|
||||
InterruptMovementBasedAuras();
|
||||
|
||||
if (!GetAI() && (GetTypeId() != TYPEID_PLAYER || (IsCharmed() && GetCharmerGUID().IsCreature())))
|
||||
UpdateCharmAI();
|
||||
RefreshAI();
|
||||
@@ -543,6 +549,16 @@ void Unit::UpdateSplinePosition()
|
||||
UpdatePosition(loc.x, loc.y, loc.z, loc.orientation);
|
||||
}
|
||||
|
||||
void Unit::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);
|
||||
}
|
||||
|
||||
void Unit::DisableSpline()
|
||||
{
|
||||
m_movementInfo.RemoveMovementFlag(MOVEMENTFLAG_FORWARD);
|
||||
@@ -9999,6 +10015,8 @@ void Unit::UpdateReactives(uint32 p_time)
|
||||
if (HasAuraState(AURA_STATE_DEFENSIVE_2))
|
||||
ModifyAuraState(AURA_STATE_DEFENSIVE_2, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -12003,15 +12021,8 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
|
||||
std::fabs(GetPositionY() - y) > 0.001f ||
|
||||
std::fabs(GetPositionZ() - z) > 0.001f);
|
||||
|
||||
// TODO: Check if orientation transport offset changed instead of only global orientation
|
||||
if (turn)
|
||||
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Turning);
|
||||
|
||||
if (relocated)
|
||||
{
|
||||
if (!GetVehicle())
|
||||
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Moving);
|
||||
|
||||
// move and update visible state if need
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
GetMap()->PlayerRelocation(ToPlayer(), x, y, z, orientation);
|
||||
@@ -12023,6 +12034,9 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
|
||||
|
||||
UpdatePositionData();
|
||||
|
||||
_positionUpdateInfo.Relocated = relocated;
|
||||
_positionUpdateInfo.Turned = turn;
|
||||
|
||||
bool isInWater = IsInWater();
|
||||
if (!IsFalling() || isInWater || IsFlying())
|
||||
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags2::Ground);
|
||||
|
||||
@@ -717,18 +717,15 @@ struct TC_GAME_API CharmInfo
|
||||
enum ReactiveType
|
||||
{
|
||||
REACTIVE_DEFENSE = 0,
|
||||
REACTIVE_DEFENSE_2 = 1
|
||||
REACTIVE_DEFENSE_2 = 1,
|
||||
MAX_REACTIVE
|
||||
};
|
||||
|
||||
#define MAX_REACTIVE 2
|
||||
#define SUMMON_SLOT_PET 0
|
||||
#define SUMMON_SLOT_TOTEM 1
|
||||
#define MAX_TOTEM_SLOT 5
|
||||
#define SUMMON_SLOT_MINIPET 5
|
||||
#define SUMMON_SLOT_QUEST 6
|
||||
#define MAX_SUMMON_SLOT 7
|
||||
|
||||
#define MAX_GAMEOBJECT_SLOT 4
|
||||
struct PositionUpdateInfo
|
||||
{
|
||||
bool Relocated = false;
|
||||
bool Turned = false;
|
||||
};
|
||||
|
||||
// delay time next attack to prevent client attack animation problems
|
||||
#define ATTACK_DISPLAY_DELAY 200
|
||||
@@ -1953,6 +1950,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
|
||||
void UpdateSplineMovement(uint32 t_diff);
|
||||
void UpdateSplinePosition();
|
||||
void InterruptMovementBasedAuras();
|
||||
|
||||
// player or player's pet
|
||||
float GetCombatRatingReduction(CombatRating cr) const;
|
||||
@@ -2006,6 +2004,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
SpellHistory* _spellHistory;
|
||||
|
||||
std::unique_ptr<MovementForces> _movementForces;
|
||||
PositionUpdateInfo _positionUpdateInfo;
|
||||
};
|
||||
|
||||
namespace Trinity
|
||||
|
||||
@@ -5855,6 +5855,23 @@ enum class SummonTitle : int32
|
||||
ServantOfNZoth = 44
|
||||
};
|
||||
|
||||
enum SummonSlot : int32
|
||||
{
|
||||
SUMMON_SLOT_ANY_TOTEM = -1,
|
||||
SUMMON_SLOT_PET = 0,
|
||||
SUMMON_SLOT_TOTEM = 1,
|
||||
SUMMON_SLOT_TOTEM_2 = 2,
|
||||
SUMMON_SLOT_TOTEM_3 = 3,
|
||||
SUMMON_SLOT_TOTEM_4 = 4,
|
||||
SUMMON_SLOT_MINIPET = 5,
|
||||
SUMMON_SLOT_QUEST = 6,
|
||||
|
||||
MAX_SUMMON_SLOT
|
||||
};
|
||||
|
||||
#define MAX_TOTEM_SLOT 5
|
||||
#define MAX_GAMEOBJECT_SLOT 4
|
||||
|
||||
enum EventId
|
||||
{
|
||||
EVENT_CHARGE = 1003,
|
||||
|
||||
Reference in New Issue
Block a user