[10841] Implement charges counting for magnet target auras.

Also implement skip spell effects redirecting if magnet target can't be
targeted by this spell effect base at spell effect target data requirements.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
michalpolko 2010-12-08 10:33:24 +03:00 committed by VladimirMangos
parent 1b4210e38c
commit 08b32d7d32
4 changed files with 34 additions and 12 deletions

View file

@ -1722,7 +1722,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
{
if (EffectChainTarget <= 1)
{
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), m_spellInfo))
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), this, effIndex))
{
m_targets.setUnitTarget(pUnitTarget);
targetUnitMap.push_back(pUnitTarget);
@ -2077,7 +2077,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
}
else
{
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), m_spellInfo))
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), this, effIndex))
{
m_targets.setUnitTarget(pUnitTarget);
targetUnitMap.push_back(pUnitTarget);
@ -2107,7 +2107,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
break;
case TARGET_SINGLE_ENEMY:
{
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), m_spellInfo))
if(Unit* pUnitTarget = m_caster->SelectMagnetTarget(m_targets.getUnitTarget(), this, effIndex))
{
m_targets.setUnitTarget(pUnitTarget);
targetUnitMap.push_back(pUnitTarget);

View file

@ -6063,29 +6063,51 @@ int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellPro
return gain;
}
Unit* Unit::SelectMagnetTarget(Unit *victim, SpellEntry const *spellInfo)
Unit* Unit::SelectMagnetTarget(Unit *victim, Spell* spell, SpellEffectIndex eff)
{
if(!victim)
return NULL;
// Magic case
if(spellInfo && (spellInfo->DmgClass == SPELL_DAMAGE_CLASS_NONE || spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC))
if (spell && (spell->m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_NONE || spell->m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MAGIC))
{
Unit::AuraList const& magnetAuras = victim->GetAurasByType(SPELL_AURA_SPELL_MAGNET);
for(Unit::AuraList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr)
if(Unit* magnet = (*itr)->GetCaster())
if(magnet->IsWithinLOSInMap(this) && magnet->isAlive())
{
if (Unit* magnet = (*itr)->GetCaster())
{
if (magnet->isAlive() && magnet->IsWithinLOSInMap(this) && spell->CheckTarget(magnet, eff))
{
if (SpellAuraHolder *holder = (*itr)->GetHolder())
if (holder->GetAuraCharges())
if (holder->DropAuraCharge())
victim->RemoveSpellAuraHolder(holder);
return magnet;
}
}
}
}
// Melee && ranged case
else
{
AuraList const& hitTriggerAuras = victim->GetAurasByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER);
for(AuraList::const_iterator i = hitTriggerAuras.begin(); i != hitTriggerAuras.end(); ++i)
if(Unit* magnet = (*i)->GetCaster())
if(magnet->isAlive() && magnet->IsWithinLOSInMap(this))
if(roll_chance_i((*i)->GetModifier()->m_amount))
{
if (Unit* magnet = (*i)->GetCaster())
{
if (magnet->isAlive() && magnet->IsWithinLOSInMap(this) && (!spell || spell->CheckTarget(magnet, eff)))
{
if (roll_chance_i((*i)->GetModifier()->m_amount))
{
if (SpellAuraHolder *holder = (*i)->GetHolder())
if (holder->GetAuraCharges())
if (holder->DropAuraCharge())
victim->RemoveSpellAuraHolder(holder);
return magnet;
}
}
}
}
}
return victim;

View file

@ -1832,7 +1832,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
bool HasAuraState(AuraState flag) const { return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); }
bool HasAuraStateForCaster(AuraState flag, uint64 caster) const;
void UnsummonAllTotems();
Unit* SelectMagnetTarget(Unit *victim, SpellEntry const *spellInfo = NULL);
Unit* SelectMagnetTarget(Unit *victim, Spell* spell = NULL, SpellEffectIndex eff = EFFECT_INDEX_0);
int32 SpellBonusWithCoeffs(SpellEntry const *spellProto, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart, float defCoeffMod = 1.0f);
int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10840"
#define REVISION_NR "10841"
#endif // __REVISION_NR_H__