Exemple #1
0
        public void MeteorImpact_Callback(Point3D impactloc)
        {
            var queue = new EffectQueue();

            queue.Deferred = true;

            for (int i = 0; i < 10; i++)
            {
                BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance(
                    impactloc, Map, MeteorRange, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
                {
                    foreach (Mobile target in AcquireTargets(impactloc, MeteorRange))
                    {
                        if (target is BaseCreature)
                        {
                            target.Damage(50, this);
                        }
                        else
                        {
                            target.Damage(10, this);
                        }
                    }
                });
                e.Send();
            }
            queue.Process();
        }
Exemple #2
0
        public void Ultima_Callback()
        {
            var startloc = new Point3D(X, Y, 100);
            var point    = new Point3D(Location);

            var queue = new EffectQueue();

            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    13920,
                    4,
                    1,
                    EffectRender.Normal,
                    TimeSpan.FromMilliseconds(60),
                    () => { }));
            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    14360,
                    0,
                    30,
                    EffectRender.Normal,
                    null,
                    () => { }));
            queue.Process();

            Timer.DelayCall(TimeSpan.FromSeconds(2.0), UltimaImpact_Callback, point);
        }
Exemple #3
0
        public void UltimaImpact_Callback(Point3D impactloc)
        {
            CurrentSpell.Clear();
            var queue = new EffectQueue();

            queue.Deferred = true;

            BaseExplodeEffect e = ExplodeFX.Smoke.CreateInstance(
                impactloc, Map, 8, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
            {
                foreach (Mobile mobile in AcquireAllTargets(impactloc, 8))
                {
                    if (mobile is PlayerMobile)
                    {
                        mobile.Damage(UltimaDamage, this);
                    }
                    else
                    {
                        mobile.Damage(UltimaPetDamage, this);
                    }
                }
            });

            e.Send();

            queue.Process();
            CantWalk = false;
        }
Exemple #4
0
        public void SandMine_Callback()
        {
            List <Mobile> rangelist = AcquireTargets(Location, 15);
            int           index     = Utility.Random(rangelist.Count);

            if (index + 1 > rangelist.Count)
            {
                return;
            }

            var startloc = new Point3D(X, Y, Z);
            var point    = new Point3D(rangelist[index].Location);

            var queue = new EffectQueue();

            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    4586,
                    0,
                    5,
                    EffectRender.Normal,
                    TimeSpan.FromSeconds(1),
                    () =>
            {
                var sandmine = new SandMine();
                sandmine.MoveToWorld(point, Map);
            }));
            queue.Process();
        }
        protected void GreaterExplosion_Callback()
        {
            var queue = new EffectQueue();

            queue.Deferred = false;

            List <Mobile> rangelist = AcquireTargets(Location, 15);
            int           index     = Utility.Random(rangelist.Count);

            if (index + 1 > rangelist.Count)
            {
                return;
            }

            Point3D endpoint = rangelist[index].Location;

            Point3D[] line = Location.GetLine3D(endpoint, Map);

            int n = 0;

            foreach (Point3D p in line)
            {
                n += 20;
                Point3D p1 = p;
                queue.Add(
                    new EffectInfo(
                        p,
                        Map,
                        14089,
                        0,
                        10,
                        30,
                        EffectRender.Normal,
                        TimeSpan.FromMilliseconds(n),
                        () =>
                {
                    foreach (Mobile player in AcquireTargets(p1, 0))
                    {
                        player.Damage(50, this);
                    }
                }));
            }

            queue.Callback = () =>
            {
                BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance(
                    endpoint, Map, 5, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
                {
                    foreach (Mobile player in AcquireTargets(endpoint, 5))
                    {
                        player.Damage(25, this);
                    }
                });
                e.Send();
            };


            queue.Process();
        }
        public static void ExampleQueuedFlamestrikes(IPoint3D source, IPoint3D target, Map map)
        {
            //Create new standard queue.
            //Deferred option is true by default, meaning all effects will be processed sequentially.
            //If it was false, all effects would be processed at the same time, regardless of any delays.
            EffectQueue queue = new EffectQueue();

            //Attach an optional effect handler.
            //This callback is fired for every effect in the queue when they are sent.
            queue.Handler = effect =>
            {
                //It's handy for using the effect object to reference the location of
                //the effect and other values needed to do stuff.
            };

            //Attach an optional callback handler.
            //This callback is fired when all effects in the queue have been processed and all delays have elapsed.
            queue.Callback = () =>
            {
                //Handy for making sure an action only happens after the entire queue is done processing.
            };

            //Generate a line of points (aka a 'path')
            var line = source.GetLine3D(target, map);

            //Build the queue based on the points in the line.
            foreach (Point3D p in line)
            {
                queue.Add(
                    new EffectInfo(
                        p,
                        map,
                        14089,
                        0,
                        10,
                        30,
                        EffectRender.Normal,
                        null,
                        () =>
                {
                    //Callback fired after effect is sent and any delay has elapsed.
                    //I like to use this for sound effects, or maybe gather mobs to damage.
                    //It's fired pretty much at the same time as the queue.Handler callback.
                }));
            }

            //Starts processing the queue and sending the effects!
            queue.Process();
        }
		public static void ExampleQueuedFlamestrikes(IPoint3D source, IPoint3D target, Map map)
		{
			//Create new standard queue.
			//Deferred option is true by default, meaning all effects will be processed sequentially.
			//If it was false, all effects would be processed at the same time, regardless of any delays.
			EffectQueue queue = new EffectQueue();

			//Attach an optional effect handler.
			//This callback is fired for every effect in the queue when they are sent.
			queue.Handler = effect =>
			{
				//It's handy for using the effect object to reference the location of 
				//the effect and other values needed to do stuff.
			};

			//Attach an optional callback handler.
			//This callback is fired when all effects in the queue have been processed and all delays have elapsed.
			queue.Callback = () =>
			{
				//Handy for making sure an action only happens after the entire queue is done processing.
			};

			//Generate a line of points (aka a 'path')
			var line = source.GetLine3D(target, map);

			//Build the queue based on the points in the line.
			foreach (Point3D p in line)
			{
				queue.Add(
					new EffectInfo(
						p,
						map,
						14089,
						0,
						10,
						30,
						EffectRender.Normal,
						null,
						() =>
						{
							//Callback fired after effect is sent and any delay has elapsed.
							//I like to use this for sound effects, or maybe gather mobs to damage.
							//It's fired pretty much at the same time as the queue.Handler callback.
						}));
			}

			//Starts processing the queue and sending the effects!
			queue.Process();
		}
