Corrected aggro radius calculation

This commit is contained in:
hondacrx
2017-11-22 12:36:15 -05:00
parent caca2dcb7e
commit 88258e844d
+13 -10
View File
@@ -1536,30 +1536,33 @@ namespace Game.Entities
float minRadius = (5.0f * WorldConfig.GetFloatValue(WorldCfg.RateCreatureAggro)); float minRadius = (5.0f * WorldConfig.GetFloatValue(WorldCfg.RateCreatureAggro));
float aggroRate = WorldConfig.GetFloatValue(WorldCfg.RateCreatureAggro); float aggroRate = WorldConfig.GetFloatValue(WorldCfg.RateCreatureAggro);
byte expansionMaxLevel = (byte)Global.ObjectMgr.GetMaxLevelForExpansion((Expansion)GetCreatureTemplate().RequiredExpansion); byte expansionMaxLevel = (byte)Global.ObjectMgr.GetMaxLevelForExpansion((Expansion)GetCreatureTemplate().RequiredExpansion);
int levelDifference = (int)(getLevel() - player.getLevel());
uint playerLevel = player.GetLevelForTarget(this);
uint creatureLevel = GetLevelForTarget(player);
if (aggroRate == 0.0f) if (aggroRate == 0.0f)
return 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 20 yards.
// The combatreach should not get taken into account for the distance so we drop it from the range (see Supremus as expample) // 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(UnitFields.CombatReach); float baseAggroDistance = 20.0f - GetCombatReach();
float aggroRadius = baseAggroDistance;
// + - 1 yard for each level difference between player and creature
float aggroRadius = baseAggroDistance + levelDifference;
// detect range auras // detect range auras
if ((float)(getLevel() + 5) <= WorldConfig.GetIntValue(WorldCfg.MaxPlayerLevel)) if ((creatureLevel + 5) <= WorldConfig.GetIntValue(WorldCfg.MaxPlayerLevel))
{ {
aggroRadius += GetTotalAuraModifier(AuraType.ModDetectRange); aggroRadius += GetTotalAuraModifier(AuraType.ModDetectRange);
aggroRadius += GetTotalAuraModifier(AuraType.ModDetectedRange); aggroRadius += player.GetTotalAuraModifier(AuraType.ModDetectedRange);
} }
// The aggro range of creatures with higher levels than the total player level for the expansion should get the maxlevel treatment // 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 // 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) // The following code is used for blizzlike behavior such as skipable bosses (e.g. Commander Springvale at level 85)
if (getLevel() > expansionMaxLevel) if (creatureLevel > expansionMaxLevel)
aggroRadius = baseAggroDistance + (expansionMaxLevel - player.getLevel()); aggroRadius += expansionMaxLevel - playerLevel;
// + - 1 yard for each level difference between player and creature
else
aggroRadius += creatureLevel - playerLevel;
// Make sure that we wont go over the total range limits // Make sure that we wont go over the total range limits
if (aggroRadius > maxRadius) if (aggroRadius > maxRadius)