Core/Spells: Fixed spell effect 93 (SPELL_EFFECT_FORCE_DESELECT) (#19001)

This commit is contained in:
xinef1
2017-02-04 20:21:12 +01:00
committed by Aokromes
parent 524b4f6121
commit a76da51e7f
3 changed files with 118 additions and 2 deletions

View File

@@ -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)

View File

@@ -158,6 +158,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;

View File

@@ -47,6 +47,7 @@
#include "Util.h"
#include "TemporarySummon.h"
#include "GridNotifiers.h"
#include "CellImpl.h"
#include "Formulas.h"
#include "ScriptMgr.h"
#include "SpellHistory.h"
@@ -4358,9 +4359,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)