Add some function for find/remove aura and use it in some cases

Signed-off-by: DiSlord <[email protected]>

--HG--
branch : trunk
This commit is contained in:
megamage
2009-02-01 16:25:55 -06:00
parent 867b90045b
commit 20b8efd932
4 changed files with 50 additions and 104 deletions
+2 -2
View File
@@ -2064,11 +2064,11 @@ void Spell::cancel(bool report)
{ {
Unit* unit = m_caster->GetGUID()==(*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID); Unit* unit = m_caster->GetGUID()==(*ihit).targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
if( unit && unit->isAlive() ) if( unit && unit->isAlive() )
unit->RemoveAurasDueToCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); unit->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID());
} }
} }
m_caster->RemoveAurasDueToCasterSpell(m_spellInfo->Id, m_caster->GetGUID()); m_caster->RemoveAurasByCasterSpell(m_spellInfo->Id, m_caster->GetGUID());
SendChannelUpdate(0); SendChannelUpdate(0);
SendInterrupted(0); SendInterrupted(0);
SendCastResult(report ? SPELL_FAILED_INTERRUPTED : SPELL_FAILED_DONT_REPORT); SendCastResult(report ? SPELL_FAILED_INTERRUPTED : SPELL_FAILED_DONT_REPORT);
+2 -2
View File
@@ -438,7 +438,7 @@ void Spell::SpellDamageSchoolDmg(uint32 effect_idx)
if( (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && ((*i)->GetSpellProto()->SpellFamilyFlags & 4) && if( (*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_WARLOCK && ((*i)->GetSpellProto()->SpellFamilyFlags & 4) &&
(*i)->GetCasterGUID()==m_caster->GetGUID() ) (*i)->GetCasterGUID()==m_caster->GetGUID() )
{ {
unitTarget->RemoveAurasDueToCasterSpell((*i)->GetId(), m_caster->GetGUID()); unitTarget->RemoveAurasByCasterSpell((*i)->GetId(), m_caster->GetGUID());
break; break;
} }
} }
@@ -2505,7 +2505,7 @@ void Spell::SpellDamageHeal(uint32 /*i*/)
int32 tickcount = GetSpellDuration(targetAura->GetSpellProto()) / targetAura->GetSpellProto()->EffectAmplitude[idx]; int32 tickcount = GetSpellDuration(targetAura->GetSpellProto()) / targetAura->GetSpellProto()->EffectAmplitude[idx];
addhealth += tickheal * tickcount; addhealth += tickheal * tickcount;
unitTarget->RemoveAurasDueToCasterSpell(targetAura->GetId(), targetAura->GetCasterGUID()); unitTarget->RemoveAurasByCasterSpell(targetAura->GetId(), targetAura->GetCasterGUID());
//addhealth += tickheal * tickcount; //addhealth += tickheal * tickcount;
//addhealth = caster->SpellHealingBonus(m_spellInfo, addhealth,HEAL, unitTarget); //addhealth = caster->SpellHealingBonus(m_spellInfo, addhealth,HEAL, unitTarget);
+35 -91
View File
@@ -3753,6 +3753,18 @@ void Unit::RemoveAura(uint32 spellId, uint32 effindex, Aura* except)
} }
} }
void Unit::RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID)
{
for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); )
{
Aura *aur = iter->second;
if (aur->GetId() == spellId && aur->GetCasterGUID() == casterGUID)
RemoveAura(iter);
else
++iter;
}
}
void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler) void Unit::RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler)
{ {
for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ) for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); )
@@ -3869,25 +3881,6 @@ void Unit::RemoveAurasDueToSpell(uint32 spellId, Aura* except)
RemoveAura(spellId,i,except); RemoveAura(spellId,i,except);
} }
void Unit::RemoveAurasDueToCasterSpell(uint32 spellId, uint64 guid)
{
for (int k=0; k < 3; ++k)
{
spellEffectPair spair = spellEffectPair(spellId, k);
for (AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);)
{
if (iter->second->GetCasterGUID() == guid)
{
RemoveAura(iter);
break;
//iter = m_Auras.upper_bound(spair); // overwrite by more appropriate
}
else
++iter;
}
}
}
void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId) void Unit::RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId)
{ {
for (int k=0; k < 3; ++k) for (int k=0; k < 3; ++k)
@@ -4127,6 +4120,22 @@ Aura* Unit::GetAura(uint32 spellId, uint32 effindex)
return NULL; return NULL;
} }
Aura* Unit::GetAura(AuraType type, uint32 family, uint64 familyFlag, uint32 familyFlag2, uint64 casterGUID)
{
AuraList const& auras = GetAurasByType(type);
for(AuraList::const_iterator i = auras.begin();i != auras.end(); ++i)
{
SpellEntry const *spell = (*i)->GetSpellProto();
if (spell->SpellFamilyName == family && (spell->SpellFamilyFlags & familyFlag || spell->SpellFamilyFlags2 & familyFlag2))
{
if (casterGUID && (*i)->GetCasterGUID()!=casterGUID)
continue;
return (*i);
}
}
return NULL;
}
bool Unit::HasAura(uint32 spellId) const bool Unit::HasAura(uint32 spellId) const
{ {
for (int i = 0; i < 3 ; ++i) for (int i = 0; i < 3 ; ++i)
@@ -7661,19 +7670,10 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
break; break;
case 5481: // Starfire Bonus case 5481: // Starfire Bonus
{ {
AuraList const& auras = pVictim->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, 0x0000000000200002LL))
for(AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
SpellEntry const* m_spell = (*itr)->GetSpellProto();
if (m_spell->SpellFamilyName == SPELLFAMILY_DRUID &&
m_spell->SpellFamilyFlags & 0x0000000000200002LL)
{
DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f;
break; break;
} }
}
break;
}
case 4418: // Increased Shock Damage case 4418: // Increased Shock Damage
case 4554: // Increased Lightning Damage case 4554: // Increased Lightning Damage
case 4555: // Improved Moonfire case 4555: // Improved Moonfire
@@ -7697,52 +7697,25 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
} }
else // Tundra Stalker else // Tundra Stalker
{ {
AuraList const& auras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); if (pVictim->GetAura(SPELL_AURA_DUMMY, SPELLFAMILY_DEATHKNIGHT, 0x0400000000000000LL))
for(AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
SpellEntry const* m_spell = (*itr)->GetSpellProto();
if (m_spell->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT &&
m_spell->SpellFamilyFlags & 0x0400000000000000LL)
{
DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f;
break; break;
} }
}
}
break; break;
} }
case 7293: // Rage of Rivendare case 7293: // Rage of Rivendare
{ {
AuraList const& auras = pVictim->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DEATHKNIGHT, 0x0200000000000000LL))
for(AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
SpellEntry const* m_spell = (*itr)->GetSpellProto();
if (m_spell->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT &&
m_spell->SpellFamilyFlags & 0x0200000000000000LL)
{
DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f;
break; break;
} }
}
break;
}
// Twisted Faith // Twisted Faith
case 7377: case 7377:
{ {
AuraList const& auras = pVictim->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE); if (pVictim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x0000000000008000LL, 0, GetGUID()))
for(AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
SpellEntry const* m_spell = (*itr)->GetSpellProto();
if (m_spell->SpellFamilyName == SPELLFAMILY_PRIEST &&
m_spell->SpellFamilyFlags & 0x0000000000008000LL &&
(*itr)->GetCasterGUID()==GetGUID())
{
DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f;
break; break;
} }
}
break;
}
// Marked for Death // Marked for Death
case 7598: case 7598:
case 7599: case 7599:
@@ -7750,20 +7723,11 @@ uint32 Unit::SpellDamageBonus(Unit *pVictim, SpellEntry const *spellProto, uint3
case 7601: case 7601:
case 7602: case 7602:
{ {
AuraList const& auras = pVictim->GetAurasByType(SPELL_AURA_MOD_STALKED); if (pVictim->GetAura(SPELL_AURA_MOD_STALKED, SPELLFAMILY_HUNTER, 0x0000000000000400LL))
for(AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
SpellEntry const* m_spell = (*itr)->GetSpellProto();
if (m_spell->SpellFamilyName == SPELLFAMILY_HUNTER &&
m_spell->SpellFamilyFlags & 0x0000000000000400LL)
{
DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f;
break; break;
} }
} }
break;
}
}
} }
/*switch(spellProto->SpellFamilyName) /*switch(spellProto->SpellFamilyName)
@@ -8380,19 +8344,10 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
break; break;
case 7798: // Glyph of Regrowth case 7798: // Glyph of Regrowth
{ {
AuraList const& auras = pVictim->GetAurasByType(SPELL_AURA_PERIODIC_HEAL); if (pVictim->GetAura(SPELL_AURA_PERIODIC_HEAL, SPELLFAMILY_DRUID, 0x0000000000000040LL))
for(AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
SpellEntry const* m_spell = (*itr)->GetSpellProto();
if (m_spell->SpellFamilyName == SPELLFAMILY_DRUID &&
m_spell->SpellFamilyFlags & 0x0000000000000040LL)
{
DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f;
break; break;
} }
}
break;
}
case 8477: // Nourish Heal Boost case 8477: // Nourish Heal Boost
{ {
int32 stepPercent = (*i)->GetModifier()->m_amount; int32 stepPercent = (*i)->GetModifier()->m_amount;
@@ -8413,21 +8368,10 @@ uint32 Unit::SpellHealingBonus(Unit *pVictim, SpellEntry const *spellProto, uint
} }
case 7871: // Glyph of Lesser Healing Wave case 7871: // Glyph of Lesser Healing Wave
{ {
AuraList const& auras = pVictim->GetAurasByType(SPELL_AURA_DUMMY); if (pVictim->GetAura(SPELL_AURA_DUMMY, SPELLFAMILY_SHAMAN, 0x0000040000000000LL, 0, GetGUID()))
for(AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
{
if ((*itr)->GetCasterGUID()!=GetGUID())
continue;
SpellEntry const* m_spell = (*itr)->GetSpellProto();
if (m_spell->SpellFamilyName == SPELLFAMILY_SHAMAN &&
m_spell->SpellFamilyFlags & 0x0000040000000000LL)
{
DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f; DoneTotalMod *= ((*i)->GetModifier()->m_amount+100.0f)/100.0f;
break; break;
} }
}
break;
}
default: default:
break; break;
} }
+3 -1
View File
@@ -1178,7 +1178,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex); void RemoveSingleAuraFromStack(uint32 spellId, uint32 effindex);
void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL); void RemoveAurasDueToSpell(uint32 spellId, Aura* except = NULL);
void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId); void RemoveAurasDueToItemSpell(Item* castItem,uint32 spellId);
void RemoveAurasDueToCasterSpell(uint32 spellId, uint64 guid); void RemoveAurasByCasterSpell(uint32 spellId, uint64 casterGUID);
void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler); void RemoveAurasDueToSpellByDispel(uint32 spellId, uint64 casterGUID, Unit *dispeler);
void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer); void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit *stealer);
void RemoveAurasDueToSpellByCancel(uint32 spellId); void RemoveAurasDueToSpellByCancel(uint32 spellId);
@@ -1335,6 +1335,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
uint8 GetVisibleAurasCount() { return m_visibleAuras.size(); } uint8 GetVisibleAurasCount() { return m_visibleAuras.size(); }
Aura* GetAura(uint32 spellId, uint32 effindex); Aura* GetAura(uint32 spellId, uint32 effindex);
Aura* GetAura(AuraType type, uint32 family, uint64 familyFlag, uint32 familyFlag2 = 0, uint64 casterGUID = 0);
AuraMap & GetAuras() { return m_Auras; } AuraMap & GetAuras() { return m_Auras; }
AuraMap const& GetAuras() const { return m_Auras; } AuraMap const& GetAuras() const { return m_Auras; }
AuraList const& GetAurasByType(AuraType type) const { return m_modAuras[type]; } AuraList const& GetAurasByType(AuraType type) const { return m_modAuras[type]; }