Beispiel #1
0
		public static void XmlLoadFromStream( Stream fs, string filename, string SpawnerPrefix, Mobile from, Point3D fromloc, Map frommap, bool loadrelative, int maxrange, bool loadnew, out int processedmaps, out int processedspawners, bool verbose )
		{

			processedmaps = 0;
			processedspawners = 0;

			if( fs == null ) return;

			// assign an id that will be used to distinguish the newly loaded spawners by appending it to their name
			Guid newloadid = Guid.NewGuid();


			int TotalCount = 0;
			int TrammelCount = 0;
			int FeluccaCount = 0;
			int IlshenarCount = 0;
			int MalasCount = 0;
			int TokunoCount = 0;
			int OtherCount = 0;
			bool questionable_spawner = false;
			bool bad_spawner = false;
			int badcount = 0;
			int questionablecount = 0;

			int failedobjectitemcount = 0;
			int failedsetitemcount = 0;
			int relativex = -1;
			int relativey = -1;
			int relativez = 0;
			Map relativemap = null;

			if( from != null )
				from.SendMessage( string.Format( "Loading {0} objects{1} from file {2}.", "XmlSpawner",
					((SpawnerPrefix != null && SpawnerPrefix.Length > 0) ? " beginning with " + SpawnerPrefix : string.Empty), filename ) );

			// Create the data set
			DataSet ds = new DataSet( SpawnDataSetName );

			// Read in the file
			bool fileerror = false;
			try
			{
				ds.ReadXml( fs );
			}
			catch
			{
				if( from != null )
					from.SendMessage( 33, "Error reading xml file {0}", filename );
				fileerror = true;
			}
			// close the file
			fs.Close();
			if( fileerror ) return;

			// Check that at least a single table was loaded
			if( ds.Tables != null && ds.Tables.Count > 0 )
			{
				// Add each spawn point to the current map
				if( ds.Tables[SpawnTablePointName] != null && ds.Tables[SpawnTablePointName].Rows.Count > 0 )
					foreach( DataRow dr in ds.Tables[SpawnTablePointName].Rows )
					{
						// load in the spawner info.  Certain fields are required and therefore cannot be ignored
						// the exception handler for those will flag bad_spawner and the result will be logged

						// Each row makes up a single spawner
						string SpawnName = "Spawner";
						try { SpawnName = (string)dr["Name"]; }
						catch { questionable_spawner = true; }

						if( loadnew )
						{
							// append the new id to the name
							SpawnName = String.Format( "{0}-{1}", SpawnName, newloadid );
						}

						// Check if there is any spawner name criteria specified on the load
						if( (SpawnerPrefix == null) || (SpawnerPrefix.Length == 0) || (SpawnName.StartsWith( SpawnerPrefix ) == true) )
						{
							// Try load the GUID (might not work so create a new GUID)
							Guid SpawnId = Guid.NewGuid();
							if( !loadnew )
							{
								try { SpawnId = new Guid( (string)dr["UniqueId"] ); }
								catch { }
							}
							else
							{
								// change the dataset guid to the newly created one when new loading
								try
								{
									dr["UniqueId"] = SpawnId;
								}
								catch { Console.WriteLine( "unable to set UniqueId" ); }
							}

							int SpawnCentreX = fromloc.X;
							int SpawnCentreY = fromloc.Y;
							int SpawnCentreZ = fromloc.Z;

							try { SpawnCentreX = int.Parse( (string)dr["CentreX"] ); }
							catch { bad_spawner = true; }
							try { SpawnCentreY = int.Parse( (string)dr["CentreY"] ); }
							catch { bad_spawner = true; }
							try { SpawnCentreZ = int.Parse( (string)dr["CentreZ"] ); }
							catch { bad_spawner = true; }

							int SpawnX = SpawnCentreX;
							int SpawnY = SpawnCentreY;
							int SpawnWidth = 0;
							int SpawnHeight = 0;
							try { SpawnX = int.Parse( (string)dr["X"] ); }
							catch { questionable_spawner = true; }
							try { SpawnY = int.Parse( (string)dr["Y"] ); }
							catch { questionable_spawner = true; }
							try { SpawnWidth = int.Parse( (string)dr["Width"] ); }
							catch { questionable_spawner = true; }
							try { SpawnHeight = int.Parse( (string)dr["Height"] ); }
							catch { questionable_spawner = true; }

							// Try load the InContainer (default to false)
							bool InContainer = false;
							int ContainerX = 0;
							int ContainerY = 0;
							int ContainerZ = 0;
							try { InContainer = bool.Parse( (string)dr["InContainer"] ); }
							catch { }
							if( InContainer )
							{
								try { ContainerX = int.Parse( (string)dr["ContainerX"] ); }
								catch { }
								try { ContainerY = int.Parse( (string)dr["ContainerY"] ); }
								catch { }
								try { ContainerZ = int.Parse( (string)dr["ContainerZ"] ); }
								catch { }
							}

							// Get the map (default to the mobiles map) if the relative distance is too great, then use the defined map

							Map SpawnMap = frommap;

							string XmlMapName = frommap.Name;

							//if(!loadrelative && !loadnew)
							{
								// Try to get the "map" field, but in case it doesn't exist, catch and discard the exception
								try { XmlMapName = (string)dr["Map"]; }
								catch { questionable_spawner = true; }

								// Convert the xml map value to a real map object
								if( string.Compare( XmlMapName, Map.Trammel.Name, true ) == 0 || XmlMapName == "Trammel" )
								{
									SpawnMap = Map.Trammel;
									TrammelCount++;
								}
								else if( string.Compare( XmlMapName, Map.Felucca.Name, true ) == 0 || XmlMapName == "Felucca" )
								{
									SpawnMap = Map.Felucca;
									FeluccaCount++;
								}
								else if( string.Compare( XmlMapName, Map.Ilshenar.Name, true ) == 0 || XmlMapName == "Ilshenar" )
								{
									SpawnMap = Map.Ilshenar;
									IlshenarCount++;
								}
								else if( string.Compare( XmlMapName, Map.Malas.Name, true ) == 0 || XmlMapName == "Malas" )
								{
									SpawnMap = Map.Malas;
									MalasCount++;
								}
								else if( string.Compare( XmlMapName, Map.Tokuno.Name, true ) == 0 || XmlMapName == "Tokuno" )
								{
									SpawnMap = Map.Tokuno;
									TokunoCount++;
								}
								else
								{
									try
									{
										SpawnMap = Map.Parse( XmlMapName );
									}
									catch { }
									OtherCount++;
								}
							}

							// test to see whether the distance between the relative center point and the spawner is too great.  If so then dont do relative
							if( relativex == -1 && relativey == -1 )
							{
								// the first xml entry in the file will determine the origin
								relativex = SpawnCentreX;
								relativey = SpawnCentreY;
								relativez = SpawnCentreZ;

								// and also the relative map to relocate from
								relativemap = SpawnMap;
							}

							int SpawnRelZ = 0;
							int OrigZ = SpawnCentreZ;
							if( loadrelative && (Math.Abs( relativex - SpawnCentreX ) <= maxrange) && (Math.Abs( relativey - SpawnCentreY ) <= maxrange)
								&& (SpawnMap == relativemap) )
							{
								// its within range so shift it
								SpawnCentreX -= relativex - fromloc.X;
								SpawnCentreY -= relativey - fromloc.Y;
								SpawnX -= relativex - fromloc.X;
								SpawnY -= relativey - fromloc.Y;
								// force it to autosearch for Z when it places it but hold onto relative Z info just in case it can be placed there
								SpawnRelZ = relativez - fromloc.Z;
								SpawnCentreZ = short.MinValue;
							}

							// if relative loading has been specified, see if the loaded map is the same as the relativemap and relocate.
							// if it doesnt match then just leave it
							if( loadrelative && (relativemap == SpawnMap) )
							{
								SpawnMap = frommap;
							}


							if( SpawnMap == Map.Internal ) bad_spawner = true;

							// Try load the IsRelativeHomeRange (default to true)
							bool SpawnIsRelativeHomeRange = true;
							try { SpawnIsRelativeHomeRange = bool.Parse( (string)dr["IsHomeRangeRelative"] ); }
							catch { }


							int SpawnHomeRange = 5;
							try { SpawnHomeRange = int.Parse( (string)dr["Range"] ); }
							catch { questionable_spawner = true; }
							int SpawnMaxCount = 1;
							try { SpawnMaxCount = int.Parse( (string)dr["MaxCount"] ); }
							catch { questionable_spawner = true; }

							//deal with double format for delay.  default is the old minute format
							bool delay_in_sec = false;
							try { delay_in_sec = bool.Parse( (string)dr["DelayInSec"] ); }
							catch { }
							TimeSpan SpawnMinDelay = TimeSpan.FromMinutes( 5 );
							TimeSpan SpawnMaxDelay = TimeSpan.FromMinutes( 10 );


							if( delay_in_sec )
							{
								try { SpawnMinDelay = TimeSpan.FromSeconds( int.Parse( (string)dr["MinDelay"] ) ); }
								catch { }
								try { SpawnMaxDelay = TimeSpan.FromSeconds( int.Parse( (string)dr["MaxDelay"] ) ); }
								catch { }
							}
							else
							{
								try { SpawnMinDelay = TimeSpan.FromMinutes( int.Parse( (string)dr["MinDelay"] ) ); }
								catch { }
								try { SpawnMaxDelay = TimeSpan.FromMinutes( int.Parse( (string)dr["MaxDelay"] ) ); }
								catch { }
							}
							TimeSpan SpawnMinRefractory = TimeSpan.FromMinutes( 0 );
							try { SpawnMinRefractory = TimeSpan.FromMinutes( double.Parse( (string)dr["MinRefractory"] ) ); }
							catch { }

							TimeSpan SpawnMaxRefractory = TimeSpan.FromMinutes( 0 );
							try { SpawnMaxRefractory = TimeSpan.FromMinutes( double.Parse( (string)dr["MaxRefractory"] ) ); }
							catch { }

							TimeSpan SpawnTODStart = TimeSpan.FromMinutes( 0 );
							try { SpawnTODStart = TimeSpan.FromMinutes( double.Parse( (string)dr["TODStart"] ) ); }
							catch { }

							TimeSpan SpawnTODEnd = TimeSpan.FromMinutes( 0 );
							try { SpawnTODEnd = TimeSpan.FromMinutes( double.Parse( (string)dr["TODEnd"] ) ); }
							catch { }

							int todmode = (int)TODModeType.Realtime;
							TODModeType SpawnTODMode = TODModeType.Realtime;
							try { todmode = int.Parse( (string)dr["TODMode"] ); }
							catch { }
							switch( (int)todmode )
							{
								case (int)TODModeType.Gametime:
									SpawnTODMode = TODModeType.Gametime;
									break;
								case (int)TODModeType.Realtime:
									SpawnTODMode = TODModeType.Realtime;
									break;
							}

							int SpawnKillReset = defKillReset;
							try { SpawnKillReset = int.Parse( (string)dr["KillReset"] ); }
							catch { }

							string SpawnProximityMessage = null;
							// proximity message
							try { SpawnProximityMessage = (string)dr["ProximityTriggerMessage"]; }
							catch { }

							string SpawnItemTriggerName = null;
							try { SpawnItemTriggerName = (string)dr["ItemTriggerName"]; }
							catch { }

							string SpawnNoItemTriggerName = null;
							try { SpawnNoItemTriggerName = (string)dr["NoItemTriggerName"]; }
							catch { }

							string SpawnSpeechTrigger = null;
							try { SpawnSpeechTrigger = (string)dr["SpeechTrigger"]; }
							catch { }

							string SpawnSkillTrigger = null;
							try { SpawnSkillTrigger = (string)dr["SkillTrigger"]; }
							catch { }

							string SpawnMobTriggerName = null;
							try { SpawnMobTriggerName = (string)dr["MobTriggerName"]; }
							catch { }
							string SpawnMobPropertyName = null;
							try { SpawnMobPropertyName = (string)dr["MobPropertyName"]; }
							catch { }
							string SpawnPlayerPropertyName = null;
							try { SpawnPlayerPropertyName = (string)dr["PlayerPropertyName"]; }
							catch { }

							double SpawnTriggerProbability = 1;
							try { SpawnTriggerProbability = double.Parse( (string)dr["TriggerProbability"] ); }
							catch { }

							int SpawnSequentialSpawning = -1;
							try { SpawnSequentialSpawning = int.Parse( (string)dr["SequentialSpawning"] ); }
							catch { }

							string SpawnRegionName = null;
							try { SpawnRegionName = (string)dr["RegionName"]; }
							catch { }

							string SpawnConfigFile = null;
							try { SpawnConfigFile = (string)dr["ConfigFile"]; }
							catch { }

							bool SpawnAllowGhost = false;
							try { SpawnAllowGhost = bool.Parse( (string)dr["AllowGhostTriggering"] ); }
							catch { }

							bool SpawnAllowNPC = false;
							try { SpawnAllowNPC = bool.Parse( (string)dr["AllowNPCTriggering"] ); }
							catch { }

							bool SpawnSpawnOnTrigger = false;
							try { SpawnSpawnOnTrigger = bool.Parse( (string)dr["SpawnOnTrigger"] ); }
							catch { }

							bool SpawnSmartSpawning = false;
							try { SpawnSmartSpawning = bool.Parse( (string)dr["SmartSpawning"] ); }
							catch { }

							string SpawnObjectPropertyName = null;
							try { SpawnObjectPropertyName = (string)dr["ObjectPropertyName"]; }
							catch { }

							// read in the object proximity target, this will be an object name, so have to do a search
							// to find the item in the world.  Also have to test for redundancy
							string triggerObjectName = null;
							try { triggerObjectName = (string)dr["ObjectPropertyItemName"]; }
							catch { }

							// read in the target for the set command, this will be an object name, so have to do a search
							// to find the item in the world.  Also have to test for redundancy
							string setObjectName = null;
							try { setObjectName = (string)dr["SetPropertyItemName"]; }
							catch { }

							// we will assign this during the self-reference resolution pass
							Item SpawnSetPropertyItem = null;

							// we will assign this during the self-reference resolution pass
							Item SpawnObjectPropertyItem = null;

							// read the duration parameter from the xml file
							// but older files wont have it so deal with that condition and set it to the default of "0", i.e. infinite duration
							// Try to get the "Duration" field, but in case it doesn't exist, catch and discard the exception
							TimeSpan SpawnDuration = TimeSpan.FromMinutes( 0 );
							try { SpawnDuration = TimeSpan.FromMinutes( double.Parse( (string)dr["Duration"] ) ); }
							catch { }

							TimeSpan SpawnDespawnTime = TimeSpan.FromHours( 0 );
							try { SpawnDespawnTime = TimeSpan.FromHours( double.Parse( (string)dr["DespawnTime"] ) ); }
							catch { }
							int SpawnProximityRange = -1;
							// Try to get the "ProximityRange" field, but in case it doesn't exist, catch and discard the exception
							try { SpawnProximityRange = int.Parse( (string)dr["ProximityRange"] ); }
							catch { }

							int SpawnProximityTriggerSound = 0;
							// Try to get the "ProximityTriggerSound" field, but in case it doesn't exist, catch and discard the exception
							try { SpawnProximityTriggerSound = int.Parse( (string)dr["ProximityTriggerSound"] ); }
							catch { }

							int SpawnAmount = 1;
							try { SpawnAmount = int.Parse( (string)dr["Amount"] ); }
							catch { }

							bool SpawnExternalTriggering = false;
							try { SpawnExternalTriggering = bool.Parse( (string)dr["ExternalTriggering"] ); }
							catch { }

							string waypointstr = null;
							try { waypointstr = (string)dr["Waypoint"]; }
							catch { }

							WayPoint SpawnWaypoint = GetWaypoint( waypointstr );

							int SpawnTeam = 0;
							try { SpawnTeam = int.Parse( (string)dr["Team"] ); }
							catch { questionable_spawner = true; }
							bool SpawnIsGroup = false;
							try { SpawnIsGroup = bool.Parse( (string)dr["IsGroup"] ); }
							catch { questionable_spawner = true; }
							bool SpawnIsRunning = false;
							try { SpawnIsRunning = bool.Parse( (string)dr["IsRunning"] ); }
							catch { questionable_spawner = true; }
							// try loading the new spawn specifications first
							SpawnObject[] Spawns = new SpawnObject[0];
							bool havenew = true;
							try { Spawns = SpawnObject.LoadSpawnObjectsFromString2( (string)dr["Objects2"] ); }
							catch { havenew = false; }
							if( !havenew )
							{
								// try loading the new spawn specifications
								try { Spawns = SpawnObject.LoadSpawnObjectsFromString( (string)dr["Objects"] ); }
								catch { questionable_spawner = true; }
								// can only have one of these defined
							}

							// do a check on the location of the spawner
							if( !IsValidMapLocation( SpawnCentreX, SpawnCentreY, SpawnMap ) )
							{
								if( from != null )
									from.SendMessage( 33, "Invalid location '{0}' at [{1} {2}] in {3}",
										SpawnName, SpawnCentreX, SpawnCentreY, XmlMapName );
								bad_spawner = true;
							}

							// Check if this spawner already exists
							XmlSpawner OldSpawner = null;
							bool found_container = false;
							bool found_spawner = false;
							Container spawn_container = null;
							if( !bad_spawner )
							{
								foreach( Item i in World.Items.Values )
								{
									if( i is XmlSpawner )
									{
										XmlSpawner CheckXmlSpawner = (XmlSpawner)i;

										// Check if the spawners GUID is the same as the one being loaded
										// and that the spawners map is the same as the one being loaded
										if( (CheckXmlSpawner.UniqueId == SpawnId.ToString())
											/* && ( CheckXmlSpawner.Map == SpawnMap || loadrelative)*/ )
										{
											OldSpawner = (XmlSpawner)i;
											found_spawner = true;
										}
									}

									//look for containers with the spawn coordinates if the incontainer flag is set
									if( InContainer && !found_container && (i is Container) && (SpawnCentreX == i.Location.X) && (SpawnCentreY == i.Location.Y) &&
										(SpawnCentreZ == i.Location.Z || SpawnCentreZ == short.MinValue) )
									{
										// assume this is the container that the spawner was in
										found_container = true;
										spawn_container = i as Container;
									}
									// ok we can break if we have handled both the spawner and any containers
									if( found_spawner && (found_container || !InContainer) )
										break;
								}
							}

							// test to see whether the spawner specification was valid, bad, or questionable
							if( bad_spawner )
							{
								badcount++;
								if( from != null )
									from.SendMessage( 33, "Invalid spawner" );
								// log it
								long fileposition = -1;
								try { fileposition = fs.Position; }
								catch { }
								try
								{
									using( StreamWriter op = new StreamWriter( "badxml.log", true ) )
									{
										op.WriteLine( "# Invalid spawner : {0}: Fileposition {1} {2}", DateTime.Now, fileposition, filename );
										op.WriteLine();
									}
								}
								catch { }
							}
							else
								if( questionable_spawner )
								{
									questionablecount++;
									if( from != null )
										from.SendMessage( 33, "Questionable spawner '{0}' at [{1} {2}] in {3}",
											SpawnName, SpawnCentreX, SpawnCentreY, XmlMapName );
									// log it
									long fileposition = -1;
									try { fileposition = fs.Position; }
									catch { }
									try
									{
										using( StreamWriter op = new StreamWriter( "badxml.log", true ) )
										{
											op.WriteLine( "# Questionable spawner : {0}: Format: X Y Z Map SpawnerName Fileposition Xmlfile", DateTime.Now );
											op.WriteLine( "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}", SpawnCentreX, SpawnCentreY, SpawnCentreZ, XmlMapName, SpawnName, fileposition, filename );
											op.WriteLine();
										}
									}
									catch { }
								}
							if( !bad_spawner )
							{
								// Delete the old spawner if it exists
								if( OldSpawner != null )
									OldSpawner.Delete();

								// Create the new spawner
								XmlSpawner TheSpawn = new XmlSpawner( SpawnId, SpawnX, SpawnY, SpawnWidth, SpawnHeight, SpawnName, SpawnMaxCount,
									SpawnMinDelay, SpawnMaxDelay, SpawnDuration, SpawnProximityRange, SpawnProximityTriggerSound, SpawnAmount,
									SpawnTeam, SpawnHomeRange, SpawnIsRelativeHomeRange, Spawns, SpawnMinRefractory, SpawnMaxRefractory, SpawnTODStart,
									SpawnTODEnd, SpawnObjectPropertyItem, SpawnObjectPropertyName, SpawnProximityMessage, SpawnItemTriggerName, SpawnNoItemTriggerName,
									SpawnSpeechTrigger, SpawnMobTriggerName, SpawnMobPropertyName, SpawnPlayerPropertyName, SpawnTriggerProbability,
									SpawnSetPropertyItem, SpawnIsGroup, SpawnTODMode, SpawnKillReset, SpawnExternalTriggering, SpawnSequentialSpawning,
									SpawnRegionName, SpawnAllowGhost, SpawnAllowNPC, SpawnSpawnOnTrigger, SpawnConfigFile, SpawnDespawnTime, SpawnSkillTrigger, SpawnSmartSpawning, SpawnWaypoint );
								//TheSpawn.Group = SpawnIsGroup;\

								string fromname = null;
								if( from != null ) fromname = from.Name;
								TheSpawn.LastModifiedBy = fromname;
								TheSpawn.FirstModifiedBy = fromname;

								// Try to find a valid Z height if required (SpawnCentreZ = short.MinValue)
								int NewZ = 0;


								// Check if relative loading is set.  If so then try loading at the z-offset position first with no surface requirement, then try auto
								/*if(loadrelative && SpawnMap.CanFit( SpawnCentreX, SpawnCentreY, OrigZ - SpawnRelZ, SpawnFitSize,true, false,false )) */

								if( loadrelative && HasTileSurface( SpawnMap, SpawnCentreX, SpawnCentreY, OrigZ - SpawnRelZ ) )
								{

									NewZ = OrigZ - SpawnRelZ;

								}
								else

									if( SpawnCentreZ == short.MinValue )
									{
										NewZ = SpawnMap.GetAverageZ( SpawnCentreX, SpawnCentreY );


										if( SpawnMap.CanFit( SpawnCentreX, SpawnCentreY, NewZ, SpawnFitSize ) == false )
										{
											for( int x = 1; x <= 39; x++ )
											{
												if( SpawnMap.CanFit( SpawnCentreX, SpawnCentreY, NewZ + x, SpawnFitSize ) )
												{
													NewZ += x;
													break;
												}
											}
										}
									}
									else
									{
										// This spawn point already has a defined Z location, so use it
										NewZ = SpawnCentreZ;
									}

								// if this is a container held spawner, drop it in the container
								if( found_container && (spawn_container != null) && !spawn_container.Deleted )
								{
									TheSpawn.Location = (new Point3D( ContainerX, ContainerY, ContainerZ ));
									spawn_container.AddItem( TheSpawn );
								}
								else
								{
									// disable the X_Y adjustments in OnLocationChange
									IgnoreLocationChange = true;
									TheSpawn.MoveToWorld( new Point3D( SpawnCentreX, SpawnCentreY, NewZ ), SpawnMap );
								}

								// reset the spawner
								TheSpawn.Reset();
								TheSpawn.Running = SpawnIsRunning;

								// update subgroup-specific next spawn times
								TheSpawn.NextSpawn = TimeSpan.Zero;
								TheSpawn.ResetNextSpawnTimes();


								// Send a message to the client that the spawner is created
								if( from != null && verbose )
									from.SendMessage( 188, "Created '{0}' in {1} at {2}", TheSpawn.Name, TheSpawn.Map.Name, TheSpawn.Location.ToString() );

								// Do a total respawn
								//TheSpawn.Respawn();

								// Increment the count
								TotalCount++;
							}
							bad_spawner = false;
							questionable_spawner = false;
						}
					}

				if( from != null )
					from.SendMessage( "Resolving spawner self references" );

				if( ds.Tables[SpawnTablePointName] != null && ds.Tables[SpawnTablePointName].Rows.Count > 0 )
					foreach( DataRow dr in ds.Tables[SpawnTablePointName].Rows )
					{
						// Try load the GUID
						bool badid = false;
						Guid SpawnId = Guid.NewGuid();
						try { SpawnId = new Guid( (string)dr["UniqueId"] ); }
						catch { badid = true; }
						if( badid ) continue;
						// Get the map
						Map SpawnMap = frommap;
						string XmlMapName = frommap.Name;

						if( !loadrelative )
						{
							try { XmlMapName = (string)dr["Map"]; }
							catch { }

							// Convert the xml map value to a real map object
							try
							{
								SpawnMap = Map.Parse( XmlMapName );
							}
							catch { }
						}

						bool found_spawner = false;
						XmlSpawner OldSpawner = null;
						foreach( Item i in World.Items.Values )
						{
							if( i is XmlSpawner )
							{
								XmlSpawner CheckXmlSpawner = (XmlSpawner)i;

								// Check if the spawners GUID is the same as the one being loaded
								// and that the spawners map is the same as the one being loaded
								if( (CheckXmlSpawner.UniqueId == SpawnId.ToString())
									/* && ( CheckXmlSpawner.Map == SpawnMap || loadrelative) */)
								{
									OldSpawner = (XmlSpawner)i;
									found_spawner = true;
								}
							}

							if( found_spawner )
								break;
						}

						if( found_spawner && OldSpawner != null && !OldSpawner.Deleted )
						{
							// resolve item name references since they may have referred to spawners that were just created
							string setObjectName = null;
							try { setObjectName = (string)dr["SetPropertyItemName"]; }
							catch { }
							if( setObjectName != null && setObjectName.Length > 0 )
							{
								// try to parse out the type information if it has also been saved
								string[] typeargs = setObjectName.Split( ",".ToCharArray(), 2 );
								string typestr = null;
								string namestr = setObjectName;

								if( typeargs.Length > 1 )
								{
									namestr = typeargs[0];
									typestr = typeargs[1];
								}

								// if this is a new load then assume that it will be referring to another newly loaded object so append the newloadid
								if( loadnew )
								{
									string tmpsetObjectName = String.Format( "{0}-{1}", namestr, newloadid );
									OldSpawner.m_SetPropertyItem = BaseXmlSpawner.FindItemByName( null, tmpsetObjectName, typestr );
								}
								// if this fails then try the original
								if( OldSpawner.m_SetPropertyItem == null )
								{
									OldSpawner.m_SetPropertyItem = BaseXmlSpawner.FindItemByName( null, namestr, typestr );
								}
								if( OldSpawner.m_SetPropertyItem == null )
								{
									failedsetitemcount++;
									if( from != null )
										from.SendMessage( 33, "Failed to initialize SetItemProperty Object '{0}' on ' '{1}' at [{2} {3}] in {4}",
											setObjectName, OldSpawner.Name, OldSpawner.Location.X, OldSpawner.Location.Y, OldSpawner.Map );
									// log it
									try
									{
										using( StreamWriter op = new StreamWriter( "badxml.log", true ) )
										{
											op.WriteLine( "# Failed SetItemProperty Object initialization : {0}: Format: ObjectName X Y Z Map SpawnerName Xmlfile",
												DateTime.Now );
											op.WriteLine( "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}",
												setObjectName, OldSpawner.Location.X, OldSpawner.Location.Y, OldSpawner.Location.Z, OldSpawner.Map, OldSpawner.Name, filename );
											op.WriteLine();
										}
									}
									catch { }
								}
							}
							string triggerObjectName = null;
							try { triggerObjectName = (string)dr["ObjectPropertyItemName"]; }
							catch { }
							if( triggerObjectName != null && triggerObjectName.Length > 0 )
							{
								string[] typeargs = triggerObjectName.Split( ",".ToCharArray(), 2 );
								string typestr = null;
								string namestr = triggerObjectName;

								if( typeargs.Length > 1 )
								{
									namestr = typeargs[0];
									typestr = typeargs[1];
								}

								// if this is a new load then assume that it will be referring to another newly loaded object so append the newloadid
								if( loadnew )
								{
									string tmptriggerObjectName = String.Format( "{0}-{1}", namestr, newloadid );
									OldSpawner.m_ObjectPropertyItem = BaseXmlSpawner.FindItemByName( null, tmptriggerObjectName, typestr );
								}
								// if this fails then try the original
								if( OldSpawner.m_ObjectPropertyItem == null )
								{
									OldSpawner.m_ObjectPropertyItem = BaseXmlSpawner.FindItemByName( null, namestr, typestr );
								}
								if( OldSpawner.m_ObjectPropertyItem == null )
								{
									failedobjectitemcount++;
									if( from != null )
										from.SendMessage( 33, "Failed to initialize TriggerObject '{0}' on ' '{1}' at [{2} {3}] in {4}",
											triggerObjectName, OldSpawner.Name, OldSpawner.Location.X, OldSpawner.Location.Y, OldSpawner.Map );
									// log it
									try
									{
										using( StreamWriter op = new StreamWriter( "badxml.log", true ) )
										{
											op.WriteLine( "# Failed TriggerObject initialization : {0}: Format: ObjectName X Y Z Map SpawnerName Xmlfile",
												DateTime.Now );
											op.WriteLine( "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}",
												triggerObjectName, OldSpawner.Location.X, OldSpawner.Location.Y, OldSpawner.Location.Z, OldSpawner.Map, OldSpawner.Name, filename );
											op.WriteLine();
										}
									}
									catch { }
								}
							}
						}
					}
			}

			// close the file
			try
			{
				fs.Close();
			}
			catch { }

			if( from != null )
				from.SendMessage( "{0} spawner(s) were created from file {1} [Trammel={2}, Felucca={3}, Ilshenar={4}, Malas={5}, Tokuno={6} Other={7}].",
					TotalCount, filename, TrammelCount, FeluccaCount, IlshenarCount, MalasCount, TokunoCount, OtherCount );
			if( failedobjectitemcount > 0 )
			{
				if( from != null )
					from.SendMessage( 33, "Failed to initialize TriggerObjects in {0} spawners. Saved to 'badxml.log'", failedobjectitemcount );
			}
			if( failedsetitemcount > 0 )
			{
				if( from != null )
					from.SendMessage( 33, "Failed to initialize SetItemProperty Objects in {0} spawners. Saved to 'badxml.log'", failedsetitemcount );
			}
			if( badcount > 0 )
			{
				if( from != null )
					from.SendMessage( 33, "{0} bad spawners detected. Saved to 'badxml.log'", badcount );
			}
			if( questionablecount > 0 )
			{
				if( from != null )
					from.SendMessage( 33, "{0} questionable spawners detected. Saved to 'badxml.log'", questionablecount );
			}
			processedmaps = 1;
			processedspawners = TotalCount;

		}
