using Server.Accounting; using Server.Commands.Generic; using Server.Commands; using Server.Items; using Server.Misc; using Server.Mobiles; using Server.Network; using Server.Regions; using Server; using System.Collections.Generic; using System.Collections; using System.IO; using System; using System.Reflection; // Added to access private variables inside BaseSpawner namespace Server.Scripts.Commands { public class BuildWorld { public static void Initialize() { CommandSystem.Register("BuildWorld", AccessLevel.Counselor, new CommandEventHandler( BuildWorlds )); } [Usage("BuildWorld")] [Description("This cleans up the world and rebuilds it, leaving players intact.")] public static void BuildWorlds( CommandEventArgs e ) { Console.WriteLine( "Removing Spawners..." ); ArrayList targets = new ArrayList(); foreach ( Item item in World.Items.Values ) if ( item is PremiumSpawner ) { targets.Add( item ); } for ( int i = 0; i < targets.Count; ++i ) { Item item = ( Item )targets[ i ]; item.Delete(); } Console.WriteLine( "Removing wild mobs and animals..." ); ArrayList mobsToDelete = new ArrayList(); foreach ( Mobile m in World.Mobiles.Values ) { if ( m is BaseCreature ) { BaseCreature bc = (BaseCreature)m; if ( !bc.Controlled && !bc.IsStabled ) { mobsToDelete.Add( bc ); } } } for ( int i = 0; i < mobsToDelete.Count; ++i ) { Mobile m = ( Mobile )mobsToDelete[ i ]; m.Delete(); } Console.WriteLine( "Decorating the world..."); CommandSystem.Handle(e.Mobile, String.Format("{0}Decorate", CommandSystem.Prefix)); CommandSystem.Handle(e.Mobile, String.Format("{0}SignGen", CommandSystem.Prefix)); CommandSystem.Handle(e.Mobile, String.Format("{0}TelGen", CommandSystem.Prefix)); Console.WriteLine( "Spawning Overworld..."); Server.SpawnGenerator.Parse( e.Mobile, "overworld.map" ); Console.WriteLine( "Spawning Town Animals..."); Server.SpawnGenerator.Parse( e.Mobile, "townanimals.map" ); Console.WriteLine( "Spawning Camps..." ); Server.SpawnGenerator.Parse( e.Mobile, "camps.map" ); Console.WriteLine( "Spawning NPC's..." ); Console.WriteLine( "Spawning Dungeons..." ); Console.WriteLine( "The world has been built." ); } } }