diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index eccbd596dd1..a3e0a61c611 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1651,31 +1651,34 @@ float Creature::GetAttackDistance(Unit const* player) const float minRadius = (5.0f * sWorld->getRate(RATE_CREATURE_AGGRO)); float aggroRate = sWorld->getRate(RATE_CREATURE_AGGRO); uint8 expansionMaxLevel = uint8(GetMaxLevelForExpansion(GetCreatureTemplate()->RequiredExpansion)); - int32 levelDifference = getLevel() - player->getLevel(); + + uint32 playerLevel = player->GetLevelForTarget(this); + uint32 creatureLevel = GetLevelForTarget(player); if (aggroRate == 0.0f) - return 0.0; + return 0.0f; // The aggro radius for creatures with equal level as the player is 20 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 = 20.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 skipable bosses (e.g. Commander Springvale at level 85) - 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) |