Exemple #1
0
            public void RecoveryAmmo(Mobile attacker, Item ammo)
            {
                int number = 0;

                if (ammo is Arrow)
                {
                    number = 1023903;
                }
                else if (ammo is Bolt)
                {
                    number = 1027163;
                }
                else
                {
                    return;
                }

                string arguments = String.Format("{0}	#{1}", ammo.Amount, number);

                bool success = false;

                Item cloak = attacker.FindItemOnLayer(Layer.Cloak);

                if (cloak is BaseQuiver)
                {
                    BaseQuiver quiver = cloak as BaseQuiver;

                    if (quiver.Ammo != null)
                    {
                        if (quiver.Ammo.GetType() == ammo.GetType() && ((quiver.Ammo.Amount + ammo.Amount) <= quiver.MaxAmmo))
                        {
                            quiver.Ammo.Amount += ammo.Amount;
                            quiver.InvalidateProperties();

                            ammo.Delete();

                            success = true;
                        }
                    }
                }

                if (!ammo.Deleted && attacker.AddToBackpack(ammo))
                {
                    success = true;
                }

                if (success)
                {
                    attacker.SendLocalizedMessage(1073504, arguments);                       // You recover ~1_NUM~ ~2_AMMO~.
                }
                else
                {
                    attacker.SendLocalizedMessage(1073559, arguments);                       // You attempt to recover ~1_NUM~ ~2_AMMO~, but there is no room in your backpack, and they are lost.
                }
            }
Exemple #2
0
        public virtual bool OnFired(Mobile attacker, Mobile defender)
        {
            Container pack = attacker.Backpack;

            if (Attributes.LowerAmmoCost < Utility.RandomMinMax(1, 100) && attacker.IsPlayer)
            {
                m_IsFalseArrow = false;

                bool success = false;

                Item cloak = attacker.FindItemOnLayer(Layer.Cloak);

                if (cloak is BaseQuiver)
                {
                    BaseQuiver quiver = cloak as BaseQuiver;

                    if (quiver.ConsumeTotal(AmmoType, 1))
                    {
                        success = true;
                        quiver.InvalidateProperties();
                    }
                }

                if (!success)
                {
                    if (pack != null && pack.ConsumeTotal(AmmoType, 1))
                    {
                        success = true;
                    }
                }

                if (!success)
                {
                    return(false);
                }
            }
            else
            {
                m_IsFalseArrow = true;
            }

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

            return(true);
        }