Skip to content

Commit

Permalink
Use AURA_INTERRUPT_FLAG_UNK2 to remove some aura on cast
Browse files Browse the repository at this point in the history
There is still a discution about how to correctly delete an holder by avoiding to restart constently from the bigining of the holder list. I think this should be adressed in the future and in the entire code.

Thank @killerwife for his suggestion and help.
  • Loading branch information
Cyberium committed May 31, 2016
1 parent 96ed0b6 commit 55adc1b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/game/Spell.cpp
Expand Up @@ -3020,13 +3020,8 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura)
// set timer base at cast time
ReSetTimer();

// stealth must be removed at cast starting (at show channel bar)
// skip triggered spell (item equip spell casting and other not explicit character casts/item uses)
if (!m_IsTriggeredSpell && isSpellBreakStealth(m_spellInfo))
{
m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
m_caster->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
}
if (!m_IsTriggeredSpell)
m_caster->RemoveAurasOnCast(m_spellInfo);

// add non-triggered (with cast time and without)
if (!m_IsTriggeredSpell)
Expand Down
40 changes: 40 additions & 0 deletions src/game/Unit.cpp
Expand Up @@ -4754,6 +4754,46 @@ void Unit::RemoveAurasWithAttribute(uint32 flags)
}
}

void Unit::RemoveAurasOnCast(SpellEntry const* castedSpellEntry)
{
for (SpellAuraHolderMap::iterator iter = m_spellAuraHolders.begin(); iter != m_spellAuraHolders.end();)
{
SpellAuraHolder* holder = iter->second;
SpellEntry const* spellEntry = holder->GetSpellProto();
bool removeThisHolder = false;

if (spellEntry->AuraInterruptFlags & AURA_INTERRUPT_FLAG_UNK2)
{
if (castedSpellEntry->HasAttribute(SPELL_ATTR_EX_NOT_BREAK_STEALTH))
{
bool foundStealth = false;
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{
if (Aura* aura = holder->m_auras[i])
{
if (aura->GetModifier()->m_auraname == SPELL_AURA_MOD_STEALTH)
{
foundStealth = true;
break;
}
}
}
removeThisHolder = !foundStealth;
}
else
removeThisHolder = true;
}

if (removeThisHolder)
{
RemoveSpellAuraHolder(iter->second);
iter = m_spellAuraHolders.begin();
}
else
++iter;
}
}

void Unit::RemoveNotOwnTrackedTargetAuras(uint32 newPhase)
{
// tracked aura targets from other casters are removed if the phase does no more fit
Expand Down
3 changes: 3 additions & 0 deletions src/game/Unit.h
Expand Up @@ -1737,6 +1737,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
void RemoveAllAurasOnDeath();
void RemoveAllAurasOnEvade();

// remove specific aura on cast
void RemoveAurasOnCast(SpellEntry const* castedSpellEntry);

// removing specific aura FROM stack by diff reasons and selections
void RemoveAuraHolderFromStack(uint32 spellId, uint32 stackAmount = 1, ObjectGuid casterGuid = ObjectGuid(), AuraRemoveMode mode = AURA_REMOVE_BY_DEFAULT);
void RemoveAuraHolderDueToSpellByDispel(uint32 spellId, uint32 stackAmount, ObjectGuid casterGuid, Unit* dispeller);
Expand Down

0 comments on commit 55adc1b

Please sign in to comment.