Beispiel #2
0
		private static void ImportSpawner( XmlElement node, Mobile from )
		{
			int count = int.Parse( GetText( node["count"], "1" ) );
			int homeRange = int.Parse( GetText( node["homerange"], "4" ) );
			int walkingRange = int.Parse( GetText( node["walkingrange"], "-1" ) );
			// width of the spawning area
			int spawnwidth = homeRange * 2;
			if( walkingRange >= 0 ) spawnwidth = walkingRange * 2;

			int team = int.Parse( GetText( node["team"], "0" ) );
			bool group = bool.Parse( GetText( node["group"], "False" ) );
			TimeSpan maxDelay = TimeSpan.Parse( GetText( node["maxdelay"], "10:00" ) );
			TimeSpan minDelay = TimeSpan.Parse( GetText( node["mindelay"], "05:00" ) );
			ArrayList creaturesName = LoadCreaturesName( node["creaturesname"] );
			string name = GetText( node["name"], "Spawner" );
			Point3D location = Point3D.Parse( GetText( node["location"], "Error" ) );
			Map map = Map.Parse( GetText( node["map"], "Error" ) );

			// allow it to make an xmlspawner instead
			// first add all of the creatures on the list
			SpawnObject[] so = new SpawnObject[creaturesName.Count];

			bool hasvendor = false;

			for( int i = 0; i < creaturesName.Count; i++ )
			{
				so[i] = new SpawnObject( (string)creaturesName[i], count );
				// check the type to see if there are vendors on it
				Type type = SpawnerType.GetType( (string)creaturesName[i] );

				// if it has basevendors on it or invalid types, then skip it
				if( type != null && (type == typeof( BaseVendor ) || type.IsSubclassOf( typeof( BaseVendor ) )) )
				{
					hasvendor = true;
				}
			}

			// assign it a unique id
			Guid SpawnId = Guid.NewGuid();

			// Create the new xml spawner
			XmlSpawner spawner = new XmlSpawner( SpawnId, location.X, location.Y, spawnwidth, spawnwidth, name, count,
				minDelay, maxDelay, TimeSpan.FromMinutes( 0 ), -1, defaultTriggerSound, 1,
				team, homeRange, false, so, TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ),
				TimeSpan.FromMinutes( 0 ), null, null, null, null, null,
				null, null, null, null, 1, null, group, defTODMode, defKillReset, false, -1, null, false, false, false, null, defDespawnTime, null, false, null );

			if( hasvendor )
			{
				spawner.SpawnRange = 0;
			}
			else
			{
				spawner.SpawnRange = homeRange;
			}
			spawner.m_PlayerCreated = true;
			string fromname = null;
			if( from != null ) fromname = from.Name;
			spawner.LastModifiedBy = fromname;
			spawner.FirstModifiedBy = fromname;

			spawner.MoveToWorld( location, map );
			if( !IsValidMapLocation( location, spawner.Map ) )
			{
				spawner.Delete();
				throw new Exception( "Invalid spawner location." );
			}
		}
