Esempio n. 1
0
        /// <summary>
        ///     Gets a collection of all objects of the given Type 'T' that are within 'range' of 'center' on the given 'map'.
        /// </summary>
        public static List <T> GetEntitiesInRange <T>(this IPoint3D center, Map map, int range) where T : IEntity
        {
            if (center == null || map == null || map == Map.Internal)
            {
                return(new List <T>());
            }

            range = Math.Abs(range);

            var ipe  = map.GetObjectsInRange(center.ToPoint3D(), range);
            var list = ipe.OfType <T>().ToList();

            ipe.Free();

            return(list);
        }
Esempio n. 2
0
        /// <summary>
        ///     Gets an ISpawner collection representing all ISpawners that are within 'range' of 'center' on the given 'map'.
        /// </summary>
        public static List <ISpawner> GetSpawnersInRange(this IPoint3D center, Map map, int range)
        {
            if (center == null || map == null || map == Map.Internal)
            {
                return(new List <ISpawner>());
            }

            range = Math.Abs(range);

            var ipe  = map.GetObjectsInRange(center.ToPoint3D(), range);
            var list = ipe.OfType <ISpawner>().ToList();

            ipe.Free();

            return(list);
        }
Esempio n. 3
0
        /// <summary>
        ///     Gets a collection of all objects of the given Type 'T' that are within 'range' of 'center' on the given 'map'.
        /// </summary>
        public static IEnumerable <T> FindEntitiesInRange <T>(this IPoint3D center, Map map, int range) where T : IEntity
        {
            if (center == null || map == null || map == Map.Internal)
            {
                yield break;
            }

            range = Math.Abs(range);

            var ipe = map.GetObjectsInRange(center.ToPoint3D(), range);

            foreach (var s in ipe.OfType <T>())
            {
                yield return(s);
            }

            ipe.Free();
        }
Esempio n. 4
0
		public static void IsThereVendor( Point3D location, Map map, out bool vendor, out bool rentalContract )
		{
			vendor = false;
			rentalContract = false;

			IPooledEnumerable eable = map.GetObjectsInRange( location, 0 );

			foreach ( IEntity entity in eable )
			{
				if ( Math.Abs( location.Z - entity.Z ) <= 16 )
				{
					if ( entity is PlayerVendor || entity is PlayerBarkeeper || entity is PlayerVendorPlaceholder )
					{
						vendor = true;
						break;
					}

					if ( entity is VendorRentalContract )
					{
						rentalContract = true;
						break;
					}
				}
			}

			eable.Free();
		}
Esempio n. 5
0
        public void Explode( Mobile from, bool direct, Point3D loc, Map map )
        {
            if ( Deleted )
                return;

            Consume();

            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;

            Effects.PlaySound( loc, map, 0x207 );
            Effects.SendLocationEffect( loc, map, 0x36BD, 20 );

            int alchemyBonus = 0;

            if ( direct )
                alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10));

            IPooledEnumerable eable = LeveledExplosion ? map.GetObjectsInRange( loc, ExplosionRange ) : map.GetMobilesInRange( loc, 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 BaseExplosionPotion && o != this )
                {
                    toExplode.Add( o );
                }
            }

            eable.Free();

            int min = Scale( from, MinDamage );
            int max = Scale( from, MaxDamage );

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

                if ( o is Mobile )
                {
                    Mobile m = (Mobile)o;

                    if ( from == null || (SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false )) )
                    {
                        if ( from != null )
                            from.DoHarmful( m );

                        int damage = Utility.RandomMinMax( min, max );

                        damage += alchemyBonus;

                        if ( !Core.AOS && damage > 40 )
                            damage = 40;
                        else if ( Core.AOS && toDamage > 2 )
                            damage /= toDamage - 1;

                        AOS.Damage( m, from, damage, 0, 100, 0, 0, 0 );
                    }
                }
                else if ( o is BaseExplosionPotion )
                {
                    BaseExplosionPotion pot = (BaseExplosionPotion)o;

                    pot.Explode( from, false, pot.GetWorldLocation(), pot.Map );
                }
            }
        }
