aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/Spell.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2025-02-05 20:10:19 +0100
committerShauren <shauren.trinity@gmail.com>2025-02-05 20:10:19 +0100
commit61819f2dc76814a85250e3859890bcb79a3be10a (patch)
tree886ad46ab834a79e8bf94559f9a7315683496b1e /src/server/game/Spells/Spell.cpp
parent8b1d6f91ad58fd31d2c5f203d11ff251689c8aed (diff)
Core/Misc: Reduce differences between branches and fix data sent in SMSG_AUCTION_COMMAND_RESULT, SMSG_PARTY_MEMBER_STATS, SMSG_BATTLEFIELD_STATUS and implemented missing SMSG_AUCTION_REMOVED_NOTIFICATION
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r--src/server/game/Spells/Spell.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 446f4ff3a1c..f1a90646117 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -5394,13 +5394,13 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
return SPELL_FAILED_ONLY_BATTLEGROUNDS;
// do not allow spells to be cast in arenas
- // - with greater than 10 min CD without SPELL_ATTR4_USABLE_IN_ARENA flag
- // - with SPELL_ATTR4_NOT_USABLE_IN_ARENA flag
- if (m_spellInfo->HasAttribute(SPELL_ATTR4_NOT_USABLE_IN_ARENA) ||
- (m_spellInfo->GetRecoveryTime() > 10 * MINUTE * IN_MILLISECONDS && !m_spellInfo->HasAttribute(SPELL_ATTR4_USABLE_IN_ARENA)))
- if (MapEntry const* mapEntry = sMapStore.LookupEntry(m_caster->GetMapId()))
- if (mapEntry->IsBattleArena())
- return SPELL_FAILED_NOT_IN_ARENA;
+ if (Player* player = m_caster->ToPlayer())
+ if (player->InArena())
+ {
+ SpellCastResult castResult = CheckArenaCastRules();
+ if (castResult != SPELL_CAST_OK)
+ return castResult;
+ }
// zone check
if (m_caster->GetTypeId() != TYPEID_PLAYER || !m_caster->ToPlayer()->IsGameMaster())
@@ -6395,6 +6395,25 @@ int32 Spell::CalculateDamage(SpellEffectInfo const& spellEffectInfo) const
return m_caster->CalculateSpellDamage(spellEffectInfo, m_spellValue->EffectBasePoints + spellEffectInfo.EffectIndex);
}
+SpellCastResult Spell::CheckArenaCastRules() const
+{
+ // check USABLE attributes
+ // USABLE takes precedence over NOT_USABLE
+ if (m_spellInfo->HasAttribute(SPELL_ATTR4_USABLE_IN_ARENA))
+ return SPELL_CAST_OK;
+
+ // check NOT_USABLE attributes
+ if (m_spellInfo->AttributesEx4 & SPELL_ATTR4_NOT_USABLE_IN_ARENA)
+ return SPELL_FAILED_NOT_IN_ARENA;
+
+ // check cooldowns
+ uint32 spellCooldown = m_spellInfo->GetRecoveryTime();
+ if (spellCooldown > 10 * MINUTE * IN_MILLISECONDS) // not sure if still needed
+ return SPELL_FAILED_NOT_IN_ARENA;
+
+ return SPELL_CAST_OK;
+}
+
SpellCastResult Spell::CheckMovement() const
{
if (IsTriggered())