Exemplo n.º 1
0
		public void InitSpawn( int x, int y, int width, int height, string name, int maxCount, TimeSpan minDelay, TimeSpan maxDelay, TimeSpan duration,
			int proximityRange, int proximityTriggerSound, int amount, int team, int homeRange, bool isRelativeHomeRange, SpawnObject[] objectsToSpawn,
			TimeSpan minRefractory, TimeSpan maxRefractory, TimeSpan todstart, TimeSpan todend, Item objectPropertyItem, string objectPropertyName, string proximityMessage,
			string itemTriggerName, string noitemTriggerName, string speechTrigger, string mobTriggerName, string mobPropertyName, string playerPropertyName, double triggerProbability,
			Item setPropertyItem, bool isGroup, TODModeType todMode, int killReset, bool externalTriggering, int sequentialSpawning, string regionName, bool allowghost, bool allownpc, bool spawnontrigger,
			string configfile, TimeSpan despawnTime, string skillTrigger, bool smartSpawning, WayPoint wayPoint )
		{

			Visible = false;
			Movable = false;
			m_X = x;
			m_Y = y;
			m_Width = width;
			m_Height = height;

			// init spawn range if compatible
			if( width == height )
				m_SpawnRange = width / 2;
			else
				m_SpawnRange = -1;
			m_Running = true;
			m_Group = isGroup;

			if( (name != null) && (name.Length > 0) )
				Name = name;
			else
				Name = "Spawner";

			m_MinDelay = minDelay;
			m_MaxDelay = maxDelay;

			// duration and proximity range parameter
			m_MinRefractory = minRefractory;
			m_MaxRefractory = maxRefractory;
			m_TODStart = todstart;
			m_TODEnd = todend;
			m_TODMode = todMode;
			m_KillReset = killReset;
			m_Duration = duration;
			m_DespawnTime = despawnTime;
			m_ProximityRange = proximityRange;
			m_ProximityTriggerSound = proximityTriggerSound;
			m_proximityActivated = false;
			m_durActivated = false;
			m_refractActivated = false;
			m_Count = maxCount;
			m_Team = team;
			m_StackAmount = amount;
			m_HomeRange = homeRange;
			m_HomeRangeIsRelative = isRelativeHomeRange;
			m_ObjectPropertyItem = objectPropertyItem;
			m_ObjectPropertyName = objectPropertyName;
			m_ProximityTriggerMessage = proximityMessage;
			m_ItemTriggerName = itemTriggerName;
			m_NoItemTriggerName = noitemTriggerName;
			m_SpeechTrigger = speechTrigger;
			SkillTrigger = skillTrigger;        // note this will register the skill as well
			m_MobTriggerName = mobTriggerName;
			m_MobPropertyName = mobPropertyName;
			m_PlayerPropertyName = playerPropertyName;
			m_TriggerProbability = triggerProbability;
			m_SetPropertyItem = setPropertyItem;
			m_ExternalTriggering = externalTriggering;
			m_ExternalTrigger = false;
			m_SequentialSpawning = sequentialSpawning;
			RegionName = regionName;
			m_AllowGhostTriggering = allowghost;
			m_AllowNPCTriggering = allownpc;
			m_SpawnOnTrigger = spawnontrigger;
			m_SmartSpawning = smartSpawning;
			ConfigFile = configfile;
			m_WayPoint = wayPoint;

			// set the totalitem property to -1 so that it doesnt show up in the item count of containers
			//TotalItems = -1;
			//UpdateTotal(this, TotalType.Items, -1);

			// Create the array of spawned objects
			m_SpawnObjects = new ArrayList();

			// Assign the list of objects to spawn
			SpawnObjects = objectsToSpawn;

			// Kick off the process
			DoTimer( TimeSpan.FromSeconds( 1 ) );
		}
Exemplo n.º 2
0
		public XmlSpawner( Guid uniqueId, int x, int y, int width, int height, string name, int maxCount, TimeSpan minDelay, TimeSpan maxDelay, TimeSpan duration,
			int proximityRange, int proximityTriggerSound, int amount, int team, int homeRange, bool isRelativeHomeRange, SpawnObject[] spawnObjects,
			TimeSpan minRefractory, TimeSpan maxRefractory, TimeSpan todstart, TimeSpan todend, Item objectPropertyItem, string objectPropertyName, string proximityMessage,
			string itemTriggerName, string noitemTriggerName, string speechTrigger, string mobTriggerName, string mobPropertyName, string playerPropertyName, double triggerProbability,
			Item setPropertyItem, bool isGroup, TODModeType todMode, int killReset, bool externalTriggering, int sequentialSpawning, string regionName,
			bool allowghost, bool allownpc, bool spawnontrigger, string configfile, TimeSpan despawnTime, string skillTrigger, bool smartSpawning, WayPoint wayPoint )
			: base( BaseItemId )
		{
			m_UniqueId = uniqueId.ToString();
			InitSpawn( x, y, width, height, name, maxCount, minDelay, maxDelay, duration,
				proximityRange, proximityTriggerSound, amount, team, homeRange, isRelativeHomeRange, spawnObjects, minRefractory, maxRefractory, todstart, todend,
				objectPropertyItem, objectPropertyName, proximityMessage, itemTriggerName, noitemTriggerName, speechTrigger, mobTriggerName, mobPropertyName, playerPropertyName,
				triggerProbability, setPropertyItem, isGroup, todMode, killReset, externalTriggering, sequentialSpawning, regionName, allowghost, allownpc, spawnontrigger, configfile,
				despawnTime, skillTrigger, smartSpawning, wayPoint );
		}
