feat: Customize expansion and set maps on first boot (#1425)

This commit is contained in:
mdodkins 2023-08-01 04:46:49 +01:00 • committed by GitHub
parent 3ffe049e08
commit a9a2a89908
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 700 additions and 269 deletions

View file

@ -1192,7 +1192,7 @@ namespace Server.Accounting
while ((uint)_index < (uint)localList.Length)
{
_current = _mobiles[_index++];
_current = localList[_index++];
if (_current?.Deleted == false)
{
return true;

View file

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using Server.Buffers;
using Server.Text;
namespace Server.Commands.Generic
{

View file

@ -1,10 +1,10 @@
using System;
using System.Reflection;
using Server.Buffers;
using Server.Commands;
using Server.Commands.Generic;
using Server.Gumps;
using Server.Targeting;
using Server.Text;
using CPA = Server.CommandPropertyAttribute;
using static Server.Attributes;

View file

@ -4,7 +4,7 @@ using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Net.Http;
using Server.Buffers;
using Server.Text;
namespace Server.Compression
{

View file

@ -1,5 +1,5 @@
using System;
using Server.Buffers;
using Server.Text;
namespace Server.Ethics.Evil
{

View file

@ -1,5 +1,5 @@
using System;
using Server.Buffers;
using Server.Text;
namespace Server.Ethics.Hero
{

View file

@ -14,11 +14,11 @@
*************************************************************************/
using System.Collections.Generic;
using Server.Buffers;
using Server.Commands.Generic;
using Server.Engines.Spawners;
using Server.Mobiles;
using Server.Network;
using Server.Text;
using CPA = Server.CommandPropertyAttribute;
namespace Server.Gumps

View file

@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Server.Mobiles;
namespace Server.Engines.Spawners
{

View file

@ -5,13 +5,14 @@ using System.Net;
using System.Runtime.InteropServices;
using System.Threading;
using Server.Accounting;
using Server.Buffers;
using Server.Collections;
using Server.Commands;
using Server.Maps;
using Server.Misc;
using Server.Multis;
using Server.Network;
using Server.Prompts;
using Server.Text;
namespace Server.Gumps
{
@ -2085,29 +2086,37 @@ namespace Server.Gumps
}
case 103:
{
if (Core.SA)
var folder = Core.SA ? "post-uoml" : "uoml";
var availableMaps = ExpansionInfo.CoreExpansion.MapSelectionFlags;
if (Core.SA && availableMaps.Includes(MapSelectionFlags.TerMur))
{
InvokeCommand("GenerateSpawners Data/Spawns/post-uoml/*/*.json");
InvokeCommand($"GenerateSpawners Data/Spawns/post-uoml/termur/*.json");
}
else
if (availableMaps.Includes(MapSelectionFlags.Malas))
{
if (Core.ML)
{
InvokeCommand("GenerateSpawners Data/Spawns/uoml/malas/*.json");
}
InvokeCommand($"GenerateSpawners Data/Spawns/{folder}/malas/*.json");
}
if (Core.SE)
{
InvokeCommand("GenerateSpawners Data/Spawns/uoml/tokuno/*.json");
}
if (availableMaps.Includes(MapSelectionFlags.Tokuno))
{
InvokeCommand($"GenerateSpawners Data/Spawns/{folder}/tokuno/*.json");
}
if (Core.AOS)
{
InvokeCommand("GenerateSpawners Data/Spawns/uoml/ilshenar/*.json");
}
if (availableMaps.Includes(MapSelectionFlags.Ilshenar))
{
InvokeCommand($"GenerateSpawners Data/Spawns/{folder}/ilshenar/*.json");
}
InvokeCommand("GenerateSpawners Data/Spawns/uoml/trammel/*.json");
InvokeCommand("GenerateSpawners Data/Spawns/uoml/felucca/*.json");
if (availableMaps.Includes(MapSelectionFlags.Trammel))
{
InvokeCommand($"GenerateSpawners Data/Spawns/{folder}/trammel/*.json");
}
if (availableMaps.Includes(MapSelectionFlags.Felucca))
{
InvokeCommand($"GenerateSpawners Data/Spawns/{folder}/felucca/*.json");
}
notice = "Spawners have been generated.";

View file

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using ModernUO.Serialization;
using Server.Buffers;
using Server.ContextMenus;
using Server.Gumps;
using Server.Multis;
using Server.Text;
namespace Server.Items
{

View file

@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using ModernUO.Serialization;
using Server.Collections;
using Server.Factions;
using Server.Gumps;
using Server.Maps;
using Server.Mobiles;
using Server.Network;
using Server.Spells;
@ -105,11 +107,11 @@ public partial class PublicMoongate : Item
var count = 0;
count += MoonGen(PMList.Trammel);
count += MoonGen(PMList.Felucca);
count += MoonGen(PMList.Ilshenar);
count += MoonGen(PMList.Malas);
count += MoonGen(PMList.Tokuno);
count += MoonGen(PMList.Trammel, MapSelectionFlags.Trammel);
count += MoonGen(PMList.Felucca, MapSelectionFlags.Felucca);
count += MoonGen(PMList.Ilshenar, MapSelectionFlags.Ilshenar);
count += MoonGen(PMList.Malas, MapSelectionFlags.Malas);
count += MoonGen(PMList.Tokuno, MapSelectionFlags.Tokuno);
World.Broadcast(0x35, true, $"{count} moongates generated.");
}
@ -137,8 +139,13 @@ public partial class PublicMoongate : Item
}
}
private static int MoonGen(PMList list)
private static int MoonGen(PMList list, MapSelectionFlags flag)
{
if (!ExpansionInfo.CoreExpansion.MapSelectionFlags.Includes(flag))
{
return 0;
}
foreach (var entry in list.Entries)
{
Item item = new PublicMoongate();
@ -355,11 +362,23 @@ public class MoongateGump : Gump
};
}
_lists = new PMList[checkLists.Length];
var availableMaps = ExpansionInfo.CoreExpansion.MapSelectionFlags;
using var filteredBySelectedMaps = PooledRefList<PMList>.Create();
for (var i = 0; i < _lists.Length; ++i)
for (var i = 0; i < checkLists.Length; ++i)
{
_lists[i] = checkLists[i];
var pmList = checkLists[i];
if (availableMaps.Includes(pmList.Map.ToSelectionFlag()))
{
filteredBySelectedMaps.Add(pmList);
}
}
int mapCount = filteredBySelectedMaps.Count;
_lists = new PMList[mapCount];
for (var i = 0; i < mapCount; i++)
{
_lists[i] = filteredBySelectedMaps[i];
}
for (var i = 0; i < _lists.Length; ++i)
@ -383,15 +402,15 @@ public class MoongateGump : Gump
AddHtmlLocalized(5, 5, 200, 20, 1012011); // Pick your destination:
for (var i = 0; i < checkLists.Length; ++i)
for (var i = 0; i < filteredBySelectedMaps.Count; ++i)
{
AddButton(10, 35 + i * 25, 2117, 2118, 0, GumpButtonType.Page, Array.IndexOf(_lists, checkLists[i]) + 1);
AddHtmlLocalized(30, 35 + i * 25, 150, 20, checkLists[i].Number);
AddButton(10, 35 + i * 25, 2117, 2118, 0, GumpButtonType.Page, Array.IndexOf(_lists, filteredBySelectedMaps[i]) + 1);
AddHtmlLocalized(30, 35 + i * 25, 150, 20, filteredBySelectedMaps[i].Number);
}
for (var i = 0; i < _lists.Length; ++i)
{
RenderPage(i, Array.IndexOf(checkLists, _lists[i]));
RenderPage(i, filteredBySelectedMaps.IndexOf(_lists[i]));
}
}

View file

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using ModernUO.Serialization;
using Server.Buffers;
using Server.Mobiles;
using Server.Network;
using Server.Spells;
using Server.Text;
namespace Server.Items;

View file

@ -3,12 +3,12 @@ using System.Collections.Generic;
using System.Net;
using ModernUO.Serialization;
using Server.Accounting;
using Server.Buffers;
using Server.ContextMenus;
using Server.Gumps;
using Server.Mobiles;
using Server.Network;
using Server.Regions;
using Server.Text;
namespace Server.Items;

View file

@ -4,6 +4,7 @@ using System.Runtime.CompilerServices;
using Server.Accounting;
using Server.Items;
using Server.Logging;
using Server.Maps;
using Server.Mobiles;
using Server.Network;
@ -197,7 +198,6 @@ public static class CharacterCreation
}
var city = GetStartLocation(args, young);
newChar.MoveToWorld(city.Location, city.Map);
logger.Information(
@ -218,11 +218,13 @@ public static class CharacterCreation
private static CityInfo GetStartLocation(CharacterCreatedEventArgs args, bool isYoung)
{
// We don't get the actual client version until after character creation
var post6000Supported = !TileMatrix.Pre6000ClientSupport;
var availableMaps = ExpansionInfo.CoreExpansion.MapSelectionFlags;
if (Core.ML && post6000Supported)
if (Core.ML && post6000Supported && availableMaps.Includes(MapSelectionFlags.Trammel))
{
return _newHavenInfo; // We don't get the client Version until AFTER Character creation
return _newHavenInfo;
}
var useHaven = isYoung;
@ -236,7 +238,7 @@ public static class CharacterCreation
{
case "necromancer":
{
if ((flags & ClientFlags.Malas) != 0)
if ((flags & ClientFlags.Malas) != 0 && availableMaps.Includes(MapSelectionFlags.Malas))
{
return new CityInfo("Umbra", "Mardoth's Tower", 2114, 1301, -50, Map.Malas);
}
@ -256,11 +258,21 @@ public static class CharacterCreation
}
case "paladin":
{
return _newHavenInfo;
if (availableMaps.Includes(MapSelectionFlags.Trammel) && post6000Supported)
{
return _newHavenInfo;
}
break;
}
case "samurai":
{
if ((flags & ClientFlags.Tokuno) != 0)
bool haotisAndTokunoAccessible =
(flags & ClientFlags.Tokuno) == ClientFlags.Tokuno &&
(flags & ClientFlags.Malas) == ClientFlags.Malas &&
availableMaps.Includes(MapSelectionFlags.Malas | MapSelectionFlags.Tokuno);
if (haotisAndTokunoAccessible)
{
return new CityInfo("Samurai DE", "Haoti's Grounds", 368, 780, -1, Map.Malas);
}
@ -280,7 +292,12 @@ public static class CharacterCreation
}
case "ninja":
{
if ((flags & ClientFlags.Tokuno) != 0)
bool enimosAndTokunoAccessible =
(flags & ClientFlags.Tokuno) == ClientFlags.Tokuno &&
(flags & ClientFlags.Malas) == ClientFlags.Malas &&
availableMaps.Includes(MapSelectionFlags.Malas | MapSelectionFlags.Tokuno);
if (enimosAndTokunoAccessible)
{
return new CityInfo("Ninja DE", "Enimo's Residence", 414, 823, -1, Map.Malas);
}
@ -300,7 +317,43 @@ public static class CharacterCreation
}
}
return post6000Supported && useHaven ? _newHavenInfo : args.City;
if (post6000Supported && useHaven && availableMaps.Includes(MapSelectionFlags.Trammel))
{
// New Haven is supported, so put them there...
// Note: if your server maps don't contain New Haven, this will place
// them in the wilderness of Ocllo
return _newHavenInfo;
}
if (useHaven)
{
// New Haven is not available, so place them in Ocllo instead, if they're aiming for Haven
CityInfo oclloBank = new CityInfo("Ocllo", "Near the bank", 3677, 2513, -1, Map.Trammel);
if (availableMaps.Includes(MapSelectionFlags.Trammel))
{
return oclloBank;
}
if (availableMaps.Includes(MapSelectionFlags.Felucca))
{
oclloBank.Map = Map.Felucca;
return oclloBank;
}
}
// They're not trying to get to Haven, so use their city selection
// instead - adjusted according to available maps
if (args.City.Map == Map.Trammel && !availableMaps.Includes(MapSelectionFlags.Trammel))
{
args.City.Map = Map.Felucca;
}
if (args.City.Map == Map.Felucca && !availableMaps.Includes(MapSelectionFlags.Felucca))
{
args.City.Map = Map.Trammel;
}
return args.City;
}
private static void SetStats(Mobile m, NetState state, StatNameValue[] stats, int prof)

View file

@ -1,9 +1,9 @@
using System;
using Server.Buffers;
using Server.Gumps;
using Server.Logging;
using Server.Mobiles;
using Server.Network;
using Server.Text;
namespace Server.Misc
{

View file

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using Server.Buffers;
using Server.Text;
namespace Server.Misc
{

View file

@ -1,8 +1,7 @@
using System;
using System.Text;
using Server.Buffers;
using Server.Engines.CannedEvil;
using Server.Mobiles;
using Server.Text;
namespace Server.Misc
{

View file

@ -133,7 +133,7 @@ namespace Server.Multis
multiID > 0 && multiID < m_MultiTable.Length && CheckValidity(m_MultiTable[multiID]);
public bool CheckValidity(int val) =>
val != -1 && (val == 0 || ((int)ExpansionInfo.CoreExpansion.CustomHousingFlag & val) != 0);
val != -1 && (val == 0 || ((int)ExpansionInfo.CoreExpansion.HousingFlags & val) != 0);
private int[] CreateTable(int length)
{

View file

@ -1,8 +1,8 @@
using System;
using Server.Buffers;
using Server.Items;
using Server.Mobiles;
using Server.Targeting;
using Server.Text;
namespace Server.SkillHandlers
{