mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-17 16:10:49 +01:00
Core/Movement: 0e2342c followup
This commit is contained in:
@@ -290,8 +290,7 @@ void CreatureGroup::LeaderStartedMoving()
|
||||
float angle = pair.second->FollowAngle + float(M_PI); // for some reason, someone thought it was a great idea to invert relativ angles...
|
||||
float dist = pair.second->FollowDist;
|
||||
|
||||
MovementGenerator const* moveGen = member->GetMotionMaster()->GetMovementGenerator([](MovementGenerator const* movement)->bool { return movement->GetMovementGeneratorType() == FORMATION_MOTION_TYPE; }, MOTION_SLOT_DEFAULT);
|
||||
if (!moveGen)
|
||||
if (!member->HasUnitState(UNIT_STATE_FOLLOW_FORMATION))
|
||||
member->GetMotionMaster()->MoveFormation(_leader, dist, angle, pair.second->LeaderWaypointIDs[0], pair.second->LeaderWaypointIDs[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,44 +209,46 @@ enum DeathState
|
||||
|
||||
enum UnitState : uint32
|
||||
{
|
||||
UNIT_STATE_DIED = 0x00000001, // player has fake death aura
|
||||
UNIT_STATE_MELEE_ATTACKING = 0x00000002, // player is melee attacking someone
|
||||
UNIT_STATE_CHARMED = 0x00000004, // having any kind of charm aura on self
|
||||
UNIT_STATE_STUNNED = 0x00000008,
|
||||
UNIT_STATE_ROAMING = 0x00000010,
|
||||
UNIT_STATE_CHASE = 0x00000020,
|
||||
UNIT_STATE_FOCUSING = 0x00000040,
|
||||
UNIT_STATE_FLEEING = 0x00000080,
|
||||
UNIT_STATE_IN_FLIGHT = 0x00000100, // player is in flight mode
|
||||
UNIT_STATE_FOLLOW = 0x00000200,
|
||||
UNIT_STATE_ROOT = 0x00000400,
|
||||
UNIT_STATE_CONFUSED = 0x00000800,
|
||||
UNIT_STATE_DISTRACTED = 0x00001000,
|
||||
UNIT_STATE_ISOLATED = 0x00002000, // area auras do not affect other players
|
||||
UNIT_STATE_ATTACK_PLAYER = 0x00004000,
|
||||
UNIT_STATE_CASTING = 0x00008000,
|
||||
UNIT_STATE_POSSESSED = 0x00010000, // being possessed by another unit
|
||||
UNIT_STATE_CHARGING = 0x00020000,
|
||||
UNIT_STATE_JUMPING = 0x00040000,
|
||||
UNIT_STATE_MOVE = 0x00100000,
|
||||
UNIT_STATE_ROTATING = 0x00200000,
|
||||
UNIT_STATE_EVADE = 0x00400000,
|
||||
UNIT_STATE_ROAMING_MOVE = 0x00800000,
|
||||
UNIT_STATE_CONFUSED_MOVE = 0x01000000,
|
||||
UNIT_STATE_FLEEING_MOVE = 0x02000000,
|
||||
UNIT_STATE_CHASE_MOVE = 0x04000000,
|
||||
UNIT_STATE_FOLLOW_MOVE = 0x08000000,
|
||||
UNIT_STATE_IGNORE_PATHFINDING = 0x10000000, // do not use pathfinding in any MovementGenerator
|
||||
UNIT_STATE_DIED = 0x00000001, // player has fake death aura
|
||||
UNIT_STATE_MELEE_ATTACKING = 0x00000002, // player is melee attacking someone
|
||||
UNIT_STATE_CHARMED = 0x00000004, // having any kind of charm aura on self
|
||||
UNIT_STATE_STUNNED = 0x00000008,
|
||||
UNIT_STATE_ROAMING = 0x00000010,
|
||||
UNIT_STATE_CHASE = 0x00000020,
|
||||
UNIT_STATE_FOCUSING = 0x00000040,
|
||||
UNIT_STATE_FLEEING = 0x00000080,
|
||||
UNIT_STATE_IN_FLIGHT = 0x00000100, // player is in flight mode
|
||||
UNIT_STATE_FOLLOW = 0x00000200,
|
||||
UNIT_STATE_ROOT = 0x00000400,
|
||||
UNIT_STATE_CONFUSED = 0x00000800,
|
||||
UNIT_STATE_DISTRACTED = 0x00001000,
|
||||
UNIT_STATE_ISOLATED = 0x00002000, // area auras do not affect other players
|
||||
UNIT_STATE_ATTACK_PLAYER = 0x00004000,
|
||||
UNIT_STATE_CASTING = 0x00008000,
|
||||
UNIT_STATE_POSSESSED = 0x00010000, // being possessed by another unit
|
||||
UNIT_STATE_CHARGING = 0x00020000,
|
||||
UNIT_STATE_JUMPING = 0x00040000,
|
||||
UNIT_STATE_FOLLOW_FORMATION = 0x00080000,
|
||||
UNIT_STATE_MOVE = 0x00100000,
|
||||
UNIT_STATE_ROTATING = 0x00200000,
|
||||
UNIT_STATE_EVADE = 0x00400000,
|
||||
UNIT_STATE_ROAMING_MOVE = 0x00800000,
|
||||
UNIT_STATE_CONFUSED_MOVE = 0x01000000,
|
||||
UNIT_STATE_FLEEING_MOVE = 0x02000000,
|
||||
UNIT_STATE_CHASE_MOVE = 0x04000000,
|
||||
UNIT_STATE_FOLLOW_MOVE = 0x08000000,
|
||||
UNIT_STATE_IGNORE_PATHFINDING = 0x10000000, // do not use pathfinding in any MovementGenerator
|
||||
UNIT_STATE_FOLLOW_FORMATION_MOVE = 0x20000000,
|
||||
|
||||
UNIT_STATE_ALL_STATE_SUPPORTED = UNIT_STATE_DIED | UNIT_STATE_MELEE_ATTACKING | UNIT_STATE_CHARMED | UNIT_STATE_STUNNED | UNIT_STATE_ROAMING | UNIT_STATE_CHASE
|
||||
| UNIT_STATE_FOCUSING | UNIT_STATE_FLEEING | UNIT_STATE_IN_FLIGHT | UNIT_STATE_FOLLOW | UNIT_STATE_ROOT | UNIT_STATE_CONFUSED
|
||||
| UNIT_STATE_DISTRACTED | UNIT_STATE_ISOLATED | UNIT_STATE_ATTACK_PLAYER | UNIT_STATE_CASTING
|
||||
| UNIT_STATE_POSSESSED | UNIT_STATE_CHARGING | UNIT_STATE_JUMPING | UNIT_STATE_MOVE | UNIT_STATE_ROTATING
|
||||
| UNIT_STATE_EVADE | UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE
|
||||
| UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE | UNIT_STATE_IGNORE_PATHFINDING,
|
||||
| UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE | UNIT_STATE_IGNORE_PATHFINDING | UNIT_STATE_FOLLOW_FORMATION_MOVE,
|
||||
|
||||
UNIT_STATE_UNATTACKABLE = UNIT_STATE_IN_FLIGHT,
|
||||
UNIT_STATE_MOVING = UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE | UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE,
|
||||
UNIT_STATE_MOVING = UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE | UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE | UNIT_STATE_FOLLOW_FORMATION_MOVE,
|
||||
UNIT_STATE_CONTROLLED = UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING,
|
||||
UNIT_STATE_LOST_CONTROL = UNIT_STATE_CONTROLLED | UNIT_STATE_POSSESSED | UNIT_STATE_JUMPING | UNIT_STATE_CHARGING,
|
||||
UNIT_STATE_CANNOT_AUTOATTACK = UNIT_STATE_CONTROLLED | UNIT_STATE_CHARGING | UNIT_STATE_CASTING,
|
||||
|
||||
@@ -30,7 +30,7 @@ FormationMovementGenerator::FormationMovementGenerator(Unit* leader, float range
|
||||
Mode = MOTION_MODE_DEFAULT;
|
||||
Priority = MOTION_PRIORITY_NORMAL;
|
||||
Flags = MOVEMENTGENERATOR_FLAG_INITIALIZATION_PENDING;
|
||||
BaseUnitState = UNIT_STATE_ROAMING;
|
||||
BaseUnitState = UNIT_STATE_FOLLOW_FORMATION;
|
||||
}
|
||||
|
||||
MovementGeneratorType FormationMovementGenerator::GetMovementGeneratorType() const
|
||||
@@ -71,34 +71,24 @@ bool FormationMovementGenerator::DoUpdate(Creature* owner, uint32 diff)
|
||||
if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting())
|
||||
{
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED);
|
||||
owner->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
owner->StopMoving();
|
||||
_nextMoveTimer.Reset(0);
|
||||
_hasPredictedDestination = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Leader has stopped moving, so do we as well
|
||||
// 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)
|
||||
{
|
||||
owner->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED);
|
||||
owner->StopMoving();
|
||||
_nextMoveTimer.Reset(0);
|
||||
_hasPredictedDestination = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Update home position
|
||||
owner->SetHomePosition(owner->GetPosition());
|
||||
if (HasFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED))
|
||||
RemoveFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED);
|
||||
|
||||
// Leader has stopped moving, so do we as well
|
||||
if (owner->HasUnitState(UNIT_STATE_ROAMING_MOVE) && _hasPredictedDestination && target->movespline->Finalized() && target->movespline->GetId() == _lastLeaderSplineID)
|
||||
{
|
||||
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
|
||||
@@ -137,9 +127,9 @@ bool FormationMovementGenerator::DoUpdate(Creature* owner, uint32 diff)
|
||||
}
|
||||
|
||||
// We have reached our destination before launching a new movement. Alling facing with leader
|
||||
if (owner->HasUnitState(UNIT_STATE_ROAMING_MOVE) && owner->movespline->Finalized())
|
||||
if (owner->HasUnitState(UNIT_STATE_FOLLOW_FORMATION_MOVE) && owner->movespline->Finalized())
|
||||
{
|
||||
owner->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
owner->ClearUnitState(UNIT_STATE_FOLLOW_FORMATION_MOVE);
|
||||
owner->SetFacingTo(target->GetOrientation());
|
||||
MovementInform(owner);
|
||||
}
|
||||
@@ -205,20 +195,21 @@ void FormationMovementGenerator::LaunchMovement(Creature* owner, Unit* target)
|
||||
init.Launch();
|
||||
|
||||
_lastLeaderPosition = target->GetPosition();
|
||||
owner->AddUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
owner->AddUnitState(UNIT_STATE_FOLLOW_FORMATION_MOVE);
|
||||
RemoveFlag(MOVEMENTGENERATOR_FLAG_INTERRUPTED);
|
||||
}
|
||||
|
||||
void FormationMovementGenerator::DoDeactivate(Creature* owner)
|
||||
{
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_DEACTIVATED);
|
||||
owner->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
owner->ClearUnitState(UNIT_STATE_FOLLOW_FORMATION_MOVE);
|
||||
}
|
||||
|
||||
void FormationMovementGenerator::DoFinalize(Creature* owner, bool active, bool movementInform)
|
||||
{
|
||||
AddFlag(MOVEMENTGENERATOR_FLAG_FINALIZED);
|
||||
if (active)
|
||||
owner->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
|
||||
owner->ClearUnitState(UNIT_STATE_FOLLOW_FORMATION_MOVE);
|
||||
|
||||
if (movementInform && HasFlag(MOVEMENTGENERATOR_FLAG_INFORM_ENABLED))
|
||||
MovementInform(owner);
|
||||
|
||||
@@ -40,7 +40,6 @@ class FormationMovementGenerator : public MovementGeneratorMedium<Creature, Form
|
||||
|
||||
private:
|
||||
void MovementInform(Creature*);
|
||||
|
||||
void LaunchMovement(Creature* owner, Unit* target);
|
||||
|
||||
static constexpr uint32 FORMATION_MOVEMENT_INTERVAL = 1200; // sniffed (3 batch update cycles)
|
||||
|
||||
Reference in New Issue
Block a user