Exemplo n.º 1
0
        public static void BuySpell(this NPC trainer, Character chr, SpellId spellEntryId)
        {
            if (!trainer.CheckTrainerCanTrain(chr))
            {
                return;
            }
            TrainerSpellEntry spellEntry = trainer.TrainerEntry.GetSpellEntry(spellEntryId);

            if (spellEntry == null || !trainer.CheckBuySpellConditions(chr, spellEntry))
            {
                return;
            }
            chr.SubtractMoney(spellEntry.GetDiscountedCost(chr, trainer));
            WCell.RealmServer.Handlers.NPCHandler.SendTrainerBuySucceeded((IPacketReceiver)chr.Client, trainer,
                                                                          spellEntry);
            SpellHandler.SendVisual((WorldObject)trainer, 179U);
            if (spellEntry.Spell.IsTeachSpell)
            {
                trainer.SpellCast.Trigger(spellEntry.Spell, new WorldObject[1]
                {
                    (WorldObject)chr
                });
            }
            else if (chr.PowerType == PowerType.Mana || spellEntry.Spell.PreviousRank == null)
            {
                chr.Spells.AddSpell(spellEntry.Spell);
                trainer.TalkToTrainer(chr);
            }
            else
            {
                chr.Spells.Replace(spellEntry.Spell.PreviousRank, spellEntry.Spell);
            }
        }
Exemplo n.º 2
0
 private static bool CheckBuySpellConditions(this NPC trainer, Character curChar, TrainerSpellEntry trainerSpell)
 {
     if (curChar.CanLearn(trainerSpell))
     {
         return(curChar.Money >= trainerSpell.GetDiscountedCost(curChar, trainer));
     }
     return(false);
 }