public virtual Point3D GetWeatherStartPoint(Point3D loc, PvPBattleWeatherDirection direction)
        {
            if (!Options.Weather.Enabled || Options.Locations.Map == null || Options.Locations.Map == Map.Internal ||
                loc == Point3D.Zero)
            {
                return(loc);
            }

            switch (direction)
            {
            case PvPBattleWeatherDirection.None:
                return(loc.Clone3D(0, 0, 80));

            case PvPBattleWeatherDirection.Random:
                direction = _WeatherDirections.GetRandom(PvPBattleWeatherDirection.None);
                break;
            }

            int x = 0, y = 0;

            Movement.Offset((Direction)direction, ref x, ref y);

            var rand = Utility.RandomMinMax(4, 8);

            return(loc.Clone3D(x * rand, y * rand, 80));
        }
Exemple #2
0
        public virtual Point3D GetWeatherStartPoint(Point3D loc, PvPBattleWeatherDirection direction)
        {
            if (!Options.Weather.Enabled || Options.Locations.Map == Map.Internal || loc == Point3D.Zero)
            {
                return(loc);
            }

            switch (direction)
            {
            case PvPBattleWeatherDirection.Random:
                return(GetWeatherStartPoint(loc, _WeatherDirections.GetRandom()));

            case PvPBattleWeatherDirection.North:
                return(loc.Clone3D(0, Utility.RandomMinMax(4, 8), 80));

            case PvPBattleWeatherDirection.East:
                return(loc.Clone3D(-Utility.RandomMinMax(4, 8), 0, 80));

            case PvPBattleWeatherDirection.South:
                return(loc.Clone3D(0, -Utility.RandomMinMax(4, 8), 80));

            case PvPBattleWeatherDirection.West:
                return(loc.Clone3D(Utility.RandomMinMax(4, 8), 0, 80));

            default:
                return(loc.Clone3D(0, 0, 80));
            }
        }
Exemple #3
0
 private void CaveInBoulder(BaseAspect aspect, Point3D loc)
 {
     new MovingEffectInfo(loc.Clone3D(-4, 0, 15), loc.Clone3D(0, 0, 4), aspect.Map, 4534, 2999, 1).Send();
     new MovingEffectInfo(loc.Clone3D(0, 0, 60), loc.Clone3D(0, 0, 5), aspect.Map, 4534, 0, 4)
     {
         SoundID = 541
     }.MovingImpact(e => BoulderImpact(aspect, e.Target.Location, 3));
 }
 private void Meteorite(BaseAspect aspect, Point3D loc)
 {
     new MovingEffectInfo(loc.Clone3D(-4, 0, 15), loc.Clone3D(0, 0, 4), aspect.Map, 4534, 2999, 1).Send();
     new MovingEffectInfo(loc.Clone3D(0, 0, 60), loc.Clone3D(0, 0, 5), aspect.Map, 4534, 1258, 4)
     {
         SoundID = 541
     }.MovingImpact(e => MeteoriteImpact(aspect, e.Target.Location, 4));
 }
        private void Hailstorm(BaseAspect aspect, Point3D loc)
        {
            var effect = Utility.RandomMinMax(9006, 9007);

            new MovingEffectInfo(loc.Clone3D(-4, 0, 15), loc.Clone3D(0, 0, 4), aspect.Map, effect, 2999, 1).Send();
            new MovingEffectInfo(loc.Clone3D(0, 0, 60), loc.Clone3D(0, 0, 5), aspect.Map, effect, 0, 4)
            {
                SoundID = 247
            }.MovingImpact(e => HailstormImpact(aspect, e.Target.Location, 4));
        }
