From 675135e19bf7d928d3b61983c7043b155e5167c7 Mon Sep 17 00:00:00 2001 From: Tereneckla Date: Fri, 31 Oct 2025 14:09:38 +0000 Subject: [PATCH] fix(Core/Spells): only include the targets size for some GroundEffects (#23478) --- src/server/game/AI/CreatureAI.cpp | 2 +- .../game/AI/ScriptedAI/ScriptedCreature.cpp | 2 +- .../game/AI/ScriptedAI/ScriptedEscortAI.cpp | 4 ++-- .../game/AI/ScriptedAI/ScriptedFollowerAI.cpp | 4 ++-- src/server/game/Entities/Creature/Creature.cpp | 4 ++-- .../game/Entities/GameObject/GameObject.h | 2 +- src/server/game/Entities/Object/Object.cpp | 18 +++++++++++------- src/server/game/Entities/Object/Object.h | 6 +++--- .../game/Grids/Notifiers/GridNotifiers.h | 7 +++---- .../Northrend/Naxxramas/boss_gothik.cpp | 2 +- 10 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index f338e7789..dce728c14 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -182,7 +182,7 @@ void CreatureAI::MoveInLineOfSight(Unit* who) if (me->IsMoveInLineOfSightDisabled()) if (me->GetCreatureType() == CREATURE_TYPE_NON_COMBAT_PET || // nothing more to do, return !who->IsInCombat() || // if not in combat, nothing more to do - !me->IsWithinDist(who, ATTACK_DISTANCE, true, false)) // if in combat and in dist - neutral to all can actually assist other creatures + !me->IsWithinDist(who, ATTACK_DISTANCE, true, false, false)) // if in combat and in dist - neutral to all can actually assist other creatures return; if (me->HasReactState(REACT_AGGRESSIVE) && me->CanStartAttack(who)) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 7a009d0ae..ca354f093 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -566,7 +566,7 @@ Player* ScriptedAI::SelectTargetFromPlayerList(float maxdist, uint32 excludeAura std::vector tList; for(Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) { - if (!me->IsWithinDistInMap(itr->GetSource(), maxdist, true, false) || !itr->GetSource()->IsAlive() || itr->GetSource()->IsGameMaster()) + if (!me->IsWithinDistInMap(itr->GetSource(), maxdist, true, false, false) || !itr->GetSource()->IsAlive() || itr->GetSource()->IsGameMaster()) continue; if (excludeAura && itr->GetSource()->HasAura(excludeAura)) continue; diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index 7fe07cf1e..85fbf8a90 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -218,10 +218,10 @@ bool npc_escortAI::IsPlayerOrGroupInRange() { for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) if (Player* member = groupRef->GetSource()) - if (me->IsWithinDistInMap(member, GetMaxPlayerDistance(), true, false)) + if (me->IsWithinDistInMap(member, GetMaxPlayerDistance(), true, false, false)) return true; } - else if (me->IsWithinDistInMap(player, GetMaxPlayerDistance(), true, false)) + else if (me->IsWithinDistInMap(player, GetMaxPlayerDistance(), true, false, false)) return true; } diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index 019bb58b5..c43f81ff4 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -202,7 +202,7 @@ void FollowerAI::UpdateAI(uint32 uiDiff) { Player* member = groupRef->GetSource(); - if (member && me->IsWithinDistInMap(member, MAX_PLAYER_DISTANCE, true, false)) + if (member && me->IsWithinDistInMap(member, MAX_PLAYER_DISTANCE, true, false, false)) { bIsMaxRangeExceeded = false; break; @@ -211,7 +211,7 @@ void FollowerAI::UpdateAI(uint32 uiDiff) } else { - if (me->IsWithinDistInMap(player, MAX_PLAYER_DISTANCE, true, false)) + if (me->IsWithinDistInMap(player, MAX_PLAYER_DISTANCE, true, false, false)) bIsMaxRangeExceeded = false; } } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 19db15590..f09242833 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -771,7 +771,7 @@ void Creature::Update(uint32 diff) } Unit* owner = GetCharmerOrOwner(); - if (IsCharmed() && !IsWithinDistInMap(owner, GetMap()->GetVisibilityRange(), true, false)) + if (IsCharmed() && !IsWithinDistInMap(owner, GetMap()->GetVisibilityRange(), true, false, false)) { RemoveCharmAuras(); } @@ -1944,7 +1944,7 @@ bool Creature::CanStartAttack(Unit const* who) const if (!_IsTargetAcceptable(who)) return false; - if (IsNeutralToAll() || !IsWithinDistInMap(who, GetAggroRange(who) + m_CombatDistance, true, false)) // pussywizard: +m_combatDistance for turrets and similar + if (IsNeutralToAll() || !IsWithinDistInMap(who, GetAggroRange(who) + m_CombatDistance, true, false, false)) // pussywizard: +m_combatDistance for turrets and similar return false; if (!CanCreatureAttack(who)) diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 5ca9ad61e..13be19952 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -414,7 +414,7 @@ private: void UpdatePackedRotation(); //! Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size. - bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/, bool /*useBoundingRadius = true*/) const override + bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/, bool /*incOwnRadius = true*/, bool /*incTargetRadius = true*/) const override { //! Following check does check 3d distance dist2compare += obj->GetObjectSize(); diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 15d9906dd..142ff909b 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1232,10 +1232,14 @@ float WorldObject::GetDistanceZ(WorldObject const* obj) const return (dist > 0 ? dist : 0); } -bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool useBoundingRadius) const +bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool incOwnRadius, bool incTargetRadius) const { - float sizefactor = useBoundingRadius ? GetObjectSize() + obj->GetObjectSize() : 0.0f; - float maxdist = dist2compare + sizefactor; + float maxdist = dist2compare; + if (incOwnRadius) + maxdist += GetObjectSize(); + + if (incTargetRadius) + maxdist += obj->GetObjectSize(); if (m_transport && obj->GetTransport() && obj->GetTransport()->GetGUID() == m_transport->GetGUID()) { @@ -1342,14 +1346,14 @@ bool WorldObject::IsWithinDist2d(const Position* pos, float dist) const } // use only if you will sure about placing both object at same map -bool WorldObject::IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool useBoundingRadius) const +bool WorldObject::IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool incOwnRadius, bool incTargetRadius) const { - return obj && _IsWithinDist(obj, dist2compare, is3D, useBoundingRadius); + return obj && _IsWithinDist(obj, dist2compare, is3D, incOwnRadius, incTargetRadius); } -bool WorldObject::IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D, bool useBoundingRadius) const +bool WorldObject::IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D, bool incOwnRadius, bool incTargetRadius) const { - return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D, useBoundingRadius); + return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D, incOwnRadius, incTargetRadius); } bool WorldObject::IsWithinLOS(float ox, float oy, float oz, VMAP::ModelIgnoreFlags ignoreFlags, LineOfSightChecks checks) const diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 0fd248d8a..ae1ddbc17 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -541,8 +541,8 @@ public: [[nodiscard]] bool IsWithinDist2d(float x, float y, float dist) const; bool IsWithinDist2d(const Position* pos, float dist) const; // use only if you will sure about placing both object at same map - bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true, bool useBoundingRadius = true) const; - bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true, bool useBoundingRadius = true) const; + bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true, bool incOwnRadius = true, bool incTargetRadius = true) const; + bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true, bool incOwnRadius = true, bool incTargetRadius = true) const; [[nodiscard]] bool IsWithinLOS(float x, float y, float z, VMAP::ModelIgnoreFlags ignoreFlags = VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks = LINEOFSIGHT_ALL_CHECKS) const; [[nodiscard]] bool IsWithinLOSInMap(WorldObject const* obj, VMAP::ModelIgnoreFlags ignoreFlags = VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks = LINEOFSIGHT_ALL_CHECKS, Optional collisionHeight = { }, Optional combatReach = { }) const; [[nodiscard]] Position GetHitSpherePointFor(Position const& dest, Optional collisionHeight = { }, Optional combatReach = { }) const; @@ -770,7 +770,7 @@ private: uint16 m_notifyflags; uint16 m_executed_notifies; - virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool useBoundingRadius = true) const; + virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool incOwnRadius = true, bool incTargetRadius = true) const; bool CanNeverSee(WorldObject const* obj) const; virtual bool CanAlwaysSee(WorldObject const* /*obj*/) const { return false; } diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index b425abcc1..d08645acd 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -1092,10 +1092,9 @@ namespace Acore { return false; } - } - if (i_funit->_IsValidAttackTarget(u, _spellInfo, i_obj->IsDynamicObject() ? i_obj : nullptr) && i_obj->IsWithinDistInMap(u, i_range,true,false)) + if (i_funit->_IsValidAttackTarget(u, _spellInfo, i_obj->IsDynamicObject() ? i_obj : nullptr) && i_obj->IsWithinDistInMap(u, i_range,true,false, true)) return true; @@ -1192,7 +1191,7 @@ namespace Acore } bool operator()(Unit* u) { - if (!me->IsWithinDistInMap(u, m_range, true, false)) + if (!me->IsWithinDistInMap(u, m_range, true, false, false)) return false; if (!me->IsValidAttackTarget(u)) @@ -1218,7 +1217,7 @@ namespace Acore explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist) : me(creature), m_range(dist) {} bool operator()(Unit* u) { - if (!me->IsWithinDistInMap(u, m_range, true, false)) + if (!me->IsWithinDistInMap(u, m_range, true, false, false)) return false; if (!me->CanStartAttack(u)) diff --git a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp index b31d500e5..f07142456 100644 --- a/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp +++ b/src/server/scripts/Northrend/Naxxramas/boss_gothik.cpp @@ -266,7 +266,7 @@ public: std::vector tList; for(Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) { - if (!me->IsWithinDistInMap(itr->GetSource(), 200.0f, true, false) || !itr->GetSource()->IsAlive() || itr->GetSource()->IsGameMaster()) + if (!me->IsWithinDistInMap(itr->GetSource(), 200.0f, true, false, false) || !itr->GetSource()->IsAlive() || itr->GetSource()->IsGameMaster()) { continue; }