Beispiel #3
0
		private static void ImportMegaSpawner( Mobile from, XmlElement node )
		{
			string name = GetText( node["Name"], "MegaSpawner" );
			bool running = bool.Parse( GetText( node["Active"], "True" ) );
			Point3D location = Point3D.Parse( GetText( node["Location"], "Error" ) );
			Map map = Map.Parse( GetText( node["Map"], "Error" ) );


			int team = 0;
			bool group = false;
			int maxcount = 0;  // default maxcount of the spawner
			int homeRange = 4; // default homerange
			int spawnRange = 4; // default homerange
			TimeSpan maxDelay = TimeSpan.FromMinutes( 10 );
			TimeSpan minDelay = TimeSpan.FromMinutes( 5 );

			XmlElement listnode = node["EntryLists"];

			int nentries = 0;
			SpawnObject[] so = null;


			if( listnode != null )
			{
				// get the number of entries
				if( listnode.HasAttributes )
				{
					XmlAttributeCollection attr = listnode.Attributes;

					nentries = int.Parse( attr.GetNamedItem( "count" ).Value );
				}
				if( nentries > 0 )
				{
					so = new SpawnObject[nentries];

					int entrycount = 0;
					bool diff = false;
					foreach( XmlElement entrynode in listnode.GetElementsByTagName( "EntryList" ) )
					{
						// go through each entry and add a spawn object for it
						if( entrynode != null )
						{
							if( entrycount == 0 )
							{
								// get the spawner defaults from the first entry
								// dont handle the individually specified entry attributes
								group = bool.Parse( GetText( entrynode["GroupSpawn"], "False" ) );
								maxDelay = TimeSpan.FromSeconds( int.Parse( GetText( entrynode["MaxDelay"], "10:00" ) ) );
								minDelay = TimeSpan.FromSeconds( int.Parse( GetText( entrynode["MinDelay"], "05:00" ) ) );
								homeRange = int.Parse( GetText( entrynode["WalkRange"], "10" ) );
								spawnRange = int.Parse( GetText( entrynode["SpawnRange"], "4" ) );
							}
							else
							{
								// just check for consistency with other entries and report discrepancies
								if( group != bool.Parse( GetText( entrynode["GroupSpawn"], "False" ) ) )
								{
									diff = true;
									// log it
									try
									{
										using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
										{
											op.WriteLine( "MSFimport : individual group entry difference: {0} vs {1}",
												GetText( entrynode["GroupSpawn"], "False" ), group );

										}
									}
									catch { }
								}
								if( minDelay != TimeSpan.FromSeconds( int.Parse( GetText( entrynode["MinDelay"], "05:00" ) ) ) )
								{
									diff = true;
									// log it
									try
									{
										using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
										{
											op.WriteLine( "MSFimport : individual mindelay entry difference: {0} vs {1}",
												GetText( entrynode["MinDelay"], "05:00" ), minDelay );

										}
									}
									catch { }
								}
								if( maxDelay != TimeSpan.FromSeconds( int.Parse( GetText( entrynode["MaxDelay"], "10:00" ) ) ) )
								{
									diff = true;
									// log it
									try
									{
										using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
										{
											op.WriteLine( "MSFimport : individual maxdelay entry difference: {0} vs {1}",
												GetText( entrynode["MaxDelay"], "10:00" ), maxDelay );

										}
									}
									catch { }
								}
								if( homeRange != int.Parse( GetText( entrynode["WalkRange"], "10" ) ) )
								{
									diff = true;
									// log it
									try
									{
										using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
										{
											op.WriteLine( "MSFimport : individual homerange entry difference: {0} vs {1}",
												GetText( entrynode["WalkRange"], "10" ), homeRange );

										}
									}
									catch { }
								}
								if( spawnRange != int.Parse( GetText( entrynode["SpawnRange"], "4" ) ) )
								{
									diff = true;
									// log it
									try
									{
										using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
										{
											op.WriteLine( "MSFimport : individual spawnrange entry difference: {0} vs {1}",
												GetText( entrynode["SpawnRange"], "4" ), spawnRange );

										}
									}
									catch { }
								}
							}

							// these apply to individual entries
							int amount = int.Parse( GetText( entrynode["Amount"], "1" ) );
							string entryname = GetText( entrynode["EntryType"], "" );

							// keep track of the maxcount for the spawner by adding the individual amounts
							maxcount += amount;

							// add the creature entry
							so[entrycount] = new SpawnObject( entryname, amount );

							entrycount++;
							if( entrycount > nentries )
							{
								// log it
								try
								{
									using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
									{
										op.WriteLine( "{0} MSFImport Error; inconsistent entry count {1} {2}", DateTime.Now, location, map );
										op.WriteLine();
									}
								}
								catch { }
								from.SendMessage( "Inconsistent entry count detected at {0} {1}.", location, map );
								break;
							}

						}
					}
					if( diff )
					{
						from.SendMessage( "Individual entry setting detected at {0} {1}.", location, map );
						// log it
						try
						{
							using( StreamWriter op = new StreamWriter( "badimport.log", true ) )
							{
								op.WriteLine( "{0} MSFImport: Individual entry setting differences listed above from spawner at {1} {2}", DateTime.Now, location, map );
								op.WriteLine();
							}
						}
						catch { }
					}
				}
			}

			// assign it a unique id
			Guid SpawnId = Guid.NewGuid();
			// Create the new xml spawner
			XmlSpawner spawner = new XmlSpawner( SpawnId, location.X, location.Y, 0, 0, name, maxcount,
				minDelay, maxDelay, TimeSpan.FromMinutes( 0 ), -1, defaultTriggerSound, 1,
				team, homeRange, false, so, TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ),
				TimeSpan.FromMinutes( 0 ), null, null, null, null, null,
				null, null, null, null, 1, null, group, defTODMode, defKillReset, false, -1, null, false, false, false, null, defDespawnTime, null, false, null );

			spawner.SpawnRange = spawnRange;
			spawner.m_PlayerCreated = true;
			string fromname = null;
			if( from != null ) fromname = from.Name;
			spawner.LastModifiedBy = fromname;
			spawner.FirstModifiedBy = fromname;

			// Try to find a valid Z height if required (Z == -999)

			if( location.Z == -999 )
			{
				int NewZ = map.GetAverageZ( location.X, location.Y );

				if( map.CanFit( location.X, location.Y, NewZ, SpawnFitSize ) == false )
				{
					for( int x = 1; x <= 39; x++ )
					{
						if( map.CanFit( location.X, location.Y, NewZ + x, SpawnFitSize ) )
						{
							NewZ += x;
							break;
						}
					}
				}
				location.Z = NewZ;
			}

			spawner.MoveToWorld( location, map );

			if( !IsValidMapLocation( location, spawner.Map ) )
			{
				spawner.Delete();
				throw new Exception( "Invalid spawner location." );
			}
		}