Exemplo n.º 3
0
		public static void XmlDefaults_OnCommand( CommandEventArgs e )
		{
			Mobile m = e.Mobile;
			if( m == null || m.Deleted ) return;
			if( e.Arguments.Length >= 1 )
			{
				// leave open the possibility of just requesting display of a single property
				if( e.Arguments.Length == 2 )
				{
					if( e.Arguments[0].ToLower() == "save" )
					{
						XmlSaveDefaults( e.Arguments[1], m );
					}
					else
						if( e.Arguments[0].ToLower() == "load" )
						{
							XmlLoadDefaults( e.Arguments[1], m );
						}
						else
							// try to set the property
							if( e.Arguments[0].ToLower() == "maxdelay" )
							{
								try
								{
									XmlSpawner.defMaxDelay = TimeSpan.FromMinutes( Convert.ToDouble( e.Arguments[1] ) );
									m.SendMessage( "MaxDelay = {0}", XmlSpawner.defMaxDelay );
								}
								catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
							}
							else
								if( e.Arguments[0].ToLower() == "mindelay" )
								{
									try
									{
										XmlSpawner.defMinDelay = TimeSpan.FromMinutes( Convert.ToDouble( e.Arguments[1] ) );
										m.SendMessage( "MinDelay = {0}", XmlSpawner.defMinDelay );
									}
									catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
								}
								else
									if( e.Arguments[0].ToLower() == "spawnrange" )
									{
										try
										{
											XmlSpawner.defSpawnRange = Convert.ToInt32( e.Arguments[1] );
											m.SendMessage( "SpawnRange = {0}", XmlSpawner.defSpawnRange );
										}
										catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
									}
									else
										if( e.Arguments[0].ToLower() == "homerange" )
										{
											try
											{
												XmlSpawner.defHomeRange = Convert.ToInt32( e.Arguments[1] );
												m.SendMessage( "HomeRange = {0}", XmlSpawner.defHomeRange );
											}
											catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
										}
										else
											if( e.Arguments[0].ToLower() == "relativehome" )
											{
												try
												{
													XmlSpawner.defRelativeHome = Convert.ToBoolean( e.Arguments[1] );
													m.SendMessage( "RelativeHome = {0}", XmlSpawner.defRelativeHome );
												}
												catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
											}
											else
												if( e.Arguments[0].ToLower() == "proximitytriggersound" )
												{
													try
													{
														XmlSpawner.defProximityTriggerSound = Convert.ToInt32( e.Arguments[1] );
														m.SendMessage( "ProximityTriggerSound = {0}", XmlSpawner.defProximityTriggerSound );
													}
													catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
												}
												else
													if( e.Arguments[0].ToLower() == "proximityrange" )
													{
														try
														{
															XmlSpawner.defProximityRange = Convert.ToInt32( e.Arguments[1] );
															m.SendMessage( "ProximityRange = {0}", XmlSpawner.defProximityRange );
														}
														catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
													}
													else
														if( e.Arguments[0].ToLower() == "triggerprobability" )
														{
															try
															{
																XmlSpawner.defTriggerProbability = Convert.ToDouble( e.Arguments[1] );
																m.SendMessage( "TriggerProbability = {0}", XmlSpawner.defTriggerProbability );
															}
															catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
														}
														else
															if( e.Arguments[0].ToLower() == "todstart" )
															{
																try
																{
																	XmlSpawner.defTODStart = TimeSpan.FromMinutes( Convert.ToDouble( e.Arguments[1] ) );
																	m.SendMessage( "TODStart = {0}", XmlSpawner.defTODStart );
																}
																catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
															}
															else
																if( e.Arguments[0].ToLower() == "todend" )
																{
																	try
																	{
																		XmlSpawner.defTODEnd = TimeSpan.FromMinutes( Convert.ToDouble( e.Arguments[1] ) );
																		m.SendMessage( "TODEnd = {0}", XmlSpawner.defTODEnd );
																	}
																	catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
																}
																else
																	if( e.Arguments[0].ToLower() == "stackamount" )
																	{
																		try
																		{
																			XmlSpawner.defAmount = Convert.ToInt32( e.Arguments[1] );
																			m.SendMessage( "StackAmount = {0}", XmlSpawner.defAmount );
																		}
																		catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
																	}
																	else
																		if( e.Arguments[0].ToLower() == "duration" )
																		{
																			try
																			{
																				XmlSpawner.defDuration = TimeSpan.FromMinutes( Convert.ToDouble( e.Arguments[1] ) );
																				m.SendMessage( "Duration = {0}", XmlSpawner.defDuration );
																			}
																			catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
																		}
																		else
																			if( e.Arguments[0].ToLower() == "group" )
																			{
																				try
																				{
																					XmlSpawner.defIsGroup = Convert.ToBoolean( e.Arguments[1] );
																					m.SendMessage( "Group = {0}", XmlSpawner.defIsGroup );
																				}
																				catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
																			}
																			else
																				if( e.Arguments[0].ToLower() == "team" )
																				{
																					try
																					{
																						XmlSpawner.defTeam = Convert.ToInt32( e.Arguments[1] );
																						m.SendMessage( "Team = {0}", XmlSpawner.defTeam );
																					}
																					catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
																				}
																				else
																					if( e.Arguments[0].ToLower() == "todmode" )
																					{
																						int todmode = (int)TODModeType.Realtime;
																						try
																						{
																							todmode = Convert.ToInt32( e.Arguments[1] );
																							switch( todmode )
																							{
																								case (int)TODModeType.Gametime:
																									XmlSpawner.defTODMode = TODModeType.Gametime;
																									break;
																								case (int)TODModeType.Realtime:
																									XmlSpawner.defTODMode = TODModeType.Realtime;
																									break;
																							}
																							m.SendMessage( "TODMode = {0}", XmlSpawner.defTODMode );
																						}
																						catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
																					}
																					else
																						if( e.Arguments[0].ToLower() == "maxrefractory" )
																						{
																							try
																							{
																								XmlSpawner.defMaxRefractory = TimeSpan.FromMinutes( Convert.ToDouble( e.Arguments[1] ) );
																								m.SendMessage( "MaxRefractory = {0}", XmlSpawner.defMaxRefractory );
																							}
																							catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
																						}
																						else
																							if( e.Arguments[0].ToLower() == "minrefractory" )
																							{
																								try
																								{
																									XmlSpawner.defMinRefractory = TimeSpan.FromMinutes( Convert.ToDouble( e.Arguments[1] ) );
																									m.SendMessage( "MinRefractory = {0}", XmlSpawner.defMinRefractory );
																								}
																								catch { m.SendMessage( "invalid value : {0}", e.Arguments[1] ); }
																							}
																							else
																							{
																								m.SendMessage( "{0} : no such default value.", e.Arguments[0] );
																							}
				}

			}
			else
			{
				// just display the values
				m.SendMessage( "TriggerProbability = {0}", XmlSpawner.defTriggerProbability );
				m.SendMessage( "ProximityRange = {0}", XmlSpawner.defProximityRange );
				m.SendMessage( "ProximityTriggerSound = {0}", XmlSpawner.defProximityTriggerSound );
				m.SendMessage( "MinRefractory = {0}", XmlSpawner.defMinRefractory );
				m.SendMessage( "MaxRefractory = {0}", XmlSpawner.defMaxRefractory );
				m.SendMessage( "TODStart = {0}", XmlSpawner.defTODStart );
				m.SendMessage( "TODEnd = {0}", XmlSpawner.defTODEnd );
				m.SendMessage( "TODMode = {0}", XmlSpawner.defTODMode );
				m.SendMessage( "StackAmount = {0}", XmlSpawner.defAmount );
				m.SendMessage( "Duration = {0}", XmlSpawner.defDuration );
				m.SendMessage( "Group = {0}", XmlSpawner.defIsGroup );
				m.SendMessage( "Team = {0}", XmlSpawner.defTeam );
				m.SendMessage( "RelativeHome = {0}", XmlSpawner.defRelativeHome );
				m.SendMessage( "SpawnRange = {0}", XmlSpawner.defSpawnRange );
				m.SendMessage( "HomeRange = {0}", XmlSpawner.defHomeRange );
				m.SendMessage( "MinDelay = {0}", XmlSpawner.defMinDelay );
				m.SendMessage( "MaxDelay = {0}", XmlSpawner.defMaxDelay );
			}
		}
