コード例 #1
0
        public virtual bool OnFired(Mobile attacker, Mobile defender)
        {
            if (this is ThrowingGloves && attacker.Player)
            {
                string ammoType = "Throwing Stones";

                ThrowingGloves glove = (ThrowingGloves)this;
                if (glove.GloveType == "Stones")
                {
                    ammoType = "Throwing Stones";
                }
                else if (glove.GloveType == "Axes")
                {
                    ammoType = "Throwing Axes";
                }
                else if (glove.GloveType == "Daggers")
                {
                    ammoType = "Throwing Daggers";
                }
                else if (glove.GloveType == "Darts")
                {
                    ammoType = "Throwing Darts";
                }
                else if (glove.GloveType == "Cards" && Server.Misc.GetPlayerInfo.isJester(attacker))
                {
                    ammoType = "Throwing Cards";
                }
                else if (glove.GloveType == "Tomatoes" && Server.Misc.GetPlayerInfo.isJester(attacker))
                {
                    ammoType = "Throwing Tomatoes";
                }
                else
                {
                    ammoType = "Throwing Stars"; glove.GloveType = "Stones";
                }

                foreach (Item i in attacker.Backpack.FindItemsByType(typeof(ThrowingWeapon), true))
                {
                    if (ammoType == "Throwing Stones")
                    {
                        ((ThrowingWeapon)i).ammo = "Throwing Stones"; i.ItemID = 0x10B6; i.Name = "throwing stone";
                    }
                    else if (ammoType == "Throwing Axes")
                    {
                        ((ThrowingWeapon)i).ammo = "Throwing Axes"; i.ItemID = 0x10B3; i.Name = "throwing axe";
                    }
                    else if (ammoType == "Throwing Daggers")
                    {
                        ((ThrowingWeapon)i).ammo = "Throwing Daggers"; i.ItemID = 0x10B7; i.Name = "throwing dagger";
                    }
                    else if (ammoType == "Throwing Darts")
                    {
                        ((ThrowingWeapon)i).ammo = "Throwing Darts"; i.ItemID = 0x10B5; i.Name = "throwing dart";
                    }
                    else if (ammoType == "Throwing Cards")
                    {
                        ((ThrowingWeapon)i).ammo = "Throwing Cards"; i.ItemID = 0x4C29; i.Name = "throwing card";
                    }
                    else if (ammoType == "Throwing Tomatoes")
                    {
                        ((ThrowingWeapon)i).ammo = "Throwing Tomatoes"; i.ItemID = 0x4C28; i.Name = "throwing tomato";
                    }
                    else
                    {
                        ((ThrowingWeapon)i).ammo = "Throwing Stars"; i.ItemID = 0x10B2; i.Name = "throwing star";
                    }
                    i.InvalidateProperties();
                }
            }

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

                if (quiver == null || Utility.Random(100) >= quiver.LowerAmmoCost)
                {
                    // 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(defender, EffectID, 18, 1, false, false);

            Server.Gumps.QuickBar.RefreshQuickBar(attacker);

            return(true);
        }
コード例 #2
0
        public override void OnHit(Mobile attacker, Mobile defender, double damageBonus)
        {
            if (!(Ammo is Krystal) && !(Ammo is HarpoonRope) && !(Ammo is MageEye) && !(Ammo is ThrowingWeapon) && attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && 0.4 >= Utility.RandomDouble())
            {
                defender.AddToBackpack(Ammo);
            }

            if (defender is BaseCreature && Ammo is ThrowingWeapon && attacker.Player)
            {
                BaseCreature bc = (BaseCreature)defender;

                if (attacker.FindItemOnLayer(Layer.OneHanded) != null)
                {
                    if (attacker.FindItemOnLayer(Layer.OneHanded) is ThrowingGloves)
                    {
                        ThrowingGloves glove = (ThrowingGloves)(attacker.FindItemOnLayer(Layer.OneHanded));
                        ThrowingWeapon knife = new ThrowingWeapon();

                        if (glove.GloveType == "Stones")
                        {
                            knife.ammo = "Throwing Stones"; knife.ItemID = 0x10B6; knife.Name = "throwing stone";
                        }
                        else if (glove.GloveType == "Axes")
                        {
                            knife.ammo = "Throwing Axes"; knife.ItemID = 0x10B3; knife.Name = "throwing axe";
                        }
                        else if (glove.GloveType == "Daggers")
                        {
                            knife.ammo = "Throwing Daggers"; knife.ItemID = 0x10B7; knife.Name = "throwing dagger";
                        }
                        else if (glove.GloveType == "Darts")
                        {
                            knife.ammo = "Throwing Darts"; knife.ItemID = 0x10B5; knife.Name = "throwing dart";
                        }
                        else if (glove.GloveType == "Cards" && Server.Misc.GetPlayerInfo.isJester(attacker))
                        {
                            knife.ammo = "Throwing Cards"; knife.ItemID = 0x4C29; knife.Name = "throwing card";
                        }
                        else if (glove.GloveType == "Tomatoes" && Server.Misc.GetPlayerInfo.isJester(attacker))
                        {
                            knife.ammo = "Throwing Tomatoes"; knife.ItemID = 0x4C28; knife.Name = "throwing tomato";
                        }
                        else
                        {
                            knife.ammo = "Throwing Stars"; knife.ItemID = 0x10B2; knife.Name = "throwing star";
                        }

                        bc.PackItem(knife);
                    }
                }
            }

            if (Core.ML && m_Velocity > 0)
            {
                int bonus = (int)attacker.GetDistanceToSqrt(defender);

                if (bonus > 0 && m_Velocity > Utility.Random(100))
                {
                    AOS.Damage(defender, attacker, bonus * 3, 100, 0, 0, 0, 0);

                    if (attacker.Player)
                    {
                        attacker.SendLocalizedMessage(1072794);                           // Your arrow hits its mark with velocity!
                    }
                    if (defender.Player)
                    {
                        defender.SendLocalizedMessage(1072795);                           // You have been hit by an arrow with velocity!
                    }
                }
            }

            base.OnHit(attacker, defender, damageBonus);
        }