Example #1
1
		public override TimeSpan OnSwing( Mobile attacker, Mobile defender ) {
			// Make sure we've been standing still for one second
			if( DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds( Core.AOS ? 0.5 : 1.0 )) || (Core.AOS && WeaponAbility.GetCurrentAbility( attacker ) is MovingShot) ) {
				bool canSwing = true;

				if( Core.AOS ) {
					canSwing = (!attacker.Paralyzed && !attacker.Frozen);

					if( canSwing ) {
						Spell sp = attacker.Spell as Spell;

						canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
					}
				}

				if( canSwing && attacker.HarmfulCheck( defender ) ) {
					attacker.DisruptiveAction();
					attacker.Send( new Swing( 0, attacker, defender ) );

					if( OnFired( attacker, defender ) ) {
						if( CheckHit( attacker, defender ) )
							OnHit( attacker, defender );
						else
							OnMiss( attacker, defender );
					}
				}

				return GetDelay( attacker );
			} else {
				return TimeSpan.FromSeconds( 0.25 );
			}
		}
Example #2
0
        private static void EventSink_StunRequest(Mobile m)
        {
            if (Core.AOS || !DuelContext.AllowSpecialAbility(m, "Stun", true))
            {
                return;
            }

            var anatValue = m.Skills.Anatomy.Value;
            var wresValue = m.Skills.Wrestling.Value;

            if (!HasFreeHands(m))
            {
                m.SendLocalizedMessage(1004031); // You must have your hands free to attempt to stun your opponent.
                m.StunReady = false;
            }
            else if (anatValue >= 80.0 && wresValue >= 80.0)
            {
                m.DisruptiveAction();
                m.StunReady = !m.StunReady;
                m.SendLocalizedMessage(m.StunReady ? 1019011 : 1019012);
            }
            else
            {
                m.SendLocalizedMessage(1004008); // You are not skilled enough to stun your opponent.
                m.StunReady = false;
            }
        }
Example #3
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            if (DateTime.Now > attacker.LastMoveTime + TimeSpan.FromSeconds(1.0))
            {
                if (attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }
            else
            {
                attacker.RevealingAction();

                return(TimeSpan.FromSeconds(0.25));
            }
        }
Example #4
0
        private static void EventSink_StunRequest(StunRequestEventArgs e)
        {
            Mobile m = e.Mobile;

            double anatValue = m.Skills[SkillName.Anatomy].Value;
            double wresValue = m.Skills[SkillName.Wrestling].Value;

            if (!HasFreeHands(m))
            {
                m.SendLocalizedMessage(1004031);                   // You must have your hands free to attempt to stun your opponent.
                m.StunReady = false;
            }
            else if (m.Followers >= 4)
            {
                m.SendMessage("You have too many followers, breaking your concentration required to stun your target.");
                m.StunReady = false;
            }
            else if (anatValue >= 80.0 && wresValue >= 80.0)
            {
                m.DisruptiveAction();
                m.StunReady = !m.StunReady;
                m.SendLocalizedMessage(m.StunReady ? 1019011 : 1019012);
            }
            else
            {
                m.SendLocalizedMessage(1004008);                   // You are not skilled enough to stun your opponent.
                m.StunReady = false;
            }
        }
Example #5
0
        private static void EventSink_StunRequest(StunRequestEventArgs e)
        {
            Mobile m = e.Mobile;

            double anatValue = m.Skills[SkillName.Anatomy].Value;
            double wresValue = m.Skills[SkillName.Wrestling].Value;

            #region Dueling
            if (!Engines.ConPVP.DuelContext.AllowSpecialAbility(m, "Stun", true))
            {
                return;
            }
            #endregion

            if (!HasFreeHands(m))
            {
                m.SendLocalizedMessage(1004031);                   // You must have your hands free to attempt to stun your opponent.
                m.StunReady = false;
            }
            else if (anatValue >= 80.0 && wresValue >= 80.0)
            {
                m.DisruptiveAction();
                m.StunReady = !m.StunReady;
                m.SendLocalizedMessage(m.StunReady ? 1019011 : 1019012);
            }
            else
            {
                m.SendLocalizedMessage(1004008);                   // You are not skilled enough to stun your opponent.
                m.StunReady = false;
            }
        }
Example #6
0
        private static void EventSink_DisarmRequest(Mobile m)
        {
            if (Core.AOS)
            {
                return;
            }

            if (!DuelContext.AllowSpecialAbility(m, "Disarm", true))
            {
                return;
            }

            var armsValue = m.Skills.ArmsLore.Value;
            var wresValue = m.Skills.Wrestling.Value;

            if (!HasFreeHands(m))
            {
                m.SendLocalizedMessage(1004029); // You must have your hands free to attempt to disarm your opponent.
                m.DisarmReady = false;
            }
            else if (armsValue >= 80.0 && wresValue >= 80.0)
            {
                m.DisruptiveAction();
                m.DisarmReady = !m.DisarmReady;
                m.SendLocalizedMessage(m.DisarmReady ? 1019013 : 1019014);
            }
            else
            {
                m.SendLocalizedMessage(1004002); // You are not skilled enough to disarm your opponent.
                m.DisarmReady = false;
            }
        }
Example #7
0
        private static void EventSink_DisarmRequest(DisarmRequestEventArgs e)
        {
            Mobile m = e.Mobile;

            if (!Engines.ConPVP.DuelContext.AllowSpecialAbility(m, "Disarm", true))
            {
                return;
            }

            if (m.IsT2A)
            {
                return;
            }

            double armsValue = m.Skills[SkillName.ArmsLore].Value;
            double wresValue = m.Skills[SkillName.Wrestling].Value;

            if (!HasFreeHands(m))
            {
                m.SendLocalizedMessage(1004029);                   // You must have your hands free to attempt to disarm your opponent.
                m.DisarmReady = false;
            }
            else if (armsValue >= 80.0 && wresValue >= 80.0)
            {
                m.DisruptiveAction();
                m.DisarmReady = !m.DisarmReady;
                m.SendLocalizedMessage(m.DisarmReady ? 1019013 : 1019014);
            }
            else
            {
                m.SendLocalizedMessage(1004002);                   // You are not skilled enough to disarm your opponent.
                m.DisarmReady = false;
            }
        }
