From 75ae86d0628f0fe2dad91a1e5b6d34c9bf4e7b7b Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sat, 6 Jul 2019 15:22:28 +0200 Subject: [PATCH] Core/Creatures: updated aggro range calculation with 335 commit data --- .../game/Entities/Creature/Creature.cpp | 30 ++++++++----------- src/server/game/Miscellaneous/SharedDefines.h | 18 +++++++++++ 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 5d7e1bb2f95..c5e7eb1acb6 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1767,38 +1767,34 @@ 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)); - - uint32 playerLevel = player->getLevel(); - uint32 creatureLevel = getLevel(); + int32 levelDifference = getLevel() - player->getLevel(); if (aggroRate == 0.0f) return 0.0f; - // The aggro radius for creatures with equal level as the player is 15 yards. + // 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 = 15.0f - GetCombatReach(); - float aggroRadius = baseAggroDistance; + float baseAggroDistance = 20.0f - GetFloatValue(UNIT_FIELD_COMBATREACH); + + // + - 1 yard for each level difference between player and creature + float aggroRadius = baseAggroDistance + float(levelDifference); // detect range auras - if ((creatureLevel + 5) <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) + if (float(getLevel() + 5) <= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) { aggroRadius += GetTotalAuraModifier(SPELL_AURA_MOD_DETECT_RANGE); - - aggroRadius += player->GetTotalAuraModifier(SPELL_AURA_MOD_DETECTED_RANGE); + aggroRadius += 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 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); + // The following code is used for blizzlike behaivior such as skippable bosses + if (getLevel() > expansionMaxLevel) + aggroRadius = baseAggroDistance + float(expansionMaxLevel - player->getLevel()); // Make sure that we wont go over the total range limits if (aggroRadius > maxRadius) diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 3d16bea3a81..fa54e747d50 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -55,6 +55,24 @@ enum Expansions MAX_EXPANSIONS = 4 }; +inline uint32 GetMaxLevelForExpansion(uint32 expansion) +{ + switch (expansion) + { + case EXPANSION_CLASSIC: + return 60; + case EXPANSION_THE_BURNING_CRUSADE: + return 70; + case EXPANSION_WRATH_OF_THE_LICH_KING: + return 80; + case EXPANSION_CATACLYSM: + return 85; + default: + break; + } + return 0; +} + enum Gender { GENDER_MALE = 0,