aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxinef1 <w.szyszko2@gmail.com>2017-02-04 20:21:12 +0100
committerShauren <shauren.trinity@gmail.com>2017-02-04 20:21:12 +0100
commit9e1b286984c63b801561a67dd4eae7910ec1af10 (patch)
tree02ce9d37632419ffcaa01134ea07c66c6c8d207d /src
parentf2963c1f6fd325e261bf596623a659884a9498b7 (diff)
Core/Spells: Fixed spell effect 93 (SPELL_EFFECT_FORCE_DESELECT) (#19001)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Grids/Notifiers/GridNotifiers.cpp68
-rw-r--r--src/server/game/Grids/Notifiers/GridNotifiers.h28
-rw-r--r--src/server/game/Spells/SpellEffects.cpp24
3 files changed, 118 insertions, 2 deletions
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp
index b58ec477e69..4d78dd23d28 100644
--- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp
@@ -328,6 +328,74 @@ void MessageDistDeliverer::Visit(DynamicObjectMapType &m)
}
}
+void MessageDistDelivererToHostile::Visit(PlayerMapType &m)
+{
+ for (PlayerMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
+ {
+ Player* target = iter->GetSource();
+ if (!target->InSamePhase(i_phaseMask))
+ continue;
+
+ if (target->GetExactDist2dSq(i_source) > i_distSq)
+ continue;
+
+ // Send packet to all who are sharing the player's vision
+ if (target->HasSharedVision())
+ {
+ SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
+ for (; i != target->GetSharedVisionList().end(); ++i)
+ if ((*i)->m_seer == target)
+ SendPacket(*i);
+ }
+
+ if (target->m_seer == target || target->GetVehicle())
+ SendPacket(target);
+ }
+}
+
+void MessageDistDelivererToHostile::Visit(CreatureMapType &m)
+{
+ for (CreatureMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
+ {
+ Creature* target = iter->GetSource();
+ if (!target->InSamePhase(i_phaseMask))
+ continue;
+
+ if (target->GetExactDist2dSq(i_source) > i_distSq)
+ continue;
+
+ // Send packet to all who are sharing the creature's vision
+ if (target->HasSharedVision())
+ {
+ SharedVisionList::const_iterator i = target->GetSharedVisionList().begin();
+ for (; i != target->GetSharedVisionList().end(); ++i)
+ if ((*i)->m_seer == target)
+ SendPacket(*i);
+ }
+ }
+}
+
+void MessageDistDelivererToHostile::Visit(DynamicObjectMapType &m)
+{
+ for (DynamicObjectMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
+ {
+ DynamicObject* target = iter->GetSource();
+ if (!target->InSamePhase(i_phaseMask))
+ continue;
+
+ if (target->GetExactDist2dSq(i_source) > i_distSq)
+ continue;
+
+ if (Unit* caster = target->GetCaster())
+ {
+ // Send packet back to the caster if the caster has vision of dynamic object
+ Player* player = caster->ToPlayer();
+ if (player && player->m_seer == target)
+ SendPacket(player);
+ }
+ }
+}
+
/*
void
MessageDistDeliverer::VisitObject(Player* player)
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index 9cc533eb27d..1048acff34a 100644
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -157,6 +157,34 @@ namespace Trinity
}
};
+ struct TC_GAME_API MessageDistDelivererToHostile
+ {
+ Unit* i_source;
+ WorldPacket* i_message;
+ uint32 i_phaseMask;
+ float i_distSq;
+
+ MessageDistDelivererToHostile(Unit* src, WorldPacket* msg, float dist)
+ : i_source(src), i_message(msg), i_phaseMask(src->GetPhaseMask()), i_distSq(dist * dist)
+ {
+ }
+
+ void Visit(PlayerMapType &m);
+ void Visit(CreatureMapType &m);
+ void Visit(DynamicObjectMapType &m);
+ template<class SKIP> void Visit(GridRefManager<SKIP> &) { }
+
+ void SendPacket(Player* player)
+ {
+ // never send packet to self
+ if (player == i_source || !player->HaveAtClient(i_source) || player->IsFriendlyTo(i_source))
+ return;
+
+ if (WorldSession* session = player->GetSession())
+ session->SendPacket(i_message);
+ }
+ };
+
struct ObjectUpdater
{
uint32 i_timeDiff;
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index e557501c095..3c7390b54c6 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -46,6 +46,7 @@
#include "Util.h"
#include "TemporarySummon.h"
#include "GridNotifiers.h"
+#include "CellImpl.h"
#include "Formulas.h"
#include "ScriptMgr.h"
#include "SpellHistory.h"
@@ -4562,9 +4563,28 @@ void Spell::EffectForceDeselect(SpellEffIndex /*effIndex*/)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
- WorldPacket data(SMSG_CLEAR_TARGET, 8);
+ float dist = m_caster->GetVisibilityRange();
+
+ // clear focus
+ WorldPacket data(SMSG_BREAK_TARGET, m_caster->GetPackGUID().size());
+ data << m_caster->GetPackGUID();
+ Trinity::MessageDistDelivererToHostile notifierBreak(m_caster, &data, dist);
+ m_caster->VisitNearbyWorldObject(dist, notifierBreak);
+
+ // and selection
+ data.Initialize(SMSG_CLEAR_TARGET, 8);
data << uint64(m_caster->GetGUID());
- m_caster->SendMessageToSet(&data, true);
+ Trinity::MessageDistDelivererToHostile notifierClear(m_caster, &data, dist);
+ m_caster->VisitNearbyWorldObject(dist, notifierClear);
+
+ // we should also force pets to remove us from current target
+ Unit::AttackerSet attackerSet;
+ for (Unit::AttackerSet::const_iterator itr = m_caster->getAttackers().begin(); itr != m_caster->getAttackers().end(); ++itr)
+ if ((*itr)->GetTypeId() == TYPEID_UNIT && !(*itr)->CanHaveThreatList())
+ attackerSet.insert(*itr);
+
+ for (Unit::AttackerSet::const_iterator itr = attackerSet.begin(); itr != attackerSet.end(); ++itr)
+ (*itr)->AttackStop();
}
void Spell::EffectSelfResurrect(SpellEffIndex effIndex)