aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMeji <alvaro.megias@outlook.com>2023-12-08 01:54:48 +0100
committerfunjoker <funjoker109@gmail.com>2023-12-12 08:44:09 +0100
commitc8e87e59e0649b3777138412655a787e7a8024b3 (patch)
treedf143a6e7a417698379b7e16ef492435d3ccf870 /src
parent9e317a047aee6f722a284af36bc850615cb39949 (diff)
Core/Spells: Fixed target radius calculation for TARGET_DEST_*_RANDOM (#29479)
(cherry picked from commit 87f3ab11d3dd5d362657aaae9c02effa8ee95f21)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Spells/Spell.cpp6
-rw-r--r--src/server/game/Spells/SpellInfo.cpp13
2 files changed, 12 insertions, 7 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index e7ad468e0ff..dbd215c35e6 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -1603,7 +1603,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn
break;
case TARGET_DEST_CASTER_RANDOM:
if (dist > objSize)
- dist = objSize + (dist - objSize) * rand_norm();
+ dist = objSize + (dist - objSize);
break;
case TARGET_DEST_CASTER_FRONT_LEFT:
case TARGET_DEST_CASTER_BACK_LEFT:
@@ -1654,8 +1654,6 @@ void Spell::SelectImplicitTargetDestTargets(SpellEffectInfo const& spellEffectIn
{
float angle = targetType.CalcDirectionAngle();
float dist = spellEffectInfo.CalcRadius(nullptr, targetIndex);
- if (targetType.GetTarget() == TARGET_DEST_TARGET_RANDOM)
- dist *= rand_norm();
Position pos = dest._position;
target->MovePositionToFirstCollision(pos, dist, angle);
@@ -1708,8 +1706,6 @@ void Spell::SelectImplicitDestDestTargets(SpellEffectInfo const& spellEffectInfo
{
float angle = targetType.CalcDirectionAngle();
float dist = spellEffectInfo.CalcRadius(m_caster, targetIndex);
- if (targetType.GetTarget() == TARGET_DEST_DEST_RANDOM)
- dist *= rand_norm();
Position pos = dest._position;
m_caster->MovePositionToFirstCollision(pos, dist, angle);
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index eba12d8a794..3f304fcdaa5 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -645,17 +645,26 @@ float SpellEffectInfo::CalcRadius(WorldObject* caster /*= nullptr*/, SpellTarget
// TargetA -> TargetARadiusEntry
// TargetB -> TargetBRadiusEntry
// Aura effects have TargetARadiusEntry == TargetBRadiusEntry (mostly)
+ SpellImplicitTargetInfo target = TargetA;
SpellRadiusEntry const* entry = TargetARadiusEntry;
if (targetIndex == SpellTargetIndex::TargetB && HasRadius(targetIndex))
+ {
+ target = TargetB;
entry = TargetBRadiusEntry;
+ }
if (!entry)
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() == TARGET_DEST_CASTER_RANDOM ||
+ target.GetTarget() == TARGET_DEST_TARGET_RANDOM ||
+ target.GetTarget() == TARGET_DEST_DEST_RANDOM)
+ radius += (entry->RadiusMax - radius) * rand_norm();
+ else if (radius == 0.0f)
radius = entry->RadiusMax;
if (caster)