/// <summary> /// Teaches a new spell to the unit. Also sends the spell learning animation, if applicable. /// </summary> void AddSpell(Spell spell, bool sendPacket) { // make sure the char knows the skill that this spell belongs to if (spell.Ability != null) { var skill = OwnerChar.Skills[spell.Ability.Skill.Id]; if (skill == null) { // learn new skill skill = OwnerChar.Skills.Add(spell.Ability.Skill, true); } if (skill.CurrentTierSpell == null || skill.CurrentTierSpell.SkillTier < spell.SkillTier) { // upgrade tier skill.CurrentTierSpell = spell; } } if (!m_byId.ContainsKey(spell.SpellId)) { var owner = OwnerChar; if (m_sendPackets && sendPacket) { SpellHandler.SendLearnedSpell(owner.Client, spell.Id); if (!spell.IsPassive) { SpellHandler.SendVisual(owner, 362); // ouchy: Unnamed constants } } var specIndex = GetSpecIndex(spell); var spells = GetSpellList(spell); var newRecord = new SpellRecord(spell.SpellId, owner.EntityId.Low, specIndex); newRecord.SaveLater(); spells.Add(newRecord); base.AddSpell(spell); } }