Beispiel #1
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));
        }
Beispiel #2
0
        public override TimeSpan OnSwing(Mobile attacker, IDamageable damageable)
        {
            // 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);
                    }
                }

                #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(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));
        }
Beispiel #3
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));
        }
Beispiel #4
0
        public virtual bool OnFired(Mobile attacker, IDamageable damageable)
        {
            WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker);

            //Type type = (Color)Enum.Parse(typeof(Enumeration.ArrowType), m_ArrowType);

            // Respect special moves that use no ammo
            if (ability != null && ability.ConsumeAmmo == false)
            {
                return(true);
            }

            if (attacker.Player)
            {
                BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
                Container  pack   = attacker.Backpack;

                int lowerAmmo = AosAttributes.GetValue(attacker, AosAttribute.LowerAmmoCost);

                if (quiver == null || Utility.Random(100) >= lowerAmmo)
                {
                    if (quiver != null && quiver.ConsumeTotal(SpecialAmmoType, 1))
                    {
                        //attacker.SendMessage("1");
                        quiver.InvalidateWeight();
                    }
                    //else if (pack == null || !pack.ConsumeTotal(m_ArrowType, 1))
                    /* UNIVERSAL STORAGE KEY BEGIN */

                    else if (pack == null || !pack.ConsumeTotal(SpecialAmmoType, 1) && !BaseStoreKey.Consume(pack, SpecialAmmoType, 1))
                    {
                        //attacker.SendMessage("2");
                        return(false);
                    }
                }
                // if( ArrowSelection > 0 & (pack == null || pack.FindItemByType(SpecialAmmoType) == null) )
                // {
                // return false;
                // }
                else if (quiver.FindItemByType(SpecialAmmoType) == null && (pack == null || pack.FindItemByType(SpecialAmmoType) == null))
                {
                    // lower ammo cost should not work when we have no ammo at all
                    //attacker.SendMessage("4");
                    return(false);
                }
                // else if( SpecialAmmoType != null && quiver.FindItemByType(SpecialAmmoType) == null && (pack == null || pack.FindItemByType(SpecialAmmoType) == null) )
                // {
                // return false;
                // }
            }

            attacker.MovingEffect(damageable, EffectID, 18, 1, false, false);


            return(true);
        }
Beispiel #5
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));
            }
        }
Beispiel #6
0
        public override void OnHit(Mobile attacker, IDamageable damageable, double damageBonus)
        {
            m_KillSave = damageable.Location;

            if (!(WeaponAbility.GetCurrentAbility(attacker) is MysticArc))
            {
                Timer.DelayCall(TimeSpan.FromMilliseconds(333.0), new TimerCallback(ThrowBack));
            }

            base.OnHit(attacker, damageable, damageBonus);
        }
Beispiel #7
0
        public override void OnMiss(Mobile attacker, IDamageable damageable)
        {
            m_Target = damageable as Mobile;

            if (!(WeaponAbility.GetCurrentAbility(attacker) is MysticArc))
            {
                Timer.DelayCall(TimeSpan.FromMilliseconds(333.0), new TimerCallback(ThrowBack));
            }

            base.OnMiss(attacker, damageable);
        }
Beispiel #8
0
        public override void OnMiss(Mobile attacker, Mobile defender)
        {
            this.m_Target = defender;

            if (!(WeaponAbility.GetCurrentAbility(attacker) is MysticArc))
            {
                Timer.DelayCall(TimeSpan.FromMilliseconds(333.0), new TimerCallback(ThrowBack));
            }

            base.OnMiss(attacker, defender);
        }
Beispiel #9
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));
        }
Beispiel #10
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
            // Kaltar, comentado, vai ser sempre 1.0 e nao : Core.SE ? 0.25 : (Core.AOS ? 0.5 : 1.0)
            if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(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);
                        }
                    }
                }

                attacker.RevealingAction();

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

                return(TimeSpan.FromSeconds(0.25));
            }
        }