Example #8
0
        private static void EventSink_DisarmRequest(DisarmRequestEventArgs e)
        {
            Mobile m = e.Mobile;

            double armsValue = m.Skills[SkillName.ArmsLore].Value;
            double wresValue = m.Skills[SkillName.Wrestling].Value;

            bool cannotDisarm = (m.Region is CustomRegion && ((CustomRegion)m.Region).CannotDisarm);

            if (cannotDisarm)
            {
                m.SendMessage("You cannot disarm here.");
                m.DisarmReady = false;
            }
            else if (!HasFreeHands(m))
            {
                m.SendLocalizedMessage(1004029);                   // You must have your hands free to attempt to disarm your opponent.
                m.DisarmReady = false;
            }
            else if (armsValue >= 80.0 && wresValue >= 80.0)
            {
                m.DisruptiveAction();
                m.DisarmReady = !m.DisarmReady;
                m.SendLocalizedMessage(m.DisarmReady ? 1019013 : 1019014);
            }
            else
            {
                m.SendLocalizedMessage(1004002);                   // You are not skilled enough to disarm your opponent.
                m.DisarmReady = false;
            }
        }
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            if (Core.TickCount > attacker.LastMoveTime + 1000)
            {
                if (attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.NetState?.SendSwing(attacker.Serial, defender.Serial);

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }
            else
            {
                attacker.RevealingAction();

                return(TimeSpan.FromSeconds(0.25));
            }
        }
Example #10
0
        public static void KillEffect(Mobile m)
        {
            m.DisruptiveAction();

            m.Warmode = false;

            m.DropHolding();

            m.Poison    = null;
            m.Combatant = null;

            if (m.Paralyzed)
            {
                m.Paralyzed = false;
            }

            if (m.Frozen)
            {
                m.Frozen = false;
            }

            m.Hits = m.HitsMax;
            m.Stam = m.StamMax;
            m.Mana = m.ManaMax;
        }
Example #11
0
            protected override void OnTick()
            {
                m_iCount++;

                m_From.DisruptiveAction();

                if (m_iCount < m_iCountMax)
                {
                    m_CraftSystem.PlayCraftEffect(m_From);
                    if (m_From.Body.Type == BodyType.Human && !m_From.Mounted)
                    {
                        m_From.Animate(9, 5, 1, true, false, 0);
                    }
                }
                else
                {
                    m_From.EndAction(typeof(CraftSystem));

                    CheckGain();
                    if (m_From is TeiravonMobile)
                    {
                        TeiravonMobile tav = m_From as TeiravonMobile;

                        bool polish = Utility.RandomBool();
                        tav.NeedPolish = polish;
                        string message = polish ? ("It could use more Polishing") : ("It could use more Finishing");
                        tav.SendGump(new CraftGump(tav, m_CraftSystem, m_Tool, message));
                    }
                }
            }
Example #12
0
		public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
		{
			// Make sure we've been standing still for .25/.5/1 second depending on Era
			if ( DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds( 1.0 )) )
			{
				if ( attacker.HarmfulCheck( defender ) )
				{
					attacker.DisruptiveAction();
					attacker.Send( new Swing( 0, attacker, defender ) );

					if ( OnFired( attacker, defender ) )
					{
						if ( CheckHit( attacker, defender ) )
							OnHit( attacker, defender );
						else
							OnMiss( attacker, defender );
					}
				}

				attacker.RevealingAction();

				return GetDelay( attacker );
			}
			else
			{
				attacker.RevealingAction();

				return TimeSpan.FromSeconds( 0.25 );
			}
		}
Example #13
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            //WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker);

            // Make sure we've been standing still for .25/.5/1 second depending on Era
            if (Core.TickCount - attacker.LastMoveTime >= 1000)
            {
                bool canSwing = true;

                if (Core.AOS)
                {
                    canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                    if (canSwing)
                    {
                        Spell sp = attacker.Spell as Spell;

                        canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                    }
                }

                #region Dueling
                if (attacker is PlayerMobile)
                {
                    PlayerMobile pm = (PlayerMobile)attacker;

                    if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(attacker, this))
                    {
                        canSwing = false;
                    }
                }
                #endregion

                if (canSwing && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }

            attacker.RevealingAction();

            return(TimeSpan.FromSeconds(0.25));
        }
Example #14
0
        private static void EventSink_StunRequest(StunRequestEventArgs e)
        {
            if (Core.AOS)
            {
                return;
            }

            Mobile m = e.Mobile;

            double anatValue = m.Skills[SkillName.Anatomy].Value;
            double wresValue = m.Skills[SkillName.Wrestling].Value;

            if (!HasFreeHands(m))
            {
                m.SendLocalizedMessage(1004031); // You must have your hands free to attempt to stun your opponent.
                m.StunReady = false;
            }
            else if (anatValue >= 80.0 && wresValue >= 80.0)
            {
                m.DisruptiveAction();
                m.StunReady = !m.StunReady;
                m.SendLocalizedMessage(m.StunReady ? 1019011 : 1019012);
            }
            else
            {
                m.SendLocalizedMessage(1004008); // You are not skilled enough to stun your opponent.
                m.StunReady = false;
            }
        }
Example #15
0
        private static void EventSink_DisarmRequest(DisarmRequestEventArgs e)
        {
            if (Core.AOS)
            {
                return;
            }

            Mobile m = e.Mobile;

            double armsValue = m.Skills[SkillName.ArmsLore].Value;
            double wresValue = m.Skills[SkillName.Wrestling].Value;

            if (!HasFreeHands(m))
            {
                m.SendLocalizedMessage(1004029); // You must have your hands free to attempt to disarm your opponent.
                m.DisarmReady = false;
            }
            else if (armsValue >= 80.0 && wresValue >= 80.0)
            {
                m.DisruptiveAction();
                m.DisarmReady = !m.DisarmReady;
                m.SendLocalizedMessage(m.DisarmReady ? 1019013 : 1019014);
            }
            else
            {
                m.SendLocalizedMessage(1004002); // You are not skilled enough to disarm your opponent.
                m.DisarmReady = false;
            }
        }
Example #16
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            //WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );

            // Make sure we've been standing still for .25/.5/1 second depending on Era
            // EraSE ? 0.25 : (EraAOS ? 0.5 : 1.0)
            if (DateTime.UtcNow > (attacker.LastMoveTime + TimeSpan.FromSeconds(0.50)) ||
                (EraAOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {
                bool canSwing = CanSwing(attacker, defender);

                if (EraAOS)
                {
                    canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                    if (canSwing)
                    {
                        var sp = attacker.Spell as Spell;

                        canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                    }
                }

                if (attacker is PlayerMobile)
                {
                    var pm = (PlayerMobile)attacker;

                    if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(attacker, this))
                    {
                        canSwing = false;
                    }
                }

                if (canSwing && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }

            attacker.RevealingAction();

            return(TimeSpan.FromSeconds(0.25));
        }
Example #17
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            // Make sure we've been standing still for .25/.5/1 second depending on Era
            if (DateTime.UtcNow > attacker.LastMoveTime + TimeSpan.FromSeconds(1.0))
            {
                if (attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }
            else
            {
                attacker.RevealingAction();

                return(TimeSpan.FromSeconds(0.25));
            }
        }
Example #18
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            if (attacker.HarmfulCheck(defender))
            {
                attacker.DisruptiveAction();
                attacker.Send(new Swing(0, attacker, defender));

                if (OnFired(attacker, defender))
                {
                    if (attacker is BaseCreature)
                    {
                        BaseCreature bc_Attacker = attacker as BaseCreature;
                        bc_Attacker.OnSwing(defender);
                    }

                    if (CheckHit(attacker, defender))
                    {
                        OnHit(attacker, defender);
                    }

                    else
                    {
                        OnMiss(attacker, defender);
                    }
                }
            }

            attacker.RevealingAction();

            return(GetDelay(attacker, false));
        }
