RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Snow on ground

X.Amubsh.X

Traveler
So its December and i want my server to Feel Christmas like or Holiday like or whatever can anyone help me on how to make the Ground have snow?

I have played with this a little and i went to MapDefinitions.cs
Code:
RegisterMap( 0, 0, 0, 7168, 4096, 0, "Felucca",        MapRules.FeluccaRules );
            RegisterMap( 1, 1, 1, 7168, 4096, 0, "Trammel",        MapRules.TrammelRules );
            RegisterMap( 2, 2, 2, 2304, 1600, 1, "Ilshenar",    MapRules.FeluccaRules );
            RegisterMap( 3, 3, 3, 2560, 2048, 1, "Malas",        MapRules.TrammelRules );
            RegisterMap( 4, 4, 4, 1448, 1448, 1, "Tokuno",        MapRules.FeluccaRules );
            RegisterMap( 5, 5, 5, 1280, 4096, 1, "TerMur",        MapRules.FeluccaRules );
 
            RegisterMap( 0x7F, 0x7F, 0x7F, Map.SectorSize, Map.SectorSize, 1, "Internal", MapRules.Internal );
 
            /* Example of registering a custom map:
            * RegisterMap( 32, 0, 0, 6144, 4096, 3, "Iceland", MapRules.FeluccaRules );
            *
            * Defined:
            * RegisterMap( <index>, <mapID>, <fileIndex>, <width>, <height>, <season>, <name>, <rules> );
            *  - <index> : An unreserved unique index for this map
            *  - <mapID> : An identification number used in client communications. For any visible maps, this value must be from 0-3
            *  - <fileIndex> : A file identification number. For any visible maps, this value must be 0, 2, 3, or 4
            *  - <width>, <height> : Size of the map (in tiles)
            *  - <name> : Reference name for the map, used in props gump, get/set commands, region loading, etc
            *  - <rules> : Rules and restrictions associated with the map. See documentation for details
            */

In that part i though i could change the 1 on most of those to 3 Just like that Ice place or whatever for seasons and it just made trees dead it only added Snow to Ilshenar...

I was wondering if anyone knew if this was only way to do it or if there was a better way that will make it so snow is on ground in places just like OSI has it? Thanks... Also i think i have heard this happens all by itself ... so like when its time it automatically would go snowy? I am not sure... But thanks for the help.
 

Safera

