mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[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:
parent
1b4210e38c
commit
08b32d7d32
4 changed files with 34 additions and 12 deletions
|
|
@ -1722,7 +1722,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
{
|
{
|
||||||
if (EffectChainTarget <= 1)
|
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);
|
m_targets.setUnitTarget(pUnitTarget);
|
||||||
targetUnitMap.push_back(pUnitTarget);
|
targetUnitMap.push_back(pUnitTarget);
|
||||||
|
|
@ -2077,7 +2077,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
}
|
}
|
||||||
else
|
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);
|
m_targets.setUnitTarget(pUnitTarget);
|
||||||
targetUnitMap.push_back(pUnitTarget);
|
targetUnitMap.push_back(pUnitTarget);
|
||||||
|
|
@ -2107,7 +2107,7 @@ void Spell::SetTargetMap(SpellEffectIndex effIndex, uint32 targetMode, UnitList&
|
||||||
break;
|
break;
|
||||||
case TARGET_SINGLE_ENEMY:
|
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);
|
m_targets.setUnitTarget(pUnitTarget);
|
||||||
targetUnitMap.push_back(pUnitTarget);
|
targetUnitMap.push_back(pUnitTarget);
|
||||||
|
|
|
||||||
|
|
@ -6063,29 +6063,51 @@ int32 Unit::DealHeal(Unit *pVictim, uint32 addhealth, SpellEntry const *spellPro
|
||||||
return gain;
|
return gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit* Unit::SelectMagnetTarget(Unit *victim, SpellEntry const *spellInfo)
|
Unit* Unit::SelectMagnetTarget(Unit *victim, Spell* spell, SpellEffectIndex eff)
|
||||||
{
|
{
|
||||||
if(!victim)
|
if(!victim)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Magic case
|
// 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);
|
Unit::AuraList const& magnetAuras = victim->GetAurasByType(SPELL_AURA_SPELL_MAGNET);
|
||||||
for(Unit::AuraList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr)
|
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;
|
return magnet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Melee && ranged case
|
// Melee && ranged case
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AuraList const& hitTriggerAuras = victim->GetAurasByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER);
|
AuraList const& hitTriggerAuras = victim->GetAurasByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER);
|
||||||
for(AuraList::const_iterator i = hitTriggerAuras.begin(); i != hitTriggerAuras.end(); ++i)
|
for(AuraList::const_iterator i = hitTriggerAuras.begin(); i != hitTriggerAuras.end(); ++i)
|
||||||
if(Unit* magnet = (*i)->GetCaster())
|
{
|
||||||
if(magnet->isAlive() && magnet->IsWithinLOSInMap(this))
|
if (Unit* magnet = (*i)->GetCaster())
|
||||||
if(roll_chance_i((*i)->GetModifier()->m_amount))
|
{
|
||||||
|
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 magnet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return victim;
|
return victim;
|
||||||
|
|
|
||||||
|
|
@ -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 HasAuraState(AuraState flag) const { return HasFlag(UNIT_FIELD_AURASTATE, 1<<(flag-1)); }
|
||||||
bool HasAuraStateForCaster(AuraState flag, uint64 caster) const;
|
bool HasAuraStateForCaster(AuraState flag, uint64 caster) const;
|
||||||
void UnsummonAllTotems();
|
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 SpellBonusWithCoeffs(SpellEntry const *spellProto, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart, float defCoeffMod = 1.0f);
|
||||||
int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask);
|
int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "10840"
|
#define REVISION_NR "10841"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue