diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 96a255881206c..03cdc913fd8ac 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -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(); diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 20a7ca05d93b8..1498dbf35ec32 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -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(); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 7f00fc7f9d86c..1a8f8a8aceb40 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -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()); + } } } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 219ee8b10029c..44ecfccdcad48 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -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 diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 088a0bbdf73dd..449d5889889fc 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1722,6 +1722,7 @@ class Unit : public WorldObject void RemoveAreaAurasDueToLeaveWorld(); void RemoveAllAuras(); void RemoveArenaAuras(); + void RemoveAurasOnEvade(); void RemoveAllAurasOnDeath(); void RemoveAllAurasRequiringDeadTarget(); void RemoveAllAurasExceptType(AuraType type); diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 5479dcdbf0079..5aeb5b6092bef 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -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 } diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 6abcd5784119c..8b584074c0025 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -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); @@ -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;