Пример #1
0
        public virtual bool CheckMana(Mobile from, bool consume)
        {
            int mana = CalculateMana(from);

            if (from.Mana < mana)
            {
                from.SendLocalizedMessage(1060181, mana.ToString());                   // You need ~1_MANA_REQUIREMENT~ mana to perform that attack
                return(false);
            }

            if (consume)
            {
                if (GetContext(from) == null)
                {
                    Timer timer = new WeaponAbilityTimer(from);
                    timer.Start();

                    AddContext(from, new WeaponAbilityContext(timer));
                }

                from.Mana -= mana;

                #region Mana Phase
                if (ManaPhase.UnderEffect(from))
                {
                    ManaPhase.OnManaConsumed(from);
                }
                #endregion
            }

            return(true);
        }
Пример #2
0
        public virtual bool CheckSequence()
        {
            int mana = ScaleMana(GetMana());

            if (Caster.Deleted || !Caster.Alive || Caster.Spell != this || State != SpellState.Sequencing)
            {
                DoFizzle();
            }
            else if (Scroll != null && !(Scroll is Runebook) && (Scroll.Amount <= 0 || Scroll.Deleted || Scroll.RootParent != Caster || (Scroll is BaseWand && (((BaseWand)Scroll).Charges <= 0 || Scroll.Parent != Caster))))
            {
                DoFizzle();
            }
            else if (!ConsumeReagents())
            {
                Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502630);                   // More reagents are needed for this spell.
            }
            else if (Caster.Mana < mana)
            {
                Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana for this spell.
            }
            else if (Caster.Frozen || Caster.Paralyzed)
            {
                Caster.SendLocalizedMessage(502646);                   // You cannot cast a spell while frozen.
                DoFizzle();
            }
            else if (CheckFizzle())
            {
                Caster.Mana -= mana;

                #region ManaPhase
                if (ManaPhase.UnderEffect(Caster))
                {
                    ManaPhase.OnManaConsumed(Caster);
                }
                #endregion

                if (Scroll is SpellStone)
                {
                    ((SpellStone)Scroll).Use(Caster);
                }
                if (Scroll is SpellScroll)
                {
                    Scroll.Consume();
                }
                else if (Scroll is BaseWand)
                {
                    ((BaseWand)Scroll).ConsumeCharge(Caster);
                }

                if (Scroll is BaseWand)
                {
                    bool m = Scroll.Movable;

                    Scroll.Movable = false;

                    if (ClearHandsOnCast)
                    {
                        Caster.ClearHands();
                    }

                    Scroll.Movable = m;
                }
                else
                {
                    if (ClearHandsOnCast)
                    {
                        Caster.ClearHands();
                    }
                }

                int karma = ComputeKarmaAward();

                if (karma != 0)
                {
                    Misc.Titles.AwardKarma(Caster, karma, true);
                }

                if (TransformationSpell.UnderTransformation(Caster, typeof(VampiricEmbraceSpell)))
                {
                    bool garlic = false;

                    for (int i = 0; !garlic && i < Info.Reagents.Length; ++i)
                    {
                        garlic = (Info.Reagents[i] == Reagent.Garlic);
                    }

                    if (garlic)
                    {
                        Caster.SendLocalizedMessage(1061651);                           // The garlic burns you!
                        AOS.Damage(Caster, Utility.RandomMinMax(17, 23), 100, 0, 0, 0, 0);
                    }
                }

                return(true);
            }
            else
            {
                DoFizzle();
            }

            return(false);
        }