mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 01:37:01 +00:00
[11766] fix spell redirection and totem destruction on hit by redirected spell
This commit is contained in:
parent
61f31980cf
commit
c60425c6bd
11 changed files with 73 additions and 26 deletions
|
|
@ -392,6 +392,8 @@ Spell::Spell( Unit* caster, SpellEntry const *info, bool triggered, ObjectGuid o
|
|||
// determine reflection
|
||||
m_canReflect = false;
|
||||
|
||||
m_spellFlags = SPELL_FLAG_NORMAL;
|
||||
|
||||
if(m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC && !(m_spellInfo->AttributesEx2 & SPELL_ATTR_EX2_CANT_REFLECTED))
|
||||
{
|
||||
for(int j = 0; j < MAX_EFFECT_INDEX; ++j)
|
||||
|
|
@ -804,6 +806,9 @@ void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex)
|
|||
// Check for effect immune skip if immuned
|
||||
bool immuned = pVictim->IsImmuneToSpellEffect(m_spellInfo, effIndex);
|
||||
|
||||
if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsTotem() && (m_spellFlags & SPELL_FLAG_REDIRECTED))
|
||||
immuned = false;
|
||||
|
||||
ObjectGuid targetGUID = pVictim->GetObjectGuid();
|
||||
|
||||
// Lookup target in already in list
|
||||
|
|
@ -858,6 +863,8 @@ void Spell::AddUnitTarget(Unit* pVictim, SpellEffectIndex effIndex)
|
|||
|
||||
// Increase time interval for reflected spells by 1.5
|
||||
target.timeDelay += target.timeDelay >> 1;
|
||||
|
||||
m_spellFlags |= SPELL_FLAG_REFLECTED;
|
||||
}
|
||||
else
|
||||
target.reflectResult = SPELL_MISS_NONE;
|
||||
|
|
@ -1004,7 +1011,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
|
|||
{
|
||||
if (target->reflectResult == SPELL_MISS_NONE) // If reflected spell hit caster -> do all effect on him
|
||||
{
|
||||
DoSpellHitOnUnit(m_caster, mask, true);
|
||||
DoSpellHitOnUnit(m_caster, mask);
|
||||
unitTarget = m_caster;
|
||||
}
|
||||
}
|
||||
|
|
@ -1147,7 +1154,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
|
|||
((Creature*)m_caster)->AI()->SpellHitTarget(unit, m_spellInfo);
|
||||
}
|
||||
|
||||
void Spell::DoSpellHitOnUnit(Unit *unit, uint32 effectMask, bool isReflected)
|
||||
void Spell::DoSpellHitOnUnit(Unit *unit, uint32 effectMask)
|
||||
{
|
||||
if (!unit || !effectMask)
|
||||
return;
|
||||
|
|
@ -1298,7 +1305,7 @@ void Spell::DoSpellHitOnUnit(Unit *unit, uint32 effectMask, bool isReflected)
|
|||
if (duration > 0)
|
||||
{
|
||||
int32 limitduration = GetDiminishingReturnsLimitDuration(m_diminishGroup, m_spellInfo);
|
||||
unit->ApplyDiminishingToDuration(m_diminishGroup, duration, m_caster, m_diminishLevel, limitduration, isReflected);
|
||||
unit->ApplyDiminishingToDuration(m_diminishGroup, duration, m_caster, m_diminishLevel, limitduration, m_spellFlags & SPELL_FLAG_REFLECTED);
|
||||
|
||||
// Fully diminished
|
||||
if (duration == 0)
|
||||
|
|
@ -1819,6 +1826,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
|||
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), this, effIndex))
|
||||
{
|
||||
m_targets.setUnitTarget(pUnitTarget);
|
||||
m_spellFlags |= SPELL_FLAG_REDIRECTED;
|
||||
targetUnitMap.push_back(pUnitTarget);
|
||||
}
|
||||
}
|
||||
|
|
@ -2257,6 +2265,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
|||
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), this, effIndex))
|
||||
{
|
||||
m_targets.setUnitTarget(pUnitTarget);
|
||||
m_spellFlags |= SPELL_FLAG_REDIRECTED;
|
||||
targetUnitMap.push_back(pUnitTarget);
|
||||
}
|
||||
}
|
||||
|
|
@ -2287,6 +2296,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
|||
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), this, effIndex))
|
||||
{
|
||||
m_targets.setUnitTarget(pUnitTarget);
|
||||
m_spellFlags |= SPELL_FLAG_REDIRECTED;
|
||||
targetUnitMap.push_back(pUnitTarget);
|
||||
}
|
||||
break;
|
||||
|
|
@ -2902,13 +2912,18 @@ void Spell::cancel()
|
|||
|
||||
case SPELL_STATE_CASTING:
|
||||
{
|
||||
for(TargetList::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
||||
for(TargetList::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
|
||||
{
|
||||
if (ihit->missCondition == SPELL_MISS_NONE)
|
||||
{
|
||||
Unit* unit = m_caster->GetObjectGuid() == (*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
|
||||
if (unit && unit->isAlive())
|
||||
unit->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetObjectGuid());
|
||||
|
||||
// prevent other effects applying if spell is already interrupted
|
||||
// i.e. if effects have different targets and it was interrupted on one of them when
|
||||
// haven't yet applied to another
|
||||
ihit->processed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue