Core/Spells: Fixed target radius calculation for TARGET_DEST_*_RANDOM

Port From (https://github.com/TrinityCore/TrinityCore/commit/87f3ab11d3dd5d362657aaae9c02effa8ee95f21)
This commit is contained in:
hondacrx
2024-02-03 22:02:40 -05:00
parent 136ad2cff0
commit 4d0362edc6
3 changed files with 13 additions and 8 deletions
+11 -2
View File
@@ -4413,17 +4413,26 @@ namespace Game.Spells
// TargetA -> TargetARadiusEntry
// TargetB -> TargetBRadiusEntry
// Aura effects have TargetARadiusEntry == TargetBRadiusEntry (mostly)
SpellImplicitTargetInfo target = TargetA;
var entry = TargetARadiusEntry;
if (targetIndex == SpellTargetIndex.TargetB && HasRadius(targetIndex))
{
target = TargetB;
entry = TargetBRadiusEntry;
}
if (entry == null)
return 0.0f;
float radius = entry.RadiusMin;
// Client uses max if min is 0
if (radius == 0.0f)
// Random targets use random value between RadiusMin and RadiusMax
// For other cases, client uses RadiusMax if RadiusMin is 0
if (target.GetTarget() == Targets.DestCasterRandom ||
target.GetTarget() == Targets.DestTargetRandom ||
target.GetTarget() == Targets.DestDestRandom)
radius += (entry.RadiusMax - radius) * RandomHelper.NextSingle();
else if (radius == 0.0f)
radius = entry.RadiusMax;
if (caster != null)