GetSpawnPosition() public méthode

public GetSpawnPosition ( ) : Server.Point3D
Résultat Server.Point3D
Exemple #1
0
        // Description: Spawn as close-to or on-top-of the 'trash item' as possible.
        // Note1: you can for instance spawn atop a 'recall rune', but not a 'small crate'. This is because
        //	CanSpawnMobile() checks for the impassable flag when testing the destination point. the 'small crate' has impassable
        //  flags (i.e., you can't walk over it.) and the recall rune does not.
        // Note2: When spawning a groundskeeper on a roof to pick up trash, you want the groundskeeper on the same Z and as close
        //	to the item as possible else they may be spawned over-the-edge placing them on the gtound and unable to pick up the item.
        // It is for this reasons that we work so hard to place the groundskeeper as close to the 'trash' item as possible.
        private static Point3D SpawnClose(Item ix, object o)
        {
            Point3D location;

            // try 5 times at the same Z - starting close and moving outward
            for (int ir = 0; ir < 5; ir++)
            {
                location = Spawner.GetSpawnPosition(ix.Map, ix.Location, ir, true, o);
                if (location != ix.Location)
                {
                    return(location);
                }
            }

            // try 5 times at any Z - starting close and moving outward
            for (int ir = 0; ir < 5; ir++)
            {
                location = Spawner.GetSpawnPosition(ix.Map, ix.Location, ir, false, o);
                if (location != ix.Location)
                {
                    return(location);
                }
            }

            // give up
            return(ix.Location);
        }
		public Mobile SpawnAt( Spawner spawner, Mobile mob )
		{
			Map map = spawner.Map;

			if ( map == null || map == Map.Internal )
				return null;

			if ((mob is BaseCreature) == false)
				return null;

			try
			{
				BaseOverland bo = null;
				BaseCreature bc = mob as BaseCreature;
				// we will make it so this is passed in
				if (mob is BaseOverland)
					bo = mob as BaseOverland;

				// use the spawners homerange except when it is a special 'guard post' 
				//	spawner (HomeRange == 0)
				bc.RangeHome = spawner.HomeRange == 0? 10 : spawner.HomeRange;

				// could be useful ... but not today
				// c.CurrentWayPoint = spawner.WayPoint;
				// c.NavDestination = spawner.NavPoint;

				bc.Home = spawner.Location;
				bc.Spawner = spawner;
				
				//if we have a navdestination as soon as we spawn start on it
				if(bc.NavDestination != NavDestinations.None)
					bc.AIObject.Think();

				/////////////////////////////
				// move it to the world
				Point3D loc = spawner.GetSpawnPosition(bc);
				bc.MoveToWorld( loc, map );

				// Okay, indicate that this overland mob should be announced on the Town Crier
				// This must be after we are moved off the internal map because the accounce code
				//	supplies 'world location' information which would be wrong if we were still on the internal map
				if (bo != null)
					bo.Announce = true;

				return bc;
			}
			catch (Exception e) 
			{
				LogHelper.LogException(e);
				Console.WriteLine("Server.Engines.OverlandSpawner : Exception {0}", e);
			}

			return null;
		}