Example #19
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            // Make sure we've been standing still for 0.5 seconds
            if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(0.5)) || (WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {
                if (CanSwing(attacker) && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    Effects.SendPacket(attacker, attacker.Map, new GraphicalEffect(EffectType.Moving, attacker.Serial, defender.Serial, ItemID, attacker.Location, defender.Location, 18, 0, false, 2));

                    if (CheckHit(attacker, defender))
                    {
                        OnHit(attacker, defender);
                    }
                    else
                    {
                        OnMiss(attacker, defender);
                    }
                }

                return(GetDelay(attacker));
            }
            else
            {
                return(TimeSpan.FromSeconds(0.5 + (0.25 * Utility.RandomDouble())));
            }
        }
Example #20
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            // Make sure we've been standing still for 0.5 seconds
            if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(0.5)) || (WeaponAbility.GetCurrentAbility(attacker) is MovingShot) || !attacker.IsPlayer)
            {
                if (CanSwing(attacker) && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                return(GetDelay(attacker));
            }
            else
            {
                return(TimeSpan.FromSeconds(0.5 + (0.25 * Utility.RandomDouble())));
            }
        }
Example #21
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            // Make sure we've been standing still for one second
            if (Core.TickCount > attacker.LastMoveTime + (Core.AOS ? 500 : 1000) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {
                if (attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                return(GetDelay(attacker));
            }
            else
            {
                return(TimeSpan.FromSeconds(0.25));
            }
        }
Example #22
0
        public override TimeSpan OnSwing(Mobile attacker, IDamageable damageable)
        {
            long nextShoot;

            if (attacker is PlayerMobile)
            {
                nextShoot = ((PlayerMobile)attacker).NextMovementTime + (Core.SE ? 250 : Core.AOS ? 500 : 1000);
            }
            else
            {
                nextShoot = attacker.LastMoveTime + attacker.ComputeMovementSpeed();
            }

            // Make sure we've been standing still for .25/.5/1 second depending on Era
            if (nextShoot <= Core.TickCount ||
                (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {
                bool canSwing = true;

                if (Core.AOS)
                {
                    canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                    if (canSwing)
                    {
                        Spell sp = attacker.Spell as Spell;

                        canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                    }
                }

                if (canSwing && attacker.HarmfulCheck(damageable))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, damageable));

                    if (OnFired(attacker, damageable))
                    {
                        if (CheckHit(attacker, damageable))
                        {
                            OnHit(attacker, damageable);
                        }
                        else
                        {
                            OnMiss(attacker, damageable);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }

            attacker.RevealingAction();

            return(TimeSpan.FromSeconds(0.25));
        }
Example #23
0
		public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
		{
			WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );

			// Make sure we've been standing still for .25/.5/1 second depending on Era
			if ( DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds( Core.SE ? 0.25 : (Core.AOS ? 0.5 : 1.0) )) || (Core.AOS && WeaponAbility.GetCurrentAbility( attacker ) is MovingShot) )
			{
				bool canSwing = true;

				if ( Core.AOS )
				{
					canSwing = ( !attacker.Paralyzed && !attacker.Frozen );

					if ( canSwing )
					{
						Spell sp = attacker.Spell as Spell;

						canSwing = ( sp == null || !sp.IsCasting || !sp.BlocksMovement );
					}
				}

                #region Dueling
                if (attacker is PlayerMobile)
                {
                    PlayerMobile pm = (PlayerMobile)attacker;

                    if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(attacker, this))
                        canSwing = false;
                }
                #endregion


				if ( canSwing && attacker.HarmfulCheck( defender ) )
				{
					attacker.DisruptiveAction();
					attacker.Send( new Swing( 0, attacker, defender ) );

					if ( OnFired( attacker, defender ) )
					{
						if ( CheckHit( attacker, defender ) )
							OnHit( attacker, defender );
						else
							OnMiss( attacker, defender );
					}
				}

				attacker.RevealingAction();

				return GetDelay( attacker );
			}
			else
			{
				attacker.RevealingAction();

				return TimeSpan.FromSeconds( 0.25 );
			}
		}
Example #24
0
            protected override void OnTick()
            {
                if (ShouldBreakConcentration())
                {
                    m_Mobile.DisruptiveAction();
                    m_Mobile.NextSkillTime = Core.TickCount + (int)DefaultDelay.TotalMilliseconds;
                }

                if (!m_Mobile.Meditating)
                {
                    Stop();
                    return;
                }

                var modifier = GetMagicEfficiencyModifier(m_Mobile);

                if (modifier > 0)
                {
                    var restored = (int)(m_RegenBase * modifier / 100);
                    if (restored >= 0)
                    {
                        m_Mobile.Mana += restored;
                    }
                    else
                    {
                        m_Mobile.SendFailureMessage("Regenerative forces cannot penetrate your armor.");
                        m_Mobile.DisruptiveAction();
                        m_Mobile.NextSkillTime = Core.TickCount + (int)DefaultDelay.TotalMilliseconds;;
                        Stop();
                        return;
                    }
                }

                if (m_Mobile.Mana == m_Mobile.ManaMax)
                {
                    m_Mobile.DisruptiveAction();
                    m_Mobile.NextSkillTime = Core.TickCount + (int)DefaultDelay.TotalMilliseconds;;
                    Stop();
                    return;
                }

                // Delay skill use long enough for the next meditation tick
                m_Mobile.NextSkillTime = Core.TickCount + (int)DefaultDelay.TotalMilliseconds * 2;
            }
Example #25
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            // Make sure we've been standing still for one second
            if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(Core.AOS ? 0.25 : 1.0)) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {
                bool canSwing = true;

                if (Core.AOS)
                {
                    canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                    if (canSwing)
                    {
                        Spell sp = attacker.Spell as Spell;

                        canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                    }
                }

                if (canSwing && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    bool          doubleS = false;
                    WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker);
                    if (ability is DoubleShot && ((int)(Math.Max(attacker.Skills[SkillName.Bushido].Value, attacker.Skills[SkillName.Ninjitsu].Value))) >= Utility.Random(130))
                    {
                        doubleS = true;
                    }

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }

                        if (doubleS)
                        {
                            OnSwing(attacker, defender);
                        }
                    }
                }

                return(GetDelay(attacker));
            }
            else
            {
                return(TimeSpan.FromSeconds(0.25));
            }
        }
Example #26
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            //Remove weapon ability -- jabs
            /*WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );*/

            // Make sure we've been standing still for .25/.5/1 second depending on Era
            if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(Core.SE ? 0.25 : (Core.AOS ? 0.5 : 1.0))) /*|| (Core.AOS && WeaponAbility.GetCurrentAbility( attacker ) is MovingShot)*/)
            {
                bool canSwing = true;

                //if ( Core.AOS )
                {
                    canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                    if (canSwing)
                    {
                        Spell sp = attacker.Spell as Spell;

                        canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                    }
                }

                if (canSwing && attacker.HarmfulCheck(defender) && Map.LineOfSight(attacker, defender))
                {
                    attacker.DisruptiveAction();

                    // Swing packet causes the client to begin automatically changing direction
                    // every few seconds to face the attacker, a feature that has never been in zulu -- jabs
                    //attacker.Send( new Swing( 0, attacker, defender ) );

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }
            else
            {
                attacker.RevealingAction();

                return(TimeSpan.FromSeconds(0.25));
            }
        }
Example #27
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender, double damageBonus = 1.0)
        {
            // WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );

            // Make sure we've been standing still for .25/.5/1 second depending on Era
            if (Core.TickCount - attacker.LastMoveTime >= (Core.SE ? 250 : Core.AOS ? 500 : 1000) ||
                Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot)
            {
                var canSwing = true;

                if (Core.AOS)
                {
                    canSwing = !attacker.Paralyzed && !attacker.Frozen;

                    if (canSwing)
                    {
                        canSwing = attacker.Spell is not Spell sp || !sp.IsCasting || !sp.BlocksMovement;
                    }
                }

                if ((attacker as PlayerMobile)?.DuelContext?.CheckItemEquip(attacker, this) == false)
                {
                    canSwing = false;
                }

                if (canSwing && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.NetState.SendSwing(attacker.Serial, defender.Serial);

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }

            attacker.RevealingAction();

            return(TimeSpan.FromSeconds(0.25));
        }
Example #28
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            //WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );

            // Make sure we've been standing still for .25/.5/1 second depending on Era
            // Core.SE ? 0.25 : (Core.AOS ? 0.5 : 1.0)
            if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(0.25)) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {
/*				bool canSwing = true;
 *
 *                              if ( Core.AOS )
 *                              {
 *                                      canSwing = ( !attacker.Paralyzed && !attacker.Frozen );
 *
 *                                      if ( canSwing )
 *                                      {
 *                                              Spell sp = attacker.Spell as Spell;
 *
 *                                              canSwing = ( sp == null || !sp.IsCasting || !sp.BlocksMovement );
 *                                      }
 *                              }
 */
                if (CanSwing(attacker, defender) && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }
            else
            {
                attacker.RevealingAction();

                return(TimeSpan.FromSeconds(0.25));
            }
        }
Example #29
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker);

            // Make sure we've been standing still for .25/.5/1 second depending on Era
            if (Core.TickCount > attacker.LastMoveTime + (Core.SE ? 250 : (Core.AOS ? 500 : 1000)) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {
                bool canSwing = true;

                if (Core.AOS)
                {
                    canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                    if (canSwing)
                    {
                        Spell sp = attacker.Spell as Spell;

                        canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                    }
                }

                if (canSwing && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                attacker.RevealingAction();

                return(GetDelay(attacker));
            }
            else
            {
                attacker.RevealingAction();

                return(TimeSpan.FromSeconds(0.25));
            }
        }
Example #30
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            // Make sure we've been standing still for one second
            if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(Core.AOS ? 0.5 : 1.0)) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {
                bool canSwing = true;

                if (Core.AOS)
                {
                    canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                    if (canSwing)
                    {
                        Spell sp = attacker.Spell as Spell;

                        canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                    }
                }

                if (canSwing && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                return(GetDelay(attacker));
            }
            else
            {
                return(TimeSpan.FromSeconds(0.25));
            }
        }
Example #31
0
        public static bool UseSkill(Mobile from, int skillID)
        {
            if (!from.CheckAlive())
            {
                return(false);
            }
            else if (!from.Region.OnSkillUse(from, skillID))
            {
                return(false);
            }
            else if (!from.AllowSkillUse((SkillName)skillID))
            {
                return(false);
            }

            if (skillID >= 0 && skillID < SkillInfo.Table.Length)
            {
                SkillInfo info = SkillInfo.Table[skillID];

                if (info.Callback != null)
                {
                    if (Core.TickCount - from.NextSkillTime >= 0 && from.Spell == null)
                    {
                        from.DisruptiveAction();

                        from.NextSkillTime = Core.TickCount + (int)(info.Callback(from)).TotalMilliseconds;

                        return(true);
                    }
                    else
                    {
                        from.SendSkillMessage();
                    }
                }
                else
                {
                    from.SendLocalizedMessage(500014); // That skill cannot be used directly.
                }
            }

            return(false);
        }
Example #32
0
        private static bool CanBegin(Mobile from)
        {
            if (!from.Alive)
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019048); // I am dead and cannot do that.
                return(false);
            }

            if (!ClearHands(from))
            {
                return(false);
            }

            if (from.Mounted)
            {
                from.SendLocalizedMessage(1005583);
                return(false);
            }

            if (AnimalForm.UnderTransformation(from))
            {
                return(false);
            }

            if (from.Frozen)
            {
                from.SendLocalizedMessage(500111); // You are frozen and cannot move.
                return(false);
            }

            if (!from.Body.IsHuman)
            {
                return(false);
            }

            from.DisruptiveAction();

            return(true);
        }
Example #33
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            // Make sure we've been standing still for one second
            if (attacker.HarmfulCheck(defender))
            {
                attacker.DisruptiveAction();
                attacker.Send(new Swing(0, attacker, defender));

                if (OnFired(attacker, defender))
                {
                    if (CheckHit(attacker, defender))
                    {
                        OnHit(attacker, defender);
                    }
                    else
                    {
                        OnMiss(attacker, defender);
                    }
                }
            }

            return(GetDelay(attacker));
        }
Example #34
0
        public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender, double damageBonus )
        {
            if (Core.AOS)
            {
                canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                if (canSwing)
                {
                    Spell sp = attacker.Spell as Spell;

                    canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                }

                if (canSwing)
                {
                    PlayerMobile p = attacker as PlayerMobile;

                    canSwing = (p == null || p.PeacedUntil <= DateTime.Now);
                }
            }

            if (attacker is Player && attacker.Weapon is Fists )
            {
                Item weapon = attacker.Weapon as Fists;

                if (attacker is Player)
                {
                    Pugilist pug = Perk.GetByType<Pugilist>((Player)attacker);

                    if (pug != null)
                    {
                        pug.MartialArt(attacker, defender);
                    }
                }

                if (attacker != null)
                {
                    if (attacker.Stam < 2)
                    {
                        attacker.SendMessage("You do not have the stamina to swing your fists.");
                        canSwing = false;
                    }
                    else
                    {
                        if (CanMoveEquipped(attacker))
                            attacker.Stam -= 2;
                    }
                }
            }

            if (Parent is Player && attacker.Weapon is BaseWeapon)
            {
                Item weapon = attacker.Weapon as BaseWeapon;

                if (weapon != null)
                {
                    if (attacker.Stam < (int)(((weapon.Weight + 2) / 2) + 2))
                        {
                            canSwing = false;
                            attacker.SendMessage("You do not have the stamina to swing your weapon.");
                        }
                        else
                        {
                            if(CanMoveEquipped(attacker))
                                attacker.Stam -= (int)(((weapon.Weight + 2) / 2) + 2);
                        }             
                }
            }          

            if( canSwing && attacker.HarmfulCheck(defender) )
            {
                attacker.DisruptiveAction();

                if( attacker.NetState != null )
                    attacker.Send(new Swing(0, attacker, defender));

                if( attacker is BaseCreature )
                {
                    BaseCreature bc = (BaseCreature)attacker;
                    WeaponAbility ab = bc.GetWeaponAbility();

                    if( ab != null )
                    {
                        if( bc.WeaponAbilityChance > Utility.RandomDouble() )
                            WeaponAbility.SetCurrentAbility(bc, ab);
                        else
                            WeaponAbility.ClearCurrentAbility(bc);
                    }
                }

                if( CheckHit(attacker, defender) )
                    OnHit(attacker, defender, damageBonus);
                else
                    OnMiss(attacker, defender);

                if (attacker.NetState != null)
                    attacker.Send(new Swing(0, attacker, defender));
            }

            return GetDelay(attacker);
        }
Example #35
0
        public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender, double damageBonus )
        {
            bool canSwing = true;

            if ( Core.AOS )
            {
                canSwing = ( !attacker.Paralyzed && !attacker.Frozen );

                if ( canSwing )
                {
                    Spell sp = attacker.Spell as Spell;

                    canSwing = ( sp == null || !sp.IsCasting || !sp.BlocksMovement );
                }
            }

            if ( canSwing && attacker.HarmfulCheck( defender ) )
            {
                attacker.DisruptiveAction();

                // Swing packet causes the client to begin automatically changing direction
                // every few seconds to face the attacker, a feature that has never been in zulu -- jabs
                /*
                if ( attacker.NetState != null )
                    attacker.Send( new Swing( 0, attacker, defender ) );
                */

                //Removed weapon ability -- jabs
                /*
                if ( attacker is BaseCreature )
                {
                    BaseCreature bc = (BaseCreature)attacker;
                    WeaponAbility ab = bc.GetWeaponAbility();

                    if ( ab != null )
                    {
                        if ( bc.WeaponAbilityChance > Utility.RandomDouble() )
                            WeaponAbility.SetCurrentAbility( bc, ab );
                        else
                            WeaponAbility.ClearCurrentAbility( bc );
                    }
                }*/

                if (CheckHit(attacker, defender))
                {
                    OnHit( attacker, defender, damageBonus );
                }
                else
                    OnMiss(attacker, defender);
            }

            return GetDelay( attacker );
        }
Example #36
0
        public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
        {
            // Make sure we've been standing still for 0.5 seconds
            if ( DateTime.Now > ( attacker.LastMoveTime + TimeSpan.FromSeconds( 0.5 ) ) || ( WeaponAbility.GetCurrentAbility( attacker ) is MovingShot ) )
            {
                if ( CanSwing( attacker ) && attacker.HarmfulCheck( defender ) )
                {
                    attacker.DisruptiveAction();
                    attacker.Send( new Swing( 0, attacker, defender ) );

                    Effects.SendPacket( attacker, attacker.Map, new GraphicalEffect( EffectType.Moving, attacker.Serial, defender.Serial, ItemID, attacker.Location, defender.Location, 18, 0, false, 2 ) );

                    if ( CheckHit( attacker, defender ) )
                        OnHit( attacker, defender );
                    else
                        OnMiss( attacker, defender );
                }

                return GetDelay( attacker );
            }
            else
            {
                return TimeSpan.FromSeconds( 0.5 + ( 0.25 * Utility.RandomDouble() ) );
            }
        }
Example #37
0
		public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender )
		{
			bool canSwing = true;

			if ( Core.AOS )
			{
				canSwing = ( !attacker.Paralyzed && !attacker.Frozen );

				if ( canSwing )
				{
					Spell sp = attacker.Spell as Spell;

					canSwing = ( sp == null || !sp.IsCasting || !sp.BlocksMovement );
				}
			}

			if ( canSwing && attacker.HarmfulCheck( defender ) )
			{
				attacker.DisruptiveAction();

				if ( attacker.NetState != null )
					attacker.Send( new Swing( 0, attacker, defender ) );

				if ( attacker is BaseCreature )
				{
					BaseCreature bc = (BaseCreature)attacker;
					WeaponAbility ab = bc.GetWeaponAbility();

					if ( ab != null )
					{
						if ( bc.WeaponAbilityChance > Utility.RandomDouble() )
							WeaponAbility.SetCurrentAbility( bc, ab );
						else
							WeaponAbility.ClearCurrentAbility( bc );
					}
				}

				if ( CheckHit( attacker, defender ) )
					OnHit( attacker, defender );
				else
					OnMiss( attacker, defender );
			}

			return GetDelay( attacker );
		}
Example #38
0
        public virtual TimeSpan OnSwing(Mobile attacker, Mobile defender, double damageBonus)
        {
            bool canSwing = CanSwing(attacker, defender);

            if (attacker is PlayerMobile)
            {
                var pm = (PlayerMobile) attacker;

                if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(attacker, this))
                {
                    canSwing = false;
                }
            }

            if (canSwing && attacker.HarmfulCheck(defender))
            {
                // true if return override is encountered
                if (XmlScript.HasTrigger(this, TriggerName.onSwing) &&
                    UberScriptTriggers.Trigger(this, defender, TriggerName.onSwing))
                {
                    return GetDelay(attacker);
                }

                attacker.DisruptiveAction();

                if (attacker.NetState != null)
                {
                    attacker.Send(new Swing(0, attacker, defender));
                }

                if (attacker is BaseCreature)
                {
                    var bc = (BaseCreature) attacker;
                    WeaponAbility ab = bc.GetWeaponAbility();

                    if (ab != null)
                    {
                        if (bc.WeaponAbilityChance > Utility.RandomDouble())
                        {
                            WeaponAbility.SetCurrentAbility(bc, ab);
                        }
                        else
                        {
                            WeaponAbility.ClearCurrentAbility(bc);
                        }
                    }
                }

                if (CheckHit(attacker, defender))
                {
                    OnHit(attacker, defender, damageBonus);
                }
                else
                {
                    OnMiss(attacker, defender);
                }
            }

            return GetDelay(attacker);
        }
