Entities/Player: Clean up client control handling behavior around possession. Mind Control should no longer cause various weirdness.
Port From (https://github.com/TrinityCore/TrinityCore/commit/bba4696de715b79b31e154d1a8e1597507812ece)
This commit is contained in:
@@ -7214,24 +7214,38 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public void SetClientControl(Unit target, bool allowMove)
|
public void SetClientControl(Unit target, bool allowMove)
|
||||||
{
|
{
|
||||||
// still affected by some aura that shouldn't allow control, only allow on last such aura to be removed
|
// a player can never client control nothing
|
||||||
if (allowMove && target.HasUnitState(UnitState.CantClientControl))
|
Cypher.Assert(target);
|
||||||
|
|
||||||
|
// don't allow possession to be overridden
|
||||||
|
if (target.HasUnitState(UnitState.Charmed) && (GetGUID() != target.GetCharmerGUID()))
|
||||||
{
|
{
|
||||||
// this should never happen, otherwise m_unitBeingMoved might be left dangling!
|
// this should never happen, otherwise m_unitBeingMoved might be left dangling!
|
||||||
Cypher.Assert(GetUnitBeingMoved() == target);
|
Log.outError(LogFilter.Player, $"Player '{GetName()}' attempt to client control '{target.GetName()}', which is charmed by GUID {target.GetCharmerGUID()}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// still affected by some aura that shouldn't allow control, only allow on last such aura to be removed
|
||||||
|
if (target.HasUnitState(UnitState.Controlled))
|
||||||
|
allowMove = false;
|
||||||
|
|
||||||
ControlUpdate packet = new();
|
ControlUpdate packet = new();
|
||||||
packet.Guid = target.GetGUID();
|
packet.Guid = target.GetGUID();
|
||||||
packet.On = allowMove;
|
packet.On = allowMove;
|
||||||
SendPacket(packet);
|
SendPacket(packet);
|
||||||
|
|
||||||
if (this != target)
|
WorldObject viewpoint = GetViewpoint();
|
||||||
SetViewpoint(target, allowMove);
|
if (viewpoint == null)
|
||||||
|
viewpoint = this;
|
||||||
|
if (target != viewpoint)
|
||||||
|
{
|
||||||
|
if (viewpoint != this)
|
||||||
|
SetViewpoint(viewpoint, false);
|
||||||
|
if (target != this)
|
||||||
|
SetViewpoint(target, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (allowMove)
|
SetMovedUnit(target);
|
||||||
SetMovedUnit(target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item GetWeaponForAttack(WeaponAttackType attackType, bool useable = false)
|
public Item GetWeaponForAttack(WeaponAttackType attackType, bool useable = false)
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ namespace Game.Entities
|
|||||||
UpdateSplineMovement(diff);
|
UpdateSplineMovement(diff);
|
||||||
GetMotionMaster().Update(diff);
|
GetMotionMaster().Update(diff);
|
||||||
|
|
||||||
if (GetAI() == null && (!IsPlayer() || IsCharmed()))
|
if (GetAI() == null && (!IsPlayer() || (IsCharmed() && GetCharmerGUID().IsCreature())))
|
||||||
UpdateCharmAI();
|
UpdateCharmAI();
|
||||||
|
|
||||||
RefreshAI();
|
RefreshAI();
|
||||||
|
|||||||
Reference in New Issue
Block a user