Exemple #8
0
        public static void FlameSpiral(Point3D target, Map map)
        {
            var queue = new EffectQueue
            {
                Deferred = false
            };

            var    points = new List <Point3D>();
            double d;
            double r = 1;
            int    newx;
            int    newy;

            points.Add(target);
            //calculate spiral vector
            for (d = 0; d < 4 * Math.PI; d += 0.01)
            {
                newx = (int)Math.Floor(target.X + (Math.Sin(d) * d) * r);
                newy = (int)Math.Floor(target.Y + (Math.Sin(d + (Math.PI / 2)) * (d + (Math.PI / 2))) * r);
                var to = new Point3D(newx, newy, target.Z);
                if (!points.Contains(to))
                {
                    points.Add(to);
                }
            }
            int n = 0;

            //Build the queue based on the points in the line.
            foreach (Point3D p in points)
            {
                n += 20;
                queue.Add(
                    new EffectInfo(p, map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n),
                                   () => { }));
            }
            n += 400; //used to offset when the spiral reverses so it doesn't overlap
            foreach (Point3D p in points.AsEnumerable().Reverse())
            {
                n += 20;
                queue.Add(
                    new EffectInfo(p, map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n),
                                   () => { }));
            }
            queue.Process();
        }
        public void MeteorImpact_Callback(Point3D impactloc)
        {
            var queue = new EffectQueue();

            queue.Deferred = true;

            BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance(
                impactloc, Map, MeteorRange, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
            {
                foreach (Mobile player in AcquireTargets(impactloc, MeteorRange))
                {
                    player.Damage(50, this);
                }
            });

            e.Send();
            queue.Process();
        }
Exemple #10
0
        public void Ultima_Callback()
        {
            List <Mobile> rangelist = AcquireTargets(Location, 15);
            int           index     = Utility.Random(rangelist.Count);

            if (index + 1 > rangelist.Count)
            {
                return;
            }

            var startloc = new Point3D(rangelist[index].X, rangelist[index].Y, 100);
            var point    = new Point3D(rangelist[index].Location);

            var queue = new EffectQueue();

            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    13920,
                    60,
                    1,
                    EffectRender.Normal,
                    TimeSpan.FromMilliseconds(60),
                    () => { }));
            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    14360,
                    0,
                    30,
                    EffectRender.Normal,
                    null,
                    () => { }));
            queue.Process();

            Timer.DelayCall(TimeSpan.FromSeconds(2.0), UltimaImpact_Callback, point);
        }