Example #39
0
        public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
        {
            WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker);

            if (this.Parent is Player)
            {
                Marksman mm = Perk.GetByType<Marksman>((Player)this.Parent);

                if (mm != null && mm.RunAndGun())
                {
                    bool canSwing = true;

                    if (Core.AOS)
                    {
                        canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                        if (canSwing)
                        {
                            Spell sp = attacker.Spell as Spell;

                            canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                        }
                    }

                    if (canSwing && attacker.HarmfulCheck(defender))
                    {
                        attacker.DisruptiveAction();
                        attacker.Send(new Swing(0, attacker, defender));

                        Item weapon = this as BaseRanged;

                        if (weapon != null)
                        {
                            if (((Player)this.Parent).Stam < (int)(((weapon.Weight + 2) / 2) + 3))
                            {
                                canSwing = false;
                                ((Player)this.Parent).SendMessage("You do not have the stamina to draw your bow.");
                            }
                            else
                            {
                                ((Player)this.Parent).Stam -= (int)(((weapon.Weight + 2) / 2) + 3);
                            }
                        }

                        if (OnFired(attacker, defender))
                        {
                            if (CheckHit(attacker, defender))
                                OnHit(attacker, defender);
                            else
                                OnMiss(attacker, defender);
                        }
                    }

                    attacker.RevealingAction();

                    return GetDelay(attacker);
                }
            }

            // Make sure we've been standing still for .25/.5/1 second depending on Era
            if( DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(Core.SE ? 0.25 : (Core.AOS ? 0.5 : 1.0))) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot) )
            {
                bool canSwing = true;

                if( Core.AOS )
                {
                    canSwing = (!attacker.Paralyzed && !attacker.Frozen);

                    if( canSwing )
                    {
                        Spell sp = attacker.Spell as Spell;

                        canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
                    }
                }

                if( canSwing && attacker.HarmfulCheck(defender) )
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    Item weapon = this as BaseRanged;

                    if (Parent is Player)
                    {
                        if (weapon != null)
                        {
                            if (((Player)this.Parent).Stam < (int)(((weapon.Weight + 2) / 2) + 3))
                            {
                                canSwing = false;
                                ((Player)this.Parent).SendMessage("You do not have the stamina to draw your bow.");
                            }
                            else
                            {
                                ((Player)this.Parent).Stam -= (int)(((weapon.Weight + 2) / 2) + 3);
                            }
                        }
                    }

                    if( OnFired(attacker, defender) )
                    {
                        if( CheckHit(attacker, defender) )
                            OnHit(attacker, defender);
                        else
                            OnMiss(attacker, defender);
                    }
                }

                attacker.RevealingAction();

                return GetDelay(attacker);
            }
            else
            {
                attacker.RevealingAction();

                return TimeSpan.FromSeconds(0.25);
            }
        }
Example #40
0
        public static void ZombieSwingDirection(Mobile mob, Direction direction, int range)
        {
            if (mob == null || mob.Weapon == null)
            {
                return;
            }

            IWeapon weapon = mob.Weapon;

            mob.Direction = direction; // don't do this b/c it kind of causes rubber band to the client

            UpdateNearbyClients(mob, direction);

            Point2D directionVector = Point2D.Zero;

            switch (direction & Direction.Mask)
            {
                case Direction.North:
                    directionVector = new Point2D(0, -1);
                    break;
                case Direction.Right:
                    directionVector = new Point2D(1, -1);
                    break;
                case Direction.East:
                    directionVector = new Point2D(1, 0);
                    break;
                case Direction.Down:
                    directionVector = new Point2D(1, 1);
                    break;
                case Direction.South:
                    directionVector = new Point2D(0, 1);
                    break;
                case Direction.Left:
                    directionVector = new Point2D(-1, 1);
                    break;
                case Direction.West:
                    directionVector = new Point2D(-1, 0);
                    break;
                case Direction.Up:
                    directionVector = new Point2D(-1, -1);
                    break;
            }

            var possibleTargets = new List<Mobile>();
            Point3D currentLoc = mob.Location;

            if (range <= 1 || directionVector == Point2D.Zero)
            {
                //IPooledEnumerable mobsOnHitSpot = mob.Map.GetMobilesInRange(new Point3D(currentLoc.X + directionVector.X, currentLoc.Y + directionVector.Y, mob.Location.Z));

                currentLoc.X += directionVector.X;
                currentLoc.Y += directionVector.Y;

                Sector newSector = mob.Map.GetSector(currentLoc);

                possibleTargets.AddRange(
                    newSector.Mobiles.Where(
                        m =>
                            (m.X == currentLoc.X && m.Y == currentLoc.Y && m != mob && mob.CanBeHarmful(m)) ||
                            m.X == mob.X && m.Y == mob.Y && m != mob));
            }
            else
            {
                for (int i = 0; i < range; i++)
                {
                    currentLoc.X += directionVector.X;
                    currentLoc.Y += directionVector.Y;

                    Sector newSector = mob.Map.GetSector(currentLoc);

                    possibleTargets.AddRange(
                        newSector.Mobiles.Where(
                            m =>
                                m.X == currentLoc.X && m.Y == currentLoc.Y && m != mob && mob.CanBeHarmful(m) &&
                                mob.InLOS(m)));

                    if (possibleTargets.Count > 0)
                    {
                        break; // we found our mark
                    }
                }
            }

            if (possibleTargets.Count > 0)
            {
                // TODO: maybe I should add a check for friends? (less likely to hit a friend?)
                Mobile target = possibleTargets[Utility.Random(possibleTargets.Count)];

                if (weapon is BaseRanged)
                {
                    var ranged = weapon as BaseRanged;
                    bool canSwing = ranged.CanSwing(mob, target);

                    if (mob is PlayerMobile)
                    {
                        var pm = (PlayerMobile) mob;

                        if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(mob, ranged))
                        {
                            canSwing = false;
                        }
                    }

                    if (canSwing && mob.HarmfulCheck(target))
                    {
                        mob.DisruptiveAction();
                        mob.Send(new Swing(0, mob, target));

                        if (ranged.OnFired(mob, target))
                        {
                            if (ranged.CheckHit(mob, target))
                            {
                                ranged.OnHit(mob, target);
                            }
                            else
                            {
                                ranged.OnMiss(mob, target);
                            }
                        }
                    }

                    mob.RevealingAction();

                    //GetDelay(mob);
                }
                else
                {
                    weapon.OnSwing(mob, target);
                }
            }
            else
            {
                if (weapon is BaseRanged)
                {
                    if (((BaseRanged) weapon).OnFired(mob, null))
                    {
                        ZombieEffect(mob, ((BaseRanged) weapon).EffectID, 18, mob.X, mob.Y, mob.Z, currentLoc.X,
                            currentLoc.Y, currentLoc.Z, false, false);
                        Effects.PlaySound(mob, mob.Map, Utility.RandomMinMax(0x538, 0x53a));
                        ZombieSwingAnimation(mob);
                    }
                }
                else
                {
                    Effects.PlaySound(mob, mob.Map, Utility.RandomMinMax(0x538, 0x53a));
                    ZombieSwingAnimation(mob);
                }
            }
        }
		public virtual TimeSpan OnSwing(Mobile attacker, Mobile defender, double damageBonus)
		{
			bool canSwing = true;

			if (Core.AOS)
			{
				canSwing = (!attacker.Paralyzed && !attacker.Frozen);

				if (canSwing)
				{
					Spell sp = attacker.Spell as Spell;

					canSwing = (sp == null || !sp.IsCasting || !sp.BlocksMovement);
				}

				if (canSwing)
				{
					PlayerMobile p = attacker as PlayerMobile;

					canSwing = (p == null || p.PeacedUntil <= DateTime.UtcNow);
				}
			}

			#region Dueling
			if (attacker is PlayerMobile)
			{
				PlayerMobile pm = (PlayerMobile)attacker;

				if (pm.DuelContext != null && !pm.DuelContext.CheckItemEquip(attacker, this))
				{
					canSwing = false;
				}
			}
			#endregion

			if (canSwing && attacker.HarmfulCheck(defender))
			{
				attacker.DisruptiveAction();

				if (attacker.NetState != null)
				{
					attacker.Send(new Swing(0, attacker, defender));
				}

				if (attacker is BaseCreature)
				{
					BaseCreature bc = (BaseCreature)attacker;
					WeaponAbility ab = bc.GetWeaponAbility();

					if (ab != null)
					{
						if (bc.WeaponAbilityChance > Utility.RandomDouble())
						{
							WeaponAbility.SetCurrentAbility(bc, ab);
						}
						else
						{
							WeaponAbility.ClearCurrentAbility(bc);
						}
					}
				}

				if (CheckHit(attacker, defender))
				{
					OnHit(attacker, defender, damageBonus);
				}
				else
				{
					OnMiss(attacker, defender);
				}
			}

			return GetDelay(attacker);
		}
