diff options
author | Shocker <shocker@freakz.ro> | 2011-04-06 17:00:05 +0300 |
---|---|---|
committer | Shocker <shocker@freakz.ro> | 2011-04-06 17:00:05 +0300 |
commit | ba80f2fbdc90df6af6d98828795e442b15fad799 (patch) | |
tree | 236f0a6ab4d33fd88ae28dc25f2eda62250f636e | |
parent | 364bb162c33275d3446d63eb39210c1513f0216f (diff) |
Core/Spells: Fix area target search for spells with SPELL_ATTR2_ALLOW_DEAD_TARGET
-rwxr-xr-x | src/server/game/Entities/Unit/Unit.cpp | 10 | ||||
-rwxr-xr-x | src/server/game/Entities/Unit/Unit.h | 2 | ||||
-rwxr-xr-x | src/server/game/Spells/Spell.cpp | 3 | ||||
-rwxr-xr-x | src/server/game/Spells/Spell.h | 9 |
4 files changed, 16 insertions, 8 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index d908242ce35..0e7ffcecd0b 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -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, diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 5cb2ddb4db0..d4af9924c85 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -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; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index a091f9cbfdf..b9e81d01bdc 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -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); diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 55b8d38820a..e6351e4626a 100755 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -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()) { |