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,88 @@
using System;
using Server.Targeting;
using Server.Engines.Plants;
namespace Server.Items
{
public class GardeningContract : Item
{
public override int LabelNumber { get { return 1155764; } } // Gardening Contract
[Constructable]
public GardeningContract()
: base(0x14F0)
{
Weight = 1.0;
}
public GardeningContract(Serial serial)
: base(serial)
{
}
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1080058); // This must be in your backpack to use it.
}
else
{
from.SendLocalizedMessage(1155765); // Target the New Magincia plant you wish to have a gardener tend to...
from.Target = new InternalTarget(this);
}
}
private class InternalTarget : Target
{
private readonly Item m_Item;
public InternalTarget(Item item)
: base(2, true, TargetFlags.None)
{
m_Item = item;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is MaginciaPlantItem)
{
MaginciaPlantItem plant = (MaginciaPlantItem)targeted;
if (!plant.IsContract)
{
if (plant.ContractTime.Month == DateTime.UtcNow.Month)
{
from.SendLocalizedMessage(1155760); // You may do this once every other month.
return;
}
plant.ContractTime = DateTime.UtcNow;
from.SendLocalizedMessage(1155762); // You have hired a gardener to tend to your plant. The gardener will no longer tend to your plant when server maintenance occurs after the expiration date of your gardening contract. While a gardener is tending to your plant you will not have to care for it.
m_Item.Delete();
}
else
{
from.SendLocalizedMessage(1155761); // A Gardener is already tending to this plant.
}
}
else
{
from.SendLocalizedMessage(1155759); // This item can only be used on New Magincia Gardening Plants.
}
}
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}

View File

