Skip to content

Commit

Permalink
[8924] Implement reapply permanent area auras for group.
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirMangos committed Dec 6, 2009
1 parent 48bea8f commit a81f47c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
40 changes: 32 additions & 8 deletions src/game/SpellAuras.cpp
Expand Up @@ -1333,26 +1333,42 @@ bool Aura::isAffectedOnSpell(SpellEntry const *spell) const

void Aura::ReapplyAffectedPassiveAuras( Unit* target )
{
std::set<uint32> affectedPassives;
std::set<uint32> affectedSelf;
std::set<uint32> affectedAuraCaster;

for(Unit::AuraMap::const_iterator itr = target->GetAuras().begin(); itr != target->GetAuras().end(); ++itr)
{
// permanent passive
if (itr->second->IsPassive() && itr->second->IsPermanent() &&
// permanent passive or permanent area aura
if (itr->second->IsPermanent() && (itr->second->IsPassive() || itr->second->IsAreaAura()) &&
// non deleted and not same aura (any with same spell id)
!itr->second->IsDeleted() && itr->second->GetId() != GetId() &&
// only applied by self and affected by aura
itr->second->GetCasterGUID() == target->GetGUID() && isAffectedOnSpell(itr->second->GetSpellProto()))
// and affected by aura
isAffectedOnSpell(itr->second->GetSpellProto()))
{
affectedPassives.insert(itr->second->GetId());
// only applied by self or aura caster
if(itr->second->GetCasterGUID() == target->GetGUID())
affectedSelf.insert(itr->second->GetId());
else if(itr->second->GetCasterGUID() == GetCasterGUID())
affectedAuraCaster.insert(itr->second->GetId());
}
}

for(std::set<uint32>::const_iterator set_itr = affectedPassives.begin(); set_itr != affectedPassives.end(); ++set_itr)
for(std::set<uint32>::const_iterator set_itr = affectedSelf.begin(); set_itr != affectedSelf.end(); ++set_itr)
{
target->RemoveAurasDueToSpell(*set_itr);
target->CastSpell(m_target, *set_itr, true);
}

if (!affectedAuraCaster.empty())
{
Unit* caster = GetCaster();
for(std::set<uint32>::const_iterator set_itr = affectedAuraCaster.begin(); set_itr != affectedAuraCaster.end(); ++set_itr)
{
target->RemoveAurasDueToSpell(*set_itr);
if (caster)
caster->CastSpell(m_target, *set_itr, true);
}
}
}

/*********************************************************/
Expand Down Expand Up @@ -1412,14 +1428,22 @@ void Aura::HandleAddModifier(bool apply, bool Real)
// reapply talents to own passive persistent auras
ReapplyAffectedPassiveAuras(m_target);

// re-aplly talents and passives applied to pet (it affected by player spellmods)
// re-apply talents/passives/area auras applied to pet (it affected by player spellmods)
if(Pet* pet = m_target->GetPet())
ReapplyAffectedPassiveAuras(pet);

// re-apply talents/passives/area auras applied to totems (it affected by player spellmods)
for(int i = 0; i < MAX_TOTEM; ++i)
if(m_target->m_TotemSlot[i])
if(Creature* totem = m_target->GetMap()->GetCreature(m_target->m_TotemSlot[i]))
ReapplyAffectedPassiveAuras(totem);

// re-apply talents/passives/area auras applied to group members (it affected by player spellmods)
if (Group* group = ((Player*)m_target)->GetGroup())
for(GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* member = itr->getSource())
if (member != m_target)
ReapplyAffectedPassiveAuras(member);
}
void Aura::HandleAddTargetTrigger(bool apply, bool /*Real*/)
{
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8923"
#define REVISION_NR "8924"
#endif // __REVISION_NR_H__

0 comments on commit a81f47c

Please sign in to comment.