public static BaseCreature Spawn( int level, Point3D p, Map map, Mobile target, bool guardian )
{
if ( map == null )
return null;
BaseCreature c = Spawn( level, p, guardian );
if ( c != null )
{
bool spawned = false;
for ( int i = 0; !spawned && i < 10; ++i )
{
int x = p.X - 3 + Utility.Random( 7 );
int y = p.Y - 3 + Utility.Random( 7 );
if ( map.CanSpawnMobile( x, y, p.Z ) )
{
c.MoveToWorld( new Point3D( x, y, p.Z ), map );
spawned = true;
}
else
{
int z = map.GetAverageZ( x, y );
if ( map.CanSpawnMobile( x, y, z ) )
{
c.MoveToWorld( new Point3D( x, y, z ), map );
spawned = true;
}
}
}
if ( !spawned )
{
c.Delete();
return null;
}
if ( target != null )
c.Combatant = target;
return c;
}
return null;
}