From 22dde9ee14d0d189755bdfd8da1b5e4ae20af33f Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 24 Dec 2025 11:20:46 +0100 Subject: [PATCH] Core/Items: Replace hardcoded spell id 483 and 55884 checks with item_template.spelltrigger ITEM_SPELLTRIGGER_LEARN_SPELL_ID (cherry picked from commit 3f1085245cece16c5a3110f56bcfb39f94e12f6c) --- .../game/AuctionHouse/AuctionHouseMgr.cpp | 18 +++++++++++------- src/server/game/Entities/Player/Player.cpp | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index fe90c0084d..20d4a7beda 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -1234,15 +1234,19 @@ void AuctionHouseObject::BuildListBuckets(WorldPackets::AuctionHouse::AuctionLis else if (bucketData->ItemClass == ITEM_CLASS_CONSUMABLE || bucketData->ItemClass == ITEM_CLASS_RECIPE || bucketData->ItemClass == ITEM_CLASS_MISCELLANEOUS) { ItemTemplate const* itemTemplate = ASSERT_NOTNULL(sObjectMgr->GetItemTemplate(bucket.first.ItemId)); - if (itemTemplate->Effects.size() >= 2 && (itemTemplate->Effects[0]->SpellID == 483 || itemTemplate->Effects[0]->SpellID == 55884)) + bool hasUnlearned = std::ranges::any_of(itemTemplate->Effects, [player, &knownPetSpecies](ItemEffectEntry const* itemEffect) { - if (player->HasSpell(itemTemplate->Effects[1]->SpellID)) - continue; - - if (BattlePetSpeciesEntry const* battlePetSpecies = BattlePets::BattlePetMgr::GetBattlePetSpeciesBySpell(itemTemplate->Effects[1]->SpellID)) + if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_ON_LEARN) + return false; + if (player->HasSpell(itemEffect->SpellID)) + return false; + if (BattlePetSpeciesEntry const* battlePetSpecies = BattlePets::BattlePetMgr::GetBattlePetSpeciesBySpell(itemEffect->SpellID)) if (knownPetSpecies.test(battlePetSpecies->ID)) - continue; - } + return false; + return true; + }); + if (!hasUnlearned) + continue; } } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index ff050b13e3..87770091a4 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -11230,10 +11230,18 @@ InventoryResult Player::CanUseItem(ItemTemplate const* proto, bool skipRequiredL return EQUIP_ERR_CANT_EQUIP_REPUTATION; // learning (recipes, mounts, pets, etc.) - if (proto->Effects.size() >= 2) - if (proto->Effects[0]->SpellID == 483 || proto->Effects[0]->SpellID == 55884) - if (HasSpell(proto->Effects[1]->SpellID)) - return EQUIP_ERR_INTERNAL_BAG_ERROR; + uint32 learnableCount = 0; + uint32 learnedCount = 0; + for (ItemEffectEntry const* itemEffect : proto->Effects) + { + if (itemEffect->TriggerType != ITEM_SPELLTRIGGER_ON_LEARN) + continue; + + ++learnableCount; + learnedCount += HasSpell(itemEffect->SpellID) ? 1 : 0; + } + if (learnableCount && learnedCount == learnableCount) + return EQUIP_ERR_NONE; if (ArtifactEntry const* artifact = sArtifactStore.LookupEntry(proto->GetArtifactID())) if (ChrSpecialization(artifact->ChrSpecializationID) != GetPrimarySpecialization())