From 8b37d93c211e4fd60c3a71aa721a9a18f8189503 Mon Sep 17 00:00:00 2001 From: WarrentyExpired Date: Sat, 8 Aug 2026 21:09:51 -0400 Subject: [PATCH] #W# BuildWorld command. --- Scripts/Commands/BuildWorld.cs | 69 ++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Scripts/Commands/BuildWorld.cs diff --git a/Scripts/Commands/BuildWorld.cs b/Scripts/Commands/BuildWorld.cs new file mode 100644 index 0000000..dd27ad6 --- /dev/null +++ b/Scripts/Commands/BuildWorld.cs @@ -0,0 +1,69 @@ +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 Towns..."); + Server.SpawnGenerator.Parse( e.Mobile, "towns.map" ); + } + } +}