@@ -0,0 +1,143 @@
using System;
using Server;
using Server.Targeting;
using Server.Engines.Plants;
using Server.Network;
namespace Server.Items
{
public class Hoe : BaseAxe, IUsesRemaining
{
public override int LabelNumber { get { return 1150482; } } // hoe
[Constructable]
public Hoe()
: base(0xE86)
{
Hue = 2524;
Weight = 11.0;
UsesRemaining = 50;
ShowUsesRemaining = true;
}
public override WeaponAbility PrimaryAbility { get { return WeaponAbility.DoubleStrike; } }
public override WeaponAbility SecondaryAbility { get { return WeaponAbility.Disarm; } }
public override int AosStrengthReq { get { return 50; } }
public override int AosMinDamage { get { return 12; } }
public override int AosMaxDamage { get { return 16; } }
public override int AosSpeed { get { return 35; } }
public override float MlSpeed { get { return 3.00f; } }
public override int InitMinHits { get { return 31; } }
public override int InitMaxHits { get { return 60; } }
public override bool CanBeWornByGargoyles { get { return true; } }
public override WeaponAnimation DefAnimation { get { return WeaponAnimation.Slash1H; } }
public override void OnDoubleClick(Mobile from)
{
if (IsChildOf(from.Backpack))
{
from.Target = new InternalTarget(this);
}
}
private class InternalTarget : Target
{
private readonly Hoe m_Hoe;
public InternalTarget(Hoe hoe)
: base(2, true, TargetFlags.None)
{
m_Hoe = hoe;
}
protected override void OnTarget(Mobile from, object targeted)
{
if (!MaginciaPlantSystem.Enabled)
{
from.SendMessage("Magincia plant placement is currently disabled.");
return;
}
Map map = from.Map;
if (targeted is LandTarget && map != null)
{
LandTarget lt = (LandTarget)targeted;
Region r = Region.Find(lt.Location, map);
if (r != null && r.IsPartOf("Magincia") && (lt.Name == "dirt" || lt.Name == "grass"))
{
if (MaginciaPlantSystem.CanAddPlant(from, lt.Location))
{
if (!MaginciaPlantSystem.CheckDelay(from))
{
return;
}
else if (from.Mounted || from.Flying)
{
from.SendLocalizedMessage(501864); // You can't mine while riding.
}
else if (from.IsBodyMod && !from.Body.IsHuman)
{
from.SendLocalizedMessage(501865); // You can't mine while polymorphed.
}
else
{
m_Hoe.UsesRemaining--;
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1150492); // You till a small area to plant.
from.Animate(AnimationType.Attack, 3);
MaginciaPlantItem dirt = new MaginciaPlantItem();
dirt.Owner = from;
dirt.StartTimer();
MaginciaPlantSystem.OnPlantPlanted(from, from.Map);
Timer.DelayCall(TimeSpan.FromSeconds(.7), new TimerStateCallback(MoveItem_Callback), new object[] { dirt, lt.Location, map });
}
}
}
else
{
from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
}
}
}
private void MoveItem_Callback(object o)
{
object[] objs = o as object[];
if (objs != null)
{
Item dirt = objs[0] as Item;
Point3D p = (Point3D)objs[1];
Map map = objs[2] as Map;
if (dirt != null)
dirt.MoveToWorld(p, map);
}
}
}
public Hoe(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}

View File

@@ -0,0 +1,258 @@
using Server;
using System;
using Server.Network;
namespace Server.Engines.Plants
{
public class MaginciaPlantItem : PlantItem
{
public override bool MaginciaPlant { get { return true; } }
public override int BowlOfDirtID { get { return 2323; } }
public override int GreenBowlID
{
get
{
if (PlantStatus <= PlantStatus.Stage3)
return 0xC7E;
else
return 0xC62;
}
}
public override int ContainerLocalization { get { return 1150436; } } // mound of dirt
public override int OnPlantLocalization { get { return 1150442; } } // You plant the seed in the mound of dirt.
public override int CantUseLocalization { get { return 501648; } } // You cannot use this unless you are the owner.
public override int LabelNumber
{
get
{
int label = base.LabelNumber;
if (label == 1029913)
label = 1022321; // patch of dirt
return label;
}
}
private DateTime m_Planted;
private DateTime m_Contract;
private Timer m_Timer;
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Owner { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime Planted { get { return m_Planted; } set { m_Planted = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime ContractTime { get { return m_Contract; } set { m_Contract = value; InvalidateProperties(); } }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime ContractEndTime => ContractTime + TimeSpan.FromDays(14);
[CommandProperty(AccessLevel.GameMaster)]
public bool IsContract => ContractEndTime > DateTime.UtcNow;
[CommandProperty(AccessLevel.GameMaster)]
public DateTime SetToDecorative { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public override bool ValidGrowthLocation
{
get
{
return RootParent == null && !Movable;
}
}
[Constructable]
public MaginciaPlantItem()
: this(false)
{
}
[Constructable]
public MaginciaPlantItem(bool fertile)
: base(2323, fertile)
{
Movable = false;
Planted = DateTime.UtcNow;
}
public override void OnDoubleClick(Mobile from)
{
if (PlantStatus >= PlantStatus.DecorativePlant)
return;
Point3D loc = GetWorldLocation();
if (!from.InLOS(loc) || !from.InRange(loc, 2))
{
from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1019045); // I can't reach that.
return;
}
if (!IsUsableBy(from))
{
LabelTo(from, CantUseLocalization);
return;
}
from.SendGump(new MainPlantGump(this));
}
public override bool IsUsableBy(Mobile from)
{
return RootParent == null && !Movable && Owner == from && IsAccessibleTo(from);
}
public override void Die()
{
base.Die();
Timer.DelayCall(TimeSpan.FromMinutes(Utility.RandomMinMax(2, 5)), new TimerCallback(Delete));
}
public override void Delete()
{
if (Owner != null && PlantStatus < PlantStatus.DecorativePlant)
MaginciaPlantSystem.OnPlantDelete(Owner, Map);
base.Delete();
}
public override void GetProperties(ObjectPropertyList list)
{
base.GetProperties(list);
if (Owner != null)
{
list.Add(1150474, string.Format("{0}\t{1}", "#1011345", Owner.Name)); // Planted in ~1_val~ by: ~2_val~
list.Add(1150478, m_Planted.ToShortDateString());
if (IsContract)
{
DateTime easternTime = TimeZoneInfo.ConvertTimeFromUtc(ContractEndTime, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
list.Add(1155763, easternTime.ToString("MM-dd-yyyy HH:mm 'ET'")); // Gardening Contract Expires: ~1_TIME~
}
if (PlantStatus == PlantStatus.DecorativePlant)
list.Add(1150490, SetToDecorative.ToShortDateString()); // Date harvested: ~1_val~
}
}
public void StartTimer()
{
m_Timer = Timer.DelayCall(TimeSpan.FromMinutes(2), new TimerCallback(Delete));
}
public override bool PlantSeed(Mobile from, Seed seed)
{
if (!CheckLocation(from, seed) || !base.PlantSeed(from, seed))
return false;
if (m_Timer != null)
{
m_Timer.Stop();
m_Timer = null;
}
return true;
}
private bool CheckLocation(Mobile from, Seed seed)
{
if (!BlocksMovement(seed))
return true;
IPooledEnumerable eable = Map.GetItemsInRange(Location, 1);
foreach (Item item in eable)
{
if (item != this && item is MaginciaPlantItem)
{
if (((MaginciaPlantItem)item).BlocksMovement())
{
eable.Free();
from.SendLocalizedMessage(1150434); // Plants that block movement cannot be planted next to other plants that block movement.
return false;
}
}
}
eable.Free();
return true;
}
public bool BlocksMovement()
{
if (PlantStatus == PlantStatus.BowlOfDirt || PlantStatus == PlantStatus.DeadTwigs)
return false;
PlantTypeInfo info = PlantTypeInfo.GetInfo(PlantType);
ItemData data = TileData.ItemTable[info.ItemID & TileData.MaxItemValue];
TileFlag flags = data.Flags;
return (flags & TileFlag.Impassable) > 0;
}
public static bool BlocksMovement(Seed seed)
{
PlantTypeInfo info = PlantTypeInfo.GetInfo(seed.PlantType);
ItemData data = TileData.ItemTable[info.ItemID & TileData.MaxItemValue];
TileFlag flags = data.Flags;
return (flags & TileFlag.Impassable) > 0;
}
public MaginciaPlantItem(Serial serial)
: base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)1); // version
writer.Write(ContractTime);
writer.Write(Owner);
writer.Write(m_Planted);
writer.Write(SetToDecorative);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
switch (version)
{
case 1:
{
ContractTime = reader.ReadDateTime();
Owner = reader.ReadMobile();
m_Planted = reader.ReadDateTime();
SetToDecorative = reader.ReadDateTime();
break;
}
case 0:
{
Owner = reader.ReadMobile();
m_Planted = reader.ReadDateTime();
SetToDecorative = reader.ReadDateTime();
break;
}
}
if (PlantStatus == PlantStatus.BowlOfDirt)
Delete();
}
}
}

View File

@@ -0,0 +1,265 @@
using Server;
using System;
using System.Collections.Generic;
using Server.Engines.NewMagincia;
namespace Server.Engines.Plants
{
public class MaginciaPlantSystem : Item
{
public static readonly bool Enabled = true;
public static readonly int PlantDelay = 4;
public Dictionary<Mobile, DateTime> PlantDelayTable { get; } = new Dictionary<Mobile, DateTime>();
public static MaginciaPlantSystem FelInstance { get; private set; }
public static MaginciaPlantSystem TramInstance { get; private set; }
public static void Initialize()
{
if (Enabled)
{
if (FelInstance == null)
{
FelInstance = new MaginciaPlantSystem();
FelInstance.MoveToWorld(new Point3D(3715, 2049, 5), Map.Felucca);
}
if (TramInstance == null)
{
TramInstance = new MaginciaPlantSystem();
TramInstance.MoveToWorld(new Point3D(3715, 2049, 5), Map.Trammel);
}
}
}
public MaginciaPlantSystem()
: base(3240)
{
Movable = false;
}
public bool CheckPlantDelay(Mobile from)
{
if (PlantDelayTable.ContainsKey(from))
{
if (PlantDelayTable[from] > DateTime.UtcNow)
{
TimeSpan left = PlantDelayTable[from] - DateTime.UtcNow;
// Time remaining to plant on the Isle of Magincia again: ~1_val~ days ~2_val~ hours ~3_val~ minutes.
from.SendLocalizedMessage(1150459, string.Format("{0}\t{1}\t{2}", left.Days.ToString(), left.Hours.ToString(), left.Minutes.ToString()));
return false;
}
}
return true;
}
public void OnPlantDelete(Mobile from)
{
if (PlantDelayTable.ContainsKey(from))
PlantDelayTable.Remove(from);
}
public void OnPlantPlanted(Mobile from)
{
if (from.AccessLevel == AccessLevel.Player)
PlantDelayTable[from] = DateTime.UtcNow + TimeSpan.FromDays(PlantDelay);
else
from.SendMessage("As staff, you bypass the {0} day plant delay.", PlantDelay);
}
public override void Delete()
{
}
public static bool CanAddPlant(Mobile from, Point3D p)
{
if (!IsValidLocation(p))
{
from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
return false;
}
Map map = from.Map;
IPooledEnumerable eable = map.GetItemsInRange(p, 17);
int plantCount = 0;
foreach (Item item in eable)
{
if (item is MaginciaPlantItem)
{
if(item.Location != p)
plantCount++;
else
{
from.SendLocalizedMessage(1150367); // This plot already has a plant!
eable.Free();
return false;
}
}
else if (!item.Movable && item.Location == p)
{
from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
eable.Free();
return false;
}
}
eable.Free();
if (plantCount > 34)
{
from.SendLocalizedMessage(1150491); // There are too many objects in this area to plant (limit 34 per 17x17 area).
return false;
}
StaticTile[] staticTiles = map.Tiles.GetStaticTiles(p.X, p.Y, true);
if (staticTiles.Length > 0)
{
from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
return false;
}
return true;
}
public static bool CheckDelay(Mobile from)
{
MaginciaPlantSystem system = null;
Map map = from.Map;
if (map == Map.Trammel)
system = TramInstance;
else if (map == Map.Felucca)
system = FelInstance;
if (system == null)
{
from.SendLocalizedMessage(1150457); // The ground here is not good for gardening.
return false;
}
return system.CheckPlantDelay(from);
}
public static bool IsValidLocation(Point3D p)
{
/*foreach (Rectangle2D rec in m_MagGrowBounds)
{
if (rec.Contains(p))
return true;
}*/
foreach (Rectangle2D rec in m_NoGrowZones)
{
if (rec.Contains(p))
return false;
}
foreach (Rectangle2D rec in MaginciaLottoSystem.MagHousingZones)
{
Rectangle2D newRec = new Rectangle2D(rec.X - 2, rec.Y - 2, rec.Width + 4, rec.Height + 7);
if (newRec.Contains(p))
return false;
}
return true;
}
public static void OnPlantDelete(Mobile owner, Map map)
{
if (owner == null || map == null)
return;
if (map == Map.Trammel)
TramInstance.OnPlantDelete(owner);
else if (map == Map.Felucca)
FelInstance.OnPlantDelete(owner);
}
public static void OnPlantPlanted(Mobile from, Map map)
{
if (map == Map.Felucca)
FelInstance.OnPlantPlanted(from);
else if (map == Map.Trammel)
TramInstance.OnPlantPlanted(from);
}
public static Rectangle2D[] MagGrowBounds { get { return m_MagGrowBounds; } }
private static readonly Rectangle2D[] m_MagGrowBounds = new Rectangle2D[]
{
new Rectangle2D(3663, 2103, 19, 19),
new Rectangle2D(3731, 2199, 7, 7),
};
private static Rectangle2D[] m_NoGrowZones = new Rectangle2D[]
{
new Rectangle2D(3683, 2144, 21, 40),
new Rectangle2D(3682, 2189, 39, 44),
new Rectangle2D(3654, 2233, 23, 30),
new Rectangle2D(3727, 2217, 15, 45),
new Rectangle2D(3558, 2134, 8, 8),
new Rectangle2D(3679, 2018, 70, 28)
};
public void DefragPlantDelayTable()
{
List<Mobile> toRemove = new List<Mobile>();
foreach (KeyValuePair<Mobile, DateTime> kvp in PlantDelayTable)
{
if (kvp.Value < DateTime.UtcNow)
toRemove.Add(kvp.Key);
}
foreach (Mobile m in toRemove)
PlantDelayTable.Remove(m);
}
public MaginciaPlantSystem(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
DefragPlantDelayTable();
writer.Write(PlantDelayTable.Count);
foreach (KeyValuePair<Mobile, DateTime> kvp in PlantDelayTable)
{
writer.Write(kvp.Key);
writer.Write(kvp.Value);
}
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
int c = reader.ReadInt();
for (int i = 0; i < c; i++)
{
Mobile m = reader.ReadMobile();
DateTime dt = reader.ReadDateTime();
if (m != null && dt > DateTime.UtcNow)
PlantDelayTable[m] = dt;
}
if (Map == Map.Felucca)
FelInstance = this;
else if (Map == Map.Trammel)
TramInstance = this;
else
Delete();
}
}
}