Beispiel #11
0
        public override bool CheckHit(Mobile attacker, Mobile defender)
        {
            BaseWeapon atkWeapon = attacker.Weapon as BaseWeapon;
            BaseWeapon defWeapon = defender.Weapon as BaseWeapon;

            Skill atkSkill = attacker.Skills[atkWeapon.Skill];
            Skill defSkill = defender.Skills[defWeapon.Skill];

            double atkValue = atkWeapon.GetAttackSkillValue(attacker, defender);
            double defValue = defWeapon.GetDefendSkillValue(attacker, defender);

            if (defValue == -50.0)
            {
                defValue = -49.9;
            }

            // chance = ( attacker_ability + 50 ) / ( ( defender_ability + 50 ) * 2 )
            double chance = (atkValue + 50.0) / ((defValue + 50.0) * 2.0);

            chance *= 1.0 + ((double)GetHitChanceBonus() / 100.0);

            WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker);

            if (ability != null)
            {
                chance *= ability.AccuracyScalar;
            }

            if (attacker.LastMoveTime + TimeSpan.FromSeconds(0.4) >= DateTime.Now)
            {
                // walking -5%, running -10%
                chance -= 0.05;
                if ((attacker.Direction & Direction.Running) != 0)
                {
                    chance -= 0.05;
                }
            }

            // moving target?
            //if ( (defender.Direction&Direction.Running) != 0 )
            //	chance -= 0.05;

            attacker.CheckSkill(atkSkill.SkillName, defSkill.Value - 30.0, defSkill.Value + 25.0);
            return(chance >= Utility.RandomDouble());           //;attacker.CheckSkill( atkSkill.SkillName, chance );
        }
Beispiel #12
0
        public override int 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;
                int  delay    = 0;
                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 (Strategy.OnFired(attacker, defender))
                    {
                        delay = Strategy.Sequence(attacker, defender);
                    }
                }

                attacker.RevealingAction();

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

                return(250);
            }
        }
Beispiel #13
0
        public virtual bool OnFired(Mobile attacker, IDamageable damageable)
        {
            WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker);

            // Respect special moves that use no ammo
            if (ability != null && ability.ConsumeAmmo == false)
            {
                return(true);
            }

            if (attacker.Player)
            {
                BaseQuiver quiver = attacker.FindItemOnLayer(Layer.Cloak) as BaseQuiver;
                Container  pack   = attacker.Backpack;

                int lowerAmmo = AosAttributes.GetValue(attacker, AosAttribute.LowerAmmoCost);

                if (quiver == null || Utility.Random(100) >= lowerAmmo)
                {
                    // consume ammo
                    if (quiver != null && quiver.ConsumeTotal(AmmoType, 1))
                    {
                        quiver.InvalidateWeight();
                    }
                    else if (pack == null || !pack.ConsumeTotal(AmmoType, 1))
                    {
                        return(false);
                    }
                }
                else if (quiver.FindItemByType(AmmoType) == null && (pack == null || pack.FindItemByType(AmmoType) == null))
                {
                    // lower ammo cost should not work when we have no ammo at all
                    return(false);
                }
            }

            attacker.MovingEffect(damageable, EffectID, 18, 1, false, false);

            return(true);
        }
Beispiel #14
0
        public void ThrowAgain()
        {
            if (this.m_Target != null && this.m_Mobile != null)
            {
                BaseThrown weapon = this.m_Mobile.Weapon as BaseThrown;

                if (weapon == null)
                {
                    return;
                }

                if (WeaponAbility.GetCurrentAbility(this.m_Mobile) is MysticArc)
                {
                    ClearCurrentAbility(this.m_Mobile);
                }

                if (weapon.CheckHit(this.m_Mobile, this.m_Target))
                {
                    weapon.OnHit(this.m_Mobile, this.m_Target, 0.0);
                    AOS.Damage(this.m_Target, this.m_Mobile, this.m_Damage, 0, 0, 0, 0, 100);
                }
            }
        }
Beispiel #15
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));
            }
        }
