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
@@ -2773,7 +2773,7 @@ namespace Framework.Constants
DestFrontLeft = 71,
DestCasterRandom = 72,
DestCasterRadius = 73,
DestRandom = 74,
DestTargetRandom = 74,
DestRadius = 75,
DestChannelTarget = 76,
UnitChannelTarget = 77,
+1 -5
View File
@@ -1114,7 +1114,7 @@ namespace Game.Spells
break;
case Targets.DestCasterRandom:
if (dist > objSize)
dist = objSize + (dist - objSize) * RandomHelper.NextSingle();
dist = objSize + (dist - objSize);
break;
case Targets.DestCasterFrontLeft:
case Targets.DestCasterBackLeft:
@@ -1164,8 +1164,6 @@ namespace Game.Spells
{
float angle = targetType.CalcDirectionAngle();
float dist = spellEffectInfo.CalcRadius(null, targetIndex);
if (targetType.GetTarget() == Targets.DestRandom)
dist *= RandomHelper.NextSingle();
Position pos = new(dest.Position);
target.MovePositionToFirstCollision(pos, dist, angle);
@@ -1218,8 +1216,6 @@ namespace Game.Spells
{
float angle = targetType.CalcDirectionAngle();
float dist = spellEffectInfo.CalcRadius(m_caster, targetIndex);
if (targetType.GetTarget() == Targets.DestRandom)
dist *= RandomHelper.NextSingle();
Position pos = new(m_targets.GetDstPos());
m_caster.MovePositionToFirstCollision(pos, dist, angle);
+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)