Core/Movement: if a creature follows an npc it will now respect the target's velocity instead of running all the time

This commit is contained in:
Ovahlord
2020-03-31 17:05:13 +02:00
parent f2ee7412bc
commit 05bdaf47fb

View File

@@ -101,11 +101,20 @@ bool FollowMovementGenerator::Update(Unit* owner, uint32 diff)
float velocity = 0.f;
if (_useTargetSpeed)
{
velocity = target->IsWalking() ? target->GetSpeed(MOVE_WALK) : target->GetSpeed(MOVE_RUN);
// Backwards player movement speed
if (target->IsPlayer() && target->HasUnitMovementFlag(MOVEMENTFLAG_BACKWARD))
velocity = target->GetSpeed(MOVE_RUN_BACK);
if (target->IsPlayer())
{
velocity = target->IsWalking() ? target->GetSpeed(MOVE_WALK) : target->GetSpeed(MOVE_RUN);
// Backwards player movement speed
if (target->IsPlayer() && target->HasUnitMovementFlag(MOVEMENTFLAG_BACKWARD))
velocity = target->GetSpeed(MOVE_RUN_BACK);
}
else
{
if (!target->movespline->Finalized())
velocity = target->movespline->Velocity();
else
velocity = target->GetSpeed(MOVE_RUN);
}
}
else
velocity = owner->IsWalking() ? owner->GetSpeed(MOVE_WALK) : owner->GetSpeed(MOVE_RUN);