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,39 @@
#region References
using Server;
#endregion
namespace Knives.TownHouses
{
public delegate void TownHouseCommandHandler(CommandInfo info);
public class CommandInfo
{
private readonly Mobile c_Mobile;
private readonly string c_Command;
private readonly string c_ArgString;
private readonly string[] c_Arguments;
public Mobile Mobile { get { return c_Mobile; } }
public string Command { get { return c_Command; } }
public string ArgString { get { return c_ArgString; } }
public string[] Arguments { get { return c_Arguments; } }
public CommandInfo(Mobile m, string com, string args, string[] arglist)
{
c_Mobile = m;
c_Command = com;
c_ArgString = args;
c_Arguments = arglist;
}
public string GetString(int num)
{
if (c_Arguments.Length > num)
{
return c_Arguments[num];
}
return "";
}
}
}

View File

@@ -0,0 +1,64 @@
#region References
using Server;
#endregion
namespace Knives.TownHouses
{
public class DecoreItemInfo
{
private string c_TypeString;
private string c_Name;
private int c_ItemID;
private int c_Hue;
private Point3D c_Location;
private Map c_Map;
public string TypeString { get { return c_TypeString; } }
public string Name { get { return c_Name; } }
public int ItemID { get { return c_ItemID; } }
public int Hue { get { return c_Hue; } }
public Point3D Location { get { return c_Location; } }
public Map Map { get { return c_Map; } }
public DecoreItemInfo()
{ }
public DecoreItemInfo(string typestring, string name, int itemid, int hue, Point3D loc, Map map)
{
c_TypeString = typestring;
c_ItemID = itemid;
c_Location = loc;
c_Map = map;
}
public void Save(GenericWriter writer)
{
writer.Write(1); // Version
// Version 1
writer.Write(c_Hue);
writer.Write(c_Name);
writer.Write(c_TypeString);
writer.Write(c_ItemID);
writer.Write(c_Location);
writer.Write(c_Map);
}
public void Load(GenericReader reader)
{
var version = reader.ReadInt();
if (version >= 1)
{
c_Hue = reader.ReadInt();
c_Name = reader.ReadString();
}
c_TypeString = reader.ReadString();
c_ItemID = reader.ReadInt();
c_Location = reader.ReadPoint3D();
c_Map = reader.ReadMap();
}
}
}

View File

@@ -0,0 +1,247 @@
#region References
using System.Linq;
using Server;
using Server.Multis;
#endregion
namespace Knives.TownHouses
{
public class General
{
public static string Version { get { return "3.01"; } }
// This setting determines the suggested gold value for a single square of a home
// which then derives price, lockdowns and secures.
public static int SuggestionFactor { get { return 600; } }
// This setting determines if players need License in order to rent out their property
public static bool RequireRenterLicense { get { return false; } }
public static void Configure()
{
EventSink.WorldSave += OnSave;
EventSink.ServerStarted += OnStarted;
EventSink.Login += OnLogin;
EventSink.Speech += HandleSpeech;
}
private static void OnStarted()
{
var i = TownHouse.AllTownHouses.Count;
while (--i >= 0)
{
if (i >= TownHouse.AllTownHouses.Count)
continue;
var h = TownHouse.AllTownHouses[i];
h.InitSectorDefinition();
RUOVersion.UpdateRegion(h.ForSaleSign);
}
}
public static void OnSave(WorldSaveEventArgs e)
{
var i = TownHouseSign.AllSigns.Count;
while (--i >= 0)
{
if (i >= TownHouseSign.AllSigns.Count)
continue;
var s = TownHouseSign.AllSigns[i];
s.ValidateOwnership();
}
}
private static void OnLogin(LoginEventArgs e)
{
var houses = BaseHouse.AllHouses.OfType<TownHouse>();
foreach (var house in houses.Where(h => h.IsSameAccount(h.Owner, e.Mobile)))
{
house.ForSaleSign.CheckDemolishTimer();
}
}
private static void HandleSpeech(SpeechEventArgs e)
{
try
{
var house = BaseHouse.FindHouseAt(e.Mobile);
if (house == null)
{
return;
}
if (house is TownHouse)
{
house.OnSpeech(e);
}
if (Insensitive.Equals(e.Speech, "create rental contract") && CanRent(e.Mobile, house, true))
{
e.Mobile.AddToBackpack(new RentalContract());
e.Mobile.SendMessage("A rental contract has been placed in your bag.");
}
else if (Insensitive.Equals(e.Speech, "check storage"))
{
int count;
e.Mobile.SendMessage(
"You have {0:#,0} lockdowns and {1:#,0} secures available.",
RemainingSecures(house),
RemainingLocks(house));
if ((count = AllRentalLocks(house)) != 0)
{
e.Mobile.SendMessage("Current rentals are using {0:#,0} of your lockdowns.", count);
}
if ((count = AllRentalSecures(house)) != 0)
{
e.Mobile.SendMessage("Current rentals are using {0:#,0} of your secures.", count);
}
}
}
catch
{ }
}
private static bool CanRent(Mobile m, BaseHouse house, bool say)
{
if (house is TownHouse && ((TownHouse)house).ForSaleSign.PriceType != "Sale")
{
if (say)
{
m.SendMessage("You must own your property to rent it.");
}
return false;
}
if (RequireRenterLicense)
{
var lic = m.Backpack.FindItemByType<RentalLicense>();
if (lic != null && lic.Owner == null)
{
lic.Owner = m;
}
if (lic == null || lic.Owner != m)
{
if (say)
{
m.SendMessage("You must have a renter's license to rent your property.");
}
return false;
}
}
if (EntireHouseContracted(house))
{
if (say)
{
m.SendMessage("This entire house already has a rental contract.");
}
return false;
}
if (RemainingSecures(house) < 0 || RemainingLocks(house) < 0)
{
if (say)
{
m.SendMessage("You don't have the storage available to rent property.");
}
return false;
}
return true;
}
#region Rental Info
public static bool EntireHouseContracted(BaseHouse house)
{
return TownHouseSign.AllSigns.OfType<RentalContract>().Any(s => house == s.ParentHouse && s.EntireHouse);
}
public static bool HasContract(BaseHouse house)
{
return TownHouseSign.AllSigns.OfType<RentalContract>().Any(s => house == s.ParentHouse);
}
public static bool HasOtherContract(BaseHouse house, RentalContract c)
{
return TownHouseSign.AllSigns.OfType<RentalContract>().Any(s => s != c && house == s.ParentHouse && s.EntireHouse);
}
public static int RemainingSecures(BaseHouse house)
{
if (house == null)
{
return 0;
}
int total;
if (Core.AOS)
{
int a, b, c, d;
total = house.GetAosMaxSecures() - house.GetAosCurSecures(out a, out b, out c, out d);
}
else
{
total = house.MaxSecures - house.SecureCount;
}
return total - AllRentalSecures(house);
}
public static int RemainingLocks(BaseHouse house)
{
if (house == null)
{
return 0;
}
int total;
if (Core.AOS)
{
total = house.GetAosMaxLockdowns() - house.GetAosCurLockdowns();
}
else
{
total = house.MaxLockDowns - house.LockDownCount;
}
return total - AllRentalLocks(house);
}
public static int AllRentalSecures(BaseHouse house)
{
return TownHouseSign.AllSigns.OfType<RentalContract>()
.Where(s => s.ParentHouse == house)
.Aggregate(0, (c, s) => c + s.Secures);
}
public static int AllRentalLocks(BaseHouse house)
{
return TownHouseSign.AllSigns.OfType<RentalContract>()
.Where(s => s.ParentHouse == house)
.Aggregate(0, (c, s) => c + s.Locks);
}
#endregion
}
}