Esempio n. 6
0
        public void Explode( bool direct, Point3D loc, Map map)
        {
            if (Deleted)
                return;

            Delete();

            if (map == null)
                return;

            Effects.PlaySound(loc, map, 0x207);
            for (int i = 0; i < 20; i++)
            {
                Point3D temp1 = new Point3D(loc.X, loc.Y, (loc.Z + i));
                Effects.SendLocationEffect(temp1, map, 0x3709, 60);
            }

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

            foreach (object o in eable)
            {
                if (o is Mobile)
                {
					if(o is ElementalChamp) { }
					else
	                    toExplode.Add(o);
                }

                else if (o is Atomic && o != this)
                {
                    toExplode.Add(o);
                }
            }

            eable.Free();

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

                if (o is Mobile)
                {
                    Mobile m = (Mobile)o;

                    Spells.SpellHelper.Damage(TimeSpan.FromTicks(0), m, 40);
                }
                else if (o is Atomic)
                {
                    Atomic pot = (Atomic)o;

                    pot.Explode( false, pot.GetWorldLocation(), pot.Map);
                }
            }
            if (map != null)
            {
                for (int x = -8; x <= 8; ++x)
                {
                    for (int y = -8; y <= 8; ++y)
                    {
                        double dist = Math.Sqrt(x * x + y * y);

                        if (dist <= 8)
                        {
                            Explotion(loc, map, X + x, Y + y);
                        }
                    }
                }
            }

        }
Esempio n. 7
0
	public void Explode( Mobile from, Point3D loc, Map map )
		{

			if ( map == null )
				return;

			Effects.PlaySound( loc, map, 0x207 );
			Effects.SendLocationEffect( loc, map, 0x36BD, 20 );


			IPooledEnumerable eable = map.GetObjectsInRange( loc, 2 ) ;
			ArrayList toExplode = new ArrayList();

			int toDamage = 0;

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

			eable.Free();
			int d = 0; // Damage scalar
			int damage = 0;
			for ( int i = 0; i < toExplode.Count; ++i )
			{
				object o;
				o = toExplode[i];
				
				if ( o is Mobile )
				{
					Mobile m = (Mobile)o;
					if ( m.InRange( loc, 0 ) )
						d = 1;
					else if ( m.InRange( loc, 1 ) )
						d = 2;
					else if ( m.InRange( loc, 2 ) )
						d = 3;
					if ( from != null || (SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false )) )
					{
						if ( from != null )
							from.DoHarmful( m );
						damage = Utility.RandomMinMax( (MinDamage / d), (MaxDamage / d) );
						if( d == 1 )
							AOS.Damage( m, from, damage, 50, 50, 0, 0, 0 ); // Same tile 50% physical 50% fire
						else
							AOS.Damage( m, from, damage, 0, 100, 0, 0, 0 ); // 2 tile radius 100% fire damage
					}
				}
				else if ( o is BaseExplosionPotion )
				{
					BaseExplosionPotion pot = (BaseExplosionPotion)o;
					pot.Explode( from, true, pot.GetWorldLocation(), pot.Map );
				}
				else if ( o is ICannonDamage )
				{
					//((ICannonDamage)o).Hits -=  Utility.RandomMinMax(MinDamage/3,MaxDamage/3);
					((ICannonDamage)o).Damage(from,Utility.RandomMinMax(MinDamage/3,MaxDamage/3));
				}
			}
		}
