From a57e27e6d3dde3136f96f6beb17de4cecb38d9ec Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sun, 13 Aug 2023 11:48:20 +0200 Subject: [PATCH] Core/Spells: implement reputation requirements for spells (mostly used in guild spells such as Guild Page) --- src/server/game/Spells/Spell.cpp | 5 +++++ src/server/game/Spells/SpellInfo.cpp | 2 ++ src/server/game/Spells/SpellInfo.h | 2 ++ 3 files changed, 9 insertions(+) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 7444bd2c7c..059509e816 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5916,6 +5916,11 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint return SPELL_FAILED_REQUIRES_SPELL_FOCUS; } + // check reputation + if (m_spellInfo->MinFactionId && m_spellInfo->MinReputation && m_caster->IsPlayer()) + if (m_caster->ToPlayer()->GetReputationRank(m_spellInfo->MinFactionId) < static_cast(m_spellInfo->MinReputation)) + return SPELL_FAILED_REPUTATION; + SpellCastResult castResult = SPELL_CAST_OK; // always (except passive spells) check items (only player related checks) diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index f62a6a4da7..02104bc49b 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -967,6 +967,8 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry, SpellEffectEntry const** effe SpellCastingRequirementsEntry const* _castreq = GetSpellCastingRequirements(); RequiresSpellFocus = _castreq ? _castreq->RequiresSpellFocus : 0; FacingCasterFlags = _castreq ? SpellFacingCasterFlags(_castreq->FacingCasterFlags) : SpellFacingCasterFlags::None; + MinFactionId = _castreq ? _castreq->MinFactionID : 0; + MinReputation = _castreq ? _castreq->MinReputation : 0; AreaGroupId = _castreq ? _castreq->RequiredAreasID : -1; // SpellCategoriesEntry diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 6844f51507..ab334c5176 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -415,6 +415,8 @@ class TC_GAME_API SpellInfo flag96 SpellFamilyFlags; uint32 DmgClass; uint32 PreventionType; + uint32 MinFactionId; + uint32 MinReputation; int32 AreaGroupId; uint32 SchoolMask; uint32 SpellDifficultyId;