Exemple #11
0
        public static void SendFlameLine(Mobile from, Mobile target)
        {
            target.Frozen = true;
            var queue = new EffectQueue
            {
                Deferred = false
            };

            Point3D endpoint = target.Location;

            Point3D[] line = from.Location.GetLine3D(endpoint, from.Map);

            int n = 0;

            foreach (Point3D p in line)
            {
                n += 20;
                //Point3D p1 = p;
                queue.Add(
                    new EffectInfo(p, from.Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { }));
            }
            queue.Process();
            Timer.DelayCall(TimeSpan.FromSeconds(1), SendSpiral, target);
        }
Exemple #12
0
        public void FlamestrikeSpiral()
        {
            var queue = new EffectQueue();

            queue.Deferred = false;

            var    points = new List <Point3D>();
            double d;
            double r = 1;
            int    newx;
            int    newy;

            points.Add(Location);
            //calculate spiral vector
            for (d = 0; d < 4 * Math.PI; d += 0.01)
            {
                newx = (int)Math.Floor(X + (Math.Sin(d) * d) * r);
                newy =
                    (int)
                    Math.Floor(Y + (Math.Sin(d + (Math.PI / 2)) * (d + (Math.PI / 2))) * r);
                var to = new Point3D(newx, newy, Z);
                if (!points.Contains(to))
                {
                    points.Add(to);
                }
            }
            int n = 0;

            //Build the queue based on the points in the line.
            foreach (Point3D p in points)
            {
                n += 20;
                Point3D p1 = p;
                queue.Add(new EffectInfo(p, Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n),
                                         () =>
                {
                    foreach (Mobile m in AcquireTargets(p1, 0))
                    {
                        m.Damage(25, this);
                    }
                }
                                         ));
            }
            n += 400; //used to offset when the spiral reverses so it doesn't overlap
            foreach (Point3D p in points.AsEnumerable().Reverse())
            {
                n += 20;
                Point3D p1 = p;
                queue.Add(new EffectInfo(p, Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n),
                                         () =>
                {
                    foreach (Mobile m in AcquireTargets(p1, 0))
                    {
                        m.Damage(25, this);
                    }
                }
                                         ));
            }
            queue.Process();

            Timer.DelayCall(TimeSpan.FromSeconds(6.0), Death_Callback);
        }
Exemple #13
0
        public void Ultima_Callback()
        {
            var startloc = new Point3D(X, Y, 100);
            var point = new Point3D(Location);

            var queue = new EffectQueue();
            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    13920,
                    4,
                    1,
                    EffectRender.Normal,
                    TimeSpan.FromMilliseconds(60),
                    () => { }));
            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    14360,
                    0,
                    30,
                    EffectRender.Normal,
                    null,
                    () => { }));
            queue.Process();

            Timer.DelayCall(TimeSpan.FromSeconds(2.0), UltimaImpact_Callback, point);
        }
Exemple #14
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);
        }
Exemple #15
0
        public void DoFireEffect(IPoint3D target)
        {
            Map map = Map;

            if (target == null || map == null)
            {
                return;
            }

            NextUse = DateTime.UtcNow + TimeSpan.FromMinutes(1);

            var      startloc = new Point3D(Location);
            IPoint3D point    = target;

            switch (CannonDirection)
            {
            case CannonDirection.South:
            {
                Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case CannonDirection.North:
            {
                Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case CannonDirection.East:
            {
                Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case CannonDirection.West:
            {
                Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }
            }
            Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));

            var queue = new EffectQueue();

            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    3699,
                    0,
                    10,
                    EffectRender.Normal,
                    TimeSpan.FromSeconds(0.1),
                    () =>
            {
                for (int count = 8; count > 0; count--)
                {
                    IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1),
                                                    target.Y + Utility.RandomMinMax(-1, 1), target.Z);
                    int effect = Utility.RandomList(0x36B0);
                    Effects.SendLocationEffect(location, map, effect, 25, 1);
                    Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));
                }
                foreach (Mobile player in AcquireAllTargets(new Point3D(point), 3))
                {
                    var damage = player.Hits * 0.4;
                    player.Damage((int)Math.Round(damage));
                }
            }));
            queue.Process();
        }
Exemple #16
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;
		}
		public static void SendFlameLine(Mobile from, Mobile target)
		{
			target.Frozen = true;
			var queue = new EffectQueue
			{
				Deferred = false
			};

			Point3D endpoint = target.Location;
			Point3D[] line = from.Location.GetLine3D(endpoint, from.Map);

			int n = 0;
			foreach (Point3D p in line)
			{
				n += 20;
				//Point3D p1 = p;
				queue.Add(
					new EffectInfo(p, from.Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { }));
			}
			queue.Process();
			Timer.DelayCall(TimeSpan.FromSeconds(1), SendSpiral, target);
		}