Beispiel #16
0
        /// <summary>
        /// StandingDelay: denotes the minimum time (in seconds) an archer must stand still
        /// before being able to fire.
        /// </summary>
        //private double StandingDelay = 0.5;

        public override TimeSpan OnSwing(Mobile attacker, Mobile defender)
        {
            Container pack = attacker.Backpack;

            // Make sure we've been standing still for the standing delay (originally was: one second)
            if (DateTime.Now > (attacker.LastMoveTime + TimeSpan.FromSeconds(CoreAI.StandingDelay)) ||
                (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot))
            {
                if (attacker.HarmfulCheck(defender))
                {
                    // Check if weapon is poisoned
                    if (PoisonCharges == 0)
                    {
                        // Not poisoned
                        // Check to make sure players backpack exists
                        if (pack != null)
                        {
                            // check for arrows/bolts
                            Item Ammo;
                            Ammo = (Item)pack.FindItemByType(AmmoType, true);
                            if (Ammo != null)
                            {
                                if (Core.UOSP || Core.UOMO)
                                {
                                }
                                else
                                {
                                    // check for poisoned cloth in backpack
                                    PoisonCloth PCloth = (PoisonCloth)pack.FindItemByType(typeof(PoisonCloth), false);
                                    if (PCloth != null)
                                    {
                                        // cloth found
                                        // check for charges
                                        if (PCloth.PoisonCharges > 0)
                                        {
                                            //Pix: 5/13/06 - make sure they don't have a spell ready
                                            Spell s = attacker.Spell as Spell;
                                            if (s != null && s.State == SpellState.Sequencing)
                                            {
                                                s.Disturb(DisturbType.EquipRequest, true, false);
                                                attacker.SendMessage("You break your concentration to poison an arrow.");
                                                attacker.FixedEffect(0x3735, 6, 30);
                                            }

                                            Poison poisonToApply = this.GetPoisonBasedOnSkillAndPoison(attacker, PCloth.Poison);

                                            Poison        = poisonToApply;
                                            PoisonCharges = 1;
                                            PCloth.PoisonCharges--;
                                            if (PCloth.Poison != null)
                                            {
                                                if (attacker.AccessLevel > AccessLevel.GameMaster)
                                                {
                                                    attacker.SendMessage("Applying poison level {0} to ammo", Poison.Name);
                                                }

                                                if (AmmoType == typeof(Arrow))
                                                {
                                                    attacker.SendMessage("You wipe an arrow with your poison soaked rag and prepare to fire it.");
                                                }
                                                else
                                                {
                                                    attacker.SendMessage("You wipe a bolt with your poison soaked rag and prepare to fire it.");
                                                }
                                            }
                                        }

                                        // If no charges are left in the cloth, remove it
                                        if (PCloth.PoisonCharges == 0)
                                        {
                                            attacker.SendMessage("The rag falls apart from use.");
                                            PCloth.Delete();
                                        }
                                        // Delay for time spent poisoning arrow
                                        if (PCloth.Delay > 0.0)
                                        {
                                            return(TimeSpan.FromSeconds(PCloth.Delay));
                                        }
                                    }
                                }
                            }
                        }
                    }

                    attacker.DisruptiveAction();
                    attacker.Send(new Swing(0, attacker, defender));
                    if (OnFired(attacker, defender))
                    {
                        if (CheckHit(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }

                    if (Core.UOAI || Core.UOAR)
                    {                           // set weapon to be unpoisoned
                        Poison        = null;
                        PoisonCharges = 0;
                    }
                }

                return(GetDelay(attacker));
            }
            else
            {
                return(TimeSpan.FromSeconds(0.25));
            }
        }
        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));
            }
        }
Beispiel #18
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));
            }
        }
        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) || (attacker is TeiravonMobile && ((TeiravonMobile)attacker).Shapeshifted && ((TeiravonMobile)attacker).IsArcher() && ((TeiravonMobile)attacker).IsUndead()))
            {
                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 (this is DwarvenBallista)
                {
                    DwarvenBallista db = (DwarvenBallista)this;
                    canSwing = false;
                    foreach (Item item in attacker.GetItemsInRange(1))
                    {
                        if (item is AddonComponent)
                        {
                            AddonComponent aoc = (AddonComponent)item;
                            if (aoc.Addon == db.Ballista)
                            {
                                canSwing = true;
                            }
                        }
                    }
                }

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

                    if (OnFired(attacker, defender))
                    {
                        if (CheckAim(attacker, defender) && !CheckDodge(attacker, defender))
                        {
                            OnHit(attacker, defender);
                        }
                        else
                        {
                            OnMiss(attacker, defender);
                        }
                    }
                }

                return(GetDelay(attacker));
            }
            else
            {
                return(TimeSpan.FromSeconds(0.25));
            }
        }
Beispiel #20
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));
            }
        }
Beispiel #21
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));
            }

            if (NewSwingState == 3 && 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);
             * }*/
        }