Beispiel #4
0
		public static void XmlImportMap(string filename, Mobile from, out int processedmaps, out int processedspawners)
		{
			processedmaps = 0;
			processedspawners = 0;
			int total_processed_maps = 0;
			int total_processed_spawners = 0;
			if (filename == null || filename.Length <= 0 || from == null || from.Deleted) return;
			// Check if the file exists
			if (System.IO.File.Exists(filename) == true)
			{
				int spawnercount = 0;
				int badspawnercount = 0;
				int linenumber = 0;
				// default is no map override, use the map spec from each spawn line
				int overridemap = -1;
				try
				{
					// Create an instance of StreamReader to read from a file.
					// The using statement also closes the StreamReader.
					using (StreamReader sr = new StreamReader(filename))
					{
						string line;
						// Read and display lines from the file until the end of
						// the file is reached.
						while ((line = sr.ReadLine()) != null)
						{
							// format of each .map line is * Dragon:Wyvern 5209 965 -40 2 2 10 50 30 1
							//  * typename:typename:... x y z map mindelay maxdelay homerange spawnrange maxcount
							// or
							//  * typename:typename:... x y z map mindelay maxdelay homerange spawnrange spawnid maxcount
							// ## are comments
							// overridemap mapnumber
							// map 0 is tram+fel
							// map 1 is fel
							// map 2 is tram
							// map 3 is ilsh
							// map 4 is mal
							// map 5 is tokuno
							linenumber++;
							string[] args = line.Trim().Split(' ');

							// look for the override keyword
							if (args.Length == 2 && (args[0].ToLower() == "overridemap"))
							{
								try
								{
									overridemap = int.Parse(args[1]);
								}
								catch { }
							}
							// look for a spawn spec line
							if (args.Length > 0 && (args[0] == "*"))
							{
								bool badspawn = false;
								int x = 0;
								int y = 0;
								int z = 0;
								int map = 0;
								int mindelay = 0;
								int maxdelay = 0;
								int homerange = 0;
								int spawnrange = 0;
								int maxcount = 0;
								int spawnid = 0;
								string[] typenames = null;
								if (args.Length != 11 && args.Length != 12)
								{
									badspawn = true;
									from.SendMessage("Invalid arg count {1} at line {0}", linenumber, args.Length);
								}
								else
								{
									// get the list of spawns
									typenames = args[1].Split(':');
									// parse the rest of the args

									if (args.Length == 11)
									{

										try
										{
											x = int.Parse(args[2]);
											y = int.Parse(args[3]);
											z = int.Parse(args[4]);
											map = int.Parse(args[5]);
											mindelay = int.Parse(args[6]);
											maxdelay = int.Parse(args[7]);
											homerange = int.Parse(args[8]);
											spawnrange = int.Parse(args[9]);
											maxcount = int.Parse(args[10]);

										}
										catch { from.SendMessage("Parsing error at line {0}", linenumber); badspawn = true; }
									}
									else
										if (args.Length == 12)
										{

											try
											{
												x = int.Parse(args[2]);
												y = int.Parse(args[3]);
												z = int.Parse(args[4]);
												map = int.Parse(args[5]);
												mindelay = int.Parse(args[6]);
												maxdelay = int.Parse(args[7]);
												homerange = int.Parse(args[8]);
												spawnrange = int.Parse(args[9]);
												spawnid = int.Parse(args[10]);
												maxcount = int.Parse(args[11]);

											}
											catch { from.SendMessage("Parsing error at line {0}", linenumber); badspawn = true; }
										}
								}
								if (!badspawn && typenames != null && typenames.Length > 0)
								{
									// everything seems ok so go ahead and make the spawner
									// check for map override
									if (overridemap >= 0) map = overridemap;
									Map spawnmap = Map.Internal;
									switch (map)
									{
										case 0:
											spawnmap = Map.Felucca;
											// note it also does trammel
											break;
										case 1:
											spawnmap = Map.Felucca;
											break;
										case 2:
											spawnmap = Map.Trammel;
											break;
										case 3:
											spawnmap = Map.Ilshenar;
											break;
										case 4:
											spawnmap = Map.Malas;
											break;
										case 5:
											try
											{
												spawnmap = Map.Parse("Tokuno");
											}
											catch { from.SendMessage("Invalid map at line {0}", linenumber); }
											break;
									}

									if (!IsValidMapLocation(x, y, spawnmap))
									{
										// invalid so dont spawn it
										badspawnercount++;
										from.SendMessage("Invalid map/location at line {0}", linenumber);
										from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber);
										continue;
									}

									// allow it to make an xmlspawner instead
									// first add all of the creatures on the list
									SpawnObject[] so = new SpawnObject[typenames.Length];

									bool hasvendor = true;
									for (int i = 0; i < typenames.Length; i++)
									{
										so[i] = new SpawnObject(typenames[i], maxcount);

										// check the type to see if there are vendors on it
										Type type = SpawnerType.GetType(typenames[i]);

										// check for vendor-only spawners which get special spawnrange treatment
										if (type != null && (type != typeof(BaseVendor) && !type.IsSubclassOf(typeof(BaseVendor))))
										{
											hasvendor = false;
										}

									}

									// assign it a unique id
									Guid SpawnId = Guid.NewGuid();

									// and give it a name based on the spawner count and file
									string spawnername = String.Format("{0}#{1}", filename, spawnercount);

									// Create the new xml spawner
									XmlSpawner spawner = new XmlSpawner(SpawnId, x, y, 0, 0, spawnername, maxcount,
										TimeSpan.FromMinutes(mindelay), TimeSpan.FromMinutes(maxdelay), TimeSpan.FromMinutes(0), -1, defaultTriggerSound, 1,
										0, homerange, false, so, TimeSpan.FromMinutes(0), TimeSpan.FromMinutes(0), TimeSpan.FromMinutes(0),
										TimeSpan.FromMinutes(0), null, null, null, null, null,
										null, null, null, null, 1, null, false, defTODMode, defKillReset, false, -1, null, false, false, false, null,
										TimeSpan.FromHours(0), null, false, null);

									if (hasvendor)
									{
										// force vendor spawners to behave like the distro
										spawner.SpawnRange = 0;
									}
									else
									{
										spawner.SpawnRange = spawnrange;
									}

									spawner.m_PlayerCreated = true;
									string fromname = null;
									if (from != null) fromname = from.Name;
									spawner.LastModifiedBy = fromname;
									spawner.FirstModifiedBy = fromname;
									spawner.MoveToWorld(new Point3D(x, y, z), spawnmap);
									if (spawner.Map == Map.Internal)
									{
										badspawnercount++;
										spawner.Delete();
										from.SendMessage("Invalid map at line {0}", linenumber);
										from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber);
										continue;
									}
									spawnercount++;
									// handle the special case of map 0 that also needs to do trammel
									if (map == 0)
									{
										spawnmap = Map.Trammel;
										// assign it a unique id
										SpawnId = Guid.NewGuid();
										// Create the new xml spawner
										spawner = new XmlSpawner(SpawnId, x, y, 0, 0, spawnername, maxcount,
											TimeSpan.FromMinutes(mindelay), TimeSpan.FromMinutes(maxdelay), TimeSpan.FromMinutes(0), -1, defaultTriggerSound, 1,
											0, homerange, false, so, TimeSpan.FromMinutes(0), TimeSpan.FromMinutes(0), TimeSpan.FromMinutes(0),
											TimeSpan.FromMinutes(0), null, null, null, null, null,
											null, null, null, null, 1, null, false, defTODMode, defKillReset, false, -1, null, false, false, false, null,
											TimeSpan.FromHours(0), null, false, null);

										spawner.SpawnRange = spawnrange;
										spawner.m_PlayerCreated = true;

										spawner.LastModifiedBy = fromname;
										spawner.FirstModifiedBy = fromname;
										spawner.MoveToWorld(new Point3D(x, y, z), spawnmap);
										if (spawner.Map == Map.Internal)
										{
											badspawnercount++;
											spawner.Delete();
											from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber);
											continue;
										}
										spawnercount++;
									}
								}
								else
								{
									badspawnercount++;
									from.SendMessage("Bad spawn at line {1}: {0}", line, linenumber);
								}
							}
						}
						sr.Close();
					}
				}
				catch (Exception e)
				{
					// Let the user know what went wrong.
					from.SendMessage("The file could not be read: {0}", e.Message);
				}
				from.SendMessage("Imported {0} spawners from {1}", spawnercount, filename);
				from.SendMessage("{0} bad spawners detected", badspawnercount);
				processedmaps = 1;
				processedspawners = spawnercount;
			}
			else
				// check to see if it is a directory
				if (System.IO.Directory.Exists(filename) == true)
				{
					// if so then import all of the .map files in the directory
					string[] files = null;
					try
					{
						files = Directory.GetFiles(filename, "*.map");
					}
					catch { }
					if (files != null && files.Length > 0)
					{
						from.SendMessage("Importing {0} .map files from directory {1}", files.Length, filename);
						foreach (string file in files)
						{
							XmlImportMap(file, from, out processedmaps, out processedspawners);
							total_processed_maps += processedmaps;
							total_processed_spawners += processedspawners;
						}
					}
					// recursively search subdirectories for more .map files
					string[] dirs = null;
					try
					{
						dirs = Directory.GetDirectories(filename);
					}
					catch { }
					if (dirs != null && dirs.Length > 0)
					{
						foreach (string dir in dirs)
						{
							XmlImportMap(dir, from, out processedmaps, out processedspawners);
							total_processed_maps += processedmaps;
							total_processed_spawners += processedspawners;
						}
					}
					from.SendMessage("Imported a total of {0} .map files and {2} spawners from directory {1}", total_processed_maps, filename, total_processed_spawners);
					processedmaps = total_processed_maps;
					processedspawners = total_processed_spawners;
				}
				else
				{
					from.SendMessage("{0} does not exist", filename);
				}
		}
