Exemple #1
0
        public void TeachSpell(Creature npc, Player player, uint spellId)
        {
            TrainerSpell trainerSpell = GetSpell(spellId);

            if (trainerSpell == null || !CanTeachSpell(player, trainerSpell))
            {
                SendTeachFailure(npc, player, spellId, TrainerFailReason.Unavailable);
                return;
            }

            float reputationDiscount = player.GetReputationPriceDiscount(npc);
            long  moneyCost          = (long)(trainerSpell.MoneyCost * reputationDiscount);

            if (!player.HasEnoughMoney(moneyCost))
            {
                SendTeachFailure(npc, player, spellId, TrainerFailReason.NotEnoughMoney);
                return;
            }

            player.ModifyMoney(-moneyCost);

            npc.SendPlaySpellVisualKit(179, 0, 0);     // 53 SpellCastDirected
            player.SendPlaySpellVisualKit(362, 1, 0);  // 113 EmoteSalute

            // learn explicitly or cast explicitly
            if (trainerSpell.IsCastable())
            {
                player.CastSpell(player, trainerSpell.SpellId, true);
            }
            else
            {
                player.LearnSpell(trainerSpell.SpellId, false);
            }
        }