diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-01-21 14:11:54 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-01-21 14:11:54 +0100 |
commit | 2a51a6454912df635099572d07789a1d6789ff4d (patch) | |
tree | 5af7415fd0889864fd8721fb048efb2d75d26fee /src/server/game/Spells/Spell.cpp | |
parent | 476b8951e1fffc05a01ab04fea6e1134a6f0f95a (diff) |
Core/Spells: Reimplemented target type 106 as random point from points predefined in database
Closes #30116
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 62a9279c343..4ad83b680c0 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1057,16 +1057,6 @@ void Spell::SelectImplicitChannelTargets(SpellEffectInfo const& spellEffectInfo, TC_LOG_DEBUG("spells", "SPELL: cannot find channel spell destination for spell ID {}, effect {}", m_spellInfo->Id, uint32(spellEffectInfo.EffectIndex)); } break; - case TARGET_DEST_CHANNEL_CASTER: - { - SpellDestination dest(*channeledSpell->GetCaster()); - if (m_spellInfo->HasAttribute(SPELL_ATTR4_USE_FACING_FROM_SPELL)) - dest._position.SetOrientation(spellEffectInfo.PositionFacing); - - CallScriptDestinationTargetSelectHandlers(dest, spellEffectInfo.EffectIndex, targetType); - m_targets.SetDst(dest); - break; - } default: ABORT_MSG("Spell::SelectImplicitChannelTargets: received not implemented target type"); break; @@ -1579,6 +1569,25 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn if (WorldObject const* summoner = casterSummon->GetSummoner()) dest = SpellDestination(*summoner); break; + case TARGET_DEST_NEARBY_DB: + { + Optional<std::pair<float, float>> radiusBounds = spellEffectInfo.CalcRadiusBounds(m_caster, targetIndex, this); + std::vector<SpellTargetPosition const*> positionsInRange; + for (auto const& [_, position] : sSpellMgr->GetSpellTargetPositions(m_spellInfo->Id, spellEffectInfo.EffectIndex)) + if (m_caster->GetMapId() == position.GetMapId() && (!radiusBounds || (!m_caster->IsInDist(position, radiusBounds->first) && m_caster->IsInDist(position, radiusBounds->second)))) + positionsInRange.push_back(&position); + + if (positionsInRange.empty()) + { + TC_LOG_DEBUG("spells", "SPELL: unknown target coordinates for spell ID {}", m_spellInfo->Id); + SendCastResult(SPELL_FAILED_NO_VALID_TARGETS); + finish(SPELL_FAILED_NO_VALID_TARGETS); + return; + } + + dest = Trinity::Containers::SelectRandomContainerElement(positionsInRange)->GetPosition(); + break; + } default: { float dist = spellEffectInfo.CalcRadius(m_caster, targetIndex); @@ -1599,7 +1608,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffectInfo const& spellEffectIn case TARGET_DEST_CASTER_FRONT_RIGHT: case TARGET_DEST_CASTER_BACK_RIGHT: { - constexpr float DefaultTotemDistance = 3.0f; + static constexpr float DefaultTotemDistance = 3.0f; if (!spellEffectInfo.HasRadius(targetIndex)) dist = DefaultTotemDistance; break; |