Core/Movement: MotionMaster reimplementation (#21888)

Internal structure and handling changes, nothing behavioural (or thats the intention at least).

(cherry picked from commit 982643cd96790ffc54e7a3e507469649f3b074d2)
This commit is contained in:
ccrs
2021-09-28 00:15:13 +02:00
committed by Shauren
parent 3e0af19b77
commit 426f9f2f92
96 changed files with 2412 additions and 1486 deletions
+13 -15
View File
@@ -1370,7 +1370,7 @@ public:
return true;
}
//npc unfollow handling
// npc unfollow handling
static bool HandleNpcUnFollowCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
@@ -1383,26 +1383,24 @@ public:
return false;
}
if (/*creature->GetMotionMaster()->empty() ||*/
creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE)
MovementGenerator* movement = creature->GetMotionMaster()->GetMovementGenerator([player](MovementGenerator const* a) -> bool
{
if (a->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE)
{
FollowMovementGenerator const* followMovement = dynamic_cast<FollowMovementGenerator const*>(a);
return followMovement && followMovement->GetTarget() == player;
}
return false;
});
if (!movement)
{
handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
handler->SetSentErrorMessage(true);
return false;
}
FollowMovementGenerator const* mgen = static_cast<FollowMovementGenerator const*>((creature->GetMotionMaster()->top()));
if (mgen->GetTarget() != player)
{
handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
handler->SetSentErrorMessage(true);
return false;
}
// reset movement
creature->GetMotionMaster()->MovementExpired(true);
creature->GetMotionMaster()->Remove(movement);
handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str());
return true;
}