Exemplo n.º 1
0
        public override void OnExplode( Mobile source, Item itemSource, int intensity, Point3D loc, Map map )
        {
            Server.Effects.PlaySound( loc, map, 0x22F );
            if ( itemSource is BombPotion )
            {
                BombPotion bomb = itemSource as BombPotion;
                int delay = (int)(intensity * Divisor);
                if ( delay <= 0 )
                    delay = 1;
                TimeSpan time = TimeSpan.FromSeconds( delay );

                List<Point3D> circlePoints = CircleHelper.CircleMidpoint( loc.X, loc.Y, loc.Z, bomb.ExplosionRange, true );
                Point3D eye = new Point3D( loc );
                eye.Z += 14;
                foreach( Point3D point in circlePoints )
                {
                    Point3D target = new Point3D(point);
                    target.Z += 14;
                    if ( map.LineOfSight( eye, target ) )
                    {
                        SmokeTile tile = new SmokeTile( time+TimeSpan.FromSeconds( Utility.RandomDouble()*5 ) );
                        tile.MoveToWorld( point, map );
                        tile.AddCurrentOccupants();
                    }
                }
            }
        }
Exemplo n.º 2
0
 public override void OnExplode( Mobile source, Item itemSource, int intensity, Point3D loc, Map map )
 {
     //Server.Effects.PlaySound( loc, map, 0x3B9 );
     foreach ( Mobile m in map.GetMobilesInRange( loc, ((BombPotion)itemSource).ExplosionRange ) )
         if ( m != null )
             if ( map.LineOfSight( loc, m ) )
                 m.MovingEffect( new Entity( Serial.Zero, loc, map ), 10244, 18, 1, false, false );
 }
Exemplo n.º 3
0
        public static Point3D GetRandomPoint3D(
            this IPoint3D start,
            int minRange,
            int maxRange,
            Map map,
            bool checkLOS,
            bool checkSpawn)
        {
            if ((map == null || map == Map.Internal) && start is IEntity)
            {
                map = ((IEntity)start).Map;
            }

            double  a, r;
            int     x, y;
            Point3D s, p;

            var c = 30;

            do
            {
                a = Utility.RandomDouble() * Math.PI * 2;
                r = minRange + (Math.Sqrt(Utility.RandomDouble()) * (maxRange - minRange));

                x = (int)(r * Math.Cos(a));
                y = (int)(r * Math.Sin(a));

                s = start.Clone3D(0, 0, 16);
                p = start.Clone3D(x, y);

                if (map != null)
                {
                    p = p.GetSurfaceTop(map);
                }

                if (map == null || ((!checkLOS || map.LineOfSight(s, p)) && (!checkSpawn || map.CanSpawnMobile(p))))
                {
                    break;
                }
            }while (--c >= 0);

            if (c >= 0)
            {
                return(p);
            }

            if (map != null)
            {
                return(start.GetSurfaceTop(map));
            }

            return(start.ToPoint3D());
        }
Exemplo n.º 4
0
 public override void OnExplode( Mobile source, Item itemSource, int intensity, Point3D loc, Map map )
 {
     Server.Effects.PlaySound( loc, map, 283 + Utility.Random( 4 ) );
     if ( itemSource is BombPotion )
     {
         BombPotion bomb = itemSource as BombPotion;
         List<Point3D> circlePoints = CircleHelper.CircleMidpoint( loc.X, loc.Y, loc.Z, bomb.ExplosionRange, true );
         Point3D eye = new Point3D( loc );
         eye.Z += 14;
         foreach( Point3D point in circlePoints )
         {
             Point3D target = new Point3D(point);
             target.Z += 14;
             if ( map.LineOfSight( eye, target ) )
                 Server.Effects.SendLocationEffect( point, map, 0x36BD, 20 );
         }
     }
 }