Exemplo n.º 4
0
		private static void LoadDefaults( XmlElement node )
		{

			try { XmlSpawner.defProximityRange = int.Parse( node["defProximityRange"].InnerText ); }
			catch { }
			try { XmlSpawner.defTriggerProbability = double.Parse( node["defTriggerProbability"].InnerText ); }
			catch { }
			try { XmlSpawner.defProximityTriggerSound = int.Parse( node["defProximityTriggerSound"].InnerText ); }
			catch { }
			try { XmlSpawner.defMinRefractory = TimeSpan.Parse( node["defMinRefractory"].InnerText ); }
			catch { }
			try { XmlSpawner.defMaxRefractory = TimeSpan.Parse( node["defMaxRefractory"].InnerText ); }
			catch { }
			try { XmlSpawner.defTODStart = TimeSpan.Parse( node["defTODStart"].InnerText ); }
			catch { }
			try { XmlSpawner.defTODEnd = TimeSpan.Parse( node["defTODEnd"].InnerText ); }
			catch { }
			try { XmlSpawner.defAmount = int.Parse( node["defStackAmount"].InnerText ); }
			catch { }
			try { XmlSpawner.defDuration = TimeSpan.Parse( node["defDuration"].InnerText ); }
			catch { }
			try { XmlSpawner.defIsGroup = bool.Parse( node["defIsGroup"].InnerText ); }
			catch { }
			try { XmlSpawner.defTeam = int.Parse( node["defTeam"].InnerText ); }
			catch { }
			try { XmlSpawner.defRelativeHome = bool.Parse( node["defRelativeHome"].InnerText ); }
			catch { }
			try { XmlSpawner.defSpawnRange = int.Parse( node["defSpawnRange"].InnerText ); }
			catch { }
			try { XmlSpawner.defHomeRange = int.Parse( node["defHomeRange"].InnerText ); }
			catch { }
			try { XmlSpawner.defMinDelay = TimeSpan.Parse( node["defMinDelay"].InnerText ); }
			catch { }
			try { XmlSpawner.defMaxDelay = TimeSpan.Parse( node["defMaxDelay"].InnerText ); }
			catch { }
			int todmode = 0;
			try { todmode = int.Parse( node["defTODMode"].InnerText ); }
			catch { }
			switch( todmode )
			{
				case (int)TODModeType.Realtime:
					XmlSpawner.defTODMode = TODModeType.Realtime;
					break;
				case (int)TODModeType.Gametime:
					XmlSpawner.defTODMode = TODModeType.Gametime;
					break;
			}
		}
