Core/Spells: Fix area target search for spells with SPELL_ATTR2_ALLOW_DEAD_TARGET

This commit is contained in:
Shocker
2011-04-06 17:00:05 +03:00
parent 364bb162c3
commit ba80f2fbdc
4 changed files with 16 additions and 8 deletions
+8 -2
View File
@@ -11986,9 +11986,15 @@ bool Unit::canAttack(Unit const* target, bool force) const
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;
if (HasFlag(UNIT_FIELD_FLAGS,
+1 -1
View File
@@ -1473,7 +1473,7 @@ class Unit : public WorldObject
bool isFrozen() 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;
virtual bool IsInWater() const;
virtual bool IsUnderWater() const;
+1 -2
View File
@@ -1846,8 +1846,7 @@ void Spell::SearchAreaTarget(std::list<Unit*> &TagUnitMap, float radius, SpellNo
break;
}
bool requireDeadTarget = bool(m_spellInfo->AttributesEx3 & SPELL_ATTR3_REQUIRE_DEAD_TARGET);
Trinity::SpellNotifierCreatureAndPlayer notifier(m_caster, TagUnitMap, radius, type, TargetType, pos, entry, requireDeadTarget);
Trinity::SpellNotifierCreatureAndPlayer notifier(m_caster, TagUnitMap, radius, type, TargetType, pos, entry, m_spellInfo);
if ((m_spellInfo->AttributesEx3 & SPELL_ATTR3_PLAYERS_ONLY)
|| (TargetType == SPELL_TARGETS_ENTRY && !entry))
m_caster->GetMap()->VisitWorld(pos->m_positionX, pos->m_positionY, radius, notifier);
+6 -3
View File
@@ -747,17 +747,20 @@ namespace Trinity
uint32 i_entry;
const Position * const i_pos;
bool i_requireDeadTarget;
SpellEntry const * i_spellProto;
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_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);
}
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)
{
Unit *target = (Unit*)itr->getSource();
@@ -770,7 +773,7 @@ namespace Trinity
case SPELL_TARGETS_ENEMY:
if (target->isTotem())
continue;
if (!target->isAttackableByAOE(i_requireDeadTarget))
if (!target->isAttackableByAOE(i_spellProto))
continue;
if (i_source->IsControlledByPlayer())
{