Exemple #6
0
        public override Point3D[][] GetTargetPoints(int count)
        {
            Point3D start = Start.Clone3D();

            int x = 0, y = 0;

            Movement.Offset(Direction, ref x, ref y);

            Point3D end = start.Clone3D(Range * x, Range * y);

            if (AverageZ)
            {
                start = start.GetWorldTop(Map);
                end   = end.GetWorldTop(Map);
            }

            var path   = start.GetLine3D(end, Map, AverageZ);
            var points = new List <Point3D> [path.Length];

            points.SetAll(i => new List <Point3D>());

            int    climb  = Climb;
            int    size   = Size;
            double height = Height;

            Action <int> a = i =>
            {
                var step = path[i];

                for (int z = 0; z < height; z += climb)
                {
                    int mm = (int)Math.Max(0, size * (z / height));

                    points[i].AddRange(step.ScanRangeGet(Map, mm, mm, ComputePoint, false).Combine().Select(p => p.Clone3D(0, 0, z)));
                }
            };

            if (path.Length < 10)
            {
                for (int i = 0; i < path.Length; i++)
                {
                    a(i);
                }
            }
            else
            {
                Parallel.For(0, path.Length, a);
            }

            var arr = points.ToMultiArray();

            foreach (var list in points)
            {
                list.Clear();
                list.TrimExcess();
            }

            return(arr);
        }
        public static void BeginGoldExplosion(
            ExplodeFX fx,
            Point3D center,
            Map map,
            int range,
            int minGold,
            int maxGold,
            int[] explodeSounds = null,
            int[] dropSounds    = null)
        {
            BaseExplodeEffect efx = fx.CreateInstance(center, map, 2, 3);

            if (efx == null)
            {
                return;
            }

            minGold = Math.Max(10, Math.Min(60000, minGold));
            maxGold = Math.Max(minGold, Math.Min(60000, maxGold));

            explodeSounds = explodeSounds ?? new[] { 284, 285, 286, 776, 1231 };

            efx.AverageZ = false;

            efx.EffectHandler = e =>
            {
                if (Utility.RandomDouble() < 0.25)
                {
                    Effects.PlaySound(e.Source, e.Map, explodeSounds.GetRandom());
                }
            };

            efx.Callback = () =>
            {
                efx.Start = efx.Start.Clone3D(0, 0, 10);

                if (efx.CurProcess >= efx.Repeat)
                {
                    EndGoldExplosion(fx, center.Clone3D(0, 0, 10 * efx.Repeat), map, range, minGold, maxGold, dropSounds);
                }
            };

            efx.Send();
        }
        public static void BeginGoldExplosion(
            ExplodeFX fx,
            Point3D center,
            Map map,
            int range,
            int minGold,
            int maxGold,
            int[] explodeSounds = null,
            int[] dropSounds = null)
        {
            BaseExplodeEffect efx = fx.CreateInstance(center, map, 2, 3);

            if (efx == null)
            {
                return;
            }

            minGold = Math.Max(10, Math.Min(60000, minGold));
            maxGold = Math.Max(minGold, Math.Min(60000, maxGold));

            explodeSounds = explodeSounds ?? new[] {284, 285, 286, 776, 1231};

            efx.AverageZ = false;

            efx.EffectHandler = e =>
            {
                if (Utility.RandomDouble() < 0.25)
                {
                    Effects.PlaySound(e.Source, e.Map, explodeSounds.GetRandom());
                }
            };

            efx.Callback = () =>
            {
                efx.Start = efx.Start.Clone3D(0, 0, 10);

                if (efx.CurProcess >= efx.Repeat)
                {
                    EndGoldExplosion(fx, center.Clone3D(0, 0, 10 * efx.Repeat), map, range, minGold, maxGold, dropSounds);
                }
            };

            efx.Send();
        }
        public static void EndGoldExplosion(
            ExplodeFX fx, Point3D center, Map map, int range, int minGold, int maxGold, int[] dropSounds = null)
        {
            BaseExplodeEffect efx = fx.CreateInstance(center, map, range);

            if (efx == null)
            {
                return;
            }

            efx.AverageZ = false;

            efx.Callback = () =>
            {
                var points = new List <Point3D>();

                center.ScanRange(
                    map,
                    range,
                    r =>
                {
                    if (!r.Excluded)
                    {
                        if (r.QueryMap.CanFit(r.Current, 1, false, false) || r.QueryMap.HasWater(r.Current))
                        {
                            points.Add(r.Current);
                        }
                        else
                        {
                            r.Exclude();
                        }
                    }

                    return(false);
                });

                if (points.Count == 0)
                {
                    return;
                }

                dropSounds = dropSounds ?? new[] { 553, 554 };

                Timer goldTimer = null;

                goldTimer = Timer.DelayCall(
                    TimeSpan.FromSeconds(1),
                    TimeSpan.FromMilliseconds(100),
                    points.Count,
                    () =>
                {
                    if (points.Count == 0)
                    {
                        if (goldTimer != null)
                        {
                            goldTimer.Running = false;
                            goldTimer         = null;
                        }

                        return;
                    }

                    Point3D p = points.GetRandom();
                    points.Remove(p);

                    Effects.PlaySound(p, map, dropSounds.GetRandom());

                    new MovingEffectInfo(p.Clone3D(0, 0, Utility.RandomMinMax(30, 50)), p, map, 3823, 0, 10,
                                         EffectRender.Lighten)
                    .MovingImpact(
                        e =>
                    {
                        int amount = Utility.RandomMinMax(minGold, maxGold);

                        if (amount <= 0)
                        {
                            return;
                        }

                        var g = new Gold(amount);
                        g.MoveToWorld(e.Target.Location, e.Map);

                        new EffectInfo(e.Target, e.Map, 14202, 51, 10, 40, EffectRender.Lighten).Send();
                        Effects.PlaySound(e.Target, e.Map, g.GetDropSound());
                    });
                });
            };

            efx.Send();
        }
