Skip to content

Commit cc908c7

Browse files
committed
Core/Units: Port movement status altering functions from master branch
1 parent 858f8c1 commit cc908c7

File tree

6 files changed

+188
-247
lines changed

6 files changed

+188
-247
lines changed

src/server/game/Entities/Creature/Creature.cpp

Lines changed: 2 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,8 +2007,8 @@ void Creature::setDeathState(DeathState s)
20072007
m_formation->FormationReset(true);
20082008

20092009
bool needsFalling = (IsFlying() || IsHovering()) && !IsUnderWater();
2010-
SetHover(false, false);
2011-
SetDisableGravity(false, false);
2010+
SetHover(false);
2011+
SetDisableGravity(false);
20122012

20132013
if (needsFalling)
20142014
GetMotionMaster()->MoveFall();
@@ -2932,124 +2932,6 @@ void Creature::SetCannotReachTarget(bool cannotReach)
29322932
TC_LOG_DEBUG("entities.unit.chase", "Creature::SetCannotReachTarget() called with true. Details: {}", GetDebugInfo());
29332933
}
29342934

2935-
bool Creature::SetWalk(bool enable)
2936-
{
2937-
if (!Unit::SetWalk(enable))
2938-
return false;
2939-
2940-
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_WALK_MODE : SMSG_SPLINE_MOVE_SET_RUN_MODE, 9);
2941-
data << GetPackGUID();
2942-
SendMessageToSet(&data, false);
2943-
return true;
2944-
}
2945-
2946-
bool Creature::SetDisableGravity(bool disable, bool packetOnly /*=false*/, bool updateAnimTier /*= true*/)
2947-
{
2948-
//! It's possible only a packet is sent but moveflags are not updated
2949-
//! Need more research on this
2950-
if (!packetOnly && !Unit::SetDisableGravity(disable, packetOnly, updateAnimTier))
2951-
return false;
2952-
2953-
if (updateAnimTier && IsAlive() && !HasUnitState(UNIT_STATE_ROOT) && !GetMovementTemplate().IsRooted())
2954-
{
2955-
if (IsGravityDisabled())
2956-
SetAnimTier(AnimTier::Fly);
2957-
else if (IsHovering())
2958-
SetAnimTier(AnimTier::Hover);
2959-
else
2960-
SetAnimTier(AnimTier::Ground);
2961-
}
2962-
2963-
if (!movespline->Initialized())
2964-
return true;
2965-
2966-
WorldPacket data(disable ? SMSG_SPLINE_MOVE_GRAVITY_DISABLE : SMSG_SPLINE_MOVE_GRAVITY_ENABLE, 9);
2967-
data << GetPackGUID();
2968-
SendMessageToSet(&data, false);
2969-
return true;
2970-
}
2971-
2972-
bool Creature::SetSwim(bool enable)
2973-
{
2974-
if (!Unit::SetSwim(enable))
2975-
return false;
2976-
2977-
if (!movespline->Initialized())
2978-
return true;
2979-
2980-
WorldPacket data(enable ? SMSG_SPLINE_MOVE_START_SWIM : SMSG_SPLINE_MOVE_STOP_SWIM);
2981-
data << GetPackGUID();
2982-
SendMessageToSet(&data, true);
2983-
return true;
2984-
}
2985-
2986-
bool Creature::SetCanFly(bool enable, bool /*packetOnly = false */)
2987-
{
2988-
if (!Unit::SetCanFly(enable))
2989-
return false;
2990-
2991-
if (!movespline->Initialized())
2992-
return true;
2993-
2994-
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_FLYING : SMSG_SPLINE_MOVE_UNSET_FLYING, 9);
2995-
data << GetPackGUID();
2996-
SendMessageToSet(&data, false);
2997-
return true;
2998-
}
2999-
3000-
bool Creature::SetWaterWalking(bool enable, bool packetOnly /* = false */)
3001-
{
3002-
if (!packetOnly && !Unit::SetWaterWalking(enable))
3003-
return false;
3004-
3005-
if (!movespline->Initialized())
3006-
return true;
3007-
3008-
WorldPacket data(enable ? SMSG_SPLINE_MOVE_WATER_WALK : SMSG_SPLINE_MOVE_LAND_WALK);
3009-
data << GetPackGUID();
3010-
SendMessageToSet(&data, true);
3011-
return true;
3012-
}
3013-
3014-
bool Creature::SetFeatherFall(bool enable, bool packetOnly /* = false */)
3015-
{
3016-
if (!packetOnly && !Unit::SetFeatherFall(enable))
3017-
return false;
3018-
3019-
if (!movespline->Initialized())
3020-
return true;
3021-
3022-
WorldPacket data(enable ? SMSG_SPLINE_MOVE_FEATHER_FALL : SMSG_SPLINE_MOVE_NORMAL_FALL);
3023-
data << GetPackGUID();
3024-
SendMessageToSet(&data, true);
3025-
return true;
3026-
}
3027-
3028-
bool Creature::SetHover(bool enable, bool packetOnly /*= false*/, bool updateAnimTier /*= true*/)
3029-
{
3030-
if (!packetOnly && !Unit::SetHover(enable, packetOnly, updateAnimTier))
3031-
return false;
3032-
3033-
if (updateAnimTier && IsAlive() && !HasUnitState(UNIT_STATE_ROOT) && !GetMovementTemplate().IsRooted())
3034-
{
3035-
if (IsGravityDisabled())
3036-
SetAnimTier(AnimTier::Fly);
3037-
else if (IsHovering())
3038-
SetAnimTier(AnimTier::Hover);
3039-
else
3040-
SetAnimTier(AnimTier::Ground);
3041-
}
3042-
3043-
if (!movespline->Initialized())
3044-
return true;
3045-
3046-
//! Not always a packet is sent
3047-
WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_HOVER : SMSG_SPLINE_MOVE_UNSET_HOVER, 9);
3048-
data << GetPackGUID();
3049-
SendMessageToSet(&data, false);
3050-
return true;
3051-
}
3052-
30532935
float Creature::GetAggroRange(Unit const* target) const
30542936
{
30552937
// Determines the aggro range for creatures (usually pets), used mainly for aggressive pet target selection.

src/server/game/Entities/Creature/Creature.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,6 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
153153

154154
CreatureAI* AI() const { return reinterpret_cast<CreatureAI*>(GetAI()); }
155155

156-
bool SetWalk(bool enable) override;
157-
bool SetDisableGravity(bool disable, bool packetOnly = false, bool updateAnimTier = true) override;
158-
bool SetSwim(bool enable) override;
159-
bool SetCanFly(bool enable, bool packetOnly = false) override;
160-
bool SetWaterWalking(bool enable, bool packetOnly = false) override;
161-
bool SetFeatherFall(bool enable, bool packetOnly = false) override;
162-
bool SetHover(bool enable, bool packetOnly = false, bool updateAnimTier = true) override;
163-
164156
uint32 GetShieldBlockValue() const override;
165157

166158
SpellSchoolMask GetMeleeDamageSchoolMask(WeaponAttackType /*attackType*/ = BASE_ATTACK, uint8 /*damageIndex*/ = 0) const override { return m_meleeDamageSchoolMask; }

src/server/game/Entities/Player/Player.cpp

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -26380,96 +26380,6 @@ bool Player::IsInWhisperWhiteList(ObjectGuid guid)
2638026380
return false;
2638126381
}
2638226382

