Core/Items: Replace hardcoded spell id 483 and 55884 checks with item_template.spelltrigger ITEM_SPELLTRIGGER_LEARN_SPELL_ID

(cherry picked from commit 3f1085245cece16c5a3110f56bcfb39f94e12f6c)
This commit is contained in:
Shauren
2026-06-28 20:54:47 +02:00
parent 6f40090a7b
commit 22dde9ee14
2 changed files with 23 additions and 11 deletions
@@ -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;
}
}
+12 -4
View File
@@ -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())