Exemple #10
0
        public static void Decapitate(Mobile from, Mobile target, Func <Mobile, Item> createHead = null)
        {
            if (from == null || target == null)
            {
                return;
            }

            Map map = target.Map;

            target.Freeze(TimeSpan.FromSeconds(1.0));

            int range   = Utility.RandomMinMax(5, 7);
            int zOffset = target.Mounted ? 20 : 10;

            Point3D src    = target.Location.Clone3D(0, 0, zOffset);
            var     points = src.GetAllPointsInRange(map, range, range);

            Effects.PlaySound(target.Location, map, 0x19C);
            target.Send(VNScreenLightFlash.Instance);

            Timer.DelayCall(
                TimeSpan.FromMilliseconds(100),
                () =>
            {
                foreach (Point3D trg in points)
                {
                    int bloodID = Utility.RandomMinMax(4650, 4655);

                    new MovingEffectInfo(src, trg.Clone3D(0, 0, 2), from.Map, bloodID).MovingImpact(
                        info =>
                    {
                        new Blood(bloodID).MoveToWorld(info.Target.Location, info.Map);
                        Effects.PlaySound(info.Target, info.Map, 0x028);
                    });
                }
            });

            target.Kill();

            Timer.DelayCall(
                TimeSpan.FromMilliseconds(100),
                () =>
            {
                var corpse = target.Corpse as Corpse;

                if (corpse != null && !corpse.Deleted)
                {
                    corpse.TurnToBones();
                }
            });

            var head = createHead != null?createHead(target) : null;

            int headID;
            int headHue;

            if (head != null)
            {
                headID  = head.ItemID;
                headHue = head.Hue;
            }
            else
            {
                headID  = 7393;
                headHue = target.SolidHueOverride >= 0 ? target.SolidHueOverride : target.Hue;
            }

            new MovingEffectInfo(src, src.Clone3D(0, 0, 40), map, headID, headHue).MovingImpact(
                info =>
                new MovingEffectInfo(
                    info.Target,
                    info.Source.Clone3D(Utility.RandomMinMax(-1, 1), Utility.RandomMinMax(-1, 1), 2),
                    info.Map,
                    headID,
                    headHue).MovingImpact(
                    hInfo =>
            {
                if (head != null && !head.Deleted)
                {
                    head.MoveToWorld(hInfo.Target.Location, info.Map);
                }
            }));
        }
Exemple #11
0
        private bool MyPeopleNeedMe()
        {
            if (IsFaction || Crystal == null || Crystal.Deleted || !Crystal.Visible || !Crystal.Movable || Utility.RandomBool())
            {
                return(false);
            }

            Crystal.PublicOverheadMessage(MessageType.Regular, 1287, false, "I MUST GO, MY PEOPLE NEED ME.");

            Point3D loc = Crystal.GetWorldLocation();

            // (Lee) The reason for using effects is efficiency,
            // since whenever the physical item's location (Z) is changed,
            // it sends a bunch of update packets, I know it's trivial,
            // but i thought you might like this example of usage of the VNc effects :)

            // Create a new deferred effect queue.
            // When the queue has finished processing, delete the crystal.
            var q = new EffectQueue(
                () =>
            {
                if (Crystal != null)
                {
                    Crystal.Delete();
                }
            });

            // Add 10 effects to the queue,
            // each with a duration of 10 (default value),
            // which translates to 1000 milliseconds (10 * 100).
            // Since they are not moving effects and each effect lasts for 1 second,
            // it should produce the same illusion of the original implementation design.
            for (int i = 0; i < 10; i++)
            {
                q.Add(
                    new EffectInfo(
                        loc.Clone3D(0, 0, i), Crystal.Map, Crystal.ItemID, Crystal.Hue, 10, 10, EffectRender.Normal, TimeSpan.Zero));
            }

            // Process the effect queue after waiting 5 seconds.
            Timer.DelayCall(
                TimeSpan.FromSeconds(5.0),
                () =>
            {
                // Anything can happen in 5 seconds, so check it all again.
                if (Crystal != null && !Crystal.Deleted && Crystal.Visible && Crystal.Movable && !IsFaction)
                {
                    // Hiding the crystal so the effects can handle the visuals
                    Crystal.Visible = false;

                    // Just in case anyone wants to try to mess with it, even when it's hidden.
                    Crystal.Movable = false;

                    q.Process();
                }

                // We don't need the queue, so explicitly dispose for efficiency (optional)
                q.Dispose();
            });

            return(true);
        }