Core/Movement: Corrected Animation Tier handling
Port From (https://github.com/TrinityCore/TrinityCore/commit/ee620856ad2918ae7ce91a37a980d9f2129a074a)
This commit is contained in:
@@ -120,14 +120,6 @@ namespace Framework.Constants
|
|||||||
public const uint SmartEscortLastOCCPoint = 0xFFFFFF;
|
public const uint SmartEscortLastOCCPoint = 0xFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AnimType
|
|
||||||
{
|
|
||||||
ToGround = 0, // 460 = ToGround, index of AnimationData.dbc
|
|
||||||
FlyToFly = 1, // 461 = FlyToFly?
|
|
||||||
ToFly = 2, // 458 = ToFly
|
|
||||||
FlyToGround = 3 // 463 = FlyToGround
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum RotateDirection
|
public enum RotateDirection
|
||||||
{
|
{
|
||||||
Left,
|
Left,
|
||||||
|
|||||||
@@ -277,13 +277,13 @@ namespace Framework.Constants
|
|||||||
All = 0xFF
|
All = 0xFF
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum UnitBytes1Flags
|
public enum AnimTier
|
||||||
{
|
{
|
||||||
None = 0x00,
|
Ground = 0, // plays ground tier animations
|
||||||
AlwaysStand = 0x01,
|
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 = 0x02,
|
Hover = 2, // plays flying tier animations or falls back to ground tier animations, automatically enables hover clientside when entering visibility with this value
|
||||||
Unk3 = 0x04,
|
Fly = 3, // plays flying tier animations
|
||||||
All = 0xFF
|
Submerged = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum UnitPVPStateFlags
|
public enum UnitPVPStateFlags
|
||||||
|
|||||||
@@ -1841,9 +1841,7 @@ namespace Game.AI
|
|||||||
target.ToUnit().AddVisFlags((UnitVisFlags)e.Action.setunitByte.byte1);
|
target.ToUnit().AddVisFlags((UnitVisFlags)e.Action.setunitByte.byte1);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// this is totally wrong to maintain compatibility with existing scripts
|
target.ToUnit().SetAnimTier((AnimTier)e.Action.setunitByte.byte1);
|
||||||
// TODO: fix with animtier overhaul
|
|
||||||
target.ToUnit().SetAnimTier((UnitBytes1Flags)(target.ToUnit().m_unitData.AnimTier | e.Action.setunitByte.byte1), false);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1868,7 +1866,7 @@ namespace Game.AI
|
|||||||
target.ToUnit().RemoveVisFlags((UnitVisFlags)e.Action.setunitByte.byte1);
|
target.ToUnit().RemoveVisFlags((UnitVisFlags)e.Action.setunitByte.byte1);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
target.ToUnit().SetAnimTier((UnitBytes1Flags)(target.ToUnit().m_unitData.AnimTier & ~e.Action.setunitByte.byte1), false);
|
target.ToUnit().SetAnimTier(AnimTier.Ground);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1807,6 +1807,7 @@ namespace Game.Entities
|
|||||||
uint scalingMode = WorldConfig.GetUIntValue(WorldCfg.RespawnDynamicMode);
|
uint scalingMode = WorldConfig.GetUIntValue(WorldCfg.RespawnDynamicMode);
|
||||||
if (scalingMode != 0)
|
if (scalingMode != 0)
|
||||||
GetMap().ApplyDynamicModeRespawnScaling(this, m_spawnId, ref respawnDelay, scalingMode);
|
GetMap().ApplyDynamicModeRespawnScaling(this, m_spawnId, ref respawnDelay, scalingMode);
|
||||||
|
|
||||||
// @todo remove the boss respawn time hack in a dynspawn follow-up once we have creature groups in instances
|
// @todo remove the boss respawn time hack in a dynspawn follow-up once we have creature groups in instances
|
||||||
if (m_respawnCompatibilityMode)
|
if (m_respawnCompatibilityMode)
|
||||||
{
|
{
|
||||||
@@ -1841,8 +1842,9 @@ namespace Game.Entities
|
|||||||
if (m_formation != null && m_formation.GetLeader() == this)
|
if (m_formation != null && m_formation.GetLeader() == this)
|
||||||
m_formation.FormationReset(true);
|
m_formation.FormationReset(true);
|
||||||
|
|
||||||
bool needsFalling = IsFlying() || IsHovering();
|
bool needsFalling = (IsFlying() || IsHovering()) && !IsUnderWater();
|
||||||
SetHover(false);
|
SetHover(false, false);
|
||||||
|
SetDisableGravity(false, false);
|
||||||
|
|
||||||
if (needsFalling)
|
if (needsFalling)
|
||||||
GetMotionMaster().MoveFall();
|
GetMotionMaster().MoveFall();
|
||||||
@@ -2374,7 +2376,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
SetStandState((UnitStandStateType)(cainfo.bytes1 & 0xFF));
|
SetStandState((UnitStandStateType)(cainfo.bytes1 & 0xFF));
|
||||||
SetVisFlags((UnitVisFlags)((cainfo.bytes1 >> 16) & 0xFF));
|
SetVisFlags((UnitVisFlags)((cainfo.bytes1 >> 16) & 0xFF));
|
||||||
SetAnimTier((UnitBytes1Flags)((cainfo.bytes1 >> 24) & 0xFF), false);
|
SetAnimTier((AnimTier)((cainfo.bytes1 >> 24) & 0xFF), false);
|
||||||
|
|
||||||
//! 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)
|
||||||
|
|||||||
@@ -4149,9 +4149,6 @@ namespace Game.Entities
|
|||||||
|
|
||||||
StopMirrorTimers(); //disable timers(bars)
|
StopMirrorTimers(); //disable timers(bars)
|
||||||
|
|
||||||
// set and clear other
|
|
||||||
SetAnimTier(UnitBytes1Flags.AlwaysStand, false);
|
|
||||||
|
|
||||||
// OnPlayerRepop hook
|
// OnPlayerRepop hook
|
||||||
Global.ScriptMgr.OnPlayerRepop(this);
|
Global.ScriptMgr.OnPlayerRepop(this);
|
||||||
}
|
}
|
||||||
@@ -4358,7 +4355,6 @@ namespace Game.Entities
|
|||||||
// speed change, land walk
|
// speed change, land walk
|
||||||
|
|
||||||
// remove death flag + set aura
|
// remove death flag + set aura
|
||||||
SetAnimTier(UnitBytes1Flags.None, false);
|
|
||||||
RemovePlayerFlag(PlayerFlags.IsOutOfBounds);
|
RemovePlayerFlag(PlayerFlags.IsOutOfBounds);
|
||||||
|
|
||||||
// This must be called always even on Players with race != RACE_NIGHTELF in case of faction change
|
// This must be called always even on Players with race != RACE_NIGHTELF in case of faction change
|
||||||
|
|||||||
@@ -659,7 +659,7 @@ namespace Game.Entities
|
|||||||
return IsInDist(obj, objBoundaryRadius);
|
return IsInDist(obj, objBoundaryRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetDisableGravity(bool disable)
|
public bool SetDisableGravity(bool disable, bool updateAnimationTier = true)
|
||||||
{
|
{
|
||||||
if (disable == IsGravityDisabled())
|
if (disable == IsGravityDisabled())
|
||||||
return false;
|
return false;
|
||||||
@@ -692,6 +692,16 @@ namespace Game.Entities
|
|||||||
SendMessageToSet(packet, true);
|
SendMessageToSet(packet, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsCreature() && updateAnimationTier && IsAlive() && !HasUnitState(UnitState.Root) && !ToCreature().GetMovementTemplate().IsRooted())
|
||||||
|
{
|
||||||
|
if (IsGravityDisabled())
|
||||||
|
SetAnimTier(AnimTier.Fly);
|
||||||
|
else if (IsHovering())
|
||||||
|
SetAnimTier(AnimTier.Hover);
|
||||||
|
else
|
||||||
|
SetAnimTier(AnimTier.Ground);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1011,7 +1021,7 @@ namespace Game.Entities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetHover(bool enable)
|
public bool SetHover(bool enable, bool updateAnimationTier = true)
|
||||||
{
|
{
|
||||||
if (enable == HasUnitMovementFlag(MovementFlag.Hover))
|
if (enable == HasUnitMovementFlag(MovementFlag.Hover))
|
||||||
return false;
|
return false;
|
||||||
@@ -1056,6 +1066,17 @@ namespace Game.Entities
|
|||||||
packet.MoverGUID = GetGUID();
|
packet.MoverGUID = GetGUID();
|
||||||
SendMessageToSet(packet, true);
|
SendMessageToSet(packet, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsCreature() && updateAnimationTier && IsAlive() && !HasUnitState(UnitState.Root) && !ToCreature().GetMovementTemplate().IsRooted())
|
||||||
|
{
|
||||||
|
if (IsGravityDisabled())
|
||||||
|
SetAnimTier(AnimTier.Fly);
|
||||||
|
else if (IsHovering())
|
||||||
|
SetAnimTier(AnimTier.Hover);
|
||||||
|
else
|
||||||
|
SetAnimTier(AnimTier.Ground);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1723,10 +1744,17 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (arrived)
|
if (arrived)
|
||||||
|
{
|
||||||
DisableSpline();
|
DisableSpline();
|
||||||
|
|
||||||
|
AnimTier? animTier = MoveSpline.GetAnimation();
|
||||||
|
if (animTier.HasValue)
|
||||||
|
SetAnimTier(animTier.Value);
|
||||||
|
}
|
||||||
|
|
||||||
UpdateSplinePosition();
|
UpdateSplinePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateSplinePosition()
|
void UpdateSplinePosition()
|
||||||
{
|
{
|
||||||
Vector4 loc = MoveSpline.ComputePosition();
|
Vector4 loc = MoveSpline.ComputePosition();
|
||||||
|
|||||||
@@ -2154,7 +2154,9 @@ namespace Game.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAnimTier(UnitBytes1Flags animTier, bool notifyClient)
|
public AnimTier GetAnimTier() { return (AnimTier)(byte)m_unitData.AnimTier; }
|
||||||
|
|
||||||
|
public void SetAnimTier(AnimTier animTier, bool notifyClient = true)
|
||||||
{
|
{
|
||||||
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.AnimTier), (byte)animTier);
|
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.AnimTier), (byte)animTier);
|
||||||
|
|
||||||
|
|||||||
@@ -358,10 +358,10 @@ namespace Game.Movement
|
|||||||
switch (waypoint.moveType)
|
switch (waypoint.moveType)
|
||||||
{
|
{
|
||||||
case WaypointMoveType.Land:
|
case WaypointMoveType.Land:
|
||||||
init.SetAnimation(AnimType.ToGround);
|
init.SetAnimation(AnimTier.Ground);
|
||||||
break;
|
break;
|
||||||
case WaypointMoveType.Takeoff:
|
case WaypointMoveType.Takeoff:
|
||||||
init.SetAnimation(AnimType.ToFly);
|
init.SetAnimation(AnimTier.Hover);
|
||||||
break;
|
break;
|
||||||
case WaypointMoveType.Run:
|
case WaypointMoveType.Run:
|
||||||
init.SetWalk(false);
|
init.SetWalk(false);
|
||||||
|
|||||||
@@ -625,7 +625,7 @@ namespace Game.Movement
|
|||||||
{
|
{
|
||||||
MoveSplineInit init = new(_owner);
|
MoveSplineInit init = new(_owner);
|
||||||
init.MoveTo(pos, false);
|
init.MoveTo(pos, false);
|
||||||
init.SetAnimation(AnimType.ToGround);
|
init.SetAnimation(AnimTier.Ground);
|
||||||
Add(new GenericMovementGenerator(init, MovementGeneratorType.Effect, id));
|
Add(new GenericMovementGenerator(init, MovementGeneratorType.Effect, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,7 +633,7 @@ namespace Game.Movement
|
|||||||
{
|
{
|
||||||
MoveSplineInit init = new(_owner);
|
MoveSplineInit init = new(_owner);
|
||||||
init.MoveTo(pos);
|
init.MoveTo(pos);
|
||||||
init.SetAnimation(AnimType.ToFly);
|
init.SetAnimation(AnimTier.Hover);
|
||||||
|
|
||||||
Add(new GenericMovementGenerator(init, MovementGeneratorType.Effect, id));
|
Add(new GenericMovementGenerator(init, MovementGeneratorType.Effect, id));
|
||||||
}
|
}
|
||||||
@@ -820,7 +820,7 @@ namespace Game.Movement
|
|||||||
{
|
{
|
||||||
init.SetFly();
|
init.SetFly();
|
||||||
init.SetCyclic();
|
init.SetCyclic();
|
||||||
init.SetAnimation(AnimType.ToFly);
|
init.SetAnimation(AnimTier.Hover);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -347,6 +347,8 @@ namespace Game.Movement
|
|||||||
public Vector3 FinalDestination() { return Initialized() ? spline.GetPoint(spline.Last()) : Vector3.Zero; }
|
public Vector3 FinalDestination() { return Initialized() ? spline.GetPoint(spline.Last()) : Vector3.Zero; }
|
||||||
public Vector3 CurrentDestination() { return Initialized() ? spline.GetPoint(point_Idx + 1) : Vector3.Zero; }
|
public Vector3 CurrentDestination() { return Initialized() ? spline.GetPoint(point_Idx + 1) : Vector3.Zero; }
|
||||||
|
|
||||||
|
public AnimTier? GetAnimation() { return anim_tier != null ? (AnimTier)anim_tier.AnimTier : null; }
|
||||||
|
|
||||||
#region Fields
|
#region Fields
|
||||||
public MoveSplineInitArgs InitArgs;
|
public MoveSplineInitArgs InitArgs;
|
||||||
public Spline spline = new();
|
public Spline spline = new();
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ namespace Game.Movement
|
|||||||
args.flags.EnableParabolic();
|
args.flags.EnableParabolic();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAnimation(AnimType anim)
|
public void SetAnimation(AnimTier anim)
|
||||||
{
|
{
|
||||||
args.time_perc = 0.0f;
|
args.time_perc = 0.0f;
|
||||||
args.animTier = new();
|
args.animTier = new();
|
||||||
|
|||||||
Reference in New Issue
Block a user