Example #42
0
        public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
        {
            // Make sure we've been standing still for one second
            if ( attacker.HarmfulCheck( defender ) )
            {
                attacker.DisruptiveAction();
                attacker.Send( new Swing( 0, attacker, defender ) );

                if ( OnFired( attacker, defender ) )
                {
                    if ( CheckHit( attacker, defender ) )
                        OnHit( attacker, defender );
                    else
                        OnMiss( attacker, defender );
                }
            }

            return GetDelay( attacker );
        }
Example #43
0
        public override TimeSpan OnSwing( Mobile attacker, Mobile defender )
        {
            //Remove weapon ability -- jabs
            /*WeaponAbility a = WeaponAbility.GetCurrentAbility( attacker );*/

            // Make sure we've been standing still for .25/.5/1 second depending on Era
            if ( DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds( Core.SE ? 0.25 : (Core.AOS ? 0.5 : 1.0) )) /*|| (Core.AOS && WeaponAbility.GetCurrentAbility( attacker ) is MovingShot)*/ )
            {
                bool canSwing = true;

                //if ( Core.AOS )
                {
                    canSwing = ( !attacker.Paralyzed && !attacker.Frozen );

                    if ( canSwing )
                    {
                        Spell sp = attacker.Spell as Spell;

                        canSwing = ( sp == null || !sp.IsCasting || !sp.BlocksMovement );
                    }
                }

                if ( canSwing && attacker.HarmfulCheck( defender ) && Map.LineOfSight(attacker, defender) )
                {
                    attacker.DisruptiveAction();

                    // Swing packet causes the client to begin automatically changing direction
                    // every few seconds to face the attacker, a feature that has never been in zulu -- jabs
                    //attacker.Send( new Swing( 0, attacker, defender ) );

                    if ( OnFired( attacker, defender ) )
                    {
                        if ( CheckHit( attacker, defender ) )
                            OnHit( attacker, defender );
                        else
                            OnMiss( attacker, defender );
                    }
                }

                attacker.RevealingAction();

                return GetDelay( attacker );
            }
            else
            {
                attacker.RevealingAction();

                return TimeSpan.FromSeconds( 0.25 );
            }
        }
Example #44
0
        public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender, double damageBonus, bool Cleave, bool assumeHit )
        {
            if( BadCombat( attacker, defender ) )
               return TimeSpan.FromSeconds( 1.0 );

            BackpackCheck( attacker );
            BackpackCheck( defender );
            HealingCheck( attacker );
            double bestDamage=0.0;

            if( !Cleave )
                ((IKhaerosMobile)attacker).CleaveAttack = false;
            else
            {
                bestDamage = RangedPercentage;
                if ( ThrustPercentage > bestDamage )
                    bestDamage = ThrustPercentage;
                if ( OverheadPercentage > bestDamage )
                    bestDamage = OverheadPercentage;
                if ( SwingPercentage > bestDamage )
                    bestDamage = SwingPercentage;
            }

            if( IsStill( attacker ) && attacker.HarmfulCheck( defender ) && OnFired( attacker, defender ) )
            {
                attacker.DisruptiveAction();
                attacker.RevealingAction();
                ((IKhaerosMobile)defender).Enthralled = false;
                CheckForInvalidStance( attacker );

                /*if( attacker.NetState != null )
                    attacker.Send( new Swing( 0, attacker, defender ) );*/

                InitializeManeuver( attacker, defender, Cleave );

                if ( assumeHit || CheckHit( attacker, defender ) )
                {
                    if ( Cleave )
                        OnHit( attacker, defender, bestDamage*damageBonus );
                    else
                        OnHit( attacker, defender, damageBonus );
                }

                else
                    OnMiss( attacker, defender );

                EndManeuver( attacker );
                return GetDelay( attacker );
            }

            if (HealthAttachment.HasHealthAttachment(attacker))
            {
                if (HealthAttachment.GetHA(attacker).HasInjury(Injury.FracturedRibs))
                    HealthAttachment.GetHA(attacker).DoInjury(Injury.FracturedRibs);
            }
            attacker.RevealingAction();
            return TimeSpan.FromSeconds( 0.25 );
        }
