aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/Spell.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2023-05-28 01:14:19 +0200
committerShauren <shauren.trinity@gmail.com>2023-05-28 01:14:19 +0200
commit3790c1e3dad36727279b22a33eea8e27418c4283 (patch)
tree1d4e7860fc6bfb79917f61eecd57207844975316 /src/server/game/Spells/Spell.cpp
parent7881f0ef5ff79b691a5abb9cd727755f49afba47 (diff)
Core/Spells: Implemented spell target type 142
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r--src/server/game/Spells/Spell.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index aa1531619c7..b45ce4a5fa8 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -1146,6 +1146,25 @@ void Spell::SelectImplicitNearbyTargets(SpellEffectInfo const& spellEffectInfo,
}
return;
}
+ if (targetType.GetTarget() == TARGET_DEST_NEARBY_ENTRY_OR_DB)
+ {
+ if (SpellTargetPosition const* st = sSpellMgr->GetSpellTargetPosition(m_spellInfo->Id, spellEffectInfo.EffectIndex))
+ {
+ SpellDestination dest(*m_caster);
+ if (st->target_mapId == m_caster->GetMapId() && m_caster->IsInDist(st->target_X, st->target_Y, st->target_Z, range))
+ dest = SpellDestination(st->target_X, st->target_Y, st->target_Z, st->target_Orientation);
+ else
+ {
+ float randomRadius = spellEffectInfo.CalcRadius(m_caster);
+ if (randomRadius > 0.0f)
+ m_caster->MovePositionToFirstCollision(dest._position, randomRadius, targetType.CalcDirectionAngle());
+ }
+
+ CallScriptDestinationTargetSelectHandlers(dest, spellEffectInfo.EffectIndex, targetType);
+ m_targets.SetDst(dest);
+ return;
+ }
+ }
break;
default:
break;
@@ -1153,6 +1172,22 @@ void Spell::SelectImplicitNearbyTargets(SpellEffectInfo const& spellEffectInfo,
}
WorldObject* target = SearchNearbyTarget(range, targetType.GetObjectType(), targetType.GetCheckType(), condList);
+ float randomRadius = 0.0f;
+ switch (targetType.GetTarget())
+ {
+ case TARGET_DEST_NEARBY_ENTRY_OR_DB:
+ // if we are here then there was no db target
+ if (!target)
+ {
+ target = m_caster;
+ // radius is only meant to be randomized when using caster fallback
+ randomRadius = spellEffectInfo.CalcRadius(m_caster);
+ }
+ break;
+ default:
+ break;
+ }
+
if (!target)
{
TC_LOG_DEBUG("spells", "Spell::SelectImplicitNearbyTargets: cannot find nearby target for spell ID {}, effect {}", m_spellInfo->Id, uint32(spellEffectInfo.EffectIndex));
@@ -1208,6 +1243,9 @@ void Spell::SelectImplicitNearbyTargets(SpellEffectInfo const& spellEffectInfo,
case TARGET_OBJECT_TYPE_DEST:
{
SpellDestination dest(*target);
+ if (randomRadius > 0.0f)
+ target->MovePositionToFirstCollision(dest._position, randomRadius, targetType.CalcDirectionAngle());
+
if (m_spellInfo->HasAttribute(SPELL_ATTR4_USE_FACING_FROM_SPELL))
dest._position.SetOrientation(spellEffectInfo.PositionFacing);