Skip to content

Commit

Permalink
Unit/Charm: Fix interaction of possess with cc at start and during po…
Browse files Browse the repository at this point in the history
…ssess
  • Loading branch information
killerwife committed Apr 6, 2022
1 parent 8343460 commit b92f961
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/game/Entities/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13346,10 +13346,21 @@ bool Unit::TakePossessOf(Unit* possessed)
possessed->SetCharmerGuid(GetObjectGuid());
SetCharm(possessed);

// stop any generated movement TODO:: this may not be correct! what about possessing a feared creature?
possessed->GetMotionMaster()->Clear();
possessed->GetMotionMaster()->MoveIdle();
const bool panic = possessed->IsInPanic(), fleeing = possessed->IsFleeing(), confused = possessed->IsConfused();

// stop any generated movement: current solution
possessed->StopMoving(true);
possessed->GetMotionMaster()->Clear(false, true);
possessed->GetMotionMaster()->MoveIdle();

if (confused)
possessed->GetMotionMaster()->MoveConfused();
else if (fleeing && !panic)
{
AuraList const& fears = possessed->GetAurasByType(SPELL_AURA_MOD_FEAR);
Unit* source = (fears.empty() ? nullptr : fears.back()->GetCaster());
possessed->GetMotionMaster()->MoveFleeing(source ? source : this);
}

Position combatStartPosition;

Expand Down Expand Up @@ -13406,7 +13417,7 @@ bool Unit::TakePossessOf(Unit* possessed)
{
player->GetCamera().SetView(possessed);
// Force client control (required to function propely)
player->UpdateClientControl(possessed, true, true);
player->UpdateClientControl(possessed, !IsCrowdControlled(), true);
player->SetMover(possessed);
player->SendForcedObjectUpdate();

Expand Down

0 comments on commit b92f961

Please sign in to comment.