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." ); } }
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." ); } }
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); } }
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 ); } } }
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); }