diff options
| author | Shauren <shauren.trinity@gmail.com> | 2017-04-16 01:13:09 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2017-04-16 01:13:09 +0200 |
| commit | c0eb6c313053d2437abf2e7fff9ab50645c98559 (patch) | |
| tree | e9c79ce1a961355911fb2e8e04d0cd39b1c409c0 /src/server/game/Spells/Spell.cpp | |
| parent | 43510a258c83215efcf5e70a253523e8a4199502 (diff) | |
Core/Entities: Update updatefields to 7.2.0
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 7880d1339b3..5b94f965067 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -965,30 +965,38 @@ void Spell::SelectImplicitChannelTargets(SpellEffIndex effIndex, SpellImplicitTa { case TARGET_UNIT_CHANNEL_TARGET: { - WorldObject* target = ObjectAccessor::GetUnit(*m_caster, m_originalCaster->GetChannelObjectGuid()); - CallScriptObjectTargetSelectHandlers(target, effIndex, targetType); - // unit target may be no longer avalible - teleported out of map for example - if (target && target->ToUnit()) - AddUnitTarget(target->ToUnit(), 1 << effIndex); - else - TC_LOG_DEBUG("spells", "SPELL: cannot find channel spell target for spell ID %u, effect %u", m_spellInfo->Id, effIndex); + for (ObjectGuid const& channelTarget : m_originalCaster->GetChannelObjects()) + { + WorldObject* target = ObjectAccessor::GetUnit(*m_caster, channelTarget); + CallScriptObjectTargetSelectHandlers(target, effIndex, targetType); + // unit target may be no longer avalible - teleported out of map for example + if (target && target->GetTypeId() == TYPEID_UNIT) + AddUnitTarget(target->ToUnit(), 1 << effIndex); + else + TC_LOG_DEBUG("spells", "SPELL: cannot find channel spell target for spell ID %u, effect %u", m_spellInfo->Id, effIndex); + } break; } case TARGET_DEST_CHANNEL_TARGET: if (channeledSpell->m_targets.HasDst()) m_targets.SetDst(channeledSpell->m_targets); - else if (WorldObject* target = ObjectAccessor::GetWorldObject(*m_caster, m_originalCaster->GetChannelObjectGuid())) + else { - CallScriptObjectTargetSelectHandlers(target, effIndex, targetType); + DynamicFieldStructuredView<ObjectGuid> channelObjects = m_originalCaster->GetChannelObjects(); + WorldObject* target = channelObjects.size() > 0 ? ObjectAccessor::GetWorldObject(*m_caster, *channelObjects.begin()) : nullptr; if (target) { - SpellDestination dest(*target); - CallScriptDestinationTargetSelectHandlers(dest, effIndex, targetType); - m_targets.SetDst(dest); + CallScriptObjectTargetSelectHandlers(target, effIndex, targetType); + if (target) + { + SpellDestination dest(*target); + CallScriptDestinationTargetSelectHandlers(dest, effIndex, targetType); + m_targets.SetDst(dest); + } } + else + TC_LOG_DEBUG("spells", "SPELL: cannot find channel spell destination for spell ID %u, effect %u", m_spellInfo->Id, effIndex); } - else - TC_LOG_DEBUG("spells", "SPELL: cannot find channel spell destination for spell ID %u, effect %u", m_spellInfo->Id, effIndex); break; case TARGET_DEST_CHANNEL_CASTER: { @@ -4356,7 +4364,7 @@ void Spell::SendChannelUpdate(uint32 time) { if (time == 0) { - m_caster->SetChannelObjectGuid(ObjectGuid::Empty); + m_caster->ClearDynamicValue(UNIT_DYNAMIC_FIELD_CHANNEL_OBJECTS); m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, 0); } @@ -4368,11 +4376,6 @@ void Spell::SendChannelUpdate(uint32 time) void Spell::SendChannelStart(uint32 duration) { - ObjectGuid channelTarget = m_targets.GetObjectTargetGUID(); - if (!channelTarget && !m_spellInfo->NeedsExplicitUnitTarget()) - if (m_UniqueTargetInfo.size() + m_UniqueGOTargetInfo.size() == 1) // this is for TARGET_SELECT_CATEGORY_NEARBY - channelTarget = !m_UniqueTargetInfo.empty() ? m_UniqueTargetInfo.front().targetGUID : m_UniqueGOTargetInfo.front().targetGUID; - WorldPackets::Spells::SpellChannelStart spellChannelStart; spellChannelStart.CasterGUID = m_caster->GetGUID(); spellChannelStart.SpellID = m_spellInfo->Id; @@ -4391,8 +4394,11 @@ void Spell::SendChannelStart(uint32 duration) } m_timer = duration; - if (!channelTarget.IsEmpty()) - m_caster->SetChannelObjectGuid(channelTarget); + for (TargetInfo const& target : m_UniqueTargetInfo) + m_caster->AddChannelObject(target.targetGUID); + + for (GOTargetInfo const& target : m_UniqueGOTargetInfo) + m_caster->AddChannelObject(target.targetGUID); m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL, m_spellInfo->Id); m_caster->SetUInt32Value(UNIT_CHANNEL_SPELL_X_SPELL_VISUAL, m_SpellVisual); |