Exemple #18
0
        public void DoFireEffect(IPoint3D target)
        {
            Map map = Map;

            if (target == null || map == null)
            {
                return;
            }

            NextUse = DateTime.UtcNow + TimeSpan.FromMinutes(1);

            var startloc = new Point3D(Location);
            IPoint3D point = target;

            switch (CannonDirection)
            {
                case CannonDirection.South:
                {
                    Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                    break;
                }
                case CannonDirection.North:
                {
                    Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                    break;
                }
                case CannonDirection.East:
                {
                    Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                    break;
                }
                case CannonDirection.West:
                {
                    Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                    break;
                }
            }
            Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));

            var queue = new EffectQueue();
            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    3699,
                    0,
                    10,
                    EffectRender.Normal,
                    TimeSpan.FromSeconds(0.1),
                    () =>
                    {
                        for (int count = 8; count > 0; count--)
                        {
                            IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1),
                                target.Y + Utility.RandomMinMax(-1, 1), target.Z);
                            int effect = Utility.RandomList(0x36B0);
                            Effects.SendLocationEffect(location, map, effect, 25, 1);
                            Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));
                        }
                        foreach (Mobile player in AcquireAllTargets(new Point3D(point), 3))
                        {
                            var damage = player.Hits * 0.4;
                            player.Damage((int)Math.Round(damage));
                        }
                    }));
            queue.Process();
        }
        public void DoFireEffect(IPoint3D target, Mobile from)
        {
            Map map = Map;

            if (target == null || map == null)
            {
                return;
            }

            var startloc = new Point3D(Location);
            IPoint3D point = target;

            switch (Facing)
            {
                case 3:
                    {
                        Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
                case 1:
                    {
                        Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
                case 2:
                    {
                        Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
                case 0:
                    {
                        Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
            }
            Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));

            var queue = new EffectQueue();
            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    m_Projectile.AnimationID,
                    m_Projectile.AnimationHue > 0 ? m_Projectile.AnimationHue-1 : 0,
                    10,
                    EffectRender.Normal,
                    TimeSpan.FromSeconds(0.1),
                    () =>
                    {
                        if (Projectile.ShipDamage > 0)
                        {
                            for (int count = 8; count > 0; count--)
                            {
                                IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1),
                                    target.Y + Utility.RandomMinMax(-1, 1), target.Z);
                                int effect = Utility.RandomList(0x36B0);
                                Effects.SendLocationEffect(location, map, effect, 25, 1);
                                Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));
                            }
                        }
                        foreach (Mobile mob in AcquireAllTargets(new Point3D(point), Projectile.DamageRange))
                        {
                            if (from.CanBeHarmful(mob))
                            {
                                mob.Damage(Projectile.PlayerDamage, from);
                                if (from.IsHarmfulCriminal(mob) && !from.Criminal)
                                    from.CriminalAction(true);
                                else if (from.IsHarmfulCriminal(mob))
                                    from.CriminalAction(false);
                            }
                        }

                        foreach (Item item in from.Map.GetItemsInRange(new Point3D(point), Projectile.DamageRange))
                        {
                            if (item is MainMast)
                            {
                                var mast = item as MainMast;
                                if (mast.HullDurability < Projectile.ShipDamage)
                                    mast.HullDurability = 0;
                                else
                                {
                                    mast.HullDurability -= (ushort)Projectile.ShipDamage;
                                }
                                mast.PublicOverheadMessage(MessageType.Label, 61, true, mast.HullDurability + "/" + mast.MaxHullDurability);
                            }

                            if (item is BaseShipWeapon)
                            {
                                var cannon = item as BaseShipWeapon;
                                if (cannon.Durability < Projectile.ShipDamage)
                                    cannon.Durability = 0;
                                else
                                {
                                    cannon.Durability -= Projectile.ShipDamage;
                                }
                            }

                            if (item is NewBaseBoat)
                            {
                                var boat = item as NewBaseBoat;
                                if (boat.HullDurability < Projectile.ShipDamage)
                                    boat.HullDurability = 0;
                                else
                                {
                                    boat.HullDurability -= (ushort)Projectile.ShipDamage;
                                }
                                boat.PublicOverheadMessage(MessageType.Label, 61, true, boat.HullDurability + "/" + boat.MaxHullDurability);
                            }
                        }
                    }));
            queue.Process();
            Projectile.Delete();
            Projectile = null;
            this.m_NextFiringTime = DateTime.UtcNow + TimeSpan.FromSeconds(15);
        }
        public void FlamestrikeSpiral()
        {
            var queue = new EffectQueue();
            queue.Deferred = false;

            var points = new List<Point3D>();
            double d;
            double r = 1;
            int newx;
            int newy;
            points.Add(Location);
            //calculate spiral vector
            for (d = 0; d < 4 * Math.PI; d += 0.01)
            {
                newx = (int) Math.Floor(X + (Math.Sin(d) * d) * r);
                newy =
                    (int)
                        Math.Floor(Y + (Math.Sin(d + (Math.PI / 2)) * (d + (Math.PI / 2))) * r);
                var to = new Point3D(newx, newy, Z);
                if (!points.Contains(to))
                {
                    points.Add(to);
                }
            }
            int n = 0;
            //Build the queue based on the points in the line.
            foreach (Point3D p in points)
            {
                n += 20;
                Point3D p1 = p;
                queue.Add(new EffectInfo(p, Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n),
                    () =>
                    {
                        foreach (Mobile m in AcquireTargets(p1, 0))
                        {
                            m.Damage(25, this);
                        }
                    }
                    ));
            }
            n += 400; //used to offset when the spiral reverses so it doesn't overlap
            foreach (Point3D p in points.AsEnumerable().Reverse())
            {
                n += 20;
                Point3D p1 = p;
                queue.Add(new EffectInfo(p, Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n),
                    () =>
                    {
                        foreach (Mobile m in AcquireTargets(p1, 0))
                        {
                            m.Damage(25, this);
                        }
                    }
                    ));
            }
            queue.Process();

            Timer.DelayCall(TimeSpan.FromSeconds(6.0), Death_Callback);
        }
        public void MeteorImpact_Callback(Point3D impactloc)
        {
            var queue = new EffectQueue();
            queue.Deferred = true;

                BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance(
                    impactloc, Map, MeteorRange, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
                    {
                        foreach (Mobile player in AcquireTargets(impactloc, MeteorRange))
                        {
                            player.Damage(50, this);
                        }
                    });
                e.Send();
            queue.Process();
        }
        protected void GreaterExplosion_Callback()
        {
            var queue = new EffectQueue();
            queue.Deferred = false;

            List<Mobile> rangelist = AcquireTargets(Location, 15);
            int index = Utility.Random(rangelist.Count);
            if (index + 1 > rangelist.Count)
            {
                return;
            }

            Point3D endpoint = rangelist[index].Location;
            Point3D[] line = Location.GetLine3D(endpoint, Map);

            int n = 0;
            foreach (Point3D p in line)
            {
                n += 20;
                Point3D p1 = p;
                queue.Add(
                    new EffectInfo(
                        p,
                        Map,
                        14089,
                        0,
                        10,
                        30,
                        EffectRender.Normal,
                        TimeSpan.FromMilliseconds(n),
                        () =>
                        {
                            foreach (Mobile player in AcquireTargets(p1, 0))
                            {
                                player.Damage(50, this);
                            }
                        }));
            }

            queue.Callback = () =>
            {
                BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance(
                    endpoint, Map, 5, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
                    {
                        foreach (Mobile player in AcquireTargets(endpoint, 5))
                        {
                            player.Damage(25, this);
                        }
                    });
                e.Send();
            };


            queue.Process();
        }
