diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index fe281d6d4..a7206cc9e 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1788,11 +1788,47 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList& case TARGET_AREAEFFECT_INSTANT: { SpellTargets targetB = SPELL_TARGETS_AOE_DAMAGE; + // Select friendly targets for positive effect if (IsPositiveEffect(m_spellInfo->Id, effIndex)) targetB = SPELL_TARGETS_FRIENDLY; - FillAreaTargets(targetUnitMap, m_caster->GetPositionX(), m_caster->GetPositionY(), radius, PUSH_DEST_CENTER, targetB); + UnitList tempTargetUnitMap; + SpellScriptTargetBounds bounds = sSpellMgr.GetSpellScriptTargetBounds(m_spellInfo->Id); + + // fill real target list if no spell script target defined + FillAreaTargets(bounds.first != bounds.second ? tempTargetUnitMap : targetUnitMap, + m_caster->GetPositionX(), m_caster->GetPositionY(), radius, PUSH_DEST_CENTER, bounds.first != bounds.second ? SPELL_TARGETS_ALL : targetB); + + if (!tempTargetUnitMap.empty()) + { + for (UnitList::const_iterator iter = tempTargetUnitMap.begin(); iter != tempTargetUnitMap.end(); ++iter) + { + if ((*iter)->GetTypeId() != TYPEID_UNIT) + continue; + + for(SpellScriptTarget::const_iterator i_spellST = bounds.first; i_spellST != bounds.second; ++i_spellST) + { + // only creature entries supported for this target type + if (i_spellST->second.type == SPELL_TARGET_TYPE_GAMEOBJECT) + continue; + + if ((*iter)->GetEntry() == i_spellST->second.targetEntry) + { + if (i_spellST->second.type == SPELL_TARGET_TYPE_DEAD && ((Creature*)(*iter))->IsCorpse()) + { + targetUnitMap.push_back((*iter)); + } + else if (i_spellST->second.type == SPELL_TARGET_TYPE_CREATURE && (*iter)->isAlive()) + { + targetUnitMap.push_back((*iter)); + } + + break; + } + } + } + } // exclude caster targetUnitMap.remove(m_caster); @@ -6348,6 +6384,8 @@ bool Spell::CheckTarget( Unit* target, SpellEffectIndex eff ) target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) && m_spellInfo->EffectImplicitTargetA[eff] != TARGET_SCRIPT && m_spellInfo->EffectImplicitTargetB[eff] != TARGET_SCRIPT && + m_spellInfo->EffectImplicitTargetA[eff] != TARGET_AREAEFFECT_INSTANT && + m_spellInfo->EffectImplicitTargetB[eff] != TARGET_AREAEFFECT_INSTANT && m_spellInfo->EffectImplicitTargetA[eff] != TARGET_AREAEFFECT_CUSTOM && m_spellInfo->EffectImplicitTargetB[eff] != TARGET_AREAEFFECT_CUSTOM ) return false; diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 0d41c7287..05486d2d4 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -2960,6 +2960,8 @@ void SpellMgr::LoadSpellScriptTarget() spellProto->EffectImplicitTargetB[i] == TARGET_SCRIPT_COORDINATES || spellProto->EffectImplicitTargetA[i] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT || spellProto->EffectImplicitTargetB[i] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT || + spellProto->EffectImplicitTargetA[i] == TARGET_AREAEFFECT_INSTANT || + spellProto->EffectImplicitTargetB[i] == TARGET_AREAEFFECT_INSTANT || spellProto->EffectImplicitTargetA[i] == TARGET_AREAEFFECT_CUSTOM || spellProto->EffectImplicitTargetB[i] == TARGET_AREAEFFECT_CUSTOM) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index f0467610b..8448412b1 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10841" + #define REVISION_NR "10842" #endif // __REVISION_NR_H__