diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-02-21 16:10:22 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-02-21 16:10:22 +0100 |
commit | 1b8ef46808c44e68f213768c6a64ccc0048f3d65 (patch) | |
tree | d77f18d278853301f546bcbab0a9ce3c2b6d2001 /src | |
parent | b811da080c1e2a73a8f7787716b5d51ed6e6b3b6 (diff) |
Core/Auras: Reimplement SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES to properly allow casting listed spells
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 12 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 23 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.h | 1 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 12 |
5 files changed, 16 insertions, 34 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index c58ade28662..bb319c43bc6 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -2556,7 +2556,7 @@ void Player::InitStatsForLevel(bool reapplyMods) AddUnitFlag2(UNIT_FLAG2_REGENERATE_POWER);// must be set // cleanup player flags (will be re-applied if need at aura load), to avoid have ghost flag without ghost aura, for example. - RemovePlayerFlag(PlayerFlags(PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST | PLAYER_ALLOW_ONLY_ABILITY)); + RemovePlayerFlag(PlayerFlags(PLAYER_FLAGS_AFK | PLAYER_FLAGS_DND | PLAYER_FLAGS_GM | PLAYER_FLAGS_GHOST)); RemoveVisFlags(UNIT_VIS_FLAGS_ALL); // one form stealth modified bytes RemovePvpFlag(UnitPVPStateFlags(UNIT_BYTE2_FLAG_FFA_PVP | UNIT_BYTE2_FLAG_SANCTUARY)); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index d3af4dc3893..e7f9c605bfe 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -673,15 +673,11 @@ void Unit::UpdateInterruptMask() m_interruptMask[i] |= spell->m_spellInfo->ChannelInterruptFlags[i]; } -bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint32 familyFlags) const +bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, flag128 familyFlags) const { - if (!HasAuraType(auraType)) - return false; - AuraEffectList const& auras = GetAuraEffectsByType(auraType); - for (AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) - if (SpellInfo const* iterSpellProto = (*itr)->GetSpellInfo()) - if (iterSpellProto->SpellFamilyName == familyName && iterSpellProto->SpellFamilyFlags[0] & familyFlags) - return true; + for (AuraEffect const* aura : GetAuraEffectsByType(auraType)) + if (aura->GetSpellInfo()->SpellFamilyName == familyName && aura->GetSpellInfo()->SpellFamilyFlags & familyFlags) + return true; return false; } diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index c21eb8514e1..18238d9340d 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -331,7 +331,7 @@ NonDefaultConstructible<pAuraEffectHandler> AuraEffectHandler[TOTAL_AURAS]= &AuraEffect::HandleNoImmediateEffect, //260 SPELL_AURA_SCREEN_EFFECT (miscvalue = id in ScreenEffect.dbc) not required any code &AuraEffect::HandlePhase, //261 SPELL_AURA_PHASE &AuraEffect::HandleNoImmediateEffect, //262 SPELL_AURA_ABILITY_IGNORE_AURASTATE implemented in Spell::CheckCast - &AuraEffect::HandleAuraAllowOnlyAbility, //263 SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES + &AuraEffect::HandleNoImmediateEffect, //263 SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES implemented in Spell::CheckCast &AuraEffect::HandleNULL, //264 SPELL_AURA_DISABLE_ATTACKING_EXCEPT_ABILITIES &AuraEffect::HandleUnused, //265 unused (4.3.4) &AuraEffect::HandleNULL, //266 SPELL_AURA_SET_VIGNETTE @@ -2361,27 +2361,6 @@ void AuraEffect::HandleAuraModPacifyAndSilence(AuraApplication const* aurApp, ui HandleAuraModSilence(aurApp, mode, apply); } -void AuraEffect::HandleAuraAllowOnlyAbility(AuraApplication const* aurApp, uint8 mode, bool apply) const -{ - if (!(mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK)) - return; - - Player* target = aurApp->GetTarget()->ToPlayer(); - - if (target) - { - if (apply) - target->AddPlayerFlag(PLAYER_ALLOW_ONLY_ABILITY); - else - { - // do not remove unit flag if there are more than this auraEffect of that kind on unit on unit - if (target->HasAuraType(SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES)) - return; - target->RemovePlayerFlag(PLAYER_ALLOW_ONLY_ABILITY); - } - } -} - void AuraEffect::HandleAuraModNoActions(AuraApplication const* aurApp, uint8 mode, bool apply) const { if (!(mode & AURA_EFFECT_HANDLE_REAL)) diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index 0f218e9e14f..8ecdbebc088 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -166,7 +166,6 @@ class TC_GAME_API AuraEffect void HandleAuraModSilence(AuraApplication const* aurApp, uint8 mode, bool apply) const; void HandleAuraModPacify(AuraApplication const* aurApp, uint8 mode, bool apply) const; void HandleAuraModPacifyAndSilence(AuraApplication const* aurApp, uint8 mode, bool apply) const; - void HandleAuraAllowOnlyAbility(AuraApplication const* aurApp, uint8 mode, bool apply) const; void HandleAuraModNoActions(AuraApplication const* aurApp, uint8 mode, bool apply) const; // tracking void HandleAuraTrackResources(AuraApplication const* aurApp, uint8 mode, bool apply) const; diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index a070167b440..67ac36e5f90 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4892,8 +4892,16 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint if (m_caster->GetTypeId() == TYPEID_PLAYER) { //can cast triggered (by aura only?) spells while have this flag - if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURASTATE) && m_caster->ToPlayer()->HasPlayerFlag(PLAYER_ALLOW_ONLY_ABILITY)) - return SPELL_FAILED_SPELL_IN_PROGRESS; + if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURASTATE)) + { + // These two auras check SpellFamilyName defined by db2 class data instead of current spell SpellFamilyName + if (m_caster->HasAuraType(SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES) + && !m_spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) + && !m_spellInfo->HasEffect(SPELL_EFFECT_ATTACK) + && !m_spellInfo->HasAttribute(SPELL_ATTR12_IGNORE_CASTING_DISABLED) + && !m_caster->HasAuraTypeWithFamilyFlags(SPELL_AURA_DISABLE_CASTING_EXCEPT_ABILITIES, sChrClassesStore.AssertEntry(m_caster->getClass())->SpellClassSet, m_spellInfo->SpellFamilyFlags)); + return SPELL_FAILED_CANT_DO_THAT_RIGHT_NOW; + } // check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat if (!IsIgnoringCooldowns() && m_caster->ToPlayer()->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent())) |