Core/Movement: followup
Port From (https://github.com/TrinityCore/TrinityCore/commit/875da437806b8956324078bc9abd0a495345d2e5)
This commit is contained in:
@@ -474,6 +474,7 @@ namespace Framework.Constants
|
||||
Possessed = 0x10000, // being possessed by another unit
|
||||
Charging = 0x20000,
|
||||
Jumping = 0x40000,
|
||||
FollowFormation = 0x80000,
|
||||
Move = 0x100000,
|
||||
Rotating = 0x200000,
|
||||
Evade = 0x400000,
|
||||
@@ -483,15 +484,17 @@ namespace Framework.Constants
|
||||
ChaseMove = 0x4000000,
|
||||
FollowMove = 0x8000000,
|
||||
IgnorePathfinding = 0x10000000,
|
||||
FollowFormationMove = 0x20000000,
|
||||
|
||||
AllStateSupported = Died | MeleeAttacking | Charmed | Stunned | Roaming | Chase
|
||||
| Focusing | Fleeing | InFlight | Follow | Root | Confused
|
||||
| Distracted | Isolated | AttackPlayer | Casting
|
||||
| Possessed | Charging | Jumping | Move | Rotating
|
||||
| Evade | RoamingMove | ConfusedMove | FleeingMove
|
||||
| ChaseMove | FollowMove | IgnorePathfinding,
|
||||
| ChaseMove | FollowMove | IgnorePathfinding | FollowFormationMove,
|
||||
|
||||
Unattackable = InFlight,
|
||||
Moving = RoamingMove | ConfusedMove | FleeingMove | ChaseMove | FollowMove,
|
||||
Moving = RoamingMove | ConfusedMove | FleeingMove | ChaseMove | FollowMove | FollowFormationMove,
|
||||
Controlled = Confused | Stunned | Fleeing,
|
||||
LostControl = Controlled | Possessed | Jumping | Charging,
|
||||
CannotAutoattack = Controlled | Charging | Casting,
|
||||
|
||||
@@ -288,8 +288,7 @@ namespace Game.Entities
|
||||
float angle = pair.Value.FollowAngle + MathF.PI; // for some reason, someone thought it was a great idea to invert relativ angles...
|
||||
float dist = pair.Value.FollowDist;
|
||||
|
||||
var moveGen = member.GetMotionMaster().GetMovementGenerator(movement => { return movement.GetMovementGeneratorType() == MovementGeneratorType.Formation; }, MovementSlot.Default);
|
||||
if (moveGen == null)
|
||||
if (!member.HasUnitState(UnitState.Formation))
|
||||
member.GetMotionMaster().MoveFormation(_leader, dist, angle, pair.Value.LeaderWaypointIDs[0], pair.Value.LeaderWaypointIDs[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Game.Movement
|
||||
Mode = MovementGeneratorMode.Default;
|
||||
Priority = MovementGeneratorPriority.Normal;
|
||||
Flags = MovementGeneratorFlags.InitializationPending;
|
||||
BaseUnitState = UnitState.Roaming;
|
||||
BaseUnitState = UnitState.FollowFormation;
|
||||
}
|
||||
|
||||
public override void DoInitialize(Creature owner)
|
||||
@@ -83,15 +83,6 @@ namespace Game.Movement
|
||||
if (owner.HasUnitState(UnitState.NotMove) || owner.IsMovementPreventedByCasting())
|
||||
{
|
||||
AddFlag(MovementGeneratorFlags.Interrupted);
|
||||
owner.ClearUnitState(UnitState.RoamingMove);
|
||||
owner.StopMoving();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Leader has stopped moving, so do we as well
|
||||
if (target.MoveSpline.Finalized() && target.MoveSpline.GetId() == _lastLeaderSplineID && _hasPredictedDestination)
|
||||
{
|
||||
owner.ClearUnitState(UnitState.RoamingMove);
|
||||
owner.StopMoving();
|
||||
_nextMoveTimer.Reset(0);
|
||||
_hasPredictedDestination = false;
|
||||
@@ -99,19 +90,19 @@ namespace Game.Movement
|
||||
}
|
||||
|
||||
// Update home position
|
||||
owner.SetHomePosition(owner.GetPosition());
|
||||
if (HasFlag(MovementGeneratorFlags.Interrupted))
|
||||
RemoveFlag(MovementGeneratorFlags.Interrupted);
|
||||
|
||||
// Leader has stopped moving, so do we as well
|
||||
if (owner.HasUnitState(UnitState.RoamingMove) && _hasPredictedDestination && target.MoveSpline.Finalized() && target.MoveSpline.GetId() == _lastLeaderSplineID)
|
||||
// If target is not moving and destination has been predicted and if we are on the same spline, we stop as well
|
||||
if (target.MoveSpline.Finalized() && target.MoveSpline.GetId() == _lastLeaderSplineID && _hasPredictedDestination)
|
||||
{
|
||||
AddFlag(MovementGeneratorFlags.Interrupted);
|
||||
owner.StopMoving();
|
||||
_nextMoveTimer.Reset(0);
|
||||
_hasPredictedDestination = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!owner.MoveSpline.Finalized())
|
||||
owner.SetHomePosition(owner.GetPosition());
|
||||
|
||||
// Formation leader has launched a new spline, launch a new one for our member as well
|
||||
// This action does not reset the regular movement launch cycle interval
|
||||
if (!target.MoveSpline.Finalized() && target.MoveSpline.GetId() != _lastLeaderSplineID)
|
||||
@@ -151,9 +142,9 @@ namespace Game.Movement
|
||||
}
|
||||
|
||||
// We have reached our destination before launching a new movement. Alling facing with leader
|
||||
if (owner.HasUnitState(UnitState.RoamingMove) && owner.MoveSpline.Finalized())
|
||||
if (owner.HasUnitState(UnitState.FollowFormationMove) && owner.MoveSpline.Finalized())
|
||||
{
|
||||
owner.ClearUnitState(UnitState.RoamingMove);
|
||||
owner.ClearUnitState(UnitState.FollowFormationMove);
|
||||
owner.SetFacingTo(target.GetOrientation());
|
||||
MovementInform(owner);
|
||||
}
|
||||
@@ -219,20 +210,21 @@ namespace Game.Movement
|
||||
init.Launch();
|
||||
|
||||
_lastLeaderPosition = target.GetPosition();
|
||||
owner.AddUnitState(UnitState.RoamingMove);
|
||||
owner.AddUnitState(UnitState.FollowFormationMove);
|
||||
RemoveFlag(MovementGeneratorFlags.Interrupted);
|
||||
}
|
||||
|
||||
public override void DoDeactivate(Creature owner)
|
||||
{
|
||||
AddFlag(MovementGeneratorFlags.Deactivated);
|
||||
owner.ClearUnitState(UnitState.RoamingMove);
|
||||
owner.ClearUnitState(UnitState.FollowFormationMove);
|
||||
}
|
||||
|
||||
public override void DoFinalize(Creature owner, bool active, bool movementInform)
|
||||
{
|
||||
AddFlag(MovementGeneratorFlags.Finalized);
|
||||
if (active)
|
||||
owner.ClearUnitState(UnitState.RoamingMove);
|
||||
owner.ClearUnitState(UnitState.FollowFormationMove);
|
||||
|
||||
if (movementInform && HasFlag(MovementGeneratorFlags.InformEnabled))
|
||||
MovementInform(owner);
|
||||
|
||||
Reference in New Issue
Block a user