From 5ed4db09e3c8c78e1a685e0137e05bfe6776d2fd Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Sun, 6 Mar 2022 21:51:59 +0100 Subject: [PATCH] fix(Core/Spells): Fixed getting max spell range for friendly targets. (#10906) Fixes #10802 --- src/server/game/Entities/Unit/Unit.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c0becee70..2a12b25e7 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -14386,20 +14386,35 @@ void Unit::ApplyDiminishingAura(DiminishingGroup group, bool apply) float Unit::GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const { if (!spellInfo->RangeEntry) + { return 0; - if (spellInfo->RangeEntry->RangeMin[1] == spellInfo->RangeEntry->RangeMin[0]) + } + + if (spellInfo->RangeEntry->RangeMax[1] == spellInfo->RangeEntry->RangeMax[0]) + { return spellInfo->GetMaxRange(); - if (target == nullptr) + } + + if (!target) + { return spellInfo->GetMaxRange(true); + } + return spellInfo->GetMaxRange(!IsHostileTo(target)); } float Unit::GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const { if (!spellInfo->RangeEntry) + { return 0; + } + if (spellInfo->RangeEntry->RangeMin[1] == spellInfo->RangeEntry->RangeMin[0]) + { return spellInfo->GetMinRange(); + } + return spellInfo->GetMinRange(!IsHostileTo(target)); }