Beispiel #5
0
		private static void ParseOldMapFormat( Mobile from, string filename, string line, string[] args, int linenumber, ref int spawnercount, ref int badspawnercount, ref int overridemap, ref double overridemintime, ref double overridemaxtime )
		{
			// format of each .map line is * Dragon:Wyvern 5209 965 -40 2 2 10 50 30 1
			//  * typename:typename:... x y z map mindelay maxdelay homerange spawnrange maxcount
			// or
			//  * typename:typename:... x y z map mindelay maxdelay homerange spawnrange spawnid maxcount
			// ## are comments
			// overridemap mapnumber
			// map 0 is tram+fel
			// map 1 is fel
			// map 2 is tram
			// map 3 is ilsh
			// map 4 is mal
			// map 5 is tokuno
			//
			// * | typename:typename:... | | | | | | x | y | z | map | mindelay maxdelay homerange spawnrange spawnid maxcount | maxcount2 | maxcount2 | maxcount3 | maxcount4 | maxcount5
			// the new format of each .map line is  * |Dragon:Wyvern| spawns:spawns| | | | | 5209 | 965 | -40 | 2 | 2 | 10 | 50 | 30 | 1

			if( args == null || from == null ) return;

			// look for the override keyword
			if( args.Length == 2 && (args[0].ToLower() == "overridemap") )
			{
				try
				{
					overridemap = int.Parse( args[1] );
				}
				catch { }
			}
			else
				if( args.Length == 2 && (args[0].ToLower() == "overridemintime") )
				{
					try
					{
						overridemintime = double.Parse( args[1] );
					}
					catch { }
				}
				else
					if( args.Length == 2 && (args[0].ToLower() == "overridemaxtime") )
					{
						try
						{
							overridemaxtime = double.Parse( args[1] );
						}
						catch { }
					}
					else
						// look for a spawn spec line
						if( args.Length > 0 && (args[0] == "*") )
						{
							bool badspawn = false;
							int x = 0;
							int y = 0;
							int z = 0;
							int map = 0;
							double mindelay = 0;
							double maxdelay = 0;
							int homerange = 0;
							int spawnrange = 0;
							int maxcount = 0;
							int spawnid = 0;
							string[] typenames = null;
							if( args.Length != 11 && args.Length != 12 )
							{
								badspawn = true;
								from.SendMessage( "Invalid arg count {1} at line {0}", linenumber, args.Length );
							}
							else
							{
								// get the list of spawns
								typenames = args[1].Split( ':' );
								// parse the rest of the args

								if( args.Length == 11 )
								{

									try
									{
										x = int.Parse( args[2] );
										y = int.Parse( args[3] );
										z = int.Parse( args[4] );
										map = int.Parse( args[5] );
										mindelay = double.Parse( args[6] );
										maxdelay = double.Parse( args[7] );
										homerange = int.Parse( args[8] );
										spawnrange = int.Parse( args[9] );
										maxcount = int.Parse( args[10] );

									}
									catch { from.SendMessage( "Parsing error at line {0}", linenumber ); badspawn = true; }
								}
								else
									if( args.Length == 12 )
									{

										try
										{
											x = int.Parse( args[2] );
											y = int.Parse( args[3] );
											z = int.Parse( args[4] );
											map = int.Parse( args[5] );
											mindelay = double.Parse( args[6] );
											maxdelay = double.Parse( args[7] );
											homerange = int.Parse( args[8] );
											spawnrange = int.Parse( args[9] );
											spawnid = int.Parse( args[10] );
											maxcount = int.Parse( args[11] );

										}
										catch { from.SendMessage( "Parsing error at line {0}", linenumber ); badspawn = true; }
									}
							}


							// apply mi/maxdelay overrides
							if( overridemintime != -1 )
							{
								mindelay = overridemintime;
							}
							if( overridemaxtime != -1 )
							{
								maxdelay = overridemaxtime;
							}
							if( mindelay > maxdelay ) maxdelay = mindelay;

							if( !badspawn && typenames != null && typenames.Length > 0 )
							{
								// everything seems ok so go ahead and make the spawner
								// check for map override
								if( overridemap >= 0 ) map = overridemap;
								Map spawnmap = Map.Internal;
								switch( map )
								{
									case 0:
										spawnmap = Map.Felucca;
										// note it also does trammel
										break;
									case 1:
										spawnmap = Map.Felucca;
										break;
									case 2:
										spawnmap = Map.Trammel;
										break;
									case 3:
										spawnmap = Map.Ilshenar;
										break;
									case 4:
										spawnmap = Map.Malas;
										break;
									case 5:
										spawnmap = Map.Tokuno;
										break;
								}

								if( !IsValidMapLocation( x, y, spawnmap ) )
								{
									// invalid so dont spawn it
									badspawnercount++;
									from.SendMessage( "Invalid map/location at line {0}", linenumber );
									from.SendMessage( "Bad spawn at line {1}: {0}", line, linenumber );
									return;
								}

								// allow it to make an xmlspawner instead
								// first add all of the creatures on the list
								SpawnObject[] so = new SpawnObject[typenames.Length];

								bool hasvendor = true;
								for( int i = 0; i < typenames.Length; i++ )
								{
									so[i] = new SpawnObject( typenames[i], maxcount );

									// check the type to see if there are vendors on it
									Type type = SpawnerType.GetType( typenames[i] );

									// check for vendor-only spawners which get special spawnrange treatment
									if( type != null && (type != typeof( BaseVendor ) && !type.IsSubclassOf( typeof( BaseVendor ) )) )
									{
										hasvendor = false;
									}

								}

								// assign it a unique id
								Guid SpawnId = Guid.NewGuid();

								// and give it a name based on the spawner count and file
								string spawnername = String.Format( "{0}#{1}", Path.GetFileNameWithoutExtension( filename ), spawnercount );

								// Create the new xml spawner
								XmlSpawner spawner = new XmlSpawner( SpawnId, x, y, 0, 0, spawnername, maxcount,
									TimeSpan.FromMinutes( mindelay ), TimeSpan.FromMinutes( maxdelay ), TimeSpan.FromMinutes( 0 ), -1, defaultTriggerSound, 1,
									0, homerange, false, so, TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ),
									TimeSpan.FromMinutes( 0 ), null, null, null, null, null,
									null, null, null, null, 1, null, false, defTODMode, defKillReset, false, -1, null, false, false, false, null,
									TimeSpan.FromHours( 0 ), null, false, null );

								if( hasvendor )
								{
									// force vendor spawners to behave like the distro
									spawner.SpawnRange = 0;
								}
								else
								{
									spawner.SpawnRange = spawnrange;
								}

								spawner.m_PlayerCreated = true;
								string fromname = null;
								if( from != null ) fromname = from.Name;
								spawner.LastModifiedBy = fromname;
								spawner.FirstModifiedBy = fromname;
								spawner.MoveToWorld( new Point3D( x, y, z ), spawnmap );
								if( spawner.Map == Map.Internal )
								{
									badspawnercount++;
									spawner.Delete();
									from.SendMessage( "Invalid map at line {0}", linenumber );
									from.SendMessage( "Bad spawn at line {1}: {0}", line, linenumber );
									return;
								}
								spawnercount++;
								// handle the special case of map 0 that also needs to do trammel
								if( map == 0 )
								{
									spawnmap = Map.Trammel;
									// assign it a unique id
									SpawnId = Guid.NewGuid();
									// Create the new xml spawner
									spawner = new XmlSpawner( SpawnId, x, y, 0, 0, spawnername, maxcount,
										TimeSpan.FromMinutes( mindelay ), TimeSpan.FromMinutes( maxdelay ), TimeSpan.FromMinutes( 0 ), -1, defaultTriggerSound, 1,
										0, homerange, false, so, TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ), TimeSpan.FromMinutes( 0 ),
										TimeSpan.FromMinutes( 0 ), null, null, null, null, null,
										null, null, null, null, 1, null, false, defTODMode, defKillReset, false, -1, null, false, false, false, null,
										TimeSpan.FromHours( 0 ), null, false, null );

									spawner.SpawnRange = spawnrange;
									spawner.m_PlayerCreated = true;

									spawner.LastModifiedBy = fromname;
									spawner.FirstModifiedBy = fromname;
									spawner.MoveToWorld( new Point3D( x, y, z ), spawnmap );
									if( spawner.Map == Map.Internal )
									{
										badspawnercount++;
										spawner.Delete();
										from.SendMessage( "Bad spawn at line {1}: {0}", line, linenumber );
										return;
									}
									spawnercount++;
								}
							}
							else
							{
								badspawnercount++;
								from.SendMessage( "Bad spawn at line {1}: {0}", line, linenumber );
							}
						}
		}
