Entities/Player: Clean up client control handling behavior around possession. Mind Control should no longer cause various weirdness. Closes #23539.

This commit is contained in:
Treeston
2019-07-02 09:52:58 +02:00
parent a8b8a43b8d
commit f6f1c48aa5
4 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -152,7 +152,7 @@ void CreatureAI::TriggerAlert(Unit const* who) const
me->GetMotionMaster()->MoveDistract(5 * IN_MILLISECONDS, me->GetAbsoluteAngle(who));
}
// adapted from logic in Spell:EffectSummonType
// adapted from logic in Spell:EffectSummonType before commit 8499434
static bool ShouldFollowOnSpawn(SummonPropertiesEntry const* properties)
{
// Summons without SummonProperties are generally scripted summons that don't belong to any owner
+22 -8
View File
@@ -23876,24 +23876,38 @@ void Player::ResurrectUsingRequestDataImpl()
void Player::SetClientControl(Unit* target, bool allowMove)
{
// still affected by some aura that shouldn't allow control, only allow on last such aura to be removed
if (allowMove && target->HasUnitState(UNIT_STATE_CANT_CLIENT_CONTROL))
// a player can never client control nothing
ASSERT(target);
// don't allow possession to be overridden
if (target->HasUnitState(UNIT_STATE_CHARMED) && (GetGUID() != target->GetCharmerGUID()))
{
// this should never happen, otherwise m_unitBeingMoved might be left dangling!
ASSERT(GetUnitBeingMoved() == target);
TC_LOG_ERROR("entities.player", "Player '%s' attempt to client control '%s', which is charmed by GUID %s",
GetName().c_str(), target->GetName().c_str(), target->GetCharmerGUID().ToString().c_str());
return;
}
// still affected by some aura that shouldn't allow control, only allow on last such aura to be removed
if (target->HasUnitState(UNIT_STATE_CONTROLLED))
allowMove = false;
WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size()+1);
data << target->GetPackGUID();
data << uint8(allowMove ? 1 : 0);
SendDirectMessage(&data);
if (this != target)
SetViewpoint(target, allowMove);
WorldObject* viewpoint = GetViewpoint();
if (!viewpoint)
viewpoint = this;
if (target != viewpoint)
{
if (viewpoint != this)
SetViewpoint(viewpoint, false);
if (target != this)
SetViewpoint(target, true);
}
if (allowMove)
SetMovedUnit(target);
SetMovedUnit(target);
}
void Player::UpdateZoneDependentAuras(uint32 newZone)
+1 -1
View File
@@ -455,7 +455,7 @@ void Unit::Update(uint32 p_time)
UpdateSplineMovement(p_time);
i_motionMaster->Update(p_time);
if (!GetAI() && (GetTypeId() != TYPEID_PLAYER || IsCharmed()))
if (!GetAI() && (GetTypeId() != TYPEID_PLAYER || (IsCharmed() && GetCharmerGUID().IsCreature())))
UpdateCharmAI();
RefreshAI();
}
-1
View File
@@ -249,7 +249,6 @@ enum UnitState : uint32
UNIT_STATE_UNATTACKABLE = UNIT_STATE_IN_FLIGHT,
UNIT_STATE_MOVING = UNIT_STATE_ROAMING_MOVE | UNIT_STATE_CONFUSED_MOVE | UNIT_STATE_FLEEING_MOVE | UNIT_STATE_CHASE_MOVE | UNIT_STATE_FOLLOW_MOVE,
UNIT_STATE_CONTROLLED = UNIT_STATE_CONFUSED | UNIT_STATE_STUNNED | UNIT_STATE_FLEEING,
UNIT_STATE_CANT_CLIENT_CONTROL = UNIT_STATE_CHARMED | UNIT_STATE_FLEEING | UNIT_STATE_CONFUSED | UNIT_STATE_POSSESSED,
UNIT_STATE_LOST_CONTROL = UNIT_STATE_CONTROLLED | UNIT_STATE_POSSESSED | UNIT_STATE_JUMPING | UNIT_STATE_CHARGING,
UNIT_STATE_CANNOT_AUTOATTACK = UNIT_STATE_CONTROLLED | UNIT_STATE_CHARGING | UNIT_STATE_CASTING,
UNIT_STATE_SIGHTLESS = UNIT_STATE_LOST_CONTROL | UNIT_STATE_EVADE,