aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2019-05-16 00:44:50 +0200
committerShauren <shauren.trinity@gmail.com>2021-12-05 18:37:48 +0100
commit6814b4d32b283c3a1b676d2f13953894a9f1ff7a (patch)
tree5f905858dbc418dc348e547cb4630ea78b8bcb29 /src
parentc511fa28037094a591d2ecc34b68c7e361f0d454 (diff)
Core/PlayerAI: apply some movement related corrections
Unit::StopMoving() is evil, and so is MotionMaster::Clear() the first can really mess up existing movement generators the second can interrupt "controlled" movements... can do it literally mid-air (cherry picked from commit a4e94dcf6bf654ef57a735a67d5e8850390c2d96)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/PlayerAI/PlayerAI.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/server/game/AI/PlayerAI/PlayerAI.cpp b/src/server/game/AI/PlayerAI/PlayerAI.cpp
index 6303e91c14a..f6f1fe98b87 100644
--- a/src/server/game/AI/PlayerAI/PlayerAI.cpp
+++ b/src/server/game/AI/PlayerAI/PlayerAI.cpp
@@ -1259,8 +1259,10 @@ void SimpleCharmedPlayerAI::UpdateAI(uint32 diff)
_isFollowing = true;
me->AttackStop();
me->CastStop();
- me->StopMoving();
- me->GetMotionMaster()->Clear();
+
+ if (me->HasUnitState(UNIT_STATE_CHASE))
+ me->GetMotionMaster()->Remove(CHASE_MOTION_TYPE);
+
me->GetMotionMaster()->MoveFollow(charmer, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
}
return;
@@ -1323,8 +1325,10 @@ void SimpleCharmedPlayerAI::UpdateAI(uint32 diff)
_isFollowing = true;
me->AttackStop();
me->CastStop();
- me->StopMoving();
- me->GetMotionMaster()->Clear();
+
+ if (me->HasUnitState(UNIT_STATE_CHASE))
+ me->GetMotionMaster()->Remove(CHASE_MOTION_TYPE);
+
me->GetMotionMaster()->MoveFollow(charmer, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
}
}
@@ -1335,17 +1339,17 @@ void SimpleCharmedPlayerAI::OnCharmed(bool isNew)
{
me->CastStop();
me->AttackStop();
- me->StopMoving();
- me->GetMotionMaster()->Clear();
- me->GetMotionMaster()->MovePoint(0, me->GetPosition(), false); // force re-sync of current position for all clients
+
+ if (me->GetMotionMaster()->Size() <= 1) // if there is no current movement (we dont want to erase/overwrite any existing stuff)
+ me->GetMotionMaster()->MovePoint(0, me->GetPosition(), false); // force re-sync of current position for all clients
}
else
{
me->CastStop();
me->AttackStop();
- // @todo only voluntary movement (don't cancel stuff like death grip or charge mid-animation)
- me->GetMotionMaster()->Clear();
- me->StopMoving();
+
+ me->GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL);
}
+
PlayerAI::OnCharmed(isNew);
}