aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2019-05-16 00:44:50 +0200
committerccrs <ccrs@users.noreply.github.com>2019-05-16 00:44:50 +0200
commita4e94dcf6bf654ef57a735a67d5e8850390c2d96 (patch)
tree5b5fcd3ee09b5c7f0d76e50a2c2cbe39878f1a52 /src
parent79b90f9d3afb3815e265fc59a1e98c92ec788012 (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
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 e35afac31c3..e148d34b04b 100644
--- a/src/server/game/AI/PlayerAI/PlayerAI.cpp
+++ b/src/server/game/AI/PlayerAI/PlayerAI.cpp
@@ -1185,8 +1185,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;
@@ -1249,8 +1251,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);
}
}
@@ -1261,17 +1265,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);
}