26383-
bool Player::SetDisableGravity(bool disable, bool packetOnly /*= false*/, bool updateAnimTier /*= true*/)
26384-
{
26385-
if (!packetOnly && !Unit::SetDisableGravity(disable, packetOnly, updateAnimTier))
26386-
return false;
26387-
26388-
WorldPacket data(disable ? SMSG_MOVE_GRAVITY_DISABLE : SMSG_MOVE_GRAVITY_ENABLE, 12);
26389-
data << GetPackGUID();
26390-
data << uint32(0); //! movement counter
26391-
SendDirectMessage(&data);
26392-
26393-
data.Initialize(MSG_MOVE_GRAVITY_CHNG, 64);
26394-
data << GetPackGUID();
26395-
BuildMovementPacket(&data);
26396-
SendMessageToSet(&data, false);
26397-
return true;
26398-
}
26399-
26400-
bool Player::SetCanFly(bool apply, bool packetOnly /*= false*/)
26401-
{
26402-
if (!apply)
26403-
SetFallInformation(0, GetPositionZ());
26404-
26405-
WorldPacket data(apply ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY, 12);
26406-
data << GetPackGUID();
26407-
data << uint32(0); //! movement counter
26408-
SendDirectMessage(&data);
26409-
26410-
if (packetOnly || Unit::SetCanFly(apply))
26411-
{
26412-
data.Initialize(MSG_MOVE_UPDATE_CAN_FLY, 64);
26413-
data << GetPackGUID();
26414-
BuildMovementPacket(&data);
26415-
SendMessageToSet(&data, false);
26416-
return true;
26417-
}
26418-
else
26419-
return false;
26420-
}
26421-
26422-
bool Player::SetHover(bool apply, bool packetOnly /*= false*/, bool updateAnimTier /*= true*/)
26423-
{
26424-
if (!packetOnly && !Unit::SetHover(apply, packetOnly, updateAnimTier))
26425-
return false;
26426-
26427-
WorldPacket data(apply ? SMSG_MOVE_SET_HOVER : SMSG_MOVE_UNSET_HOVER, 12);
26428-
data << GetPackGUID();
26429-
data << uint32(0); //! movement counter
26430-
SendDirectMessage(&data);
26431-
26432-
data.Initialize(MSG_MOVE_HOVER, 64);
26433-
data << GetPackGUID();
26434-
BuildMovementPacket(&data);
26435-
SendMessageToSet(&data, false);
26436-
return true;
26437-
}
26438-
26439-
bool Player::SetWaterWalking(bool apply, bool packetOnly /*= false*/)
26440-
{
26441-
if (!packetOnly && !Unit::SetWaterWalking(apply))
26442-
return false;
26443-
26444-
WorldPacket data(apply ? SMSG_MOVE_WATER_WALK : SMSG_MOVE_LAND_WALK, 12);
26445-
data << GetPackGUID();
26446-
data << uint32(0); //! movement counter
26447-
SendDirectMessage(&data);
26448-
26449-
data.Initialize(MSG_MOVE_WATER_WALK, 64);
26450-
data << GetPackGUID();
26451-
BuildMovementPacket(&data);
26452-
SendMessageToSet(&data, false);
26453-
return true;
26454-
}
26455-
26456-
bool Player::SetFeatherFall(bool apply, bool packetOnly /*= false*/)
26457-
{
26458-
if (!packetOnly && !Unit::SetFeatherFall(apply))
26459-
return false;
26460-
26461-
WorldPacket data(apply ? SMSG_MOVE_FEATHER_FALL : SMSG_MOVE_NORMAL_FALL, 12);
26462-
data << GetPackGUID();
26463-
data << uint32(0); //! movement counter
26464-
SendDirectMessage(&data);
26465-
26466-
data.Initialize(MSG_MOVE_FEATHER_FALL, 64);
26467-
data << GetPackGUID();
26468-
BuildMovementPacket(&data);
26469-
SendMessageToSet(&data, false);
26470-
return true;
26471-
}
26472-
2647326383
void Player::SendMovementSetCollisionHeight(float height)
2647426384
{
2647526385
WorldPacket data(SMSG_MOVE_SET_COLLISION_HGT, GetPackGUID().size() + 4 + 4);

src/server/game/Entities/Player/Player.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,11 +2255,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
22552255
bool IsInWhisperWhiteList(ObjectGuid guid);
22562256
void RemoveFromWhisperWhiteList(ObjectGuid guid) { WhisperList.remove(guid); }
22572257

2258-
bool SetDisableGravity(bool disable, bool packetOnly /* = false */, bool updateAnimTier = true) override;
2259-
bool SetCanFly(bool apply, bool packetOnly = false) override;
2260-
bool SetWaterWalking(bool apply, bool packetOnly = false) override;
2261-
bool SetFeatherFall(bool apply, bool packetOnly = false) override;
2262-
bool SetHover(bool enable, bool packetOnly = false, bool updateAnimTier = true) override;
22632258
void SendMovementSetCollisionHeight(float height);
22642259

22652260
bool CanFly() const override { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); }

0 commit comments

Comments
 (0)