Esempio n. 8
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 );
                }
            }
        }
		public void Explode( Mobile from, bool direct, Point3D loc, Map map )
		{
			if ( Deleted )
				return;

			Consume();

			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;

			Effects.SendLocationParticles( EffectItem.Create( loc, map, EffectItem.DefaultDuration ), 0x36B0, 1, 14, 63, 7, 9915, 0 );
			Effects.PlaySound( loc, map, 0x229 );

			IPooledEnumerable eable = LeveledExplosion ? map.GetObjectsInRange( loc, ExplosionRange ) : map.GetMobilesInRange( loc, 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 BasePoisonExplosionPotion && o != this )
				{
					toExplode.Add( o );
				}
			}

			eable.Free();

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

				if ( o is Mobile )
				{
					Mobile m = (Mobile)o;

					if ( from == null || (SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false )) )
					{
						if ( from != null )
							from.DoHarmful( m );
							
						int level = 0;
						if( this.PotionEffect == PotionEffect.ExplosionLesser )
						{
							level = 1;
						}
						else if ( this.PotionEffect == PotionEffect.Explosion )
						{
							level = 2;
						}
						else if ( this.PotionEffect == PotionEffect.ExplosionGreater )
						{
							level = 3;
						}
							
						m.ApplyPoison( from, Poison.GetPoison(level) );
					}
				}
				else if ( o is BasePoisonExplosionPotion )
				{
					BasePoisonExplosionPotion pot = (BasePoisonExplosionPotion)o;

					pot.Explode( from, false, pot.GetWorldLocation(), pot.Map );
				}
			}
		}
Esempio n. 10
0
      private void Explode( Mobile from, Point3D loc, Map map )
      {
         if ( map == null )
            return;

         Effects.PlaySound( loc, map, 0x207 );
         Effects.SendLocationEffect( loc, map, 0x36BD, 20 );
         IPooledEnumerable eable = map.GetObjectsInRange( loc, 2 );
         ArrayList toExplode = new ArrayList();

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

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

            if ( o is Mobile )
            {
               Mobile m = (Mobile)o;
               if ( m.InRange( loc, 0 ) )
                  d = 1;
               else if ( m.InRange( loc, 1 ) )
                  d = 2;
               else if ( m.InRange( loc, 2 ) )
                  d = 3;
               if ( from == null || (SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false )) )
               {
                  if ( from != null )
                     from.DoHarmful( m );

                  int damage = Utility.RandomMinMax( (60 / d), (80 / d) );

                  AOS.Damage( m, from, damage, 0, 100, 0, 0, 0 );
               }
            }
            else if ( o is BaseExplosionPotion )
            {
               BaseExplosionPotion pot = (BaseExplosionPotion)o;

               pot.Explode( from, false, pot.GetWorldLocation(), pot.Map );
            }
         }
      }
