mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-26 07:06:23 +00:00
fix(Scripts/ICC): Fix Valkyr "teleportation" effect caused by movement desynchronization between server and client. (#20080)
This commit is contained in:
committed by
GitHub
parent
67f587d958
commit
2e0a57084c
@@ -2417,6 +2417,8 @@ public:
|
||||
ObjectGuid _grabbedPlayer;
|
||||
bool didbelow50pct;
|
||||
bool dropped;
|
||||
bool grabbed;
|
||||
float _lastSpeed;
|
||||
InstanceScript* _instance;
|
||||
|
||||
bool IsHeroic() { return me->GetMap()->IsHeroic(); }
|
||||
@@ -2547,6 +2549,8 @@ public:
|
||||
if (me->HasUnitState(UNIT_STATE_CASTING | UNIT_STATE_STUNNED))
|
||||
return;
|
||||
|
||||
HandleSpeedChangeIfNeeded();
|
||||
|
||||
switch (_events.ExecuteEvent())
|
||||
{
|
||||
case EVENT_GRAB_PLAYER:
|
||||
@@ -2557,6 +2561,8 @@ public:
|
||||
}
|
||||
break;
|
||||
case EVENT_MOVE_TO_DROP_POS:
|
||||
grabbed = true;
|
||||
_lastSpeed = me->GetSpeed(MOVE_WALK);
|
||||
me->AddUnitState(UNIT_STATE_NO_ENVIRONMENT_UPD);
|
||||
me->SetCanFly(false);
|
||||
me->SetDisableGravity(false);
|
||||
@@ -2596,6 +2602,24 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// For some reason, when the Valkyr has a slowdown effect, the speed of PointMovementGenerator
|
||||
// and the speed on the client side differ, which leads to a "teleportation" effect when a stun aura is applied.
|
||||
// Restarting the motion master on speed change ensures the movement is synced between the server and client.
|
||||
void HandleSpeedChangeIfNeeded()
|
||||
{
|
||||
if (!grabbed || dropped)
|
||||
return;
|
||||
|
||||
if (me->GetSpeed(MOVE_WALK) == _lastSpeed)
|
||||
return;
|
||||
|
||||
_lastSpeed = me->GetSpeed(MOVE_WALK);
|
||||
me->GetMotionMaster()->Clear();
|
||||
me->StopMovingOnCurrentPos();
|
||||
|
||||
_events.ScheduleEvent(EVENT_MOVE_TO_DROP_POS, 0);
|
||||
}
|
||||
};
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
|
||||
Reference in New Issue
Block a user