Exemplo n.º 5
0
        public override void OnExplode( Mobile source, Item itemSource, int intensity, Point3D loc, Map map )
        {
            Server.Effects.PlaySound( loc, map, 456 + Utility.Random( 3 ) );
            int range = 5;

            if ( itemSource is BombPotion )
                range = ((BombPotion)itemSource).ExplosionRange;

            int delay = (int)(intensity * Divisor);

            if ( delay <= 0 )
                delay = 1;

            TimeSpan time = TimeSpan.FromSeconds( delay );

            Point3D start = new Point3D( loc.X-range, loc.Y-range, loc.Z );
            Point3D end = new Point3D( loc.X+range, loc.Y+range, loc.Z );
            StickyGooRegion region = new StickyGooRegion( source, new Rectangle3D(
                start.X, start.Y, start.Z, end.X - start.X + 1, end.Y - start.Y + 1, 1
            ) );

            region.Register();
            Timer.DelayCall( time, new TimerStateCallback( ReleaseRegion ), region );

            List<Point3D> circlePoints = CircleHelper.CircleMidpoint( loc.X, loc.Y, loc.Z, range, true );
            Point3D eye = new Point3D( loc );
            eye.Z += 14;

            foreach( Point3D point in circlePoints )
            {
                Point3D target = new Point3D(point);
                target.Z += 14;
                if ( map.LineOfSight( eye, target ) )
                    new StickyGooTile( time+TimeSpan.FromSeconds( Utility.RandomDouble()*5 ) ).MoveToWorld( point, map );
            }
        }
Exemplo n.º 6
0
        public void Explode( Mobile from, bool direct, Point3D loc, Map map )
        {
            if ( Deleted )
                return;

            Delete();

            for ( int i = 0; m_Users != null && i < m_Users.Count; ++i )
            {
                Mobile m = (Mobile)m_Users[i];
                ThrowTarget targ = m.Target as ThrowTarget;

                if ( targ != null && targ.Potion == this )
                    Target.Cancel( m );
            }

            if ( map == null )
            {
                return;
            }

            IPooledEnumerable eable = LeveledExplosion ? map.GetObjectsInRange( loc, m_ExplosionRange ) : map.GetMobilesInRange( loc, m_ExplosionRange );
            ArrayList toExplode = new ArrayList();

            int toDamage = 0;

            foreach ( object o in eable )
            {
                if ( o is Mobile )
                {
                    toExplode.Add( o );
                    ++toDamage;
                }
                else if ( o is BombPotion && o != this )
                {
                    toExplode.Add( o );
                }
            }

            eable.Free();

            foreach ( KeyValuePair<CustomEffect, int> kvp in Effects )
            {
                CustomPotionEffect effect = CustomPotionEffect.GetEffect( kvp.Key );
                if ( effect != null )
                    effect.OnExplode( from, this, kvp.Value, loc, map );
            }

            Point3D eye = new Point3D( loc );
            eye.Z += 14;

            for ( int i = 0; i < toExplode.Count; ++i )
            {
                object o = toExplode[i];

                if ( o is Mobile )
                {
                    Mobile m = (Mobile)o;
                    Point3D target = new Point3D( m.Location );
                    target.Z += 14;

                    if ( from == null || (SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false )) )
                    {
                        if ( o != null && map.LineOfSight( eye, target ) )
                        {
                            foreach ( KeyValuePair<CustomEffect, int> kvp in Effects )
                            {
                                CustomPotionEffect effect = CustomPotionEffect.GetEffect( kvp.Key );
                                if ( effect != null )
                                    effect.ApplyEffect( m, from, kvp.Value, this );
                            }
                        }
                    }
                }
                else if ( o is BombPotion )
                {
                    BombPotion pot = (BombPotion)o;
                    Point3D target = new Point3D( pot.Location );
                    target.Z += 14;
                    if ( o != null && map.LineOfSight( eye, target ) )
                        pot.Explode( from, false, pot.GetWorldLocation(), pot.Map );
                }
            }
        }
Exemplo n.º 7
0
        public static Point3D GetSpawnPosition(Point3D from, Map map, int range)
        {
            if (map == null)
                return from;

            for (int i = 0; i < 10; i++)
            {
                int x = from.X + Utility.Random(range);
                int y = from.Y + Utility.Random(range);
                int z = map.GetAverageZ(x, y);

                if (Utility.RandomBool())
                    x *= -1;

                if (Utility.RandomBool())
                    y *= -1;

                Point3D p = new Point3D(x, y, from.Z);

                if (map.CanSpawnMobile(p) && map.LineOfSight(from, p))
                    return p;

                p = new Point3D(x, y, z);

                if (map.CanSpawnMobile(p) && map.LineOfSight(from, p))
                    return p;
            }

            return from;
        }