Esempio n. 11
0
		public void Explode( Mobile from, bool direct, Point3D loc, Map map )
		{
			PBGrenade nade = this;
			if ( Deleted )
				return;

			Consume();

			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.Nade == this )
					Target.Cancel( m );
			}

			if ( map == null )
				return;

			Effects.PlaySound( loc, map, 0x207 );
			Effects.SendLocationEffect( loc, map, 0x36BD, 35, this.Hue, 0 );

			int alchemyBonus = 0;

			if ( direct )
				alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10));

			IPooledEnumerable eable = LeveledExplosion ? map.GetObjectsInRange( loc, ExplosionRange ) : map.GetMobilesInRange( loc, 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 PBGrenade && o != this )
				{
					toExplode.Add( o );
				}
			}

			eable.Free();

		

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

				if ( o is Mobile )
				{
					Mobile m = (Mobile)o;

					if ( from == null || (SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false )) )
					{
						if ( from != null )
							//from.DoHarmful( m );
							
							if ( m_PBGI.Players.Contains(m) || m_PBGI.NpcPlayers.Contains(m) )
							{
							DoDamage( nade, from, m );
							}
							else
							{
							from.SendMessage( "You cannot attack someone that is not playing!" );
				            m.SendMessage( "You are not playing Paintball, please leave the area." );
							}

					

						/*

						if ( !Core.AOS && damage > 40 )
							damage = 40;
						else if ( Core.AOS && toDamage > 2 )
							damage /= toDamage - 1;

						AOS.Damage( m, from, damage, 0, 100, 0, 0, 0 ); */
					}
				}
				else if ( o is PBGrenade )
				{
					PBGrenade pot = (PBGrenade)o;

					pot.Explode( from, false, pot.GetWorldLocation(), pot.Map );
				}
				else
				{
					DoDamage( nade, from );
				}
			}
		}
        public void Explode( Mobile from, Point3D loc, Map map )
        {
            if ( Deleted )
                return;

            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;

            Effects.PlaySound( loc, map, 0x207 );
            Effects.SendLocationEffect( loc, map, 0x36BD, 20 );

            IPooledEnumerable eable = map.GetObjectsInRange( loc, ExplosionRange );
            ArrayList toExplode = new ArrayList();
            foreach ( object o in eable )
            {
                if ( o is Mobile )
                {
                    toExplode.Add( o );
                    AddPotions( ((Mobile)o).Backpack, toExplode );
                }
                else if ( o is Item )
                {
                    if ( o is BaseExplosionPotion && o != this )
                        toExplode.Add( o );
                    else if ( ((Item)o).Items.Count > 0 )
                        AddPotions( (Item)o, toExplode );
                }
            }

            eable.Free();

            int min = Scale( from, MinDamage );
            int max = Scale( from, MaxDamage );

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

                if ( o is Mobile )
                {
                    Mobile m = (Mobile)o;

                    int dist = (int)m.GetDistanceToSqrt( loc );
                    if ( dist > ExplosionRange )
                        continue;

                    if ( from == null || from.CanBeHarmful( m, false ) )
                    {
                        if ( from != null )
                            from.DoHarmful( m );
                        m.Damage( (int)( Utility.RandomMinMax( min, max ) * 3.0/4.0 ) );
                    }
                }
                else if ( o is BaseExplosionPotion )
                {
                    BaseExplosionPotion pot = (BaseExplosionPotion)o;

                    //pot.Explode( from, false, pot.GetWorldLocation(), pot.Map );
                    if ( ( pot.m_Timer == null || !pot.m_Timer.Running ) && !pot.Deleted )
                    {
                        Point3D pp = pot.GetWorldLocation();
                        int x, y, z;
                        double val;
                        x = pp.X - loc.X;
                        y = pp.Y - loc.Y;
                        z = pp.Z - loc.Z;

                        if ( x == 0 && y == 0 && z == 0 )
                        {
                            val = 0;
                        }
                        else
                        {
                            val = Math.Sqrt( x*x + y*y );
                            val = Math.Sqrt( val*val + z*z );
                        }

                        if ( (int)val <= ExplosionRange )
                        {
                            val += Utility.Random( 4 );
                            if ( val < 1 )
                                val = 0;

                            pot.m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 0.75 ), TimeSpan.FromSeconds( 1.0 ), ((int)val)+1, new TimerStateCallback( pot.Detonate_OnTick ), new object[]{from, ((int)val)} );
                        }
                    }
                }
            }

            Delete();
        }
      public void Explode( Mobile from, bool direct, Point3D loc, Map map )
      {
         if ( Deleted )
            return;

         Delete();

         if ( map == null )
            return;

         Effects.PlaySound( loc, map, 0x207 );
         for( int i=0; i<20;i++)
         {
            Point3D temp1 = new Point3D( loc.X, loc.Y, (loc.Z + i));
            Effects.SendLocationEffect( temp1, map, 0x3709, 60 );
         }

         int alchemyBonus = direct ? (int)(from.Skills[SkillName.Alchemy].Value / 10) : 0;

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

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

         eable.Free();

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

            if ( o is Mobile )
            {
               Mobile m = (Mobile)o;

               if ( from == null || (SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false )) )
               {
                  if ( from != null )
                     from.DoHarmful( m );

                  int damage = Utility.RandomMinMax( MinDamage, MaxDamage );

                  damage += alchemyBonus;

                  if ( damage > 40 )
                     damage = 40;

                  AOS.Damage( from, damage, 0, 100, 0, 0, 0 );
               }
            }
            else if ( o is BaseAtomicBomb )
            {
               BaseAtomicBomb pot = (BaseAtomicBomb)o;

               pot.Explode( from, false, pot.GetWorldLocation(), pot.Map );
            }
         }
         if ( map != null )
         {
            for ( int x = -8; x <= 8; ++x )
            {
               for ( int y = -8; y <= 8; ++y )
               {
                  double dist = Math.Sqrt(x*x+y*y);

                  if ( dist <= 8 )
                  {
                     Explotion( loc, map, X + x, Y + y );
                  }
               }
            }
         }

      }