Exemple #23
0
        public void DoFireEffect(IPoint3D target, Mobile from)
        {
            Map map = Map;

            if (target == null || map == null)
            {
                return;
            }

            var      startloc = new Point3D(Location);
            IPoint3D point    = target;

            switch (Facing)
            {
            case 3:
            {
                Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case 1:
            {
                Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case 2:
            {
                Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case 0:
            {
                Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }
            }
            Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));

            var queue = new EffectQueue();

            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    m_Projectile.AnimationID,
                    m_Projectile.AnimationHue > 0 ? m_Projectile.AnimationHue - 1 : 0,
                    10,
                    EffectRender.Normal,
                    TimeSpan.FromSeconds(0.1),
                    () =>
            {
                if (Projectile.ShipDamage > 0)
                {
                    for (int count = 8; count > 0; count--)
                    {
                        IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1),
                                                        target.Y + Utility.RandomMinMax(-1, 1), target.Z);
                        int effect = Utility.RandomList(0x36B0);
                        Effects.SendLocationEffect(location, map, effect, 25, 1);
                        Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));
                    }
                }
                foreach (Mobile mob in AcquireAllTargets(new Point3D(point), Projectile.DamageRange))
                {
                    if (from.CanBeHarmful(mob))
                    {
                        mob.Damage(Projectile.PlayerDamage, from);
                        if (from.IsHarmfulCriminal(mob) && !from.Criminal)
                        {
                            from.CriminalAction(true);
                        }
                        else if (from.IsHarmfulCriminal(mob))
                        {
                            from.CriminalAction(false);
                        }
                    }
                }

                foreach (Item item in from.Map.GetItemsInRange(new Point3D(point), Projectile.DamageRange))
                {
                    if (item is MainMast)
                    {
                        var mast = item as MainMast;
                        if (mast.HullDurability < Projectile.ShipDamage)
                        {
                            mast.HullDurability = 0;
                        }
                        else
                        {
                            mast.HullDurability -= (ushort)Projectile.ShipDamage;
                        }
                        mast.PublicOverheadMessage(MessageType.Label, 61, true, mast.HullDurability + "/" + mast.MaxHullDurability);
                    }

                    if (item is BaseShipWeapon)
                    {
                        var cannon = item as BaseShipWeapon;
                        if (cannon.Durability < Projectile.ShipDamage)
                        {
                            cannon.Durability = 0;
                        }
                        else
                        {
                            cannon.Durability -= Projectile.ShipDamage;
                        }
                    }

                    if (item is NewBaseBoat)
                    {
                        var boat = item as NewBaseBoat;
                        if (boat.HullDurability < Projectile.ShipDamage)
                        {
                            boat.HullDurability = 0;
                        }
                        else
                        {
                            boat.HullDurability -= (ushort)Projectile.ShipDamage;
                        }
                        boat.PublicOverheadMessage(MessageType.Label, 61, true, boat.HullDurability + "/" + boat.MaxHullDurability);
                    }
                }
            }));
            queue.Process();
            Projectile.Delete();
            Projectile            = null;
            this.m_NextFiringTime = DateTime.UtcNow + TimeSpan.FromSeconds(15);
        }
        public void Ultima_Callback()
        {
            List<Mobile> rangelist = AcquireTargets(Location, 15);
            int index = Utility.Random(rangelist.Count);
            if (index + 1 > rangelist.Count)
            {
                return;
            }

            var startloc = new Point3D(rangelist[index].X, rangelist[index].Y, 100);
            var point = new Point3D(rangelist[index].Location);

            var queue = new EffectQueue();
            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    13920,
                    60,
                    1,
                    EffectRender.Normal,
                    TimeSpan.FromMilliseconds(60),
                    () => { }));
            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    14360,
                    0,
                    30,
                    EffectRender.Normal,
                    null,
                    () => { }));
            queue.Process();

            Timer.DelayCall(TimeSpan.FromSeconds(2.0), UltimaImpact_Callback, point);
        }
        public void UltimaImpact_Callback(Point3D impactloc)
        {
            CurrentSpell.Clear();
            var queue = new EffectQueue();
            queue.Deferred = true;

            BaseExplodeEffect e = ExplodeFX.Smoke.CreateInstance(
                impactloc, Map, 5, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
                {
                    foreach (Mobile mobile in AcquireAllTargets(impactloc, 5))
                    {
                        if (mobile is ZombieAvatar)
                        {
                            mobile.Damage(UltimaDamage, this);
                        }
                    }
                });
            e.Send();

            queue.Process();
            CantWalk = false;
        }
        protected override void OnInvoke(BaseAspect aspect)
        {
            if (aspect == null || aspect.Deleted)
            {
                return;
            }

            var map = aspect.Map;
            var x   = aspect.X;
            var y   = aspect.Y;
            var z   = aspect.Z;

            var count = Utility.RandomMinMax(5, 10);
            var sect  = 360 / count;

            var shift = Utility.RandomMinMax(0, sect);
            var range = Math.Max(3, aspect.RangePerception - 3);

            for (var i = 0; i < count; i++)
            {
                var t = Angle.GetPoint3D(x, y, z, shift + (i * sect), range);
                var l = aspect.PlotLine3D(t).TakeWhile(p => map.HasLand(p) && !map.HasWater(p));

                var q = new EffectQueue(range);

                var c = -1;

                foreach (var p in l)
                {
                    q.Add(
                        new EffectInfo(p, map, 14089, 0, 8, 15, EffectRender.Darken)
                    {
                        QueueIndex = ++c
                    });
                }

                if (q.Count == 0)
                {
                    q.Dispose();
                    continue;
                }

                q.Handler = fx =>
                {
                    var isEnd = fx.QueueIndex >= c;

                    if (!TryBurst(aspect, fx, ref isEnd) || isEnd)
                    {
                        q.Clear();
                    }
                };

                q.Callback = q.Dispose;

                Timer.DelayCall(
                    TimeSpan.FromSeconds(0.2 * i),
                    () =>
                {
                    aspect.Direction = aspect.GetDirection(t);

                    if (aspect.PlayAttackAnimation())
                    {
                        aspect.PlayAttackSound();
                    }

                    q.Process();
                });
            }
        }
		public static void SendSpiral(Mobile target)
		{
			var queue = new EffectQueue
			{
				Deferred = false
			};

			var points = new List<Point3D>();
			double d;
			double r = 1;
			int newx;
			int newy;
			points.Add(target.Location);
			//calculate spiral vector
			for (d = 0; d < 4 * Math.PI; d += 0.01)
			{
				newx = (int)Math.Floor(target.X + (Math.Sin(d) * d) * r);
				newy = (int)Math.Floor(target.Y + (Math.Sin(d + (Math.PI / 2)) * (d + (Math.PI / 2))) * r);
				var to = new Point3D(newx, newy, target.Z);
				if (!points.Contains(to))
				{
					points.Add(to);
				}
			}
			int n = 0;
			//Build the queue based on the points in the line.
			foreach (Point3D p in points)
			{
				n += 20;
				queue.Add(
					new EffectInfo(p, target.Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { }));
			}
			n += 400; //used to offset when the spiral reverses so it doesn't overlap
			foreach (Point3D p in points.AsEnumerable().Reverse())
			{
				n += 20;
				queue.Add(
					new EffectInfo(p, target.Map, 14089, 0, 10, 30, EffectRender.Normal, TimeSpan.FromMilliseconds(n), () => { }));
			}
			queue.Process();
			target.Frozen = false;
		}
        public void UltimaImpact_Callback(Point3D impactloc)
        {
            var queue = new EffectQueue();
            queue.Deferred = true;

            BaseExplodeEffect e = ExplodeFX.Smoke.CreateInstance(
                impactloc, Map, 4, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
                {
                    foreach (Mobile mobile in AcquireAllTargets(impactloc, 4))
                    {
                        if (mobile is PlayerMobile)
                        {
                            mobile.Damage(5, this);
                        }
                        else
                        {
                            mobile.Damage(25, this);
                        }
                    }
                });
            e.Send();

            queue.Process();
            CantWalk = false;
        }
