mirror of
https://gitcode.com/GitHub_Trending/az/azerothcore-wotlk.git
synced 2026-07-10 19:03:11 +00:00
fix(Core/Creature): stop mid-fight summons and proximity aggro from preferring totems/pets over players (#26457)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1925,6 +1925,11 @@ bool Creature::CanStartAttack(Unit const* who, bool force) const
|
||||
if (!_IsTargetAcceptable(who))
|
||||
return false;
|
||||
|
||||
// Totems never pull proximity aggro; they are only attacked in response
|
||||
// to threat they generate themselves (e.g. Searing Totem)
|
||||
if (who->IsTotem())
|
||||
return false;
|
||||
|
||||
if (IsNeutralToAll() || !IsWithinDistInMap(who, GetAggroRange(who) + m_CombatDistance, true, false, false))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2337,8 +2337,9 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
|
||||
|
||||
summon->InitSummon();
|
||||
|
||||
// call MoveInLineOfSight for nearby creatures
|
||||
Acore::AIRelocationNotifier notifier(*summon);
|
||||
// call MoveInLineOfSight for nearby players and creatures; players are visited
|
||||
// first (grid typelist order) so aggressive summons prefer them over pets/totems
|
||||
Acore::AIRelocationNotifier notifier(*summon, true);
|
||||
Cell::VisitObjects(summon, notifier, GetVisibilityRange());
|
||||
|
||||
return summon;
|
||||
|
||||
@@ -186,6 +186,19 @@ void AIRelocationNotifier::Visit(CreatureMapType& m)
|
||||
}
|
||||
}
|
||||
|
||||
void AIRelocationNotifier::Visit(PlayerMapType& m)
|
||||
{
|
||||
if (!includePlayers)
|
||||
return;
|
||||
|
||||
Creature* creature = i_unit.ToCreature();
|
||||
if (!creature || creature->IsMoveInLineOfSightStrictlyDisabled())
|
||||
return;
|
||||
|
||||
for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
|
||||
CreatureUnitRelocationWorker(creature, iter->GetSource());
|
||||
}
|
||||
|
||||
// Uses visibility map
|
||||
void MessageDistDeliverer::Visit(VisiblePlayersMap const& m)
|
||||
{
|
||||
|
||||
@@ -91,9 +91,11 @@ namespace Acore
|
||||
{
|
||||
Unit& i_unit;
|
||||
bool isCreature;
|
||||
explicit AIRelocationNotifier(Unit& unit) : i_unit(unit), isCreature(unit.IsCreature()) {}
|
||||
bool includePlayers;
|
||||
explicit AIRelocationNotifier(Unit& unit, bool includePlayers = false) : i_unit(unit), isCreature(unit.IsCreature()), includePlayers(includePlayers) {}
|
||||
template<class T> void Visit(GridRefMgr<T>&) {}
|
||||
void Visit(CreatureMapType&);
|
||||
void Visit(PlayerMapType&);
|
||||
};
|
||||
|
||||
enum class TeamFilter
|
||||
|
||||
Reference in New Issue
Block a user