Core/Creatures: fixed creature aggro radius calculation

This commit is contained in:
Ovahlord
2026-08-27 21:26:07 +02:00
parent c9b40ed3ec
commit 41c4d4e4a6
@@ -2172,17 +2172,14 @@ float Creature::GetAttackDistance(Unit const* player) const
float maxRadius = 45.0f * aggroRate;
float minRadius = 5.0f * aggroRate;
int32 expansionMaxLevel = int32(GetMaxLevelForExpansion(GetCreatureTemplate()->RequiredExpansion));
int32 expansionMaxLevel = int32(GetMaxLevelForExpansion(GetCreatureDifficulty()->GetHealthScalingExpansion()));
int32 playerLevel = player->GetLevelForTarget(this);
int32 creatureLevel = GetLevelForTarget(player);
int32 levelDifference = creatureLevel - playerLevel;
// The aggro radius for creatures with equal level as the player is 20 yards.
// The aggro radius for creatures with equal level as the player is 15 yards.
// The combatreach should not get taken into account for the distance so we drop it from the range (see Supremus as expample)
float baseAggroDistance = 20.0f - GetCombatReach();
// + - 1 yard for each level difference between player and creature
float aggroRadius = baseAggroDistance + float(levelDifference);
float baseAggroDistance = 15.0f - GetCombatReach();
float aggroRadius = baseAggroDistance;
// detect range auras
if (uint32(creatureLevel + 5) <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
@@ -2196,6 +2193,8 @@ float Creature::GetAttackDistance(Unit const* player) const
// The following code is used for blizzlike behaviour such as skippable bosses
if (creatureLevel > expansionMaxLevel)
aggroRadius = baseAggroDistance + float(expansionMaxLevel - playerLevel);
else // + - 1 yard for each level difference between player and creature
aggroRadius += float(creatureLevel - playerLevel);
// Make sure that we wont go over the total range limits
if (aggroRadius > maxRadius)