Exemple #29
0
        public void DoAbilityMoltenBreath(BaseCreature target, BaseMetaPet pet)
        {
            pet.PlaySound(pet.BaseSoundID);
            pet.Animate(12, 5, 1, true, false, 0);

            var queue = new EffectQueue();

            queue.Deferred = false;

            Point3D endpoint = target.Location;

            Point3D[] line = pet.Location.GetLine3D(endpoint, pet.Map);

            if (target.InRange(pet.Location, 10))
            {
                int n = 0;
                foreach (Point3D p in line)
                {
                    n += 20;
                    Point3D p1 = p;
                    queue.Add(
                        new EffectInfo(
                            p,
                            pet.Map,
                            14089,
                            0,
                            10,
                            30,
                            EffectRender.Normal,
                            TimeSpan.FromMilliseconds(n),
                            () =>
                    {
                        foreach (Mobile player in AcquireTargets(pet, p1, 0))
                        {
                            player.Damage(Level * 9, pet);
                        }
                    }));
                }

                queue.Callback = () =>
                {
                    BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance(
                        endpoint, pet.Map, 2, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
                    {
                        foreach (Mobile mobile in AcquireTargets(pet, endpoint, 2))
                        {
                            mobile.Damage(Level * 8, pet);
                        }
                    });
                    e.Send();
                };


                queue.Process();
                Experience++;

                if (Experience >= NextLevelExperience)
                {
                    LevelUpMoltenBreath(pet.ControlMaster);
                }

                NextUse = DateTime.UtcNow + CoolDown;
            }
        }
