diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index e29d24a9808..95d04490893 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1785,34 +1785,38 @@ bool Creature::CheckNoGrayAggroConfig(uint32 playerLevel, uint32 creatureLevel) float Creature::GetAttackDistance(Unit const* player) const { // WoW Wiki: the minimum radius seems to be 5 yards, while the maximum range is 45 yards + float maxRadius = (45.0f * sWorld->getRate(RATE_CREATURE_AGGRO)); + float minRadius = (5.0f * sWorld->getRate(RATE_CREATURE_AGGRO)); float aggroRate = sWorld->getRate(RATE_CREATURE_AGGRO); - float maxRadius = (45.0f * aggroRate); - float minRadius = (5.0f * aggroRate); uint8 expansionMaxLevel = uint8(GetMaxLevelForExpansion(GetCreatureTemplate()->expansion)); - int32 levelDifference = getLevel() - player->getLevel(); + + uint32 playerLevel = player->getLevel(); + uint32 creatureLevel = getLevel(); if (aggroRate == 0.0f) return 0.0f; - // 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 - GetFloatValue(UNIT_FIELD_COMBATREACH); - - // + - 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 (float(getLevel() + 5) <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) + if ((creatureLevel + 5) <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) { aggroRadius += GetTotalAuraModifier(SPELL_AURA_MOD_DETECT_RANGE); - aggroRadius += GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE); + + aggroRadius += player->GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE); } // The aggro range of creatures with higher levels than the total player level for the expansion should get the maxlevel treatment // This makes sure that creatures such as bosses wont have a bigger aggro range than the rest of the npc's - // The following code is used for blizzlike behaivior such as skippable bosses - if (getLevel() > expansionMaxLevel) - aggroRadius = baseAggroDistance + float(expansionMaxLevel - player->getLevel()); + // The following code is used for blizzlike behavior such as skipable bosses (e.g. Commander Springvale at level 85) + if (creatureLevel > expansionMaxLevel) + aggroRadius += float(expansionMaxLevel) - float(playerLevel); + // + - 1 yard for each level difference between player and creature + else + aggroRadius += float(creatureLevel) - float(playerLevel); // Make sure that we wont go over the total range limits if (aggroRadius > maxRadius)