Overwrite

Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
Unstable Kitsune
2023-11-28 23:20:26 -05:00
parent 3cd54811de
commit b918192e4e
11608 changed files with 2644205 additions and 47 deletions

View File

@@ -0,0 +1,223 @@
using Server;
using System;
using Server.Multis;
using Server.Items;
using Server.Mobiles;
using System.Collections.Generic;
using System.Linq;
namespace Server.Regions
{
public class CorgulRegion : BaseRegion
{
public static void Initialize()
{
EventSink.Login += new LoginEventHandler(OnLogin);
Timer.DelayCall(TimeSpan.FromSeconds(30), () =>
{
foreach (CorgulRegion reg in Region.Regions.OfType<CorgulRegion>())
{
if (reg.Altar != null && reg.Altar.Activated)
continue;
foreach (BaseMulti multi in reg.GetEnumeratedMultis())
{
if (multi is BaseBoat)
reg.RemoveBoat((BaseBoat)multi);
}
}
});
}
private List<Item> m_Markers;
private CorgulAltar m_Altar;
private Rectangle2D m_Bounds;
public CorgulAltar Altar { get { return m_Altar; } }
public CorgulRegion(Rectangle2D rec, CorgulAltar altar)
: base("Corgul Boss Region", altar.Map, Region.DefaultPriority, new Rectangle2D[] { rec })
{
//MarkBounds(rec);
m_Altar = altar;
m_Bounds = rec;
}
public void MarkBounds(Rectangle2D rec)
{
m_Markers = new List<Item>();
int w = rec.X + rec.Width;
int h = rec.Y + rec.Height;
int t = 0;
for (int x = rec.X; x <= w; x++)
{
for (int y = rec.Y; y <= h; y++)
{
if (x == rec.X || x == rec.X + rec.Width || y == rec.Y || y == rec.Y + rec.Height)
{
if (t >= 10)
{
MarkerItem i = new MarkerItem(14089);
i.MoveToWorld(new Point3D(x, y, 0), this.Map);
m_Markers.Add(i);
t = 0;
}
else
t++;
}
}
}
}
public override void OnUnregister()
{
if (m_Markers == null)
return;
foreach (Item i in m_Markers)
i.Delete();
m_Markers.Clear();
}
public override bool OnBeginSpellCast(Mobile m, ISpell s)
{
if(m.AccessLevel == AccessLevel.Player) {
if (s is Server.Spells.Sixth.MarkSpell || s is Server.Spells.Fourth.RecallSpell || s is Server.Spells.Seventh.GateTravelSpell
|| s is Server.Spells.Chivalry.SacredJourneySpell)
return false;
}
return true;
}
public override bool CheckTravel(Mobile m, Point3D newLocation, Server.Spells.TravelCheckType travelType)
{
return false;
}
public void CheckExit(BaseBoat boat)
{
if (boat != null)
Timer.DelayCall(TimeSpan.FromSeconds(1), new TimerStateCallback(RemoveBoat_Callback), boat );
}
public void RemovePlayers(bool message)
{
List<Mobile> list = GetMobiles();
foreach (Mobile m in list)
{
if (message && m is PlayerMobile)
m.SendMessage("You have failed to meet the deadline.");
if (BaseBoat.FindBoatAt(m, m.Map) != null)
continue;
if (m is PlayerMobile || (m is BaseCreature && ((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned))
{
Point3D go = CorgulAltar.GetRandomPoint(CorgulAltar.LandKickLocation, this.Map);
BaseCreature.TeleportPets(m, go, this.Map);
m.MoveToWorld(go, this.Map);
}
}
foreach(BaseBoat b in this.GetEnumeratedMultis().OfType<BaseBoat>())
{
if(b != null)
RemoveBoat(b);
}
}
public void RemoveBoat_Callback(object o)
{
if (o is BaseBoat)
RemoveBoat((BaseBoat)o);
}
public void RemoveBoat(BaseBoat boat)
{
if (boat == null)
return;
//First, we'll try and put the boat in the cooresponding location where it warped in
if (boat.Map != null && boat.Map != Map.Internal && m_Altar != null && m_Altar.WarpRegion != null)
{
Map map = boat.Map;
Rectangle2D rec = m_Altar.WarpRegion.Bounds;
int x = boat.X - m_Bounds.X;
int y = boat.Y - m_Bounds.Y;
int z = map.GetAverageZ(x, y);
Point3D ePnt = new Point3D(rec.X + x, rec.Y + y, -5);
int offsetX = ePnt.X - boat.X;
int offsetY = ePnt.Y - boat.Y;
int offsetZ = map.GetAverageZ(ePnt.X, ePnt.Y) - boat.Z;
if (boat.CanFit(ePnt, this.Map, boat.ItemID))
{
boat.Teleport(offsetX, offsetY, offsetZ);
//int z = this.Map.GetAverageZ(boat.X, boat.Y);
if (boat.Z != -5)
boat.Z = -5;
if (boat.TillerMan != null)
boat.TillerManSay(501425); //Ar, turbulent water!
return;
}
}
//Plan B, lets kick to some random location who-knows-where
for (int i = 0; i < 25; i++)
{
Rectangle2D rec = CorgulAltar.BoatKickLocation;
Point3D ePnt = CorgulAltar.GetRandomPoint(rec, Map);
int offsetX = ePnt.X - boat.X;
int offsetY = ePnt.Y - boat.Y;
int offsetZ = ePnt.Z - boat.Z;
if (boat.CanFit(ePnt, this.Map, boat.ItemID))
{
boat.Teleport(offsetX, offsetY, -5);
boat.SendMessageToAllOnBoard("A rough patch of sea has disoriented the crew!");
//int z = this.Map.GetAverageZ(boat.X, boat.Y);
if (boat.Z != -5)
boat.Z = -5;
if (boat.TillerMan != null)
boat.TillerManSay(501425); //Ar, turbulent water!
break;
}
}
}
public static void OnLogin(LoginEventArgs e)
{
Mobile from = e.Mobile;
Region reg = Region.Find(from.Location, from.Map);
if (reg is CorgulRegion)
{
CorgulAltar altar = ((CorgulRegion)reg).Altar;
if (altar != null && !altar.Activated)
{
Point3D pnt = CorgulAltar.GetRandomPoint(CorgulAltar.LandKickLocation, from.Map);
BaseCreature.TeleportPets(from, pnt, from.Map);
from.MoveToWorld(pnt, from.Map);
}
}
}
}
}

View File

@@ -0,0 +1,425 @@
using System;
using System.Xml;
using System.Linq;
using Server;
using Server.Mobiles;
using Server.Items;
using Server.Multis;
using System.Collections.Generic;
using Server.Commands;
using Server.Engines.Quests;
using Server.Spells;
namespace Server.Regions
{
public class SeaMarketRegion : BaseRegion
{
private static readonly TimeSpan KickDuration = TimeSpan.FromMinutes(20);
private static SeaMarketRegion m_Region1;
private static SeaMarketRegion m_Region2;
private Timer m_Timer;
private static Timer m_BlabTimer;
private static bool m_RestrictBoats;
private Dictionary<BaseBoat, DateTime> m_BoatTable = new Dictionary<BaseBoat, DateTime>();
public Dictionary<BaseBoat, DateTime> BoatTable { get { return m_BoatTable; } }
public static bool RestrictBoats
{
get { return m_RestrictBoats; }
set
{
m_RestrictBoats = value;
if (value)
{
if (m_Region1 != null)
m_Region1.StartTimer();
if (m_Region2 != null)
m_Region2.StartTimer();
}
else
{
if (m_Region1 != null)
m_Region1.StopTimer();
if (m_Region2 != null)
m_Region2.StopTimer();
}
}
}
public static Rectangle2D[] Bounds { get { return m_Bounds; } }
private static Rectangle2D[] m_Bounds = new Rectangle2D[]
{
new Rectangle2D(4529, 2296, 45, 112),
};
public SeaMarketRegion(XmlElement xml, Map map, Region parent)
: base(xml, map, parent)
{
}
public override void OnRegister()
{
if (m_Region1 == null)
{
m_Region1 = this;
}
else if (m_Region2 == null)
{
m_Region2 = this;
}
}
public override bool CheckTravel(Mobile traveller, Point3D p, TravelCheckType type)
{
switch (type)
{
case TravelCheckType.RecallTo:
case TravelCheckType.GateTo:
{
return BaseBoat.FindBoatAt(p, Map) != null;
}
case TravelCheckType.Mark:
{
return false;
}
}
return base.CheckTravel(traveller, p, type);
}
public override bool AllowHousing(Mobile from, Point3D p)
{
return false;
}
#region Pirate Blabbing
public static Dictionary<Mobile, DateTime> m_PirateBlabTable = new Dictionary<Mobile, DateTime>();
private static readonly TimeSpan BlabDuration = TimeSpan.FromSeconds(60);
public static void TryPirateBlab(Mobile from, Mobile npc)
{
if (m_PirateBlabTable.ContainsKey(from) && m_PirateBlabTable[from] > DateTime.UtcNow || BountyQuestSpawner.Bounties.Count <= 0)
return;
//Make of list of bounties on their map
List<Mobile> bounties = new List<Mobile>();
foreach (Mobile mob in BountyQuestSpawner.Bounties.Keys)
{
if (mob.Map == from.Map && mob is PirateCaptain && !bounties.Contains(mob))
bounties.Add(mob);
}
if (bounties.Count > 0)
{
Mobile bounty = bounties[Utility.Random(bounties.Count)];
if (bounty != null)
{
PirateCaptain capt = (PirateCaptain)bounty;
int xLong = 0, yLat = 0;
int xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
Point3D loc = capt.Location;
Map map = capt.Map;
string locArgs;
string combine;
if (Sextant.Format(loc, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth))
locArgs = String.Format("{0}°{1}'{2},{3}°{4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W");
else
locArgs = "?????";
combine = String.Format("{0}\t{1}", capt.PirateName > -1 ? String.Format("#{0}", capt.PirateName) : capt.Name, locArgs);
int cliloc = Utility.RandomMinMax(1149856, 1149865);
npc.SayTo(from, cliloc, combine);
m_PirateBlabTable[from] = DateTime.UtcNow + BlabDuration;
}
}
ColUtility.Free(bounties);
}
public static void CheckBlab_Callback()
{
CheckBabble(m_Region1);
CheckBabble(m_Region2);
CheckBabble(TokunoDocksRegion.Instance);
}
public static void CheckBabble(Region r)
{
if (r == null)
return;
foreach (var player in r.GetEnumeratedMobiles().Where(p => p is PlayerMobile &&
p.Alive /*&&
QuestHelper.GetQuest((PlayerMobile)p, typeof(ProfessionalBountyQuest)) != null*/))
{
IPooledEnumerable eable = player.GetMobilesInRange(4);
foreach (Mobile mob in eable)
{
if (mob is BaseVendor || mob is MondainQuester || mob is GalleonPilot)
{
TryPirateBlab(player, mob);
break;
}
}
eable.Free();
}
}
#endregion
#region Boat Restriction
public void StartTimer()
{
if (m_Timer != null)
m_Timer.Stop();
m_Timer = new InternalTimer(this);
m_Timer.Start();
}
public void StopTimer()
{
if (m_Timer != null)
m_Timer.Stop();
m_Timer = null;
}
public List<BaseBoat> GetBoats()
{
List<BaseBoat> list = new List<BaseBoat>();
foreach (BaseBoat boat in this.GetEnumeratedMultis().OfType<BaseBoat>())
list.Add(boat);
return list;
}
public void OnTick()
{
if (!m_RestrictBoats)
{
StopTimer();
return;
}
List<BaseBoat> boats = GetBoats();
List<BaseBoat> toRemove = new List<BaseBoat>();
foreach (KeyValuePair<BaseBoat, DateTime> kvp in m_BoatTable)
{
BaseBoat boat = kvp.Key;
DateTime moveBy = kvp.Value;
if (boat == null || !boats.Contains(boat) || boat.Deleted)
toRemove.Add(boat);
else if (DateTime.UtcNow >= moveBy && KickBoat(boat))
toRemove.Add(boat);
else
{
if (boat.Owner != null && boat.Owner.NetState != null)
{
TimeSpan ts = moveBy - DateTime.UtcNow;
if ((int)ts.TotalMinutes <= 10)
{
int rem = Math.Max(1, (int)ts.TotalMinutes);
boat.Owner.SendLocalizedMessage(1149787 + (rem - 1));
}
}
}
}
foreach (BaseBoat boat in boats)
{
if (!m_BoatTable.ContainsKey(boat) && !boat.IsMoving && boat.Owner != null && boat.Owner.AccessLevel == AccessLevel.Player)
AddToTable(boat);
}
foreach (BaseBoat b in toRemove)
m_BoatTable.Remove(b);
ColUtility.Free(toRemove);
ColUtility.Free(boats);
}
public void AddToTable(BaseBoat boat)
{
if (m_BoatTable.ContainsKey(boat))
return;
m_BoatTable.Add(boat, DateTime.UtcNow + KickDuration);
if (boat.Owner != null && boat.Owner.NetState != null)
boat.Owner.SendMessage("You can only dock your boat here for {0} minutes.", (int)KickDuration.TotalMinutes);
}
private Rectangle2D[] m_KickLocs = new Rectangle2D[]
{
new Rectangle2D(m_Bounds[0].X - 100, m_Bounds[0].X - 100, 200 + m_Bounds[0].Width, 100),
new Rectangle2D(m_Bounds[0].X - 100, m_Bounds[0].Y, 100, m_Bounds[0].Height + 100),
new Rectangle2D(m_Bounds[0].X, m_Bounds[0].Y + m_Bounds[0].Height, m_Bounds[0].Width + 100, 100),
new Rectangle2D(m_Bounds[0].X + m_Bounds[0].Width, m_Bounds[0].Y, 100, m_Bounds[0].Height),
};
public bool KickBoat(BaseBoat boat)
{
if (boat == null || boat.Deleted)
return false;
for (int i = 0; i < 25; i++)
{
Rectangle2D rec = m_KickLocs[Utility.Random(m_KickLocs.Length)];
int x = Utility.RandomMinMax(rec.X, rec.X + rec.Width);
int y = Utility.RandomMinMax(rec.Y, rec.Y + rec.Height);
int z = boat.Z;
Point3D p = new Point3D(x, y, z);
if (boat.CanFit(p, boat.Map, boat.ItemID))
{
boat.Teleport(x - boat.X, y - boat.Y, z - boat.Z);
if (boat.Owner != null && boat.Owner.NetState != null)
boat.SendMessageToAllOnBoard(1149785); //A strong tide comes and carries your boat to deeper water.
return true;
}
}
return false;
}
private class InternalTimer : Timer
{
private SeaMarketRegion m_Region;
public InternalTimer(SeaMarketRegion reg)
: base(TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(1))
{
m_Region = reg;
}
protected override void OnTick()
{
if (m_Region != null)
m_Region.OnTick();
}
}
public static void StartTimers_Callback()
{
RestrictBoats = m_RestrictBoats;
m_BlabTimer = Timer.DelayCall(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), new TimerCallback(CheckBlab_Callback));
m_BlabTimer.Priority = TimerPriority.OneSecond;
}
#endregion
public static void Save(GenericWriter writer)
{
writer.Write((int)0);
writer.Write(m_RestrictBoats);
}
public static void Load(GenericReader reader)
{
int version = reader.ReadInt();
m_RestrictBoats = reader.ReadBool();
Timer.DelayCall(TimeSpan.FromSeconds(30), new TimerCallback(StartTimers_Callback));
}
public static void GetBoatInfo_OnCommand(CommandEventArgs e)
{
List<BaseBoat> boats = new List<BaseBoat>(m_Region1.BoatTable.Keys);
List<DateTime> times = new List<DateTime>(m_Region1.BoatTable.Values);
e.Mobile.SendMessage("========Boat Info for Felucca as Follows===========");
e.Mobile.SendMessage("Boats: {0}", boats.Count);
if (!m_RestrictBoats)
e.Mobile.SendMessage("Boat restriction is currenlty disabled.");
Console.WriteLine("========Boat Info as Follows===========");
Console.WriteLine("Boats: {0}", boats.Count);
if (!m_RestrictBoats)
Console.WriteLine("Boat restriction is currenlty disabled.");
for (int i = 0; i < boats.Count; i++)
{
BaseBoat boat = boats[i];
if (boat == null || boat.Deleted)
continue;
e.Mobile.SendMessage("Boat Name: {0}; Boat Owner: {1}; Expires: {2}", boat.ShipName, boat.Owner, times[i]);
Console.WriteLine("Boat Name: {0}; Boat Owner: {1}; Expires: {2}", boat.ShipName, boat.Owner, times[i]);
}
boats.Clear();
times.Clear();
boats = new List<BaseBoat>(m_Region2.BoatTable.Keys);
times = new List<DateTime>(m_Region2.BoatTable.Values);
e.Mobile.SendMessage("========Boat Info for Trammel as Follows===========");
e.Mobile.SendMessage("Boats: {0}", boats.Count);
if (!m_RestrictBoats)
e.Mobile.SendMessage("Boat restriction is currenlty disabled.");
Console.WriteLine("========Boat Info as Follows===========");
Console.WriteLine("Boats: {0}", boats.Count);
if (!m_RestrictBoats)
Console.WriteLine("Boat restriction is currenlty disabled.");
for (int i = 0; i < boats.Count; i++)
{
BaseBoat boat = boats[i];
if (boat == null || boat.Deleted)
continue;
e.Mobile.SendMessage("Boat Name: {0}; Boat Owner: {1}; Expires: {2}", boat.ShipName, boat.Owner, times[i]);
Console.WriteLine("Boat Name: {0}; Boat Owner: {1}; Expires: {2}", boat.ShipName, boat.Owner, times[i]);
}
}
public static void SetRestriction_OnCommand(CommandEventArgs e)
{
if (m_RestrictBoats)
{
RestrictBoats = false;
e.Mobile.SendMessage("Boat restriction in the sea market is no longer active.");
}
else
{
RestrictBoats = true;
e.Mobile.SendMessage("Boat restriction in the sea market is now active.");
}
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Xml;
using Server;
using Server.Mobiles;
namespace Server.Regions
{
public class TokunoDocksRegion : GuardedRegion
{
public static TokunoDocksRegion Instance { get { return m_Region; } }
private static TokunoDocksRegion m_Region;
public TokunoDocksRegion(XmlElement xml, Map map, Region parent)
: base(xml, map, parent)
{
m_Region = this;
}
public override bool AllowHousing(Mobile from, Point3D p)
{
return false;
}
}
}

View File

@@ -0,0 +1,156 @@
using Server;
using System;
using Server.Multis;
using Server.Items;
using Server.Mobiles;
using System.Collections.Generic;
using System.Linq;
namespace Server.Regions
{
public class CorgulWarpRegion : Region
{
private CorgulAltar m_Pedestal;
private Rectangle2D m_Bounds;
private List<Item> m_Markers;
public Rectangle2D Bounds { get { return m_Bounds; } }
public CorgulWarpRegion(CorgulAltar ped, Rectangle2D rec)
: base("Corgul Warp Region", ped.Map, Region.DefaultPriority, new Rectangle2D[] { rec })
{
m_Pedestal = ped;
m_Bounds = rec;
//MarkBounds(rec);
}
public void MarkBounds(Rectangle2D rec)
{
m_Markers = new List<Item>();
int w = rec.X + rec.Width;
int h = rec.Y + rec.Height;
int t = 0;
for (int x = rec.X; x <= w; x++)
{
for (int y = rec.Y; y <= h; y++)
{
if (x == rec.X || x == rec.X + rec.Width || y == rec.Y || y == rec.Y + rec.Height)
{
if (t >= 10)
{
MarkerItem i = new MarkerItem(14089);
i.MoveToWorld(new Point3D(x, y, -5), this.Map);
m_Markers.Add(i);
t = 0;
}
else
t++;
}
}
}
}
public override void OnUnregister()
{
if (m_Markers == null)
return;
foreach (Item i in m_Markers)
i.Delete();
m_Markers.Clear();
}
public void CheckEnter(BaseBoat boat)
{
if (boat == null || this.Map == null || this.Map == Map.Internal)
return;
//Do not enter corgul region if we aren't in this region anymore
Region r = Region.Find(boat.Location, boat.Map);
if (r != null && !r.IsPartOf(this))
return;
Map map = this.Map;
List<PlayerMobile> pms = new List<PlayerMobile>();
bool hasMap = false;
foreach (var i in boat.GetEntitiesOnBoard().OfType<PlayerMobile>().Where(pm => pm.NetState != null))
{
pms.Add((PlayerMobile)i);
PlayerMobile pm = (PlayerMobile)i;
if (pm.Backpack == null)
continue;
Item item = pm.Backpack.FindItemByType(typeof(CorgulIslandMap));
if (item != null && item is CorgulIslandMap && this.Contains(((CorgulIslandMap)item).DestinationPoint))
{
hasMap = true;
break;
}
}
if (hasMap)
{
int x = boat.X - m_Bounds.X;
int y = boat.Y - m_Bounds.Y;
int z = map.GetAverageZ(x, y);
Point3D ePnt = new Point3D(CorgulAltar.CorgulBounds.X + x, CorgulAltar.CorgulBounds.Y + y, 0);
int offsetX = ePnt.X - boat.X;
int offsetY = ePnt.Y - boat.Y;
int offsetZ = map.GetAverageZ(ePnt.X, ePnt.Y) - boat.Z;
if (boat.CanFit(ePnt, this.Map, boat.ItemID))
{
boat.Teleport(offsetX, offsetY, offsetZ);
//int z = this.Map.GetAverageZ(boat.X, boat.Y);
if (boat.Z != 0)
boat.Z = 0;
if (boat.TillerMan != null)
boat.TillerManSay(501425); //Ar, turbulent water!
}
else
{
boat.StopMove(true);
boat.SendMessageToAllOnBoard("The boat has struck a coral reef!");
}
}
}
}
public class MarkerItem : Static
{
public MarkerItem(int itemID) : base(itemID)
{
Hue = 1234;
}
public MarkerItem(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
Delete();
}
}
}