Exemple #30
0
        public void SandMine_Callback()
        {
            List<Mobile> rangelist = AcquireTargets(Location, 15);
            int index = Utility.Random(rangelist.Count);
            if (index + 1 > rangelist.Count)
            {
                return;
            }

            var startloc = new Point3D(X, Y, Z);
            var point = new Point3D(rangelist[index].Location);

            var queue = new EffectQueue();
            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    4586,
                    0,
                    5,
                    EffectRender.Normal,
                    TimeSpan.FromSeconds(1),
                    () =>
                    {
                        var sandmine = new SandMine();
                        sandmine.MoveToWorld(point, Map);
                    }));
            queue.Process();
        }
        public void DoFireEffect(IPoint3D target, Mobile from)
        {
            Map map = Map;

            if (target == null || map == null)
            {
                return;
            }

            //NextUse = DateTime.UtcNow + TimeSpan.FromMinutes(1);

            var startloc = new Point3D(Location);
            IPoint3D point = target;

            switch (Facing)
            {
                case 3:
                    {
                        Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
                case 1:
                    {
                        Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
                case 2:
                    {
                        Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
                case 0:
                    {
                        Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                        break;
                    }
            }
            Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));

            var queue = new EffectQueue();
            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    3699,
                    0,
                    10,
                    EffectRender.Normal,
                    TimeSpan.FromSeconds(0.1),
                    () =>
                    {
                        for (int count = 8; count > 0; count--)
                        {
                            IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1),
                                target.Y + Utility.RandomMinMax(-1, 1), target.Z);
                            int effect = Utility.RandomList(0x36B0);
                            Effects.SendLocationEffect(location, map, effect, 25, 1);
                            Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));
                        }
                    }));
            queue.Process();
        }