View File

@@ -0,0 +1,132 @@
#if ServUO58
#define ServUOX
#endif
using System.Collections;
using Server;
using Server.Network;
using Server.Gumps;
using System.IO;
namespace Knives.TownHouses
{
public class GumpResponse
{
private static PacketHandler m_Successor;
public static void Initialize()
{
m_Successor = PacketHandlers.GetHandler(0xB1);
PacketHandlers.Register(0xB1, 0, true, DisplayGumpResponse);
#if !ServUOX
PacketHandlers.Register6017(0xB1, 0, true, DisplayGumpResponse);
#endif
}
public static void DisplayGumpResponse(NetState state, PacketReader pvSrc)
{
int serial = pvSrc.ReadInt32();
int typeID = pvSrc.ReadInt32();
int button = pvSrc.ReadInt32();
pvSrc.Seek(-12, SeekOrigin.Current);
int index = state.Gumps.Count;
while (--index >= 0)
{
if (index >= state.Gumps.Count)
continue;
Gump gump = state.Gumps[index];
if (gump == null)
continue;
if (gump.Serial == serial && gump.TypeID == typeID)
{
state.Gumps.RemoveAt(index);
if (!CheckResponse(gump, state.Mobile, button))
return;
if (!state.Gumps.Contains(gump))
state.Gumps.Insert(index, gump);
}
}
if (m_Successor != null)
m_Successor.OnReceive(state, pvSrc);
else
PacketHandlers.DisplayGumpResponse(state, pvSrc);
}
private static bool CheckResponse(Gump gump, Mobile m, int id)
{
if (m == null || !m.Player)
return true;
TownHouse th = null;
ArrayList list = new ArrayList();
foreach (Item item in m.GetItemsInRange(20))
{
if (item is TownHouse)
list.Add(item);
}
foreach (TownHouse t in list)
{
if (t.Owner == m)
{
th = t;
break;
}
}
if (th == null || th.ForSaleSign == null)
return true;
#if ServUOX
if (gump is HouseGump)
#else
if (gump is HouseGumpAOS)
#endif
{
int val = id - 1;
if (val < 0)
return true;
int type = val % 15;
int index = val / 15;
if (th.ForSaleSign.ForcePublic && type == 3 && index == 12 && th.Public)
{
m.SendMessage("This house cannot be private.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.ForcePrivate && type == 3 && index == 13 && !th.Public)
{
m.SendMessage("This house cannot be public.");
m.SendGump(gump);
return false;
}
if (th.ForSaleSign.NoTrade && type == 6 && index == 1)
{
m.SendMessage("This house cannot be traded.");
m.SendGump(gump);
return false;
}
}
return true;
}
}
}