Beispiel #1
0
        public static SpecialMove GetCurrentMove(Mobile m)
        {
            if (m == null)
            {
                return(null);
            }

            if (!Core.SE)
            {
                ClearCurrentMove(m);
                return(null);
            }

            SpecialMove move = null;

            m_Table.TryGetValue(m, out move);

            if (move != null && move.ValidatesDuringHit && !move.Validate(m))
            {
                ClearCurrentMove(m);
                return(null);
            }

            return(move);
        }
Beispiel #2
0
		public bool InstAllowSpecialMove( Mobile from, string name, SpecialMove move )
		{

			if ( !m_StartedBeginCountdown )
				return true;

			DuelPlayer pl = Find( from );

			if ( pl == null || pl.Eliminated )
				return true;

			if ( CantDoAnything( from ) )
				return false;

			string title = null;

			if( move is NinjaMove )
				title = "Bushido";
			else if( move is SamuraiMove )
				title = "Ninjitsu";


			if ( title == null || name == null || m_Ruleset.GetOption( title, name ) )
				return true;

			from.SendMessage( "The dueling ruleset prevents you from using this move." );
			return false;
		}
Beispiel #3
0
        public static void Register(int spellID, Type type)
        {
            if (spellID < 0 || spellID >= m_Types.Length)
            {
                return;
            }

            if (m_Types[spellID] == null)
            {
                ++m_Count;
            }

            m_Types[spellID] = type;

            m_IDsFromTypes.TryAdd(type, spellID);

            if (type.IsSubclassOf(typeof(SpecialMove)))
            {
                SpecialMove spm = null;

                try
                {
                    spm = type.CreateInstance <SpecialMove>();
                }
                catch
                {
                    // ignored
                }

                if (spm != null)
                {
                    SpecialMoves.Add(spellID, spm);
                }
            }
        }
Beispiel #4
0
		public static bool AllowSpecialMove( Mobile from, string name, SpecialMove move )
		{
			PlayerMobile pm = from as PlayerMobile;

			if( pm == null )
				return true;

			DuelContext dc = pm.DuelContext;

			return (dc == null || dc.InstAllowSpecialMove( from, name, move ));
		}
Beispiel #5
0
        public static void ClearAllMoves(Mobile m)
        {
            foreach (Int32 moveID in SpellRegistry.SpecialMoves.Keys)
            {
                SpecialMove move = SpellRegistry.SpecialMoves[moveID] as SpecialMove;

                if (move != null && moveID != -1)
                {
                    m.Send(new ToggleSpecialAbility(moveID + 1, false));
                }
            }
        }
Beispiel #6
0
        public static void ClearAllMoves(Mobile m)
        {
            foreach (DictionaryEntry de in SpellRegistry.SpecialMoves)
            {
                SpecialMove move = (SpecialMove)de.Value;

                int moveID = SpellRegistry.GetRegistryNumber(move);

                if (moveID != -1)
                {
                    m.Send(new ToggleSpecialAbility(moveID + 1, false));
                }
            }
        }
Beispiel #7
0
        public static bool SetCurrentMove(Mobile m, SpecialMove move)
        {
            if (!Core.SE)
            {
                ClearCurrentMove(m);
                return(false);
            }

            if (move != null && !move.Validate(m))
            {
                ClearCurrentMove(m);
                return(false);
            }

            bool sameMove = (move == GetCurrentMove(m));

            ClearCurrentMove(m);

            if (sameMove)
            {
                return(true);
            }

            if (move != null)
            {
                WeaponAbility.ClearCurrentAbility(m);

                m_Table[m] = move;

                move.OnUse(m);

                int moveID = SpellRegistry.GetRegistryNumber(move);

                if (moveID > 0)
                {
                    m.Send(new ToggleSpecialAbility(moveID + 1, true));
                }

                Server.Spells.SkillMasteries.SkillMasterySpell.OnToggleSpecialAbility(m);

                move.SendAbilityMessage(m);
            }

            return(true);
        }