Exemple #32
0
        public void DoFireEffect(IPoint3D target, Mobile from)
        {
            Map map = Map;

            if (target == null || map == null)
            {
                return;
            }

            //NextUse = DateTime.UtcNow + TimeSpan.FromMinutes(1);

            var      startloc = new Point3D(Location);
            IPoint3D point    = target;

            switch (Facing)
            {
            case 3:
            {
                Effects.SendLocationEffect(new Point3D(X, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case 1:
            {
                Effects.SendLocationEffect(new Point3D(X, Y - 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case 2:
            {
                Effects.SendLocationEffect(new Point3D(X + 1, Y, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }

            case 0:
            {
                Effects.SendLocationEffect(new Point3D(X - 1, Y + 1, Z - 2), map, Utility.RandomList(0x3728), 16, 1);
                break;
            }
            }
            Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));

            var queue = new EffectQueue();

            queue.Deferred = false;

            queue.Add(
                new MovingEffectInfo(
                    startloc,
                    point,
                    Map,
                    3699,
                    0,
                    10,
                    EffectRender.Normal,
                    TimeSpan.FromSeconds(0.1),
                    () =>
            {
                for (int count = 8; count > 0; count--)
                {
                    IPoint3D location = new Point3D(target.X + Utility.RandomMinMax(-1, 1),
                                                    target.Y + Utility.RandomMinMax(-1, 1), target.Z);
                    int effect = Utility.RandomList(0x36B0);
                    Effects.SendLocationEffect(location, map, effect, 25, 1);
                    Effects.PlaySound(target, map, Utility.RandomList(0x11B, 0x11C, 0x11D));
                }
            }));
            queue.Process();
        }
Exemple #33
0
        public void DoAbilityMoltenBreath(BaseCreature target, BaseMetaPet pet)
        {
            pet.AIObject.NextMove = DateTime.UtcNow + TimeSpan.FromSeconds(1.0);
            pet.PlaySound(pet.BaseSoundID);
            pet.Animate(12, 5, 1, true, false, 0);

            var queue = new EffectQueue();
            queue.Deferred = false;

            Point3D endpoint = target.Location;
            Point3D[] line = pet.Location.GetLine3D(endpoint, pet.Map);

            if (target.InRange(pet.Location, 10))
            {
                int n = 0;
                foreach (Point3D p in line)
                {
                    n += 20;
                    Point3D p1 = p;
                    queue.Add(
                        new EffectInfo(
                            p,
                            pet.Map,
                            14089,
                            0,
                            10,
                            30,
                            EffectRender.Normal,
                            TimeSpan.FromMilliseconds(n),
                            () =>
                            {
                                foreach (Mobile player in AcquireTargets(pet, p1, 0))
                                {
                                    player.Damage(Level * 5, pet);
                                }
                            }));
                }

                queue.Callback = () =>
                {
                    BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance(
                        endpoint, pet.Map, 2, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
                        {
                            foreach (Mobile mobile in AcquireTargets(pet, endpoint, 2))
                            {
                                mobile.Damage(Level * 3, pet);
                            }
                        });
                    e.Send();
                };


                queue.Process();
                Experience++;

                if (Experience >= NextLevelExperience)
                {
                    LevelUpMoltenBreath(pet.ControlMaster);
                }

                NextUse = DateTime.UtcNow + CoolDown;
            }
        }
Exemple #34
0
        public void MeteorImpact_Callback(Point3D impactloc)
        {
            var queue = new EffectQueue();
            queue.Deferred = true;

            for (int i = 0; i < 10; i++)
            {
                BaseExplodeEffect e = ExplodeFX.Fire.CreateInstance(
                    impactloc, Map, MeteorRange, 0, TimeSpan.FromMilliseconds(1000 - ((10) * 100)), null, () =>
                    {
                        foreach (Mobile target in AcquireTargets(impactloc, MeteorRange))
                        {
                            if (target is BaseCreature)
                                target.Damage(50, this);
                            else
                                target.Damage(10, this);
                        }
                    });
                e.Send();
            }
            queue.Process();
        }