Core/Spells: Fix area target search for spells with SPELL_ATTR2_ALLOW_DEAD_TARGET
This commit is contained in:
@@ -11986,9 +11986,15 @@ bool Unit::canAttack(Unit const* target, bool force) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Unit::isAttackableByAOE(bool requireDeadTarget) const
|
bool Unit::isAttackableByAOE(SpellEntry const * spellProto) const
|
||||||
{
|
{
|
||||||
if (isAlive() == requireDeadTarget)
|
bool targetMustBeDead = spellProto ? bool(spellProto->AttributesEx3 & SPELL_ATTR3_REQUIRE_DEAD_TARGET) : false;
|
||||||
|
bool targetCanBeDead = spellProto ? bool(spellProto->AttributesEx2 & SPELL_ATTR2_ALLOW_DEAD_TARGET) : false;
|
||||||
|
|
||||||
|
if (targetMustBeDead && isAlive())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!targetMustBeDead && !targetCanBeDead && !isAlive())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (HasFlag(UNIT_FIELD_FLAGS,
|
if (HasFlag(UNIT_FIELD_FLAGS,
|
||||||
|
|||||||
@@ -1473,7 +1473,7 @@ class Unit : public WorldObject
|
|||||||
bool isFrozen() const;
|
bool isFrozen() const;
|
||||||
|
|
||||||
bool isTargetableForAttack() const;
|
bool isTargetableForAttack() const;
|
||||||
bool isAttackableByAOE(bool requireDeadTarget = false) const;
|
bool isAttackableByAOE(SpellEntry const * spellProto = NULL) const;
|
||||||
bool canAttack(Unit const* target, bool force = true) const;
|
bool canAttack(Unit const* target, bool force = true) const;
|
||||||
virtual bool IsInWater() const;
|
virtual bool IsInWater() const;
|
||||||
virtual bool IsUnderWater() const;
|
virtual bool IsUnderWater() const;
|
||||||
|
|||||||
@@ -1846,8 +1846,7 @@ void Spell::SearchAreaTarget(std::list<Unit*> &TagUnitMap, float radius, SpellNo
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool requireDeadTarget = bool(m_spellInfo->AttributesEx3 & SPELL_ATTR3_REQUIRE_DEAD_TARGET);
|
Trinity::SpellNotifierCreatureAndPlayer notifier(m_caster, TagUnitMap, radius, type, TargetType, pos, entry, m_spellInfo);
|
||||||
Trinity::SpellNotifierCreatureAndPlayer notifier(m_caster, TagUnitMap, radius, type, TargetType, pos, entry, requireDeadTarget);
|
|
||||||
if ((m_spellInfo->AttributesEx3 & SPELL_ATTR3_PLAYERS_ONLY)
|
if ((m_spellInfo->AttributesEx3 & SPELL_ATTR3_PLAYERS_ONLY)
|
||||||
|| (TargetType == SPELL_TARGETS_ENTRY && !entry))
|
|| (TargetType == SPELL_TARGETS_ENTRY && !entry))
|
||||||
m_caster->GetMap()->VisitWorld(pos->m_positionX, pos->m_positionY, radius, notifier);
|
m_caster->GetMap()->VisitWorld(pos->m_positionX, pos->m_positionY, radius, notifier);
|
||||||
|
|||||||
@@ -747,17 +747,20 @@ namespace Trinity
|
|||||||
uint32 i_entry;
|
uint32 i_entry;
|
||||||
const Position * const i_pos;
|
const Position * const i_pos;
|
||||||
bool i_requireDeadTarget;
|
bool i_requireDeadTarget;
|
||||||
|
SpellEntry const * i_spellProto;
|
||||||
|
|
||||||
SpellNotifierCreatureAndPlayer(Unit *source, std::list<Unit*> &data, float radius, SpellNotifyPushType type,
|
SpellNotifierCreatureAndPlayer(Unit *source, std::list<Unit*> &data, float radius, SpellNotifyPushType type,
|
||||||
SpellTargets TargetType = SPELL_TARGETS_ENEMY, const Position *pos = NULL, uint32 entry = 0, bool requireDeadTarget = false)
|
SpellTargets TargetType = SPELL_TARGETS_ENEMY, const Position *pos = NULL, uint32 entry = 0, SpellEntry const * spellProto = NULL)
|
||||||
: i_data(&data), i_push_type(type), i_radius(radius), i_TargetType(TargetType),
|
: i_data(&data), i_push_type(type), i_radius(radius), i_TargetType(TargetType),
|
||||||
i_source(source), i_entry(entry), i_pos(pos), i_requireDeadTarget(requireDeadTarget)
|
i_source(source), i_entry(entry), i_pos(pos), i_spellProto(spellProto)
|
||||||
{
|
{
|
||||||
ASSERT(i_source);
|
ASSERT(i_source);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T> inline void Visit(GridRefManager<T> &m)
|
template<class T> inline void Visit(GridRefManager<T> &m)
|
||||||
{
|
{
|
||||||
|
i_requireDeadTarget = i_spellProto ? bool(i_spellProto->AttributesEx3 & SPELL_ATTR3_REQUIRE_DEAD_TARGET) : false;
|
||||||
|
|
||||||
for (typename GridRefManager<T>::iterator itr = m.begin(); itr != m.end(); ++itr)
|
for (typename GridRefManager<T>::iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||||
{
|
{
|
||||||
Unit *target = (Unit*)itr->getSource();
|
Unit *target = (Unit*)itr->getSource();
|
||||||
@@ -770,7 +773,7 @@ namespace Trinity
|
|||||||
case SPELL_TARGETS_ENEMY:
|
case SPELL_TARGETS_ENEMY:
|
||||||
if (target->isTotem())
|
if (target->isTotem())
|
||||||
continue;
|
continue;
|
||||||
if (!target->isAttackableByAOE(i_requireDeadTarget))
|
if (!target->isAttackableByAOE(i_spellProto))
|
||||||
continue;
|
continue;
|
||||||
if (i_source->IsControlledByPlayer())
|
if (i_source->IsControlledByPlayer())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user