diff options
| author | NoName <322016+Faq@users.noreply.github.com> | 2020-09-08 18:12:52 +0300 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-02-05 15:40:31 +0100 |
| commit | ee620856ad2918ae7ce91a37a980d9f2129a074a (patch) | |
| tree | 119fcdb41718dc738fce784c149c913d60ea8f0b /src/server/game/Entities | |
| parent | 358dc78e47a6276e9f511e6510e04865d2d87fd2 (diff) | |
Core/Movement: Corrected Animation Tier handling (PR #24875)
Co-authored-by: Warpten <vertozor@gmail.com>
Co-authored-by: Ovahlord <dreadkiller@gmx.de>
Co-authored-by: Carbenium <carbenium@outlook.com>
(cherry picked from commit dad187615df603ad8614531a0ec84c1a5e136838)
Diffstat (limited to 'src/server/game/Entities')
| -rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 8 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 4 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 35 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 7 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/UnitDefines.h | 14 |
5 files changed, 46 insertions, 22 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 0ca2f5fc298..8688592fc0b 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2100,6 +2100,7 @@ void Creature::setDeathState(DeathState s) uint32 respawnDelay = m_respawnDelay; if (uint32 scalingMode = sWorld->getIntConfig(CONFIG_RESPAWN_DYNAMICMODE)) GetMap()->ApplyDynamicModeRespawnScaling(this, m_spawnId, respawnDelay, scalingMode); + // @todo remove the boss respawn time hack in a dynspawn follow-up once we have creature groups in instances if (m_respawnCompatibilityMode) { @@ -2135,8 +2136,9 @@ void Creature::setDeathState(DeathState s) if (m_formation && m_formation->GetLeader() == this) m_formation->FormationReset(true); - bool needsFalling = IsFlying() || IsHovering(); - SetHover(false); + bool needsFalling = (IsFlying() || IsHovering()) && !IsUnderWater(); + SetHover(false, false); + SetDisableGravity(false, false); if (needsFalling) GetMotionMaster()->MoveFall(); @@ -2670,7 +2672,7 @@ bool Creature::LoadCreaturesAddon() SetStandState(UnitStandStateType(cainfo->bytes1 & 0xFF)); SetVisFlags(UnitVisFlags((cainfo->bytes1 >> 16) & 0xFF)); - SetAnimTier(UnitBytes1_Flags((cainfo->bytes1 >> 24) & 0xFF), false); + SetAnimTier(AnimTier((cainfo->bytes1 >> 24) & 0xFF), false); //! 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) diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index fcf87e12376..b782c3ad2dc 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -4294,9 +4294,6 @@ void Player::BuildPlayerRepop() StopMirrorTimers(); //disable timers(bars) - // set and clear other - SetAnimTier(UNIT_BYTE1_FLAG_ALWAYS_STAND, false); - // OnPlayerRepop hook sScriptMgr->OnPlayerRepop(this); } @@ -4310,7 +4307,6 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) // speed change, land walk // remove death flag + set aura - SetAnimTier(UNIT_BYTE1_FLAG_NONE, false); RemovePlayerFlag(PLAYER_FLAGS_IS_OUT_OF_BOUNDS); // This must be called always even on Players with race != RACE_NIGHTELF in case of faction change diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 19c2e050bed..f9e66caa44d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -534,8 +534,13 @@ void Unit::UpdateSplineMovement(uint32 t_diff) } if (arrived) + { DisableSpline(); + if (Optional<AnimTier> animTier = movespline->GetAnimation()) + SetAnimTier(*animTier); + } + UpdateSplinePosition(); } @@ -9925,15 +9930,15 @@ void Unit::SetStandState(UnitStandStateType state, uint32 animKitID /* = 0*/) } } -void Unit::SetAnimTier(UnitBytes1_Flags animTier, bool notifyClient) +void Unit::SetAnimTier(AnimTier animTier, bool notifyClient /*= true*/) { - SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::AnimTier), animTier); + SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::AnimTier), AsUnderlyingType(animTier)); if (notifyClient) { WorldPackets::Misc::SetAnimTier setAnimTier; setAnimTier.Unit = GetGUID(); - setAnimTier.Tier = animTier; + setAnimTier.Tier = AsUnderlyingType(animTier); SendMessageToSet(setAnimTier.Write(), true); } } @@ -12447,7 +12452,7 @@ bool Unit::SetWalk(bool enable) return true; } -bool Unit::SetDisableGravity(bool disable) +bool Unit::SetDisableGravity(bool disable, bool updateAnimationTier /*= true*/) { if (disable == IsGravityDisabled()) return false; @@ -12484,6 +12489,16 @@ bool Unit::SetDisableGravity(bool disable) SendMessageToSet(packet.Write(), true); } + if (IsCreature() && updateAnimationTier && IsAlive() && !HasUnitState(UNIT_STATE_ROOT) && !ToCreature()->GetMovementTemplate().IsRooted()) + { + if (IsGravityDisabled()) + SetAnimTier(AnimTier::Fly); + else if (IsHovering()) + SetAnimTier(AnimTier::Hover); + else + SetAnimTier(AnimTier::Ground); + } + return true; } @@ -12640,7 +12655,7 @@ bool Unit::SetFeatherFall(bool enable) return true; } -bool Unit::SetHover(bool enable) +bool Unit::SetHover(bool enable, bool updateAnimationTier /*= true*/) { if (enable == HasUnitMovementFlag(MOVEMENTFLAG_HOVER)) return false; @@ -12690,6 +12705,16 @@ bool Unit::SetHover(bool enable) SendMessageToSet(packet.Write(), true); } + if (IsCreature() && updateAnimationTier && IsAlive() && !HasUnitState(UNIT_STATE_ROOT) && !ToCreature()->GetMovementTemplate().IsRooted()) + { + if (IsGravityDisabled()) + SetAnimTier(AnimTier::Fly); + else if (IsHovering()) + SetAnimTier(AnimTier::Hover); + else + SetAnimTier(AnimTier::Ground); + } + return true; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 50e27c7f32b..b0438292d04 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -998,7 +998,8 @@ class TC_GAME_API Unit : public WorldObject void RemoveVisFlags(UnitVisFlags flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::VisFlags), flags); } void SetVisFlags(UnitVisFlags flags) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::VisFlags), flags); } - void SetAnimTier(UnitBytes1_Flags animTier, bool notifyClient); + AnimTier GetAnimTier() const { return AnimTier(*m_unitData->AnimTier); } + void SetAnimTier(AnimTier animTier, bool notifyClient = true); bool IsMounted() const { return HasUnitFlag(UNIT_FLAG_MOUNT); } uint32 GetMountDisplayId() const { return m_unitData->MountDisplayID; } @@ -1205,13 +1206,13 @@ class TC_GAME_API Unit : public WorldObject bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING); } bool IsHovering() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_HOVER); } bool SetWalk(bool enable); - bool SetDisableGravity(bool disable); + bool SetDisableGravity(bool disable, bool updateAnimationTier = true); bool SetFall(bool enable); bool SetSwim(bool enable); bool SetCanFly(bool enable); bool SetWaterWalking(bool enable); bool SetFeatherFall(bool enable); - bool SetHover(bool enable); + bool SetHover(bool enable, bool updateAnimationTier = true); bool SetCollision(bool disable); bool SetCanTransitionBetweenSwimAndFly(bool enable); bool SetCanTurnWhileFalling(bool enable); diff --git a/src/server/game/Entities/Unit/UnitDefines.h b/src/server/game/Entities/Unit/UnitDefines.h index f19ca62a94d..3e3d124dc28 100644 --- a/src/server/game/Entities/Unit/UnitDefines.h +++ b/src/server/game/Entities/Unit/UnitDefines.h @@ -56,14 +56,14 @@ enum UnitVisFlags : uint8 UNIT_VIS_FLAGS_ALL = 0xFF }; -// byte flags value (UNIT_FIELD_BYTES_1, 3) -enum UnitBytes1_Flags : uint8 +// UNIT_FIELD_BYTES_1 (UNIT_BYTES_1_OFFSET_ANIM_TIER) +enum class AnimTier : uint8 { - UNIT_BYTE1_FLAG_NONE = 0x00, - UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01, - UNIT_BYTE1_FLAG_HOVER = 0x02, - UNIT_BYTE1_FLAG_UNK_3 = 0x04, - UNIT_BYTE1_FLAG_ALL = 0xFF + Ground = 0, // plays ground tier animations + Swim = 1, // falls back to ground tier animations, not handled by the client, should never appear in sniffs, will prevent tier change animations from playing correctly if used + Hover = 2, // plays flying tier animations or falls back to ground tier animations, automatically enables hover clientside when entering visibility with this value + Fly = 3, // plays flying tier animations + Submerged = 4 }; // low byte (0 from 0..3) of UNIT_FIELD_BYTES_2 |
