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
+15 -3
View File
@@ -1816,10 +1816,22 @@ namespace Game.Spells
Player player = unitTarget.ToPlayer();
uint spellToLearn = (m_spellInfo.Id == 483 || m_spellInfo.Id == 55884) ? (uint)damage : effectInfo.TriggerSpell;
player.LearnSpell(spellToLearn, false);
if (m_CastItem != null && effectInfo.TriggerSpell == 0)
{
foreach (var itemEffect in m_CastItem.GetEffects())
{
if (itemEffect.TriggerType != ItemSpelltriggerType.LearnSpellId)
continue;
Log.outDebug(LogFilter.Spells, "Spell: Player {0} has learned spell {1} from NpcGUID={2}", player.GetGUID().ToString(), spellToLearn, m_caster.GetGUID().ToString());
player.LearnSpell((uint)itemEffect.SpellID, false);
}
}
if (effectInfo.TriggerSpell != 0)
{
player.LearnSpell(effectInfo.TriggerSpell, false);
Log.outDebug(LogFilter.Spells, $"Spell: {player.GetGUID()} has learned spell {effectInfo.TriggerSpell} from {m_caster.GetGUID()}");
}
}
[SpellEffectHandler(SpellEffectName.Dispel)]