fix(Core/Movement): Send proper movement animation visuals. (#10843)

Fixed #10812
Fixed #10814
This commit is contained in:
UltraNix
2022-03-06 18:31:41 +01:00
committed by GitHub
parent 41cc053c68
commit 617d85a498
7 changed files with 37 additions and 36 deletions
@@ -0,0 +1,3 @@
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1645976772405658200');
UPDATE `creature_template` SET `flags_extra`=`flags_extra`|512 WHERE `entry` IN (33186,33724,28859,31734);
+24 -24
View File
@@ -204,7 +204,7 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipientGroup(0), Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipientGroup(0),
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f), m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f),
m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE), m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE),
m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_originalAnimTier(UNIT_BYTE1_FLAG_GROUND), m_AlreadyCallAssistance(false), m_spawnId(0), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false), m_AlreadySearchedAssistance(false), m_regenHealth(true), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL), m_originalEntry(0), m_moveInLineOfSightDisabled(false), m_moveInLineOfSightStrictlyDisabled(false),
m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_detectionDistance(20.0f), m_waypointID(0), m_path_id(0), m_formation(nullptr), _lastDamagedTime(nullptr), m_cannotReachTarget(false), m_cannotReachTimer(0), m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_detectionDistance(20.0f), m_waypointID(0), m_path_id(0), m_formation(nullptr), _lastDamagedTime(nullptr), m_cannotReachTarget(false), m_cannotReachTimer(0),
_isMissingSwimmingFlagOutOfCombat(false), m_assistanceTimer(0) _isMissingSwimmingFlagOutOfCombat(false), m_assistanceTimer(0)
@@ -1856,8 +1856,8 @@ void Creature::setDeathState(DeathState s, bool despawn)
m_formation->FormationReset(true, false); m_formation->FormationReset(true, false);
bool needsFalling = !despawn && (IsFlying() || IsHovering()) && !IsUnderWater(); bool needsFalling = !despawn && (IsFlying() || IsHovering()) && !IsUnderWater();
SetHover(false); SetHover(false, false, false);
SetDisableGravity(false); SetDisableGravity(false, false, false);
if (needsFalling) if (needsFalling)
GetMotionMaster()->MoveFall(0, true); GetMotionMaster()->MoveFall(0, true);
@@ -2536,8 +2536,7 @@ bool Creature::LoadCreaturesAddon(bool reload)
//SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_PET_TALENTS, uint8((cainfo->bytes1 >> 8) & 0xFF)); //SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_PET_TALENTS, uint8((cainfo->bytes1 >> 8) & 0xFF));
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_PET_TALENTS, 0); SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_PET_TALENTS, 0);
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, uint8((cainfo->bytes1 >> 16) & 0xFF)); SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_VIS_FLAG, uint8((cainfo->bytes1 >> 16) & 0xFF));
m_originalAnimTier = uint8((cainfo->bytes1 >> 24) & 0xFF); SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, uint8((cainfo->bytes1 >> 24) & 0xFF));
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, m_originalAnimTier);
//! Suspected correlation between UNIT_FIELD_BYTES_1, offset 3, value 0x2: //! Suspected correlation between UNIT_FIELD_BYTES_1, offset 3, value 0x2:
//! If no inhabittype_fly (if no MovementFlag_DisableGravity or MovementFlag_CanFly flag found in sniffs) //! If no inhabittype_fly (if no MovementFlag_DisableGravity or MovementFlag_CanFly flag found in sniffs)
@@ -2973,7 +2972,7 @@ bool Creature::SetWalk(bool enable)
return true; return true;
} }
bool Creature::SetDisableGravity(bool disable, bool packetOnly/*=false*/) bool Creature::SetDisableGravity(bool disable, bool packetOnly /*= false*/, bool updateAnimationTier /*= true*/)
{ {
//! It's possible only a packet is sent but moveflags are not updated //! It's possible only a packet is sent but moveflags are not updated
//! Need more research on this //! Need more research on this
@@ -2994,8 +2993,15 @@ bool Creature::SetDisableGravity(bool disable, bool packetOnly/*=false*/)
return true; return true;
} }
if (!movespline->Initialized()) if (updateAnimationTier && IsAlive() && !HasUnitState(UNIT_STATE_ROOT) && !GetMovementTemplate().IsRooted())
return true; {
if (IsLevitating())
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_FLY);
else if (IsHovering())
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_HOVER);
else
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_GROUND);
}
WorldPacket data(disable ? SMSG_SPLINE_MOVE_GRAVITY_DISABLE : SMSG_SPLINE_MOVE_GRAVITY_ENABLE, 9); WorldPacket data(disable ? SMSG_SPLINE_MOVE_GRAVITY_DISABLE : SMSG_SPLINE_MOVE_GRAVITY_ENABLE, 9);
data << GetPackGUID(); data << GetPackGUID();
@@ -3008,9 +3014,6 @@ bool Creature::SetSwim(bool enable)
if (!Unit::SetSwim(enable)) if (!Unit::SetSwim(enable))
return false; return false;
if (!movespline->Initialized())
return true;
WorldPacket data(enable ? SMSG_SPLINE_MOVE_START_SWIM : SMSG_SPLINE_MOVE_STOP_SWIM); WorldPacket data(enable ? SMSG_SPLINE_MOVE_START_SWIM : SMSG_SPLINE_MOVE_STOP_SWIM);
data << GetPackGUID(); data << GetPackGUID();
SendMessageToSet(&data, true); SendMessageToSet(&data, true);
@@ -3078,9 +3081,6 @@ bool Creature::SetCanFly(bool enable, bool /*packetOnly*/ /* = false */)
return true; return true;
} }
if (!movespline->Initialized())
return true;
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_FLYING : SMSG_SPLINE_MOVE_UNSET_FLYING, 9); WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_FLYING : SMSG_SPLINE_MOVE_UNSET_FLYING, 9);
data << GetPackGUID(); data << GetPackGUID();
SendMessageToSet(&data, false); SendMessageToSet(&data, false);
@@ -3106,9 +3106,6 @@ bool Creature::SetWaterWalking(bool enable, bool packetOnly /* = false */)
return true; return true;
} }
if (!movespline->Initialized())
return true;
WorldPacket data(enable ? SMSG_SPLINE_MOVE_WATER_WALK : SMSG_SPLINE_MOVE_LAND_WALK, 9); WorldPacket data(enable ? SMSG_SPLINE_MOVE_WATER_WALK : SMSG_SPLINE_MOVE_LAND_WALK, 9);
data << GetPackGUID(); data << GetPackGUID();
SendMessageToSet(&data, true); SendMessageToSet(&data, true);
@@ -3134,24 +3131,27 @@ bool Creature::SetFeatherFall(bool enable, bool packetOnly /* = false */)
return true; return true;
} }
if (!movespline->Initialized())
return true;
WorldPacket data(enable ? SMSG_SPLINE_MOVE_FEATHER_FALL : SMSG_SPLINE_MOVE_NORMAL_FALL, 9); WorldPacket data(enable ? SMSG_SPLINE_MOVE_FEATHER_FALL : SMSG_SPLINE_MOVE_NORMAL_FALL, 9);
data << GetPackGUID(); data << GetPackGUID();
SendMessageToSet(&data, true); SendMessageToSet(&data, true);
return true; return true;
} }
bool Creature::SetHover(bool enable, bool packetOnly /*= false*/) bool Creature::SetHover(bool enable, bool packetOnly /*= false*/, bool updateAnimationTier /*= true*/)
{ {
if (!packetOnly && !Unit::SetHover(enable)) if (!packetOnly && !Unit::SetHover(enable))
return false; return false;
if (!movespline->Initialized()) if (updateAnimationTier && IsAlive() && !HasUnitState(UNIT_STATE_ROOT) && !GetMovementTemplate().IsRooted())
return true; {
if (IsLevitating())
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_FLY);
else if (IsHovering())
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_HOVER);
else
SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_ANIM_TIER, UNIT_BYTE1_FLAG_GROUND);
}
//! Not always a packet is sent
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_HOVER : SMSG_SPLINE_MOVE_UNSET_HOVER, 9); WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_HOVER : SMSG_SPLINE_MOVE_UNSET_HOVER, 9);
data << GetPackGUID(); data << GetPackGUID();
SendMessageToSet(&data, false); SendMessageToSet(&data, false);
+2 -4
View File
@@ -133,12 +133,12 @@ public:
[[nodiscard]] CreatureAI* AI() const { return (CreatureAI*)i_AI; } [[nodiscard]] CreatureAI* AI() const { return (CreatureAI*)i_AI; }
bool SetWalk(bool enable) override; bool SetWalk(bool enable) override;
bool SetDisableGravity(bool disable, bool packetOnly = false) override; bool SetDisableGravity(bool disable, bool packetOnly = false, bool updateAnimationTier = true) override;
bool SetSwim(bool enable) override; bool SetSwim(bool enable) override;
bool SetCanFly(bool enable, bool packetOnly = false) override; bool SetCanFly(bool enable, bool packetOnly = false) override;
bool SetWaterWalking(bool enable, bool packetOnly = false) override; bool SetWaterWalking(bool enable, bool packetOnly = false) override;
bool SetFeatherFall(bool enable, bool packetOnly = false) override; bool SetFeatherFall(bool enable, bool packetOnly = false) override;
bool SetHover(bool enable, bool packetOnly = false) override; bool SetHover(bool enable, bool packetOnly = false, bool updateAnimationTier = true) override;
bool HasSpellFocus(Spell const* focusSpell = nullptr) const; bool HasSpellFocus(Spell const* focusSpell = nullptr) const;
struct struct
@@ -412,8 +412,6 @@ protected:
uint8 m_equipmentId; uint8 m_equipmentId;
int8 m_originalEquipmentId; // can be -1 int8 m_originalEquipmentId; // can be -1
uint8 m_originalAnimTier;
bool m_AlreadyCallAssistance; bool m_AlreadyCallAssistance;
bool m_AlreadySearchedAssistance; bool m_AlreadySearchedAssistance;
bool m_regenHealth; bool m_regenHealth;
+2 -2
View File
@@ -15397,7 +15397,7 @@ bool Player::IsInWhisperWhiteList(ObjectGuid guid)
return false; return false;
} }
bool Player::SetDisableGravity(bool disable, bool packetOnly /*= false*/) bool Player::SetDisableGravity(bool disable, bool packetOnly /*= false*/, bool /*updateAnimationTier = true*/)
{ {
if (!packetOnly && !Unit::SetDisableGravity(disable)) if (!packetOnly && !Unit::SetDisableGravity(disable))
return false; return false;
@@ -15436,7 +15436,7 @@ bool Player::SetCanFly(bool apply, bool packetOnly /*= false*/)
return true; return true;
} }
bool Player::SetHover(bool apply, bool packetOnly /*= false*/) bool Player::SetHover(bool apply, bool packetOnly /*= false*/, bool /*updateAnimationTier = true*/)
{ {
// moved inside, flag can be removed on landing and wont send appropriate packet to client when aura is removed // moved inside, flag can be removed on landing and wont send appropriate packet to client when aura is removed
if (!packetOnly /* && !Unit::SetHover(apply)*/) if (!packetOnly /* && !Unit::SetHover(apply)*/)
+2 -2
View File
@@ -2505,11 +2505,11 @@ public:
bool IsInWhisperWhiteList(ObjectGuid guid); bool IsInWhisperWhiteList(ObjectGuid guid);
void RemoveFromWhisperWhiteList(ObjectGuid guid) { WhisperList.remove(guid); } void RemoveFromWhisperWhiteList(ObjectGuid guid) { WhisperList.remove(guid); }
bool SetDisableGravity(bool disable, bool packetOnly /* = false */) override; bool SetDisableGravity(bool disable, bool packetOnly = false, bool updateAnimationTier = true) override;
bool SetCanFly(bool apply, bool packetOnly = false) override; bool SetCanFly(bool apply, bool packetOnly = false) override;
bool SetWaterWalking(bool apply, bool packetOnly = false) override; bool SetWaterWalking(bool apply, bool packetOnly = false) override;
bool SetFeatherFall(bool apply, bool packetOnly = false) override; bool SetFeatherFall(bool apply, bool packetOnly = false) override;
bool SetHover(bool enable, bool packetOnly = false) override; bool SetHover(bool enable, bool packetOnly = false, bool updateAnimationTier = true) override;
[[nodiscard]] bool CanFly() const override { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); } [[nodiscard]] bool CanFly() const override { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); }
[[nodiscard]] bool CanEnterWater() const override { return true; } [[nodiscard]] bool CanEnterWater() const override { return true; }
+2 -2
View File
@@ -19900,7 +19900,7 @@ bool Unit::SetWalk(bool enable)
return true; return true;
} }
bool Unit::SetDisableGravity(bool disable, bool /*packetOnly = false*/) bool Unit::SetDisableGravity(bool disable, bool /*packetOnly = false*/, bool /*updateAnimationTier = true*/)
{ {
if (disable == IsLevitating()) if (disable == IsLevitating())
return false; return false;
@@ -19999,7 +19999,7 @@ void Unit::SendMovementFeatherFall(Player* sendTo)
sendTo->SendDirectMessage(&data); sendTo->SendDirectMessage(&data);
} }
bool Unit::SetHover(bool enable, bool /*packetOnly = false*/) bool Unit::SetHover(bool enable, bool /*packetOnly = false*/, bool /*updateAnimationTier = true*/)
{ {
if (enable == HasUnitMovementFlag(MOVEMENTFLAG_HOVER)) if (enable == HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
return false; return false;
+2 -2
View File
@@ -1698,12 +1698,12 @@ public:
void SendMovementFlagUpdate(bool self = false); void SendMovementFlagUpdate(bool self = false);
virtual bool SetWalk(bool enable); virtual bool SetWalk(bool enable);
virtual bool SetDisableGravity(bool disable, bool packetOnly = false); virtual bool SetDisableGravity(bool disable, bool packetOnly = false, bool updateAnimationTier = true);
virtual bool SetSwim(bool enable); virtual bool SetSwim(bool enable);
virtual bool SetCanFly(bool enable, bool packetOnly = false); virtual bool SetCanFly(bool enable, bool packetOnly = false);
virtual bool SetWaterWalking(bool enable, bool packetOnly = false); virtual bool SetWaterWalking(bool enable, bool packetOnly = false);
virtual bool SetFeatherFall(bool enable, bool packetOnly = false); virtual bool SetFeatherFall(bool enable, bool packetOnly = false);
virtual bool SetHover(bool enable, bool packetOnly = false); virtual bool SetHover(bool enable, bool packetOnly = false, bool updateAnimationTier = true);
// pussywizard: // pussywizard:
void SendMovementWaterWalking(Player* sendTo); void SendMovementWaterWalking(Player* sendTo);