fix(Core/Units): Stop melee attacking victim if being charmed by non-friendly target. (#11353)
Fixes #11316
This commit is contained in:
@@ -17896,6 +17896,8 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
|||||||
// Set charmed
|
// Set charmed
|
||||||
charmer->SetCharm(this, true);
|
charmer->SetCharm(this, true);
|
||||||
|
|
||||||
|
StopAttackingInvalidTarget();
|
||||||
|
|
||||||
if (GetTypeId() == TYPEID_UNIT)
|
if (GetTypeId() == TYPEID_UNIT)
|
||||||
{
|
{
|
||||||
if (MovementGenerator* movementGenerator = GetMotionMaster()->GetMotionSlot(MOTION_SLOT_IDLE))
|
if (MovementGenerator* movementGenerator = GetMotionMaster()->GetMotionSlot(MOTION_SLOT_IDLE))
|
||||||
@@ -18060,6 +18062,8 @@ void Unit::RemoveCharmedBy(Unit* charmer)
|
|||||||
|
|
||||||
charmer->SetCharm(this, false);
|
charmer->SetCharm(this, false);
|
||||||
|
|
||||||
|
StopAttackingInvalidTarget();
|
||||||
|
|
||||||
Player* playerCharmer = charmer->ToPlayer();
|
Player* playerCharmer = charmer->ToPlayer();
|
||||||
if (playerCharmer)
|
if (playerCharmer)
|
||||||
{
|
{
|
||||||
@@ -19591,6 +19595,37 @@ void Unit::StopAttackFaction(uint32 faction_id)
|
|||||||
(*itr)->StopAttackFaction(faction_id);
|
(*itr)->StopAttackFaction(faction_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Unit::StopAttackingInvalidTarget()
|
||||||
|
{
|
||||||
|
AttackerSet const& attackers = getAttackers();
|
||||||
|
for (AttackerSet::const_iterator itr = attackers.begin(); itr != attackers.end();)
|
||||||
|
{
|
||||||
|
Unit* attacker = (*itr);
|
||||||
|
if (!attacker->IsValidAttackTarget(this))
|
||||||
|
{
|
||||||
|
attacker->AttackStop();
|
||||||
|
if (attacker->GetTypeId() == TYPEID_PLAYER)
|
||||||
|
{
|
||||||
|
attacker->ToPlayer()->SendAttackSwingCancelAttack();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Unit* controled : attacker->m_Controlled)
|
||||||
|
{
|
||||||
|
if (controled->GetVictim() == this && !controled->IsValidAttackTarget(this))
|
||||||
|
{
|
||||||
|
controled->AttackStop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
itr = attackers.begin();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Unit::OutDebugInfo() const
|
void Unit::OutDebugInfo() const
|
||||||
{
|
{
|
||||||
LOG_ERROR("entities.unit", "Unit::OutDebugInfo");
|
LOG_ERROR("entities.unit", "Unit::OutDebugInfo");
|
||||||
|
|||||||
@@ -1360,6 +1360,7 @@ public:
|
|||||||
void CombatStop(bool includingCast = false);
|
void CombatStop(bool includingCast = false);
|
||||||
void CombatStopWithPets(bool includingCast = false);
|
void CombatStopWithPets(bool includingCast = false);
|
||||||
void StopAttackFaction(uint32 faction_id);
|
void StopAttackFaction(uint32 faction_id);
|
||||||
|
void StopAttackingInvalidTarget();
|
||||||
Unit* SelectNearbyTarget(Unit* exclude = nullptr, float dist = NOMINAL_MELEE_RANGE) const;
|
Unit* SelectNearbyTarget(Unit* exclude = nullptr, float dist = NOMINAL_MELEE_RANGE) const;
|
||||||
Unit* SelectNearbyNoTotemTarget(Unit* exclude = nullptr, float dist = NOMINAL_MELEE_RANGE) const;
|
Unit* SelectNearbyNoTotemTarget(Unit* exclude = nullptr, float dist = NOMINAL_MELEE_RANGE) const;
|
||||||
void SendMeleeAttackStop(Unit* victim = nullptr);
|
void SendMeleeAttackStop(Unit* victim = nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user