Core/Spells: Fixed target radius calculation for TARGET_DEST_*_RANDOM
Port From (https://github.com/TrinityCore/TrinityCore/commit/87f3ab11d3dd5d362657aaae9c02effa8ee95f21)
This commit is contained in:
@@ -2773,7 +2773,7 @@ namespace Framework.Constants
|
|||||||
DestFrontLeft = 71,
|
DestFrontLeft = 71,
|
||||||
DestCasterRandom = 72,
|
DestCasterRandom = 72,
|
||||||
DestCasterRadius = 73,
|
DestCasterRadius = 73,
|
||||||
DestRandom = 74,
|
DestTargetRandom = 74,
|
||||||
DestRadius = 75,
|
DestRadius = 75,
|
||||||
DestChannelTarget = 76,
|
DestChannelTarget = 76,
|
||||||
UnitChannelTarget = 77,
|
UnitChannelTarget = 77,
|
||||||
|
|||||||
@@ -1114,7 +1114,7 @@ namespace Game.Spells
|
|||||||
break;
|
break;
|
||||||
case Targets.DestCasterRandom:
|
case Targets.DestCasterRandom:
|
||||||
if (dist > objSize)
|
if (dist > objSize)
|
||||||
dist = objSize + (dist - objSize) * RandomHelper.NextSingle();
|
dist = objSize + (dist - objSize);
|
||||||
break;
|
break;
|
||||||
case Targets.DestCasterFrontLeft:
|
case Targets.DestCasterFrontLeft:
|
||||||
case Targets.DestCasterBackLeft:
|
case Targets.DestCasterBackLeft:
|
||||||
@@ -1164,8 +1164,6 @@ namespace Game.Spells
|
|||||||
{
|
{
|
||||||
float angle = targetType.CalcDirectionAngle();
|
float angle = targetType.CalcDirectionAngle();
|
||||||
float dist = spellEffectInfo.CalcRadius(null, targetIndex);
|
float dist = spellEffectInfo.CalcRadius(null, targetIndex);
|
||||||
if (targetType.GetTarget() == Targets.DestRandom)
|
|
||||||
dist *= RandomHelper.NextSingle();
|
|
||||||
|
|
||||||
Position pos = new(dest.Position);
|
Position pos = new(dest.Position);
|
||||||
target.MovePositionToFirstCollision(pos, dist, angle);
|
target.MovePositionToFirstCollision(pos, dist, angle);
|
||||||
@@ -1218,8 +1216,6 @@ namespace Game.Spells
|
|||||||
{
|
{
|
||||||
float angle = targetType.CalcDirectionAngle();
|
float angle = targetType.CalcDirectionAngle();
|
||||||
float dist = spellEffectInfo.CalcRadius(m_caster, targetIndex);
|
float dist = spellEffectInfo.CalcRadius(m_caster, targetIndex);
|
||||||
if (targetType.GetTarget() == Targets.DestRandom)
|
|
||||||
dist *= RandomHelper.NextSingle();
|
|
||||||
|
|
||||||
Position pos = new(m_targets.GetDstPos());
|
Position pos = new(m_targets.GetDstPos());
|
||||||
m_caster.MovePositionToFirstCollision(pos, dist, angle);
|
m_caster.MovePositionToFirstCollision(pos, dist, angle);
|
||||||
|
|||||||
@@ -4413,17 +4413,26 @@ namespace Game.Spells
|
|||||||
// TargetA -> TargetARadiusEntry
|
// TargetA -> TargetARadiusEntry
|
||||||
// TargetB -> TargetBRadiusEntry
|
// TargetB -> TargetBRadiusEntry
|
||||||
// Aura effects have TargetARadiusEntry == TargetBRadiusEntry (mostly)
|
// Aura effects have TargetARadiusEntry == TargetBRadiusEntry (mostly)
|
||||||
|
SpellImplicitTargetInfo target = TargetA;
|
||||||
var entry = TargetARadiusEntry;
|
var entry = TargetARadiusEntry;
|
||||||
if (targetIndex == SpellTargetIndex.TargetB && HasRadius(targetIndex))
|
if (targetIndex == SpellTargetIndex.TargetB && HasRadius(targetIndex))
|
||||||
|
{
|
||||||
|
target = TargetB;
|
||||||
entry = TargetBRadiusEntry;
|
entry = TargetBRadiusEntry;
|
||||||
|
}
|
||||||
|
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
float radius = entry.RadiusMin;
|
float radius = entry.RadiusMin;
|
||||||
|
|
||||||
// Client uses max if min is 0
|
// Random targets use random value between RadiusMin and RadiusMax
|
||||||
if (radius == 0.0f)
|
// 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;
|
radius = entry.RadiusMax;
|
||||||
|
|
||||||
if (caster != null)
|
if (caster != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user