Пример #1
0
 public DoubloonTransferTarget(Doubloon doubloon) : base(50, true, TargetFlags.None, false)
 {
     m_Doubloon = doubloon;
 }
        public void TakeDamage(Mobile from, int damage)
        {
            if (from == null)
            {
                return;
            }

            if (damage < 1)
            {
                damage = 1;
            }

            //Break
            if (damage >= m_HitPoints)
            {
                Effects.PlaySound(Location, Map, 0x11B);

                m_HitPoints = 0;

                PlayerMobile player     = from as PlayerMobile;
                BaseShip     playerShip = BaseShip.FindShipAt(player.Location, player.Map);

                int doubloonValue = 10;

                switch (m_CrateType)
                {
                case CrateType.Bronze: doubloonValue = Utility.RandomMinMax(10, 25); break;

                case CrateType.Silver: doubloonValue = Utility.RandomMinMax(25, 100); break;

                case CrateType.Gold: doubloonValue = Utility.RandomMinMax(100, 250); break;
                }

                if (player != null && playerShip != null)
                {
                    if (!playerShip.Deleted)
                    {
                        if (playerShip.DepositDoubloons(doubloonValue))
                        {
                            Doubloon doubloonPile = new Doubloon(doubloonValue);
                            player.SendSound(doubloonPile.GetDropSound());
                            doubloonPile.Delete();

                            //playerShip.doubloonsEarned += doubloonValue;

                            player.SendMessage("You have recovered " + doubloonValue.ToString() + " doubloons worth of materials in the cargo! The coins have been placed in your ship's hold.");
                        }

                        else
                        {
                            player.SendMessage("You have earned doubloons, but alas there was not enough room in your ship's hold to place them all!");
                        }
                    }
                }

                Point3D startLocation       = Location;
                IEntity effectStartLocation = new Entity(Serial.Zero, Location, Map);

                Effects.SendLocationParticles(effectStartLocation, Utility.RandomList(0x36BD, 0x36BF, 0x36CB, 0x36BC), 30, 7, 0, 0, 5044, 0);

                int debrisCount = Utility.RandomMinMax(6, 8);

                for (int a = 0; a < debrisCount; a++)
                {
                    int itemId;

                    Point3D endLocation;
                    IEntity effectEndLocation;

                    if (Utility.RandomDouble() <= .80)
                    {
                        itemId      = Utility.RandomList(7041, 7044, 7053, 7067, 7068, 7069, 7070, 7604, 7605);
                        endLocation = new Point3D(X + Utility.RandomMinMax(-3, 3), Y + Utility.RandomMinMax(-3, 3), Z + 5);

                        effectEndLocation = new Entity(Serial.Zero, endLocation, Map);
                    }

                    else
                    {
                        itemId      = Utility.RandomList(3117, 3118, 3119, 3120);
                        endLocation = new Point3D(X + Utility.RandomMinMax(-2, 2), Y + Utility.RandomMinMax(-2, 2), Z);

                        effectEndLocation = new Entity(Serial.Zero, endLocation, Map);
                    }

                    Effects.SendMovingEffect(effectStartLocation, effectEndLocation, itemId, 5, 0, false, false, 0, 0);

                    double distance = Utility.GetDistanceToSqrt(startLocation, endLocation);

                    double destinationDelay = (double)distance * .16;
                    double explosionDelay   = ((double)distance * .16) + 1;

                    Timer.DelayCall(TimeSpan.FromSeconds(destinationDelay), delegate
                    {
                        if (this == null)
                        {
                            return;
                        }

                        Blood debris  = new Blood();
                        debris.Name   = "debris";
                        debris.ItemID = itemId;

                        debris.MoveToWorld(endLocation, Map);
                        Effects.PlaySound(endLocation, Map, 0x027);
                    });
                }

                Delete();
            }

            //Damage
            else
            {
                int debrisCount = Utility.RandomMinMax(1, 2);

                for (int a = 0; a < debrisCount; a++)
                {
                    int itemId = Utility.RandomList(7041, 7044, 7053, 7067, 7068, 7069, 7070, 7604, 7605);

                    Blood debris = new Blood();
                    debris.Name   = "debris";
                    debris.ItemID = itemId;

                    Point3D endLocation = new Point3D(X + Utility.RandomMinMax(-2, 2), Y + Utility.RandomMinMax(-2, 2), Z + 5);

                    debris.MoveToWorld(endLocation, Map);
                    Effects.PlaySound(endLocation, Map, 0x027);
                }

                //Wood Breaking Sound
                Effects.PlaySound(Location, Map, Utility.RandomList(0x11D)); //0x3B7, 0x3B5, 0x3B1

                m_HitPoints -= damage;
            }
        }
        public void OnTarget(Mobile from, object obj)
        {
            if (Deleted || m_InUse)
            {
                return;
            }

            IPoint3D p3D = obj as IPoint3D;

            if (p3D == null)
            {
                return;
            }

            Map map = from.Map;

            if (map == null || map == Map.Internal)
            {
                return;
            }

            int x = p3D.X, y = p3D.Y, z = map.GetAverageZ(x, y); // OSI just takes the targeted Z

            if (!from.InRange(p3D, 6))
            {
                from.SendLocalizedMessage(500976); // You need to be closer to the water to fish!
            }
            else if (!from.InLOS(obj))
            {
                from.SendLocalizedMessage(500979); // You cannot see that location.
            }
            else if (RequireDeepWater ? FullValidation(map, x, y) : (ValidateDeepWater(map, x, y) || ValidateUndeepWater(map, obj, ref z)))
            {
                Point3D p = new Point3D(x, y, z);

                if (GetType() == typeof(SpecialFishingNet))
                {
                    for (int i = 1; i < Amount; ++i) // these were stackable before, doh
                    {
                        from.AddToBackpack(new SpecialFishingNet());
                    }
                }

                BaseShip ownerShip = BaseShip.FindShipAt(from.Location, from.Map);

                PlayerMobile player = from as PlayerMobile;

                if (ownerShip != null && player != null)
                {
                    if (ownerShip.IsFriend(player) || ownerShip.IsOwner(player) || ownerShip.IsCoOwner(player))
                    {
                        double doubloonValue = Utility.RandomMinMax(5, 10);

                        int finalDoubloonAmount = (int)doubloonValue;

                        bool shipOwner          = ownerShip.IsOwner(player);
                        bool bankDoubloonsValid = false;
                        bool holdPlacementValid = false;

                        //Deposit Half In Player's Bank
                        if (Banker.DepositUniqueCurrency(player, typeof(Doubloon), finalDoubloonAmount))
                        {
                            Doubloon doubloonPile = new Doubloon(finalDoubloonAmount);
                            player.SendSound(doubloonPile.GetDropSound());
                            doubloonPile.Delete();

                            bankDoubloonsValid = true;
                        }

                        //Deposit Other Half in Ship
                        if (ownerShip.DepositDoubloons(finalDoubloonAmount))
                        {
                            Doubloon doubloonPile = new Doubloon(finalDoubloonAmount);
                            player.SendSound(doubloonPile.GetDropSound());
                            doubloonPile.Delete();

                            holdPlacementValid = true;
                        }

                        if (shipOwner)
                        {
                            player.PirateScore += finalDoubloonAmount;
                            //ownerShip.doubloonsEarned += finalDoubloonAmount * 2;

                            if (bankDoubloonsValid && holdPlacementValid)
                            {
                                player.SendMessage("You've received " + (finalDoubloonAmount * 2).ToString() + " doubloons for using a net! They have been evenly split between your bank box and your ship's hold.");
                            }

                            else if (bankDoubloonsValid && !holdPlacementValid)
                            {
                                player.SendMessage("You've earned " + (finalDoubloonAmount * 2).ToString() + " doubloons, however there was not enough room to place all of them in your ship's hold.");
                            }

                            else if (!bankDoubloonsValid && holdPlacementValid)
                            {
                                player.SendMessage("You've earned " + (finalDoubloonAmount * 2).ToString() + " doubloons, however there was not enough room to place all of them in your bank box.");
                            }
                        }

                        else
                        {
                            player.PirateScore += finalDoubloonAmount;
                            //ownerShip.doubloonsEarned += finalDoubloonAmount;

                            if (bankDoubloonsValid)
                            {
                                player.SendMessage("You've earned " + finalDoubloonAmount.ToString() + " doubloons for using a net! They have been placed in your bank box.");
                            }
                            else
                            {
                                player.SendMessage("You've earned doubloons, but there was not enough room to place all of them in your bank box.");
                            }
                        }
                    }
                }

                m_InUse = true;
                Movable = false;
                MoveToWorld(p, map);

                SpellHelper.Turn(from, p);
                from.Animate(12, 5, 1, true, false, 0);

                Effects.SendLocationEffect(p, map, 0x352D, 16, 4);
                Effects.PlaySound(p, map, 0x364);

                Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.25), 14, new TimerStateCallback(DoEffect), new object[] { p, 0, from });

                from.SendLocalizedMessage(RequireDeepWater ? 1010487 : 1074492); // You plunge the net into the sea... / You plunge the net into the water...
            }
            else
            {
                from.SendLocalizedMessage(RequireDeepWater ? 1010485 : 1074491); // You can only use this net in deep water! / You can only use this net in water!
            }
        }