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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user