Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core/Unit: Fix removal of auras on evade issues #14771

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/game/AI/CreatureAI.cpp
Expand Up @@ -231,7 +231,7 @@ bool CreatureAI::_EnterEvadeMode()

// don't remove vehicle auras, passengers aren't supposed to drop off the vehicle
// don't remove clone caster on evade (to be verified)
me->RemoveAllAurasExceptType(SPELL_AURA_CONTROL_VEHICLE, SPELL_AURA_CLONE_CASTER);
me->RemoveAurasOnEvade();

// sometimes bosses stuck in combat?
me->DeleteThreatList();
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/AI/SmartScripts/SmartAI.cpp
Expand Up @@ -413,7 +413,7 @@ void SmartAI::EnterEvadeMode()
if (!me->IsAlive() || me->IsInEvadeMode())
return;

me->RemoveAllAurasExceptType(SPELL_AURA_CONTROL_VEHICLE, SPELL_AURA_CLONE_CASTER);
me->RemoveAurasOnEvade();

me->AddUnitState(UNIT_STATE_EVADE);
me->DeleteThreatList();
Expand Down
7 changes: 5 additions & 2 deletions src/server/game/Entities/Creature/Creature.cpp
Expand Up @@ -2093,8 +2093,11 @@ bool Creature::LoadCreaturesAddon(bool reload)
continue;
}

AddAura(*itr, this);
TC_LOG_DEBUG("entities.unit", "Spell: %u added to creature (GUID: %u Entry: %u)", *itr, GetGUIDLow(), GetEntry());
if (Aura* newAddonAura = AddAura(*itr, this))
{
newAddonAura->SetSpawnAura(true);
TC_LOG_DEBUG("entities.unit", "Spell: %u added to creature (GUID: %u Entry: %u)", *itr, GetGUIDLow(), GetEntry());
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions src/server/game/Entities/Unit/Unit.cpp
Expand Up @@ -4040,6 +4040,27 @@ void Unit::RemoveArenaAuras()
}
}

void Unit::RemoveAurasOnEvade()
{
if (IsPet() || IsGuardian()) // if pet or guardian shouldn't lose any aura
return;

for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
{
AuraApplication const* aurApp = iter->second;
Aura const* aura = aurApp->GetBase();

if (!aura->IsSpawnAura() && // auras which are not set on creature spaw
!aura->IsPassive() && // not passive
!aura->GetSpellInfo()->HasAttribute(SPELL_ATTR3_DEATH_PERSISTENT) && // not death-persistent
!(aura->GetSpellInfo()->HasAura(SPELL_AURA_CONTROL_VEHICLE) || // not control vehicle or clone caster
aura->GetSpellInfo()->HasAura(SPELL_AURA_CLONE_CASTER)))
RemoveAura(iter);
else
++iter;
}
}

void Unit::RemoveAllAurasOnDeath()
{
// used just after dieing to remove all visible auras
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Entities/Unit/Unit.h
Expand Up @@ -1722,6 +1722,7 @@ class Unit : public WorldObject
void RemoveAreaAurasDueToLeaveWorld();
void RemoveAllAuras();
void RemoveArenaAuras();
void RemoveAurasOnEvade();
void RemoveAllAurasOnDeath();
void RemoveAllAurasRequiringDeadTarget();
void RemoveAllAurasExceptType(AuraType type);
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Spells/Auras/SpellAuras.cpp
Expand Up @@ -346,6 +346,7 @@ m_isRemoved(false), m_isSingleTarget(false), m_isUsingCharges(false), m_dropEven
m_duration = m_maxDuration;
m_procCharges = CalcMaxCharges(caster);
m_isUsingCharges = m_procCharges != 0;
m_spawn = false;
memset(m_effects, 0, sizeof(m_effects));
// m_casterLevel = cast item level/caster level, caster level should be saved to db, confirmed with sniffs
}
Expand Down
4 changes: 4 additions & 0 deletions src/server/game/Spells/Auras/SpellAuras.h
Expand Up @@ -134,6 +134,8 @@ class Aura
void RefreshTimers();
bool IsExpired() const { return !GetDuration() && !m_dropEvent; }
bool IsPermanent() const { return GetMaxDuration() == -1; }
bool IsSpawnAura() const { return m_spawn; }
void SetSpawnAura(bool onSpawn){ m_spawn = onSpawn; }

uint8 GetCharges() const { return m_procCharges; }
void SetCharges(uint8 charges);
Expand Down Expand Up @@ -260,6 +262,8 @@ class Aura
uint8 m_procCharges; // Aura charges (0 for infinite)
uint8 m_stackAmount; // Aura stack amount

bool m_spawn; // Aura which was added on creature spawn

AuraEffect* m_effects[3];
ApplicationMap m_applications;

Expand Down