Example #45
0
		public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender, double damageBonus )
		{
			if ( attacker.HarmfulCheck( defender ) )
			{
				attacker.DisruptiveAction();

				if ( attacker.NetState != null )
					attacker.Send( new Swing( 0, attacker, defender ) );

				if ( CheckHit( attacker, defender ) )
					OnHit( attacker, defender, damageBonus );
				else
					OnMiss( attacker, defender );
			}

			return GetDelay( attacker );
		}
Example #46
0
		public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender, double damageBonus )
		{
			if ( attacker.HarmfulCheck( defender ) )
			{
				attacker.DisruptiveAction();

				if ( attacker.NetState != null )
					attacker.Send( new Swing( 0, attacker, defender ) );

                if (attacker is BaseCreature)
                {   
                    if (!(attacker is BaseGuard))                                               //Taran: We prefer delayed anims before delayed hits (before you could run away 10 tiles before getting hit)
                        new HitDelayTimer((BaseCreature)attacker, defender, this, damageBonus, TimeSpan.FromMilliseconds(0)).Start(); //GetAnimDelay((BaseWeapon)attacker.Weapon)).Start();
                    else //Taran: Guards have a slight hitdelay so you can run for a bit if you are lucky
                        new HitDelayTimer((BaseCreature)attacker, defender, this, damageBonus, TimeSpan.FromMilliseconds(300)).Start();
                }
                else if (attacker is PlayerMobile)
                {
                    PlayerMobile pm = (PlayerMobile)attacker;

                    if (pm.CurrentSwingTimer == null)
                        new SwingDelayTimer(pm, defender, this, GetAnimDelay((BaseWeapon)attacker.Weapon)).Start();
                }

				SpellHelper.Turn(attacker, defender);
				PlaySwingAnimation(attacker);
			}

            return GetDelay( attacker );
		}
Example #47
0
        public virtual TimeSpan OnSwing( Mobile attacker, Mobile defender, double damageBonus )
        {
            bool canSwing = true;
            int OldSwingState = attacker.SwingState;
            int NewSwingState = this.AdvanceSwingState(attacker);

            if (OldSwingState == NewSwingState)
                return TimeSpan.Zero;

            if (NewSwingState < 2)
                return TimeSpan.Zero;

            if (NewSwingState == 2)
                PlaySwingAnimation(attacker);

            if (NewSwingState == 3 && attacker.HarmfulCheck(defender))
            {
                attacker.DisruptiveAction();

                if (attacker.NetState != null)
                    attacker.Send(new Swing(0, attacker, defender));

                if (attacker is BaseCreature)
                {
                    BaseCreature bc = (BaseCreature)attacker;
                    WeaponAbility ab = bc.GetWeaponAbility();

                    if (ab != null)
                    {
                        if (bc.WeaponAbilityChance > Utility.RandomDouble())
                            WeaponAbility.SetCurrentAbility(bc, ab);
                        else
                            WeaponAbility.ClearCurrentAbility(bc);
                    }
                }

                if (CheckHit(attacker, defender))
                    OnHit(attacker, defender, damageBonus);
                else
                    OnMiss(attacker, defender);
            }

            return GetDelay( attacker );
        }
Example #48
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker);

            // If you move the swing delay will be reset
            if (DateTime.Now > (attacker.LastMoveTime + GetDelay(attacker)))
            {
                bool canSwing = true;
                Spells.SpellHelper.Turn(attacker, defender);

                if (canSwing && attacker.HarmfulCheck(defender))
                {
                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));

                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender, attacker as PlayerMobile))
                        {
                            if (attacker is PlayerMobile)
                            {
                                PlayerMobile pm = (PlayerMobile) attacker;

                                if (pm.LastSwingActionResult == PlayerMobile.SwingAction.Hit)
                                    pm.SwingCount++;
                                else
                                {
                                    pm.LastSwingActionResult = PlayerMobile.SwingAction.Hit;
                                    pm.SwingCount = 2;
                                }
                            }
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            if (attacker is PlayerMobile)
                            {
                                PlayerMobile pm = (PlayerMobile) attacker;
                                if (pm.LastSwingActionResult == PlayerMobile.SwingAction.Miss)
                                    pm.SwingCount++;
                                else
                                {
                                    pm.LastSwingActionResult = PlayerMobile.SwingAction.Miss;
                                    pm.SwingCount = 2;
                                }
                            }
                            OnMiss(attacker, defender);
                        }
                    }
                    else
                        attacker.SendAsciiMessage("You are out of ammo");
                }

                attacker.RevealingAction();

                return GetDelay(attacker);
            }
            else
            {
                attacker.RevealingAction();

                return TimeSpan.FromSeconds(0.25);
            }
        }
Example #49
0
        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            WeaponAbility a = WeaponAbility.GetCurrentAbility(attacker);
            //attacker.SendMessage(this.SwingState.ToString());
            /*if (DateTime.Now <= (attacker.LastMoveTime + TimeSpan.FromSeconds(0.25)))
            {

                return TimeSpan.Zero;
            }*/
            // Make sure we've been standing still for .25/.5/1 second depending on Era
            /*if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(Core.SE ? 0.25 : (Core.AOS ? 0.5 : 1.0))) || (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {*/
            bool canSwing = true;
            int OldSwingState = attacker.SwingState;
            int NewSwingState = this.AdvanceSwingState(attacker);
            if (OldSwingState == NewSwingState)
                return TimeSpan.Zero;
            if (NewSwingState < 2)
                return TimeSpan.Zero;

            if (NewSwingState == 2)
            {
                if (!OnFired(attacker, defender))
                {
                    this.ResetSwingState(1);
                    return TimeSpan.Zero;
                }
                PlaySwingAnimation(attacker);
                //attacker.PlaySound(GetMissAttackSound(attacker, defender));
                attacker.DisruptiveAction();
                attacker.Send(new Swing(0, attacker, defender));

                if (CheckHit(attacker, defender))
                    OnHit(attacker, defender);
                else
                    OnMiss(attacker, defender);
            }

            if (NewSwingState == 3 && attacker.HarmfulCheck(defender))
            {

                /*if (OnFired(attacker, defender))
                {*/

                //}
            }

            attacker.RevealingAction();

            return GetDelay(attacker);
            /*}
            else
            {
                attacker.RevealingAction();

                return TimeSpan.FromSeconds(0.25);
            }*/
        }