Beispiel #6
0
        public static void Setup(CommandEventArgs e)
        {
            if (VoidPoolController.InstanceTram != null || VoidPoolController.InstanceFel != null)
                e.Mobile.SendMessage("This has already been setup!");
            else
            {
                var one = new VoidPoolController(Map.Trammel);
                WeakEntityCollection.Add("newcovetous", one);
                one.MoveToWorld(new Point3D(5605, 1998, 10), Map.Trammel);

                var two = new VoidPoolController(Map.Felucca);
                WeakEntityCollection.Add("newcovetous", two);
                two.MoveToWorld(new Point3D(5605, 1998, 10), Map.Felucca);

                int id = 0;
                int hue = 0;

                for (int x = 5497; x <= 5503; x++)
                {
                    for (int y = 1995; y <= 2001; y++)
                    {
                        if (x == 5497 && y == 1995) id = 1886;
                        else if (x == 5497 && y == 2001) id = 1887;
                        else if (x == 5503 && y == 1995) id = 1888;
                        else if (x == 5503 && y == 2001) id = 1885;
                        else if (x == 5497) id = 1874;
                        else if (x == 5503) id = 1876;
                        else if (y == 1995) id = 1873;
                        else if (y == 2001) id = 1875;
                        else
                        {
                            //id = 1168;
                            id = Utility.Random(8511, 6);
                        }

                        hue = id >= 8511 ? 0 : 1954;

                        var item = new Static(id);
                        item.Name = "Void Pool";
                        item.Hue = hue;
                        WeakEntityCollection.Add("newcovetous", item);
                        item.MoveToWorld(new Point3D(x, y, 5), Map.Trammel);

                        item = new Static(id);
                        item.Name = "Void Pool";
                        item.Hue = hue;
                        WeakEntityCollection.Add("newcovetous", item);
                        item.MoveToWorld(new Point3D(x, y, 5), Map.Felucca);
                    }
                }

                XmlSpawner spawner = new XmlSpawner("corathesorceress");
                spawner.MoveToWorld(new Point3D(5457, 1808, 0), Map.Trammel);
                spawner.SpawnRange = 5;
                spawner.MinDelay = TimeSpan.FromHours(1);
                spawner.MaxDelay = TimeSpan.FromHours(1.5);
                spawner.DoRespawn = true;

                spawner = new XmlSpawner("corathesorceress");
                spawner.MoveToWorld(new Point3D(5457, 1808, 0), Map.Felucca);
                spawner.SpawnRange = 5;
                spawner.MinDelay = TimeSpan.FromHours(1);
                spawner.MaxDelay = TimeSpan.FromHours(1.5);
                spawner.DoRespawn = true;

                spawner = new XmlSpawner("velathesorceress");
                spawner.MoveToWorld(new Point3D(2254, 1207, 0), Map.Trammel);
                spawner.SpawnRange = 0;
                spawner.DoRespawn = true;

                spawner = new XmlSpawner("velathesorceress");
                spawner.MoveToWorld(new Point3D(2254, 1207, 0), Map.Felucca);
                spawner.SpawnRange = 0;
                spawner.DoRespawn = true;

                AddWaypoints();
                ConvertSpawners();
            }
        }