Exemplo n.º 5
0
		public void LoadXmlConfig( string filename )
		{
			if( filename == null || filename.Length <= 0 ) return;
			// Check if the file exists
			if( System.IO.File.Exists( filename ) == true )
			{
				FileStream fs = null;
				try
				{
					fs = File.Open( filename, FileMode.Open, FileAccess.Read );
				}
				catch { }

				if( fs == null )
				{
					status_str = String.Format( "Unable to open {0} for loading", filename );
					return;
				}

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

				// Read in the file
				bool fileerror = false;
				try
				{
					ds.ReadXml( fs );
				}
				catch { fileerror = true; }
				// close the file
				fs.Close();
				if( fileerror )
				{
					Console.WriteLine( "XmlSpawner: Error in XML config file '{0}'", filename );
					return;
				}

				// Check that at least a single table was loaded
				if( ds.Tables != null && ds.Tables.Count > 0 )
				{
					if( ds.Tables[XmlTableName] != null && ds.Tables[XmlTableName].Rows.Count > 0 )
					{
						foreach( DataRow dr in ds.Tables[XmlTableName].Rows )
						{
							bool valid_entry;
							string strEntry = null;
							bool boolEntry = true;
							double doubleEntry = 0;
							int intEntry = 0;

							valid_entry = true;
							try { strEntry = (string)dr["Name"]; }
							catch { valid_entry = false; }
							if( valid_entry ) { Name = strEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["X"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_X = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["Y"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_Y = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["Width"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_Width = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["Height"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_Height = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["CentreX"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { X = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["CentreY"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { Y = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["CentreZ"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { Z = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["SequentialSpawning"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_SequentialSpawning = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["ProximityRange"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_ProximityRange = intEntry; }

							valid_entry = true;
							try { strEntry = (string)dr["ProximityTriggerMessage"]; }
							catch { valid_entry = false; }
							if( valid_entry ) { m_ProximityTriggerMessage = strEntry; }

							valid_entry = true;
							try { strEntry = (string)dr["SpeechTrigger"]; }
							catch { valid_entry = false; }
							if( valid_entry ) { m_SpeechTrigger = strEntry; }

							valid_entry = true;
							try { strEntry = (string)dr["SkillTrigger"]; }
							catch { valid_entry = false; }
							if( valid_entry ) { m_SkillTrigger = strEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["ProximityTriggerSound"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_ProximityTriggerSound = intEntry; }

							valid_entry = true;
							try { strEntry = (string)dr["ItemTriggerName"]; }
							catch { valid_entry = false; }
							if( valid_entry ) { m_ItemTriggerName = strEntry; }

							valid_entry = true;
							try { strEntry = (string)dr["NoItemTriggerName"]; }
							catch { valid_entry = false; }
							if( valid_entry ) { m_NoItemTriggerName = strEntry; }

							// check for the delayinsec entry
							bool delayinsec = false;
							try { delayinsec = bool.Parse( (string)dr["DelayInSec"] ); }
							catch { }

							valid_entry = true;
							try { doubleEntry = double.Parse( (string)dr["MinDelay"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { if( delayinsec ) m_MinDelay = TimeSpan.FromSeconds( doubleEntry ); else m_MinDelay = TimeSpan.FromMinutes( doubleEntry ); }

							valid_entry = true;
							try { doubleEntry = double.Parse( (string)dr["MaxDelay"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { if( delayinsec ) m_MaxDelay = TimeSpan.FromSeconds( doubleEntry ); else m_MaxDelay = TimeSpan.FromMinutes( doubleEntry ); }

							valid_entry = true;
							try { doubleEntry = double.Parse( (string)dr["Duration"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_Duration = TimeSpan.FromMinutes( doubleEntry ); }

							valid_entry = true;
							try { doubleEntry = double.Parse( (string)dr["DespawnTime"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_DespawnTime = TimeSpan.FromHours( doubleEntry ); }

							valid_entry = true;
							try { doubleEntry = double.Parse( (string)dr["MinRefractory"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_MinRefractory = TimeSpan.FromMinutes( doubleEntry ); }

							valid_entry = true;
							try { doubleEntry = double.Parse( (string)dr["MaxRefractory"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_MaxRefractory = TimeSpan.FromMinutes( doubleEntry ); }

							valid_entry = true;
							try { doubleEntry = double.Parse( (string)dr["TODStart"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_TODStart = TimeSpan.FromMinutes( doubleEntry ); }

							valid_entry = true;
							try { doubleEntry = double.Parse( (string)dr["TODEnd"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_TODEnd = TimeSpan.FromMinutes( doubleEntry ); }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["TODMode"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_TODMode = (TODModeType)intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["Amount"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_StackAmount = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["MaxCount"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_Count = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["Range"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_HomeRange = intEntry; }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["Team"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_Team = intEntry; }

							valid_entry = true;
							try { strEntry = (string)dr["WayPoint"]; }
							catch { valid_entry = false; }
							if( valid_entry ) { m_WayPoint = GetWaypoint( strEntry ); }

							valid_entry = true;
							try { intEntry = int.Parse( (string)dr["KillReset"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_KillReset = intEntry; }

							valid_entry = true;
							try { doubleEntry = double.Parse( (string)dr["TriggerProbability"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_TriggerProbability = doubleEntry; }

							valid_entry = true;
							try { boolEntry = bool.Parse( (string)dr["ExternalTriggering"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_ExternalTriggering = boolEntry; }

							valid_entry = true;
							try { boolEntry = bool.Parse( (string)dr["IsGroup"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_Group = boolEntry; }

							valid_entry = true;
							try { boolEntry = bool.Parse( (string)dr["IsHomeRangeRelative"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_HomeRangeIsRelative = boolEntry; }

							valid_entry = true;
							try { boolEntry = bool.Parse( (string)dr["AllowGhostTriggering"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_AllowGhostTriggering = boolEntry; }

							valid_entry = true;
							try { boolEntry = bool.Parse( (string)dr["AllowNPCTriggering"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_AllowNPCTriggering = boolEntry; }

							valid_entry = true;
							try { boolEntry = bool.Parse( (string)dr["SpawnOnTrigger"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_SpawnOnTrigger = boolEntry; }

							valid_entry = true;
							try { boolEntry = bool.Parse( (string)dr["SmartSpawning"] ); }
							catch { valid_entry = false; }
							if( valid_entry ) { m_SmartSpawning = boolEntry; }

							valid_entry = true;
							try { strEntry = (string)dr["RegionName"]; }
							catch { valid_entry = false; }
							if( valid_entry )
							{
								RegionName = strEntry;
							}

							valid_entry = true;
							try { strEntry = (string)dr["PlayerPropertyName"]; }
							catch { valid_entry = false; }
							if( valid_entry )
							{
								m_PlayerPropertyName = strEntry;
							}

							valid_entry = true;
							try { strEntry = (string)dr["MobPropertyName"]; }
							catch { valid_entry = false; }
							if( valid_entry )
							{
								m_MobPropertyName = strEntry;
							}

							valid_entry = true;
							try { strEntry = (string)dr["MobTriggerName"]; }
							catch { valid_entry = false; }
							if( valid_entry )
							{
								m_MobTriggerName = strEntry;
							}

							valid_entry = true;
							try { strEntry = (string)dr["ObjectPropertyName"]; }
							catch { valid_entry = false; }
							if( valid_entry )
							{
								m_ObjectPropertyName = strEntry;
							}

							valid_entry = true;
							try { strEntry = (string)dr["ObjectPropertyItemName"]; }
							catch { valid_entry = false; }
							if( valid_entry )
							{
								string[] typeargs = strEntry.Split( ",".ToCharArray(), 2 );
								string typestr = null;
								string namestr = strEntry;

								if( typeargs.Length > 1 )
								{
									namestr = typeargs[0];
									typestr = typeargs[1];
								}
								m_ObjectPropertyItem = BaseXmlSpawner.FindItemByName( this, namestr, typestr );
							}

							valid_entry = true;
							try { strEntry = (string)dr["SetPropertyItemName"]; }
							catch { valid_entry = false; }
							if( valid_entry )
							{
								string[] typeargs = strEntry.Split( ",".ToCharArray(), 2 );
								string typestr = null;
								string namestr = strEntry;

								if( typeargs.Length > 1 )
								{
									namestr = typeargs[0];
									typestr = typeargs[1];
								}
								m_SetPropertyItem = BaseXmlSpawner.FindItemByName( this, namestr, typestr );
							}

							valid_entry = true;
							try { strEntry = (string)dr["Name"]; }
							catch { valid_entry = false; }
							if( valid_entry ) { Name = strEntry; }

							valid_entry = true;
							try { strEntry = (string)dr["Map"]; }
							catch { valid_entry = false; }
							if( valid_entry )
							{
								// Convert the xml map value to a real map object
								try
								{
									Map = Map.Parse( strEntry );
								}
								catch { }
							}

							// try loading the new spawn specifications first
							SpawnObject[] Spawns = new SpawnObject[0];
							bool havenew = true;
							valid_entry = 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 { valid_entry = false; }
								// can only have one of these defined
							}
							if( valid_entry )
							{

								// clear existing spawns
								RemoveSpawnObjects();

								// Create the new array of spawned objects
								m_SpawnObjects = new ArrayList();

								// Assign the list of objects to spawn
								SpawnObjects = Spawns;
							}
						}
					}
				}
			}
		}
Exemplo n.º 6
0
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
			bool haveproximityrange = false;
			bool hasnewobjectinfo = false;
			int tmpSpawnListSize = 0;
			ArrayList tmpSubGroup = null;
			ArrayList tmpSequentialResetTime = null;
			ArrayList tmpSequentialResetTo = null;
			ArrayList tmpKillsNeeded = null;
			ArrayList tmpRequireSurface = null;
			ArrayList tmpRestrictKillsToSubgroup = null;
			ArrayList tmpClearOnAdvance = null;
			ArrayList tmpMinDelay = null;
			ArrayList tmpMaxDelay = null;
			ArrayList tmpNextSpawn = null;
			ArrayList tmpDisableSpawn = null;
			ArrayList tmpPackRange = null;
			ArrayList tmpSpawnsPer = null;

			switch( version )
			{
				case 30:
					{
						m_AllowNPCTriggering = reader.ReadBool();
						goto case 29;
					}
				case 29:
					{
						tmpSpawnListSize = reader.ReadInt();
						tmpSpawnsPer = new ArrayList( tmpSpawnListSize );
						for( int i = 0; i < tmpSpawnListSize; ++i )
						{
							int spawnsper = reader.ReadInt();

							tmpSpawnsPer.Add( spawnsper );

						}
						goto case 28;
					}
				case 28:
					{
						if( version < 29 )
							tmpSpawnListSize = reader.ReadInt();

						tmpPackRange = new ArrayList( tmpSpawnListSize );
						for( int i = 0; i < tmpSpawnListSize; ++i )
						{
							int packrange = reader.ReadInt();

							tmpPackRange.Add( packrange );

						}
						goto case 27;
					}
				case 27:
					{
						if( version < 28 )
							tmpSpawnListSize = reader.ReadInt();

						tmpDisableSpawn = new ArrayList( tmpSpawnListSize );
						for( int i = 0; i < tmpSpawnListSize; ++i )
						{
							bool disablespawn = reader.ReadBool();

							tmpDisableSpawn.Add( disablespawn );

						}
						goto case 26;
					}
				case 26:
					{
						m_SpawnOnTrigger = reader.ReadBool();
						m_FirstModified = reader.ReadDateTime();
						m_LastModified = reader.ReadDateTime();
						goto case 25;
					}
				case 25:
					{
						goto case 24;
					}
				case 24:
					{
						if( version < 27 )
							tmpSpawnListSize = reader.ReadInt();
						tmpRestrictKillsToSubgroup = new ArrayList( tmpSpawnListSize );
						tmpClearOnAdvance = new ArrayList( tmpSpawnListSize );
						tmpMinDelay = new ArrayList( tmpSpawnListSize );
						tmpMaxDelay = new ArrayList( tmpSpawnListSize );
						tmpNextSpawn = new ArrayList( tmpSpawnListSize );
						for( int i = 0; i < tmpSpawnListSize; ++i )
						{
							bool restrictkills = reader.ReadBool();
							bool clearadvance = reader.ReadBool();
							double mind = reader.ReadDouble();
							double maxd = reader.ReadDouble();
							DateTime nextspawn = reader.ReadDeltaTime();

							tmpRestrictKillsToSubgroup.Add( restrictkills );
							tmpClearOnAdvance.Add( clearadvance );
							tmpMinDelay.Add( mind );
							tmpMaxDelay.Add( maxd );
							tmpNextSpawn.Add( nextspawn );
						}

						bool hasitems = reader.ReadBool();

						if( hasitems )
						{
							m_ShowBoundsItems = reader.ReadItemList();
						}
						goto case 23;
					}
				case 23:
					{
						IsInactivated = reader.ReadBool();
						SmartSpawning = reader.ReadBool();

						goto case 22;
					}
				case 22:
					{
						SkillTrigger = reader.ReadString();    // note this will also register the skill
						m_skill_that_triggered = (SkillName)reader.ReadInt();
						m_FreeRun = reader.ReadBool();
						m_mob_who_triggered = reader.ReadMobile();
						goto case 21;
					}
				case 21:
					{
						m_DespawnTime = reader.ReadTimeSpan();
						goto case 20;
					}
				case 20:
					{
						if( version < 24 )
							tmpSpawnListSize = reader.ReadInt();
						tmpRequireSurface = new ArrayList( tmpSpawnListSize );
						for( int i = 0; i < tmpSpawnListSize; ++i )
						{
							bool requiresurface = reader.ReadBool();
							tmpRequireSurface.Add( requiresurface );
						}
						goto case 19;
					}
				case 19:
					{
						m_ConfigFile = reader.ReadString();
						m_OnHold = reader.ReadBool();
						m_HoldSequence = reader.ReadBool();
						m_FirstModifiedBy = reader.ReadString();
						m_LastModifiedBy = reader.ReadString();
						// deserialize the keyword tag list
						int tagcount = reader.ReadInt();
						m_KeywordTagList = new ArrayList( tagcount );
						for( int i = 0; i < tagcount; i++ )
						{
							BaseXmlSpawner.KeywordTag tag = new BaseXmlSpawner.KeywordTag( null, this );
							tag.Deserialize( reader );
						}
						goto case 18;
					}
				case 18:
					{
						m_AllowGhostTriggering = reader.ReadBool();
						goto case 17;
					}
				case 17:
					{
						if( version < 25 )
						{
							// the textentrybooks are deleted on deserialization so no need to track them
							reader.ReadItem();
						}
						goto case 16;
					}
				case 16:
					{
						hasnewobjectinfo = true;
						m_SequentialSpawning = reader.ReadInt();
						TimeSpan seqdelay = reader.ReadTimeSpan();
						m_SeqEnd = DateTime.Now + seqdelay;
						if( version < 20 )
						{
							tmpSpawnListSize = reader.ReadInt();
						}
						tmpSubGroup = new ArrayList( tmpSpawnListSize );
						tmpSequentialResetTime = new ArrayList( tmpSpawnListSize );
						tmpSequentialResetTo = new ArrayList( tmpSpawnListSize );
						tmpKillsNeeded = new ArrayList( tmpSpawnListSize );
						for( int i = 0; i < tmpSpawnListSize; ++i )
						{
							int subgroup = reader.ReadInt();
							double resettime = reader.ReadDouble();
							int resetto = reader.ReadInt();
							int killsneeded = reader.ReadInt();
							tmpSubGroup.Add( subgroup );
							tmpSequentialResetTime.Add( resettime );
							tmpSequentialResetTo.Add( resetto );
							tmpKillsNeeded.Add( killsneeded );
						}
						m_RegionName = reader.ReadString();	// 2004.02.08 :: Omega Red
						goto case 15;
					}
				case 15:
					{
						m_ExternalTriggering = reader.ReadBool();
						m_ExternalTrigger = reader.ReadBool();
						goto case 14;
					}
				case 14:
					{
						m_NoItemTriggerName = reader.ReadString();
						goto case 13;
					}
				case 13:
					{
						m_GumpState = reader.ReadString();
						goto case 12;
					}
				case 12:
					{
						int todtype = reader.ReadInt();
						switch( todtype )
						{
							case (int)TODModeType.Gametime:
								m_TODMode = TODModeType.Gametime;
								break;
							case (int)TODModeType.Realtime:
								m_TODMode = TODModeType.Realtime;
								break;
						}
						goto case 11;
					}
				case 11:
					{
						m_KillReset = reader.ReadInt();
						m_skipped = reader.ReadBool();
						m_spawncheck = reader.ReadInt();
						goto case 10;
					}
				case 10:
					{
						m_SetPropertyItem = reader.ReadItem();
						goto case 9;
					}
				case 9:
					{
						m_TriggerProbability = reader.ReadDouble();
						goto case 8;
					}
				case 8:
					{
						m_MobPropertyName = reader.ReadString();
						m_MobTriggerName = reader.ReadString();
						m_PlayerPropertyName = reader.ReadString();
						goto case 7;
					}
				case 7:
					{
						m_SpeechTrigger = reader.ReadString();
						goto case 6;
					}
				case 6:
					{
						m_ItemTriggerName = reader.ReadString();
						goto case 5;
					}
				case 5:
					{
						m_ProximityTriggerMessage = reader.ReadString();
						m_ObjectPropertyItem = reader.ReadItem();
						m_ObjectPropertyName = reader.ReadString();
						m_killcount = reader.ReadInt();
						goto case 4;
					}
				case 4:
					{
						haveproximityrange = true;
						m_ProximityRange = reader.ReadInt();
						m_ProximityTriggerSound = reader.ReadInt();
						m_proximityActivated = reader.ReadBool();
						m_durActivated = reader.ReadBool();
						m_refractActivated = reader.ReadBool();
						m_StackAmount = reader.ReadInt();
						m_TODStart = reader.ReadTimeSpan();
						m_TODEnd = reader.ReadTimeSpan();
						m_MinRefractory = reader.ReadTimeSpan();
						m_MaxRefractory = reader.ReadTimeSpan();
						if( m_refractActivated == true )
						{
							TimeSpan delay = reader.ReadTimeSpan();
							DoTimer3( delay );
						}
						if( m_durActivated == true )
						{
							TimeSpan delay = reader.ReadTimeSpan();
							DoTimer2( delay );
						}
						goto case 3;
					}
				case 3:
					{
						m_ShowContainerStatic = reader.ReadItem() as Static;
						goto case 2;
					}
				case 2:
					{
						m_Duration = reader.ReadTimeSpan();
						goto case 1;
					}
				case 1:
					{
						m_UniqueId = reader.ReadString();
						m_HomeRangeIsRelative = reader.ReadBool();
						goto case 0;
					}
				case 0:
					{
						m_Name = reader.ReadString();
						// backward compatibility with old name storage
						if( m_Name != null && m_Name != String.Empty ) Name = m_Name;
						m_X = reader.ReadInt();
						m_Y = reader.ReadInt();
						m_Width = reader.ReadInt();
						m_Height = reader.ReadInt();
						if( m_Width == m_Height )
							m_SpawnRange = m_Width / 2;
						else
							m_SpawnRange = -1;
						if( !haveproximityrange )
						{
							m_ProximityRange = -1;
						}
						m_WayPoint = reader.ReadItem() as WayPoint;
						m_Group = reader.ReadBool();
						m_MinDelay = reader.ReadTimeSpan();
						m_MaxDelay = reader.ReadTimeSpan();
						m_Count = reader.ReadInt();
						m_Team = reader.ReadInt();
						m_HomeRange = reader.ReadInt();
						m_Running = reader.ReadBool();

						if( m_Running == true )
						{
							TimeSpan delay = reader.ReadTimeSpan();
							DoTimer( delay );
						}

						// Read in the size of the spawn object list
						int SpawnListSize = reader.ReadInt();
						m_SpawnObjects = new ArrayList( SpawnListSize );
						for( int i = 0; i < SpawnListSize; ++i )
						{
							string TypeName = reader.ReadString();
							int TypeMaxCount = reader.ReadInt();

							SpawnObject TheSpawnObject = new SpawnObject( TypeName, TypeMaxCount );

							m_SpawnObjects.Add( TheSpawnObject );

							string typeName = BaseXmlSpawner.ParseObjectType( TypeName );
							// does it have a substitution that might change its validity?
							// if so then let it go

							if( typeName == null || ((SpawnerType.GetType( typeName ) == null) &&
								(!BaseXmlSpawner.IsTypeOrItemKeyword( typeName ) && typeName.IndexOf( '{' ) == -1 && !typeName.StartsWith( "*" ) && !typeName.StartsWith( "#" ))) )
							{
								if( m_WarnTimer == null )
									m_WarnTimer = new WarnTimer2();

								m_WarnTimer.Add( Location, Map, TypeName );

								this.status_str = "invalid type: " + typeName;
							}

							// Read in the number of spawns already
							int SpawnedCount = reader.ReadInt();

							TheSpawnObject.SpawnedObjects = new ArrayList( SpawnedCount );

							for( int x = 0; x < SpawnedCount; ++x )
							{
								int serial = reader.ReadInt();
								if( serial < -1 )
								{
									// minusone is reserved for unknown types by default
									//  minustwo on is used for referencing keyword tags
									int tagserial = -1 * (serial + 2);
									// get the tag with that serial and add it
									BaseXmlSpawner.KeywordTag t = BaseXmlSpawner.GetFromTagList( this, tagserial );
									if( t != null )
									{
										TheSpawnObject.SpawnedObjects.Add( t );
									}
								}
								else
								{
									IEntity e = World.FindEntity( serial );

									if( e != null )
										TheSpawnObject.SpawnedObjects.Add( e );
								}
							}
						}
						// now have to reintegrate the later version spawnobject information into the earlier version desered objects
						if( hasnewobjectinfo && tmpSpawnListSize == SpawnListSize )
						{
							for( int i = 0; i < SpawnListSize; ++i )
							{
								SpawnObject so = (SpawnObject)m_SpawnObjects[i];

								so.SubGroup = (int)tmpSubGroup[i];
								so.SequentialResetTime = (double)tmpSequentialResetTime[i];
								so.SequentialResetTo = (int)tmpSequentialResetTo[i];
								so.KillsNeeded = (int)tmpKillsNeeded[i];
								if( version > 19 )
									so.RequireSurface = (bool)tmpRequireSurface[i];
								bool restrictkills = false;
								bool clearadvance = true;
								double mind = -1;
								double maxd = -1;
								DateTime nextspawn = DateTime.MinValue;
								if( version > 23 )
								{
									restrictkills = (bool)tmpRestrictKillsToSubgroup[i];
									clearadvance = (bool)tmpClearOnAdvance[i];
									mind = (double)tmpMinDelay[i];
									maxd = (double)tmpMaxDelay[i];
									nextspawn = (DateTime)tmpNextSpawn[i];
								}
								so.RestrictKillsToSubgroup = restrictkills;
								so.ClearOnAdvance = clearadvance;
								so.MinDelay = mind;
								so.MaxDelay = maxd;
								so.NextSpawn = nextspawn;

								bool disablespawn = false;
								if( version > 26 )
								{
									disablespawn = (bool)tmpDisableSpawn[i];
								}
								so.Disabled = disablespawn;

								int packrange = -1;
								if( version > 27 )
								{
									packrange = (int)tmpPackRange[i];
								}
								so.PackRange = packrange;

								int spawnsper = 1;
								if( version > 28 )
								{
									spawnsper = (int)tmpSpawnsPer[i];
								}
								so.SpawnsPerTick = spawnsper;

							}
						}

						break;
					}
			}
		}