Beispiel #8
0
        public static void ClearCurrentMove(Mobile m)
        {
            SpecialMove move = (SpecialMove)m_Table[m];

            if (move != null)
            {
                move.OnClearMove(m);

                int moveID = SpellRegistry.GetRegistryNumber(move);

                if (moveID > 0)
                {
                    m.Send(new ToggleSpecialAbility(moveID + 1, false));
                }
            }

            m_Table.Remove(m);
        }
Beispiel #9
0
        public static bool SetCurrentMove(Mobile m, SpecialMove move)
        {
            if (!Core.SE)
            {
                ClearCurrentMove(m);
                return(false);
            }

            if (move?.Validate(m) == false)
            {
                ClearCurrentMove(m);
                return(false);
            }

            var sameMove = move == GetCurrentMove(m);

            ClearCurrentMove(m);

            if (sameMove)
            {
                return(true);
            }

            if (move != null)
            {
                WeaponAbility.ClearCurrentAbility(m);

                Table[m] = move;

                move.OnUse(m);

                var moveID = SpellRegistry.GetRegistryNumber(move);

                if (moveID > 0)
                {
                    m.Send(new ToggleSpecialAbility(moveID + 1, true));
                }

                TextDefinition.SendMessageTo(m, move.AbilityMessage);
            }

            return(true);
        }
Beispiel #10
0
        public static void Register(int spellID, Type type)
        {
            if (spellID < 0 || spellID >= m_Types.Length)
            {
                return;
            }

            if (m_Types[spellID] == null)
            {
                ++m_Count;
            }

            m_Types[spellID] = type;

            #region SpecialMoves
            if (!m_IDsFromTypes.ContainsKey(type))
            {
                m_IDsFromTypes.Add(type, spellID);
            }

            if (type.IsSubclassOf(typeof(SpecialMove)))
            {
                SpecialMove spm = null;

                try
                {
                    spm = Activator.CreateInstance(type) as SpecialMove;
                }
                catch
                {
                }

                if (spm != null)
                {
                    m_SpecialMoves.Add(spellID, spm);
                }
            }
            #endregion
        }
Beispiel #11
0
        public static SpecialMove GetCurrentMove(Mobile m)
        {
            if (m == null)
            {
                return(null);
            }

            SpecialMove move = null;

            if (m_Table.Contains(m))
            {
                move = (SpecialMove)m_Table[m];
            }

            if (move != null && move.ValidatesDuringHit && !move.Validate(m))
            {
                ClearCurrentMove(m);
                return(null);
            }

            return(move);
        }
Beispiel #12
0
        public static void Register(int spellID, Type type)
        {
            if (spellID < 0 || spellID >= m_Types.Length)
            {
                return;
            }

            if (m_Types[spellID] == null)
            {
                ++m_Count;
            }

            m_Types[spellID] = type;

            if (!m_IDsFromTypes.ContainsKey(type))
            {
                m_IDsFromTypes.Add(type, spellID);
            }

            if (type.IsSubclassOf(typeof(SpecialMove)))
            {
                SpecialMove spm = null;

                try
                {
                    spm = Activator.CreateInstance(type) as SpecialMove;
                }
                catch (Exception e)
                {
                    Server.Diagnostics.ExceptionLogging.LogException(e);
                }

                if (spm != null)
                {
                    m_SpecialMoves.Add(spellID, spm);
                }
            }
        }
		public static int GetRegistryNumber( SpecialMove s )
		{
			return GetRegistryNumber( s.GetType() );
		}
