Ejemplo n.º 1
0
        public static void DoSleep(Mobile from, Mobile m)
        {
            /* Puts the Target into a temporary Sleep state. In this state,
             * a Slept Target will be unable to attack or cast spells, and
             * will move at a much slower speed. A Slept Target will awaken
             * if harmed or after a set amount of time. The Sleep duration
             * is determined by a comparison between the Caster's Evaluating
             * Intelligence and Mysticism skills and the Target's Resisting
             * Spells skill.
             *
             * Buff message:
             * - Movement slowed.
             * - Cannot attack or cast spells.
             * - Defensive capabilities greatly reduced.
             */

            from.PlaySound(0x653);

            int seconds = (int)(GetBaseSkill(from) + GetBoostSkill(from)) / 20;

            seconds -= (int)m.Skills[SkillName.MagicResist].Value / 10;

            if (seconds > 0 && !UnderCooldown(m))
            {
                BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Sleep, 1080139, TimeSpan.FromSeconds(seconds), m, seconds.ToString()));

                Timer t = new InternalTimer(m, DateTime.Now + TimeSpan.FromSeconds(seconds));
                t.Start();

                List <AttributeMod> mods = new List <AttributeMod>();
                mods.Add(new AttributeMod(MagicalAttribute.AttackChance, -45));
                mods.Add(new AttributeMod(MagicalAttribute.DefendChance, -45));
                mods.Add(new AttributeMod(MagicalAttribute.WeaponSpeed, -40));
                mods.Add(new AttributeMod(MagicalAttribute.CastSpeed, -2));
                mods.Add(new AttributeMod(MagicalAttribute.CastRecovery, -4));
                foreach (AttributeMod mod in mods)
                {
                    m.AddAttributeMod(mod);
                }

                m_SleptTable[m] = new SleepContext(t, mods);

                m.ForcedWalk = true;

                int cooldownSeconds = seconds + (int)m.Skills.MagicResist.Value / 10;

                m_CooldownTable.Add(m);
                Timer.DelayCall(TimeSpan.FromSeconds(cooldownSeconds), new TimerCallback(
                                    delegate
                {
                    m_CooldownTable.Remove(m);
                }));
            }
            else
            {
                from.SendLocalizedMessage(1080136);                // Your target resists sleep.
                m.SendLocalizedMessage(1080137);                   // You resist sleep.
            }
        }
Ejemplo n.º 2
0
        public static void RemoveEffect(Mobile m)
        {
            if (!m_SleptTable.ContainsKey(m))
            {
                return;
            }

            SleepContext context = m_SleptTable[m];

            context.Timer.Stop();

            foreach (AttributeMod mod in context.Mods)
            {
                m.RemoveAttributeMod(mod);
            }

            m_SleptTable.Remove(m);

            BuffInfo.RemoveBuff(m, BuffIcon.Sleep);
            m.ForcedWalk = false;
        }
Ejemplo n.º 3
0
        public static void DoSleep( Mobile from, Mobile m )
        {
            /* Puts the Target into a temporary Sleep state. In this state,
             * a Slept Target will be unable to attack or cast spells, and
             * will move at a much slower speed. A Slept Target will awaken
             * if harmed or after a set amount of time. The Sleep duration
             * is determined by a comparison between the Caster's Evaluating
             * Intelligence and Mysticism skills and the Target's Resisting
             * Spells skill.
             *
             * Buff message:
             * - Movement slowed.
             * - Cannot attack or cast spells.
             * - Defensive capabilities greatly reduced.
             */

            from.PlaySound( 0x653 );

            int seconds = (int) ( GetBaseSkill( from ) + GetBoostSkill( from ) ) / 20;
            seconds -= (int) m.Skills[SkillName.MagicResist].Value / 10;

            if ( seconds > 0 && !UnderCooldown( m ) )
            {
                BuffInfo.AddBuff( m, new BuffInfo( BuffIcon.Sleep, 1080139, TimeSpan.FromSeconds( seconds ), m, seconds.ToString() ) );

                Timer t = new InternalTimer( m, DateTime.Now + TimeSpan.FromSeconds( seconds ) );
                t.Start();

                List<AttributeMod> mods = new List<AttributeMod>();
                mods.Add( new AttributeMod( MagicalAttribute.AttackChance, -45 ) );
                mods.Add( new AttributeMod( MagicalAttribute.DefendChance, -45 ) );
                mods.Add( new AttributeMod( MagicalAttribute.WeaponSpeed, -40 ) );
                mods.Add( new AttributeMod( MagicalAttribute.CastSpeed, -2 ) );
                mods.Add( new AttributeMod( MagicalAttribute.CastRecovery, -4 ) );
                foreach ( AttributeMod mod in mods )
                {
                    m.AddAttributeMod( mod );
                }

                m_SleptTable[m] = new SleepContext( t, mods );

                m.ForcedWalk = true;

                int cooldownSeconds = seconds + (int) m.Skills.MagicResist.Value / 10;

                m_CooldownTable.Add( m );
                Timer.DelayCall( TimeSpan.FromSeconds( cooldownSeconds ), new TimerCallback(
                    delegate
                    {
                        m_CooldownTable.Remove( m );
                    } ) );
            }
            else
            {
                from.SendLocalizedMessage( 1080136 ); // Your target resists sleep.
                m.SendLocalizedMessage( 1080137 ); // You resist sleep.
            }
        }