Page
I am looking into something similar. I have a feeling that combining edits in mapdefinitions.cs and defining seasonal textures in TexTerr.def might do the trick. Did you figure this out yet? I also heard that there may be an ingame [command to change seasons. I'll ask in forums.
 

Vorspire

Knight
Here's the Winterfest_Init.cs script I use to initialize my Winterfest event, it caches all of the Maps' current seasons before applying changes, then updating all netstates with the change:

Code:
#region References
using System;
using System.Collections.Generic;
using System.Linq;

using Server;
using Server.Network;

using VitaNex.IO;
using VitaNex.Network;

#endregion

namespace VitaNex.Modules.Holidays.Winterfest
{
	[CoreModule("Winterfest")]
	public static partial class Winterfest
	{
		private static readonly Type _TypeOfWinterfestSpawn = typeof(WinterfestSpawn);
		private static readonly Type _TypeOfWinterfestSpawnElite = typeof(WinterfestSpawnElite);

		static Winterfest()
		{
			SpawnTypes =
				_TypeOfWinterfestSpawn.GetConstructableChildren(
					t => (t != null && !t.IsEqualOrChildOf(_TypeOfWinterfestSpawnElite)));

			EliteSpawnTypes = _TypeOfWinterfestSpawnElite.GetConstructableChildren();

			_InternalTimer = PollTimer.CreateInstance(
				TimeSpan.FromMinutes(1),
				InternalCallback,
				() => !CMOptions.ForceDisable);

			Grottos.OnSerialize = SerializeGrottos;
			Grottos.OnDeserialize = DeserializeGrottos;

			ExtendedOPL.OnItemOPLRequest += GetProperties;
			ExtendedOPL.OnMobileOPLRequest += GetProperties;

			RegisterGrotto("Covetous", Map.Felucca, _BoundsCovetous);
			RegisterGrotto("Destard", Map.Felucca, _BoundsDestard);
			RegisterGrotto("Hythloth", Map.Felucca, _BoundsHythloth);
			RegisterGrotto("Deceit", Map.Felucca, _BoundsDeceit);
			RegisterGrotto("Shame", Map.Felucca, _BoundsShame);
			RegisterGrotto("Wrong", Map.Felucca, _BoundsWrong);

			RegisterGrotto("Covetous", Map.Trammel, _BoundsCovetous);
			RegisterGrotto("Destard", Map.Trammel, _BoundsDestard);
			RegisterGrotto("Hythloth", Map.Trammel, _BoundsHythloth);
			RegisterGrotto("Deceit", Map.Trammel, _BoundsDeceit);
			RegisterGrotto("Shame", Map.Trammel, _BoundsShame);
			RegisterGrotto("Wrong", Map.Trammel, _BoundsWrong);

			Map.AllMaps.ForEach(
				map =>
				{
					if (!_DefaultSeasons.ContainsKey(map))
					{
						_DefaultSeasons.Add(map, (Season)map.Season);
					}
					else
					{
						_DefaultSeasons[map] = (Season)map.Season;
					}
				});
		}

		private static void CMEnabled()
		{
			GenerateVendors();
			GenerateSpawners();

			Items.ForEach(
				item =>
				{
					if (item != null && !item.Deleted)
					{
						item.Active = true;
					}
				});

			Spawns.ForEach(
				spawn =>
				{
					if (spawn != null && !spawn.Deleted)
					{
						spawn.Active = true;
					}
				});

			Vendors.ForEach(
				vendor =>
				{
					if (vendor != null && !vendor.Deleted)
					{
						vendor.Active = true;
					}
				});

			Map.AllMaps.ForEach(
				map =>
				{
					if (!_DefaultSeasons.ContainsKey(map))
					{
						_DefaultSeasons.Add(map, (Season)map.Season);
					}
					else
					{
						_DefaultSeasons[map] = (Season)map.Season;
					}

					map.Season = Season.Winter.GetID();
				});

			NetState.Instances.Where(
				ns =>
				!(ns == null || ns.Socket == null || ns.Mobile == null || ns.Mobile.Map == null || ns.Mobile.Map == Map.Internal))
					.ToList()
					.ForEach(ns => ns.Send(SeasonChange.Instantiate(Season.Winter.GetID(), true)));
		}

		private static void CMDisabled()
		{
			Map.AllMaps.ForEach(
				map =>
				{
					map.Season = _DefaultSeasons[map].GetID();
				});

			NetState.Instances.Where(
				ns =>
				!(ns == null || ns.Socket == null || ns.Mobile == null || ns.Mobile.Map == null || ns.Mobile.Map == Map.Internal))
					.ToList()
					.ForEach(ns => ns.Send(SeasonChange.Instantiate(ns.Mobile.Map.Season, true)));

			Items.ForEach(
				item =>
				{
					if (item != null && !item.Deleted)
					{
						item.Active = false;
					}
				});

			Spawns.ForEach(
				spawn =>
				{
					if (spawn != null && !spawn.Deleted)
					{
						spawn.Active = false;
					}
				});

			Vendors.ForEach(
				vendor =>
				{
					if (vendor != null && !vendor.Deleted)
					{
						vendor.Active = false;
					}
				});

			RemoveVendors();
			RemoveSpawners();
		}

		private static void CMInvoke()
		{
			if (_Spawners.Count == 0)
			{
				GenerateSpawners();
			}

			if (_Vendors.Count == 0)
			{
				GenerateVendors();
			}
		}

		private static void CMSave()
		{
			VitaNexCore.TryCatch(
				() =>
				{
					DataStoreResult result = _Grottos.Export();
					CMOptions.ToConsole("{0} grottos saved, {1}", _Grottos.Count > 0 ? _Grottos.Count.ToString("#,#") : "0", result);
				},
				CMOptions.ToConsole);
		}

		private static void CMLoad()
		{
			VitaNexCore.TryCatch(
				() =>
				{
					DataStoreResult result = _Grottos.Import();
					CMOptions.ToConsole("{0} grottos loaded, {1}.", _Grottos.Count > 0 ? _Grottos.Count.ToString("#,#") : "0", result);
				},
				CMOptions.ToConsole);
		}

		private static bool SerializeGrottos(GenericWriter writer)
		{
			int version = writer.SetVersion(0);

			switch (version)
			{
				case 0:
					{
						writer.WriteBlockDictionary(
							Grottos,
							(name, maps) =>
							{
								writer.Write(name);
								writer.WriteBlockDictionary(
									maps,
									(m, bounds) =>
									{
										writer.Write(m);
										writer.WriteBlockList(bounds, writer.Write);
									});
							});
					}
					break;
			}

			return true;
		}

		private static bool DeserializeGrottos(GenericReader reader)
		{
			int version = reader.GetVersion();

			switch (version)
			{
				case 0:
					{
						Grottos.Clear();

						reader.ReadBlockDictionary(
							() =>
							{
								string name = reader.ReadString();

								var maps = reader.ReadBlockDictionary(
									() =>
									{
										Map m = reader.ReadMap();
										var bounds = reader.ReadBlockList(reader.ReadRect2D);
										return new KeyValuePair<Map, List<Rectangle2D>>(m, bounds);
									});

								return new KeyValuePair<string, Dictionary<Map, List<Rectangle2D>>>(name, maps);
							},
							Grottos);
					}
					break;
			}

			return true;
		}
	}
}

The "Season" enum script is as follows:
Code:
namespace VitaNex.Network
{
	public enum Season
	{
		Spring = 0,
		Summer = 1,
		Autumn = 2,
		Winter = 3,
		Desolation = 4,
		Fall = Autumn,
	}

	public static class SeasonEnumExt
	{
		public static int GetID(this Season season)
		{
			return (int)season;
		}

		public static string GetName(this Season season)
		{
			return season.ToString();
		}
	}
}

This code was written for .NET 4.0 - the extension methods won't work in standard RunUO releases, but it can be used as a REFERENCE, not a source to copy & paste ;)

Just to add, UO never had it's snow tile transitions finished for all maps, some maps doesn't display snow at all for some tiles and other tiles that are supposed to be snow, end up looking like jagged cobble stone paving (including dirt roads)
In short, the implementation of seasons was never finished by the game devs.
 

Safera

Page
Thanks for the info, Vorspire. I'm in no way, shape, or form a programmer, but I appreciate your snippets for reference...especially, seeing the number declarations for each season. That, in itself, helps a lot.

I am working with Eri and have converted over a lot of her custom tiles, so it will be neat to see if we have enough to make a difference in most areas...but the idea of trying it is enticing.

Thanks again!
 

Safera

Page
I thought I'd look at your script code again real quick and I'm wondering...

Vorspire Does this script just add different spawns, vendors & text based upon season or did you change any tiles? (If you changed tiles, this is the part I'm not getting.)
 

Vorspire

Knight
No, it's part of a larger system, this script makes sure that the Maps are set to winter whenever the event is active, most of the code is in other main scripts, but that snippet shows how to dynamically change the seasons on maps, and how to cache the default settings to a Dictionary<TKey, TValue> so they can be restored if the event is disabled.
 
Top