Beispiel #14
0
        public bool Cast()
        {
            if (Caster.Spell is Spell && ((Spell)Caster.Spell).State == SpellState.Sequencing)
            {
                ((Spell)Caster.Spell).Disturb(DisturbType.NewCast);
            }

            if (!Caster.CheckAlive())
            {
                return(false);
            }
            else if (Caster.Spell != null && Caster.Spell.IsCasting)
            {
                Caster.SendLocalizedMessage(502642);                   // You are already casting a spell.
            }
            else if (BlockedByHorrificBeast && TransformationSpell.UnderTransformation(Caster, typeof(HorrificBeastSpell)))
            {
                Caster.SendLocalizedMessage(1061091);                   // You cannot cast that spell in this form.
            }
            else if (BlockedByAnimalForm && AnimalForm.UnderTransformation(Caster))
            {
                Caster.SendLocalizedMessage(1061091);                   // You cannot cast that spell in this form.
            }
            else if (!(Scroll is BaseWand) && (Caster.Paralyzed || Caster.Frozen))
            {
                Caster.SendLocalizedMessage(502643);                   // You can not cast a spell while frozen.
            }
            else if (CheckNextSpellTime && DateTime.UtcNow < Caster.NextSpellTime)
            {
                Caster.SendLocalizedMessage(502644);                   // You have not yet recovered from casting a spell.
            }
            else if (BaseBardCreature.IsCalmed(Caster))
            {
                Caster.SendLocalizedMessage(1072060);                   // You cannot cast a spell while calmed.
            }
            else if (Caster.Mana >= ScaleMana(GetMana()))
            {
                if (Caster.Spell == null && Caster.CheckSpellCast(this) && CheckCast() && Caster.Region.OnBeginSpellCast(Caster, this))
                {
                    State        = SpellState.Casting;
                    Caster.Spell = this;

                    if (RevealOnCast)
                    {
                        Caster.RevealingAction();
                    }

                    SayMantra();

                    TimeSpan castDelay = this.GetCastDelay();

                    /*
                     * OSI cast delay is computed with a global timer based on ticks. There is
                     * one tick per 0.25 seconds, so every tick the timer computes all the
                     * spells ready to cast. This introduces a random additional delay of 0-0.25
                     * seconds due to fact that the first tick is always incomplete. We add this
                     * manually here to enhance the gameplay to get the real OSI feeling.
                     */
                    castDelay += TimeSpan.FromSeconds(0.25 * Utility.RandomDouble());

                    if (ShowHandMovement && Caster.Body.IsHuman && !(Scroll is SpellStone))
                    {
                        int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds);

                        if (count != 0)
                        {
                            m_AnimTimer = new AnimTimer(this, count);
                            m_AnimTimer.Start();
                        }

                        if (Info.LeftHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, Info.LeftHandEffect, EffectLayer.LeftHand);
                        }

                        if (Info.RightHandEffect > 0)
                        {
                            Caster.FixedParticles(0, 10, 5, Info.RightHandEffect, EffectLayer.RightHand);
                        }
                    }

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

                    m_CastTimer = new CastTimer(this, castDelay);
                    m_CastTimer.Start();

                    SpecialMove.ClearCurrentMove(Caster);
                    WeaponAbility.ClearCurrentAbility(Caster);

                    OnBeginCast();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                Caster.LocalOverheadMessage(MessageType.Regular, 0x22, 502625);                   // Insufficient mana
            }

            return(false);
        }
Beispiel #15
0
 public static int GetRegistryNumber(SpecialMove s) => GetRegistryNumber(s.GetType());
Beispiel #16
0
        public static bool SetCurrentMove( Mobile m, SpecialMove move )
        {
            if ( !Core.SE )
            {
                ClearCurrentMove( m );
                return false;
            }

            if ( move != null && !move.Validate( m ) )
            {
                ClearCurrentMove( m );
                return false;
            }

            bool sameMove = ( move == GetCurrentMove( m ) );

            ClearCurrentMove( m );

            if ( sameMove )
                return true;

            if ( move != null )
            {
                WeaponAbility.ClearCurrentAbility( m );

                m_Table[m] = move;

                move.OnUse( m );

                int moveID = SpellRegistry.GetRegistryNumber( move );

                if ( moveID > 0 )
                    m.Send( new ToggleSpecialAbility( moveID + 1, true ) );

                TextDefinition.SendMessageTo( m, move.AbilityMessage );
            }

            return true;
        }
Beispiel #17
0
 public static int GetRegistryNumber(SpecialMove s)
 {
     return(GetRegistryNumber(s.GetType()));
 }