Beispiel #22
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())));
            }
        }
Beispiel #23
0
        // Taken from BaseWeapon.cs
        // TODO: Make static function to use everywhere
        public static bool CheckHitChance(Mobile attacker, Mobile defender)
        {
//			BaseWeapon atkWeapon = attacker.Weapon as BaseWeapon;
            BaseWeapon defWeapon = defender.Weapon as BaseWeapon;

            Skill atkSkill = attacker.Skills[SkillName.Ninjitsu];
            Skill defSkill = defender.Skills[defWeapon.Skill];

            double atkValue = atkSkill.Value;
            double defValue = defWeapon.GetDefendSkillValue(attacker, defender);

            //attacker.CheckSkill( atkSkill.SkillName, defValue - 20.0, 120.0 );
            //defender.CheckSkill( defSkill.SkillName, atkValue - 20.0, 120.0 );

            double ourValue, theirValue;

            int bonus = 0;

            if (Core.AOS)
            {
                if (atkValue <= -20.0)
                {
                    atkValue = -19.9;
                }

                if (defValue <= -20.0)
                {
                    defValue = -19.9;
                }

                // Hit Chance Increase = 45%
                int atkChance = AosAttributes.GetValue(attacker, AosAttribute.AttackChance);
                if (atkChance > 45)
                {
                    atkChance = 45;
                }

                bonus += atkChance;

                if (attacker.BodyMod == 0xF6 || attacker.BodyMod == 0x19)
                {
                    bonus += (int)(attacker.Skills[SkillName.Ninjitsu].Value * 0.1);
                }                 // TODO: verify

                if (Spells.Chivalry.DivineFurySpell.UnderEffect(attacker))
                {
                    bonus += 10;
                }                 // attacker gets 10% bonus when they're under divine fury

                if (HitLower.IsUnderAttackEffect(attacker))
                {
                    bonus -= 25;
                }                 // Under Hit Lower Attack effect -> 25% malus

                if (LightningStrike.UnderEffect(attacker))
                {
                    bonus = 45;
                }

                ourValue = (atkValue + 20.0) * (100 + bonus);

                // Defense Chance Increase = 45%
                bonus = AosAttributes.GetValue(defender, AosAttribute.DefendChance);
                if (bonus > 45)
                {
                    bonus = 45;
                }

                if (Spells.Chivalry.DivineFurySpell.UnderEffect(defender))
                {
                    bonus -= 20;
                }                 // defender loses 20% bonus when they're under divine fury

                if (HitLower.IsUnderDefenseEffect(defender))
                {
                    bonus -= 25;
                }                 // Under Hit Lower Defense effect -> 25% malus


                if (BaseWeapon.UnderSurprise(defender))
                {
                    bonus -= 20;
                }                 // TODO: verify


                if (Feint.UnderEffect(defender) && defender.Combatant != null && defender.Combatant == attacker)
                {
                    int chf = Utility.Random(10, 15);

                    bonus += (int)((chf / 100.0) * bonus);
                }

                if (Block.UnderEffect(defender))
                {
                    int chb = Utility.Random(10, 15);

                    bonus += (int)((chb / 100.0) * bonus);
                }

                double discordanceScalar = 0.0;

                if (SkillHandlers.Discordance.GetScalar(attacker, ref discordanceScalar))
                {
                    bonus += (int)(discordanceScalar * 100);
                }

                theirValue = (defValue + 20.0) * (100 + bonus);

                bonus = 0;
            }
            else
            {
                if (atkValue <= -50.0)
                {
                    atkValue = -49.9;
                }

                if (defValue <= -50.0)
                {
                    defValue = -49.9;
                }

                ourValue   = (atkValue + 50.0);
                theirValue = (defValue + 50.0);
            }

            double chance = ourValue / (theirValue * 2.0);

            chance *= 1.0 + ((double)bonus / 100);

            if (Core.AOS && chance < 0.02)
            {
                chance = 0.02;
            }

            WeaponAbility ability = WeaponAbility.GetCurrentAbility(attacker);

            if (ability != null)
            {
                chance *= ability.AccuracyScalar;
            }

            return(attacker.CheckSkill(atkSkill.SkillName, chance));

            //return ( chance >= Utility.RandomDouble() );
        }
Beispiel #24
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())));
            }
        }