Beispiel #7
0
        public static void GenerateDeco(CommandEventArgs e)
        {
            string name = "highseas";

            CharydbisSpawner.GenerateCharydbisSpawner();
            BountyQuestSpawner.GenerateShipSpawner();

            CorgulAltar altar;

            altar = new CorgulAltar();
            altar.MoveToWorld(new Point3D(2453, 865, 0), Map.Felucca);
            WeakEntityCollection.Add(name, altar);

            altar = new CorgulAltar();
            altar.MoveToWorld(new Point3D(2453, 865, 0), Map.Trammel);
            WeakEntityCollection.Add(name, altar);

            ProfessionalBountyBoard board;
            
            board = new ProfessionalBountyBoard();
            board.MoveToWorld(new Point3D(4544, 2298, -1), Map.Trammel);
            WeakEntityCollection.Add(name, board);

            board = new ProfessionalBountyBoard();
            board.MoveToWorld(new Point3D(4544, 2298, -1), Map.Felucca);
            WeakEntityCollection.Add(name, board);

            LocalizedSign sign;

            sign = new LocalizedSign(3025, 1152653); //The port of Zento Parking Area
            sign.MoveToWorld(new Point3D(713, 1359, 53), Map.Tokuno);
            WeakEntityCollection.Add(name, sign);

            sign = new LocalizedSign(3023, 1149821); //Winds Tavern
            sign.MoveToWorld(new Point3D(4548, 2300, -6), Map.Trammel);
            WeakEntityCollection.Add(name, sign);

            sign = new LocalizedSign(3023, 1149821); //Winds Tavern
            sign.MoveToWorld(new Point3D(4548, 2300, -6), Map.Felucca);
            WeakEntityCollection.Add(name, sign);

            sign = new LocalizedSign(3023, 1149820); //General Store
            sign.MoveToWorld(new Point3D(4543, 2317, -3), Map.Trammel);
            WeakEntityCollection.Add(name, sign);

            sign = new LocalizedSign(3023, 1149820); //General Store
            sign.MoveToWorld(new Point3D(4543, 2317, -3), Map.Felucca);
            WeakEntityCollection.Add(name, sign);

            XmlSpawner sp;
            string toSpawn = "FishMonger";

            //Britain
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(1482, 1754, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(1482, 1754, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Moonglow
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4406, 1049, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4406, 1049, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Trinsic
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(2061, 2855, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(2061, 2855, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Vesper
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(3009, 826, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(3009, 826, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Jhelom
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(1373, 3885, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(1373, 3885, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Skara Brae
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(641, 2234, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.MoveToWorld(new Point3D(641, 2234, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Papua
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(5827, 3258, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(5827, 3258, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Floating Eproriam
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 0;
            sp.HomeRange = 0;
            sp.MoveToWorld(new Point3D(4552, 2299, -1), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 0;
            sp.HomeRange = 0;
            sp.MoveToWorld(new Point3D(4540, 2321, -1), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            toSpawn = "DocksAlchemist";

            //Britain
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(1482, 1754, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(1482, 1754, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Moonglow
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4406, 1049, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4406, 1049, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Trinsic
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(2061, 2855, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(2061, 2855, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Vesper
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(3009, 826, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(3009, 826, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Jhelom
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(1373, 3885, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(1373, 3885, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Skara Brae
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(641, 2234, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.MoveToWorld(new Point3D(641, 2234, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Papua
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(5827, 3258, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(5827, 3258, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            //Floating Eproriam
            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4552, 2299, -1), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4540, 2321, -1), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            toSpawn = "GBBigglesby";

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4544, 2302, -1), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4544, 2302, -1), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            toSpawn = "GBBigglesby/Name/Mitsubishi/Title/the fleet officer";

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 10;
            sp.MoveToWorld(new Point3D(713, 1370, 6), Map.Tokuno);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            toSpawn = "BoatPainter";

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 15;
            sp.MoveToWorld(new Point3D(4552, 2337, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 15;
            sp.MoveToWorld(new Point3D(4552, 2337, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            toSpawn = "Banker";

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4554, 2315, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4554, 2315, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            toSpawn = "CrabFisher";

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 15;
            sp.MoveToWorld(new Point3D(4552, 2336, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 15;
            sp.MoveToWorld(new Point3D(4552, 2336, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 15;
            sp.MoveToWorld(new Point3D(4552, 2378, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 15;
            sp.MoveToWorld(new Point3D(4552, 2378, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            toSpawn = "DockMaster";

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 10;
            sp.MoveToWorld(new Point3D(4565, 2307, -2), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 10;
            sp.MoveToWorld(new Point3D(4565, 2307, -2), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            toSpawn = "SeaMarketTavernKeeper";

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4544, 2302, -1), Map.Trammel);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            sp = new XmlSpawner(toSpawn);
            sp.SpawnRange = 1;
            sp.HomeRange = 5;
            sp.MoveToWorld(new Point3D(4544, 2302, -1), Map.Felucca);
            sp.Respawn();
            WeakEntityCollection.Add(name, sp);

            SeaMarketBuoy bouy1 = new SeaMarketBuoy();
            SeaMarketBuoy bouy2 = new SeaMarketBuoy();
            SeaMarketBuoy bouy3 = new SeaMarketBuoy();
            SeaMarketBuoy bouy4 = new SeaMarketBuoy();
            SeaMarketBuoy bouy5 = new SeaMarketBuoy();
            SeaMarketBuoy bouy6 = new SeaMarketBuoy();
            SeaMarketBuoy bouy7 = new SeaMarketBuoy();
            SeaMarketBuoy bouy8 = new SeaMarketBuoy();

            Rectangle2D bound = Server.Regions.SeaMarketRegion.Bounds[0];

            bouy1.MoveToWorld(new Point3D(bound.X, bound.Y, -5), Map.Felucca);
            bouy2.MoveToWorld(new Point3D(bound.X, bound.Y, -5), Map.Trammel);
            WeakEntityCollection.Add(name, bouy1);
            WeakEntityCollection.Add(name, bouy2);

            bouy3.MoveToWorld(new Point3D(bound.X + bound.Width, bound.Y, -5), Map.Felucca);
            bouy4.MoveToWorld(new Point3D(bound.X + bound.Width, bound.Y, -5), Map.Trammel);
            WeakEntityCollection.Add(name, bouy3);
            WeakEntityCollection.Add(name, bouy4);

            bouy5.MoveToWorld(new Point3D(bound.X + bound.Width, bound.Y + bound.Height, -5), Map.Felucca);
            bouy6.MoveToWorld(new Point3D(bound.X + bound.Width, bound.Y + bound.Height, -5), Map.Trammel);
            WeakEntityCollection.Add(name, bouy5);
            WeakEntityCollection.Add(name, bouy6);

            bouy7.MoveToWorld(new Point3D(bound.X, bound.Y + bound.Height, -5), Map.Felucca);
            bouy8.MoveToWorld(new Point3D(bound.X, bound.Y + bound.Height, -5), Map.Trammel);
            WeakEntityCollection.Add(name, bouy7);
            WeakEntityCollection.Add(name, bouy8);

            Console.WriteLine("High Seas Content generated.");
        }
Beispiel #8
0
			protected override void OnTarget( Mobile from, object targeted )
			{
				if(from == null) return;

				// assign it a unique id
				Guid SpawnId = Guid.NewGuid();
				// count the number of entries to be added for maxcount
				int maxcount = 0;
				for(int i = 0; i<MaxEntries;i++)
				{
					if(defs.SelectionList != null && i < defs.SelectionList.Length && defs.SelectionList[i] &&
						defs.NameList != null && i < defs.NameList.Length && defs.NameList[i] != null && defs.NameList[i].Length > 0)
					{
						maxcount++;
					}
				}
                
				// if autonumbering is enabled, name the spawner with the name+number
				string sname = defs.SpawnerName;
				if(defs.AutoNumber)
				{
					sname = String.Format("{0}#{1}",defs.SpawnerName, defs.AutoNumberValue);
				}

				XmlSpawner spawner = new XmlSpawner( SpawnId, from.Location.X, from.Location.Y, 0, 0, sname, maxcount,
					defs.MinDelay, defs.MaxDelay, defs.Duration, defs.ProximityRange, defs.ProximitySound, 1,
					defs.Team, defs.HomeRange, defs.HomeRangeIsRelative, new XmlSpawner.SpawnObject[0], defs.RefractMin, defs.RefractMax,
					defs.TODStart, defs.TODEnd, null, defs.TriggerObjectProp, defs.ProximityMsg, defs.TriggerOnCarried, defs.NoTriggerOnCarried,
					defs.SpeechTrigger, null, null, defs.PlayerTriggerProp, defs.TriggerProbability , null, defs.Group, defs.TODMode, defs.KillReset, defs.ExternalTriggering,
					defs.SequentialSpawn, null, defs.AllowGhostTrig, defs.AllowNPCTrig, defs.SpawnOnTrigger, null, defs.DespawnTime, defs.SkillTrigger, defs.SmartSpawning, null);

				spawner.PlayerCreated = true;

				// if the object is a container, then place it in the container
				if(targeted is Container)
				{
					((Container)targeted).DropItem(spawner);
				} 
				else
				{
					// place the spawner at the targeted location
					IPoint3D p = targeted as IPoint3D;
					if(p == null)
					{
						spawner.Delete();
						return;
					}
					if ( p is Item )
						p = ((Item)p).GetWorldTop();

					spawner.MoveToWorld( new Point3D(p), from.Map );

				}

				spawner.SpawnRange = defs.SpawnRange;
				// add entries from the name list
				for(int i = 0; i<MaxEntries;i++)
				{
					if(defs.SelectionList != null && i < defs.SelectionList.Length && defs.SelectionList[i] &&
						defs.NameList != null && i < defs.NameList.Length && defs.NameList[i] != null && defs.NameList[i].Length > 0)
					{
						spawner.AddSpawn = defs.NameList[i];
					}
				}

				defs.LastSpawner = spawner;
           
				if(defs.AutoNumber)
					// bump the autonumber
					defs.AutoNumberValue++;

				//from.CloseGump(typeof(XmlAddGump));
				XmlAddGump.Refresh(m_state.Mobile, true);

				// open the spawner gump 
				DoShowGump(from, spawner);

			}
Beispiel #9
0
        public static void Generate()
        {
            ExperimentalRoomController controller = new ExperimentalRoomController();
            controller.MoveToWorld(new Point3D(980, 1117, -42), Map.TerMur);

            //Room 0 to 1
            ExperimentalRoomDoor door = new ExperimentalRoomDoor(Room.RoomZero, DoorFacing.WestCCW);
            ExperimentalRoomBlocker blocker = new ExperimentalRoomBlocker(Room.RoomZero);
            door.Hue = 1109;
            door.MoveToWorld(new Point3D(984, 1116, -42), Map.TerMur);
            blocker.MoveToWorld(new Point3D(984, 1116, -42), Map.TerMur);

            door = new ExperimentalRoomDoor(Room.RoomZero, DoorFacing.EastCW);
            blocker = new ExperimentalRoomBlocker(Room.RoomZero);
            door.Hue = 1109;
            door.MoveToWorld(new Point3D(985, 1116, -42), Map.TerMur);
            blocker.MoveToWorld(new Point3D(985, 1116, -42), Map.TerMur);

            //Room 1 to 2
            door = new ExperimentalRoomDoor(Room.RoomOne, DoorFacing.WestCCW);
            blocker = new ExperimentalRoomBlocker(Room.RoomOne);
            door.Hue = 1109;
            door.MoveToWorld(new Point3D(984, 1102, -42), Map.TerMur);
            blocker.MoveToWorld(new Point3D(984, 1102, -42), Map.TerMur);

            door = new ExperimentalRoomDoor(Room.RoomOne, DoorFacing.EastCW);
            blocker = new ExperimentalRoomBlocker(Room.RoomOne);
            door.Hue = 1109;
            door.MoveToWorld(new Point3D(985, 1102, -42), Map.TerMur);
            blocker.MoveToWorld(new Point3D(985, 1102, -42), Map.TerMur);

            //Room 2 to 3
            door = new ExperimentalRoomDoor(Room.RoomTwo, DoorFacing.WestCCW);
            blocker = new ExperimentalRoomBlocker(Room.RoomTwo);
            door.Hue = 1109;
            door.MoveToWorld(new Point3D(984, 1090, -42), Map.TerMur);
            blocker.MoveToWorld(new Point3D(984, 1090, -42), Map.TerMur);

            door = new ExperimentalRoomDoor(Room.RoomTwo, DoorFacing.EastCW);
            blocker = new ExperimentalRoomBlocker(Room.RoomTwo);
            door.Hue = 1109;
            door.MoveToWorld(new Point3D(985, 1090, -42), Map.TerMur);
            blocker.MoveToWorld(new Point3D(985, 1090, -42), Map.TerMur);

            //Room 3 to 4
            door = new ExperimentalRoomDoor(Room.RoomTwo, DoorFacing.WestCCW);
            blocker = new ExperimentalRoomBlocker(Room.RoomThree);
            door.Hue = 1109;
            door.MoveToWorld(new Point3D(984, 1072, -42), Map.TerMur);
            blocker.MoveToWorld(new Point3D(984, 1072, -42), Map.TerMur);

            door = new ExperimentalRoomDoor(Room.RoomTwo, DoorFacing.EastCW);
            blocker = new ExperimentalRoomBlocker(Room.RoomThree);
            door.Hue = 1109;
            door.MoveToWorld(new Point3D(985, 1072, -42), Map.TerMur);
            blocker.MoveToWorld(new Point3D(985, 1072, -42), Map.TerMur);

            ExperimentalRoomChest chest = new ExperimentalRoomChest();
            chest.MoveToWorld(new Point3D(984, 1064, -37), Map.TerMur);

            ExperimentalBook instr = new ExperimentalBook();
            instr.Movable = false;
            instr.MoveToWorld(new Point3D(995, 1114, -36), Map.TerMur);

            SecretDungeonDoor dd = new SecretDungeonDoor(DoorFacing.NorthCCW);
            dd.ClosedID = 87;
            dd.OpenedID = 88;
            dd.MoveToWorld(new Point3D(1007, 1119, -42), Map.TerMur);

            LocalizedSign sign = new LocalizedSign(3026, 1113407);  // Experimental Room Access
            sign.Movable = false;
            sign.MoveToWorld(new Point3D(980, 1119, -37), Map.TerMur);

            //Puzze Room
            PuzzleBox box = new PuzzleBox(PuzzleType.WestBox);
            box.MoveToWorld(new Point3D(1090, 1171, 11), Map.TerMur);

            box = new PuzzleBox(PuzzleType.EastBox);
            box.MoveToWorld(new Point3D(1104, 1171, 11), Map.TerMur);

            box = new PuzzleBox(PuzzleType.NorthBox);
            box.MoveToWorld(new Point3D(1097, 1163, 11), Map.TerMur);

            XmlSpawner spawner = new XmlSpawner("MagicKey");
            spawner.MoveToWorld(new Point3D(1109, 1150, -12), Map.TerMur);
            spawner.SpawnRange = 0;
            spawner.MinDelay = TimeSpan.FromSeconds(30);
            spawner.MaxDelay = TimeSpan.FromSeconds(45);
            spawner.DoRespawn = true;

            PuzzleBook book = new PuzzleBook();
            book.Movable = false;
            book.MoveToWorld(new Point3D(1109, 1153, -17), Map.TerMur);

            PuzzleRoomTeleporter tele = new PuzzleRoomTeleporter();
            tele.PointDest = new Point3D(1097, 1173, 1);
            tele.MapDest = Map.TerMur;
            tele.MoveToWorld(new Point3D(1097, 1175, 0), Map.TerMur);

            tele = new PuzzleRoomTeleporter();
            tele.PointDest = new Point3D(1098, 1173, 1);
            tele.MapDest = Map.TerMur;
            tele.MoveToWorld(new Point3D(1098, 1175, 0), Map.TerMur);

            MetalDoor2 door2 = new MetalDoor2(DoorFacing.WestCCW);
            door2.Locked = true;
            door2.KeyValue = 50000;
            door2.MoveToWorld(new Point3D(1097, 1174, 1), Map.TerMur);

            door2 = new MetalDoor2(DoorFacing.EastCW);
            door2.Locked = true;
            door2.KeyValue = 50000;
            door2.MoveToWorld(new Point3D(1098, 1174, 1), Map.TerMur);

            Teleporter telep = new Teleporter();
            telep.PointDest = new Point3D(1097, 1175, 0);
            telep.MapDest = Map.TerMur;
            telep.MoveToWorld(new Point3D(1097, 1173, 1), Map.TerMur);

            telep = new Teleporter();
            telep.PointDest = new Point3D(1098, 1175, 0);
            telep.MapDest = Map.TerMur;
            telep.MoveToWorld(new Point3D(1098, 1173, 1), Map.TerMur);

            telep = new Teleporter();
            telep.PointDest = new Point3D(996, 1117, -42);
            telep.MapDest = Map.TerMur;
            telep.MoveToWorld(new Point3D(980, 1064, -42), Map.TerMur);

            Static sparkle = new Static(14138);
            sparkle.MoveToWorld(new Point3D(980, 1064, -42), Map.TerMur);

            //Maze of Death
            UnderworldPuzzleBox pBox = new UnderworldPuzzleBox();
            pBox.MoveToWorld(new Point3D(1068, 1026, -37), Map.TerMur);

            GoldenCompass compass = new GoldenCompass();
            compass.MoveToWorld(new Point3D(1070, 1055, -34), Map.TerMur);

            Item map = new RolledMapOfTheUnderworld();
            map.MoveToWorld(new Point3D(1072, 1055, -36), Map.TerMur);
            map.Movable = false;

            FountainOfFortune f = new FountainOfFortune();
            f.MoveToWorld(new Point3D(1121, 962, -42), Map.TerMur);

            Console.WriteLine("Experimental Room, Puzzle Room and Maze of Death initialized.");
        }
Beispiel #10
0
        private void Setup()
        {
            Static s;

            for (int i = 0; i < 9; i++)
            {
                s = new Static(2931);
                s.MoveToWorld(new Point3D(748 + i, 2136, 0), Map.Trammel);

                s = new Static(2928);
                s.MoveToWorld(new Point3D(748 + i, 2137, 0), Map.Trammel);

                s = new Static(2931);
                s.MoveToWorld(new Point3D(748 + i, 2136, 0), Map.Felucca);

                s = new Static(2928);
                s.MoveToWorld(new Point3D(748 + i, 2137, 0), Map.Felucca);
            }

            HuntingDisplayTrophy trophy = new HuntingDisplayTrophy(HuntType.GrizzlyBear);
            trophy.MoveToWorld(new Point3D(748, 2137, 6), Map.Trammel);

            trophy = new HuntingDisplayTrophy(HuntType.GrizzlyBear);
            trophy.MoveToWorld(new Point3D(748, 2137, 6), Map.Felucca);

            trophy = new HuntingDisplayTrophy(HuntType.GrayWolf);
            trophy.MoveToWorld(new Point3D(751, 2137, 6), Map.Felucca);

            trophy = new HuntingDisplayTrophy(HuntType.GrayWolf);
            trophy.MoveToWorld(new Point3D(751, 2137, 6), Map.Trammel);

            trophy = new HuntingDisplayTrophy(HuntType.Cougar);
            trophy.MoveToWorld(new Point3D(753, 2137, 6), Map.Felucca);

            trophy = new HuntingDisplayTrophy(HuntType.Cougar);
            trophy.MoveToWorld(new Point3D(753, 2137, 6), Map.Trammel);

            trophy = new HuntingDisplayTrophy(HuntType.Turkey);
            trophy.MoveToWorld(new Point3D(756, 2137, 6), Map.Felucca);

            trophy = new HuntingDisplayTrophy(HuntType.Turkey);
            trophy.MoveToWorld(new Point3D(756, 2137, 6), Map.Trammel);

            trophy = new HuntingDisplayTrophy(HuntType.Bull);
            trophy.MoveToWorld(new Point3D(748, 2136, 2), Map.Felucca);

            trophy = new HuntingDisplayTrophy(HuntType.Bull);
            trophy.MoveToWorld(new Point3D(748, 2136, 2), Map.Trammel);

            trophy = new HuntingDisplayTrophy(HuntType.Boar);
            trophy.MoveToWorld(new Point3D(750, 2136, 2), Map.Felucca);

            trophy = new HuntingDisplayTrophy(HuntType.Boar);
            trophy.MoveToWorld(new Point3D(750, 2136, 2), Map.Trammel);

            trophy = new HuntingDisplayTrophy(HuntType.Walrus);
            trophy.MoveToWorld(new Point3D(752, 2136, 2), Map.Felucca);

            trophy = new HuntingDisplayTrophy(HuntType.Walrus);
            trophy.MoveToWorld(new Point3D(752, 2136, 2), Map.Trammel);

            trophy = new HuntingDisplayTrophy(HuntType.Alligator);
            trophy.MoveToWorld(new Point3D(754, 2136, 2), Map.Felucca);

            trophy = new HuntingDisplayTrophy(HuntType.Alligator);
            trophy.MoveToWorld(new Point3D(754, 2136, 2), Map.Trammel);

            trophy = new HuntingDisplayTrophy(HuntType.Eagle);
            trophy.MoveToWorld(new Point3D(756, 2136, 3), Map.Felucca);

            trophy = new HuntingDisplayTrophy(HuntType.Eagle);
            trophy.MoveToWorld(new Point3D(756, 2136, 3), Map.Trammel);

            XmlSpawner spawner = new XmlSpawner("HuntMaster");
            spawner.MoveToWorld(new Point3D(747, 2148, 0), Map.Felucca);
            spawner.DoRespawn = true;

            spawner = new XmlSpawner("HuntMaster");
            spawner.MoveToWorld(new Point3D(747, 2148, 0), Map.Trammel);
            spawner.DoRespawn = true;
        }