Core/Items: Refactored learning spells from items to check for ITEM_SPELLTRIGGER_LEARN_SPELL_ID instead of hardcoded spell ids

Port From (https://github.com/TrinityCore/TrinityCore/commit/6b69338990a651c54dd9d2b5ad3281a4d702efb7)
This commit is contained in:
hondacrx
2021-10-16 18:18:28 -04:00
parent e9c6424cd8
commit d2c62555c1
4 changed files with 25 additions and 48 deletions
+10 -9
View File
@@ -1059,16 +1059,17 @@ namespace Game
if (!item)
return;
if (item.GetBonus().EffectCount < 2)
return;
uint spellToLearn = (uint)item.GetEffect(1).SpellID;
var entry = Global.SpellMgr.GetBattlePetSpecies(spellToLearn);
if (entry != null)
foreach (var itemEffect in item.GetEffects())
{
GetBattlePetMgr().AddPet(entry.Id, BattlePetMgr.SelectPetDisplay(entry), BattlePetMgr.RollPetBreed(entry.Id), BattlePetMgr.GetDefaultPetQuality(entry.Id));
_player.UpdateCriteria(CriteriaType.UniquePetsOwned);
if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId)
continue;
var entry = Global.SpellMgr.GetBattlePetSpecies((uint)itemEffect.SpellID);
if (entry != null)
{
GetBattlePetMgr().AddPet(entry.Id, BattlePetMgr.SelectPetDisplay(entry), BattlePetMgr.RollPetBreed(entry.Id), BattlePetMgr.GetDefaultPetQuality(entry.Id));
_player.UpdateCriteria(CriteriaType.UniquePetsOwned);
}
}
GetPlayer().DestroyItem(item.GetBagSlot(), item.GetSlot(), true);