From acb9db88913f41b59ac7e26d234dc9059eb4b4be Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 17 Jul 2022 22:49:28 -0400 Subject: [PATCH] Fixes creatures aggro range, Wrong check on pathpoints, and a crash when there is no unitCaster. --- Source/Game/Entities/Creature/Creature.cs | 8 ++++---- Source/Game/Movement/Generators/PathGenerator.cs | 2 +- Source/Game/Spells/Spell.cs | 2 +- Source/Scripts/Spells/Mage.cs | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index ca09cdfb8..221b64b28 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -1786,10 +1786,10 @@ namespace Game.Entities float maxRadius = 45.0f * aggroRate; float minRadius = 5.0f * aggroRate; - uint expansionMaxLevel = Global.ObjectMgr.GetMaxLevelForExpansion((Expansion)GetCreatureTemplate().RequiredExpansion); - uint playerLevel = player.GetLevelForTarget(this); - uint creatureLevel = GetLevelForTarget(player); - uint levelDifference = creatureLevel - playerLevel; + int expansionMaxLevel = (int)Global.ObjectMgr.GetMaxLevelForExpansion((Expansion)GetCreatureTemplate().RequiredExpansion); + int playerLevel = (int)player.GetLevelForTarget(this); + int creatureLevel = (int)GetLevelForTarget(player); + int levelDifference = creatureLevel - playerLevel; // 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) diff --git a/Source/Game/Movement/Generators/PathGenerator.cs b/Source/Game/Movement/Generators/PathGenerator.cs index 78e0d7b99..f6baef3f8 100644 --- a/Source/Game/Movement/Generators/PathGenerator.cs +++ b/Source/Game/Movement/Generators/PathGenerator.cs @@ -952,7 +952,7 @@ namespace Game.Movement return; // check if we even need to do anything - if ((_pathPoints[0] - target).LengthSquared() >= distSq) + if ((_pathPoints[_pathPoints.Length - 1] - target).LengthSquared() >= distSq) return; int i = _pathPoints.Length - 1; diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index c2da5b1bd..66a841a05 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -3372,7 +3372,7 @@ namespace Game.Spells return; Unit unitCaster = m_caster.ToUnit(); - if (unitCaster != null) + if (unitCaster == null) return; // successful cast of the initial autorepeat spell is moved to idle state so that it is not deleted as long as autorepeat is active diff --git a/Source/Scripts/Spells/Mage.cs b/Source/Scripts/Spells/Mage.cs index 6ae2d66fe..05e26b73c 100644 --- a/Source/Scripts/Spells/Mage.cs +++ b/Source/Scripts/Spells/Mage.cs @@ -1018,7 +1018,7 @@ namespace Scripts.Spells.Mage } } - // 205021 - Ray of Frost + [Script] // 205021 - Ray of Frost class spell_mage_ray_of_frost : SpellScript { public override bool Validate(SpellInfo spellInfo) @@ -1039,6 +1039,7 @@ namespace Scripts.Spells.Mage } } + [Script] class spell_mage_ray_of_frost_aura : AuraScript { public override bool Validate(SpellInfo spellInfo)