Server.Spells.SpellHelper.FindValidSpawnLocation C# (CSharp) Méthode

FindValidSpawnLocation() public static méthode

public static FindValidSpawnLocation ( Map map, Point3D &p, bool surroundingsOnly ) : bool
map Map
p Point3D
surroundingsOnly bool
Résultat bool
		public static bool FindValidSpawnLocation( Map map, ref Point3D p, bool surroundingsOnly )
		{
			if( map == null )	//sanity
				return false;

			if( !surroundingsOnly )
			{
				if( map.CanSpawnMobile( p ) )	//p's fine.
				{
					p = new Point3D( p );
					return true;
				}

				int z = map.GetAverageZ( p.X, p.Y );

				if( map.CanSpawnMobile( p.X, p.Y, z ) )
				{
					p = new Point3D( p.X, p.Y, z );
					return true;
				}
			}

			int offset = Utility.Random( 8 ) * 2;

			for( int i = 0; i < m_Offsets.Length; i += 2 )
			{
				int x = p.X + m_Offsets[(offset + i) % m_Offsets.Length];
				int y = p.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length];

				if( map.CanSpawnMobile( x, y, p.Z ) )
				{
					p = new Point3D( x, y, p.Z );
					return true;
				}
				else
				{
					int z = map.GetAverageZ( x, y );

					if( map.CanSpawnMobile( x, y, z ) )
					{
						p = new Point3D( x, y, z );
						return true;
					}
				}
			}

			return false;
		}

Usage Example

Exemple #1
0
        public static void Summon(BaseCreature creature, Mobile caster, int sound, TimeSpan duration, bool scaleDuration, bool scaleStats)
        {
            Map map = caster.Map;

            if (map == null)
            {
                return;
            }

            double scale = 1.0 + (caster.Skills[SkillName.Magery].Value - 100.0) / 200.0;

            if (scaleDuration)
            {
                duration = TimeSpan.FromSeconds(duration.TotalSeconds * scale);
            }

            if (scaleStats)
            {
                creature.RawStr = (int)(creature.RawStr * scale);
                creature.Hits   = creature.HitsMax;

                creature.RawDex = (int)(creature.RawDex * scale);
                creature.Stam   = creature.StamMax;

                creature.RawInt = (int)(creature.RawInt * scale);
                creature.Mana   = creature.ManaMax;
            }

            Point3D p = new Point3D(caster);

            if (SpellHelper.FindValidSpawnLocation(map, ref p, true))
            {
                BaseCreature.Summon(creature, caster, p, sound, duration);
                return;
            }


            creature.Delete();
            caster.SendLocalizedMessage(501942);               // That location is blocked.
        }
All Usage Examples Of Server.Spells.SpellHelper::FindValidSpawnLocation