From 4ff88148c82621bd1b678ca4a062e9dc0eea0b4b Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Wed, 11 Oct 2023 02:09:44 +0200 Subject: [PATCH] Core/Spells: only provide base difficulty spell Ids to criteria events to match their requirements (see It's Not Easy Being Green' for reference) --- src/server/game/Spells/Spell.cpp | 7 ++++--- src/server/game/Spells/SpellMgr.cpp | 13 +++++++++---- src/server/game/Spells/SpellMgr.h | 1 + 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 02d31c3434..86aea2bcdd 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2930,9 +2930,10 @@ SpellMissInfo Spell::PreprocessSpellHit(Unit* unit, bool scaleAura, TargetInfo& if (Player* player = unit->ToPlayer()) { - player->FailAchievementCriteria(AchievementCriteriaFailEvent::BeSpellTarget, m_spellInfo->Id); - player->StartAchievementCriteria(AchievementCriteriaStartEvent::BeSpellTarget, m_spellInfo->Id); - player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, m_spellInfo->Id, 0, 0, m_caster); + uint32 baseSpellId = sSpellMgr->GetSpellIdForDifficulty(m_spellInfo->Id, REGULAR_DIFFICULTY); + player->FailAchievementCriteria(AchievementCriteriaFailEvent::BeSpellTarget, baseSpellId); + player->StartAchievementCriteria(AchievementCriteriaStartEvent::BeSpellTarget, baseSpellId); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BE_SPELL_TARGET, baseSpellId, 0, 0, m_caster); } if (Player* player = m_caster->ToPlayer()) diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 840d293aa6..4aa6450ba5 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -176,13 +176,18 @@ void SpellMgr::SetSpellDifficultyId(uint32 spellId, uint32 id) uint32 SpellMgr::GetSpellIdForDifficulty(uint32 spellId, WorldObject const* caster) const { - if (!GetSpellInfo(spellId)) - return spellId; - if (!caster || !caster->GetMap() || !caster->GetMap()->IsDungeon()) return spellId; - uint32 mode = uint32(caster->GetMap()->GetSpawnMode()); + return GetSpellIdForDifficulty(spellId, Difficulty(caster->GetMap()->GetSpawnMode())); +} + +uint32 SpellMgr::GetSpellIdForDifficulty(uint32 spellId, Difficulty difficulty) const +{ + if (!GetSpellInfo(spellId)) + return spellId; + + uint32 mode = difficulty; if (mode >= MAX_DIFFICULTY) { TC_LOG_ERROR("spells", "SpellMgr::GetSpellIdForDifficulty: Incorrect difficulty for spell %u.", spellId); diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 2b482db72f..60a3292b72 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -616,6 +616,7 @@ class TC_GAME_API SpellMgr uint32 GetSpellDifficultyId(uint32 spellId) const; void SetSpellDifficultyId(uint32 spellId, uint32 id); uint32 GetSpellIdForDifficulty(uint32 spellId, WorldObject const* caster) const; + uint32 GetSpellIdForDifficulty(uint32 spellId, Difficulty difficulty) const; SpellInfo const* GetSpellForDifficultyFromSpell(SpellInfo const* spell, WorldObject const* caster) const; // Spell Ranks table