Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
422
Scripts/SubSystem/TownHouses/Items/RentalContract.cs
Normal file
422
Scripts/SubSystem/TownHouses/Items/RentalContract.cs
Normal file
@@ -0,0 +1,422 @@
|
||||
#region References
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Multis;
|
||||
#endregion
|
||||
|
||||
namespace Knives.TownHouses
|
||||
{
|
||||
public class RentalContract : TownHouseSign
|
||||
{
|
||||
private Mobile c_RentalMaster;
|
||||
private Mobile c_RentalClient;
|
||||
private BaseHouse c_ParentHouse;
|
||||
|
||||
public BaseHouse ParentHouse { get { return c_ParentHouse; } }
|
||||
|
||||
public Mobile RentalClient
|
||||
{
|
||||
get { return c_RentalClient; }
|
||||
set
|
||||
{
|
||||
c_RentalClient = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public Mobile RentalMaster { get { return c_RentalMaster; } }
|
||||
public bool Completed { get; set; }
|
||||
public bool EntireHouse { get; set; }
|
||||
|
||||
public RentalContract()
|
||||
{
|
||||
ItemID = 0x14F0;
|
||||
Movable = true;
|
||||
RentByTime = TimeSpan.FromDays(1);
|
||||
RecurRent = true;
|
||||
MaxZ = MinZ;
|
||||
}
|
||||
|
||||
public bool HasContractedArea(Rectangle2D rect, int z)
|
||||
{
|
||||
foreach (Item item in AllSigns)
|
||||
{
|
||||
if (item is RentalContract && item != this && item.Map == Map && c_ParentHouse == ((RentalContract)item).ParentHouse)
|
||||
{
|
||||
foreach (Rectangle2D rect2 in ((RentalContract)item).Blocks)
|
||||
{
|
||||
for (var x = rect.Start.X; x < rect.End.X; ++x)
|
||||
{
|
||||
for (var y = rect.Start.Y; y < rect.End.Y; ++y)
|
||||
{
|
||||
if (rect2.Contains(new Point2D(x, y)))
|
||||
{
|
||||
if (((RentalContract)item).MinZ <= z && ((RentalContract)item).MaxZ >= z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasContractedArea(int z)
|
||||
{
|
||||
foreach (Item item in AllSigns)
|
||||
{
|
||||
if (item is RentalContract && item != this && item.Map == Map && c_ParentHouse == ((RentalContract)item).ParentHouse)
|
||||
{
|
||||
if (((RentalContract)item).MinZ <= z && ((RentalContract)item).MaxZ >= z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DepositTo(Mobile m)
|
||||
{
|
||||
if (m == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Free)
|
||||
{
|
||||
m.SendMessage("Since this home is free, you do not receive the deposit.");
|
||||
return;
|
||||
}
|
||||
|
||||
m.BankBox.DropItem(new Gold(Price));
|
||||
m.SendMessage("You have received a {0} gold deposit from your town house.", Price);
|
||||
}
|
||||
|
||||
public override void ValidateOwnership()
|
||||
{
|
||||
if (Completed && c_RentalMaster == null)
|
||||
{
|
||||
Delete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (c_RentalClient != null && (c_ParentHouse == null || c_ParentHouse.Deleted))
|
||||
{
|
||||
Delete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (c_RentalClient != null && !Owned)
|
||||
{
|
||||
Delete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ParentHouse == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ValidateLocSec())
|
||||
{
|
||||
if (DemolishTimer == null)
|
||||
{
|
||||
BeginDemolishTimer(TimeSpan.FromHours(48));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDemolishTimer();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DemolishAlert()
|
||||
{
|
||||
if (ParentHouse == null || c_RentalMaster == null || c_RentalClient == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
c_RentalMaster.SendMessage(
|
||||
"You have begun to use lockdowns reserved for {0}, and their rental unit will collapse in {1}.",
|
||||
c_RentalClient.Name,
|
||||
Math.Round((DemolishTime - DateTime.UtcNow).TotalHours, 2));
|
||||
c_RentalClient.SendMessage(
|
||||
"Alert your land lord, {0}, they are using storage reserved for you. They have violated the rental agreement, which will end in {1} if nothing is done.",
|
||||
c_RentalMaster.Name,
|
||||
Math.Round((DemolishTime - DateTime.UtcNow).TotalHours, 2));
|
||||
}
|
||||
|
||||
public void FixLocSec()
|
||||
{
|
||||
var count = 0;
|
||||
|
||||
if ((count = General.RemainingSecures(c_ParentHouse) + Secures) < Secures)
|
||||
{
|
||||
Secures = count;
|
||||
}
|
||||
|
||||
if ((count = General.RemainingLocks(c_ParentHouse) + Locks) < Locks)
|
||||
{
|
||||
Locks = count;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ValidateLocSec()
|
||||
{
|
||||
if (General.RemainingSecures(c_ParentHouse) + Secures < Secures)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (General.RemainingLocks(c_ParentHouse) + Locks < Locks)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ConvertItems(bool keep)
|
||||
{
|
||||
if (House == null || c_ParentHouse == null || c_RentalMaster == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (BaseDoor door in c_ParentHouse.Doors.OfType<BaseDoor>().ToArray())
|
||||
{
|
||||
if (door.Map == House.Map && House.Region.Contains(door.Location))
|
||||
{
|
||||
ConvertDoor(door);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (SecureInfo info in c_ParentHouse.Secures.ToArray())
|
||||
{
|
||||
if (info.Item.Map == House.Map && House.Region.Contains(info.Item.Location))
|
||||
{
|
||||
c_ParentHouse.Release(c_RentalMaster, info.Item);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Item item in c_ParentHouse.LockDowns.Keys.ToArray())
|
||||
{
|
||||
if (item.Map == House.Map && House.Region.Contains(item.Location))
|
||||
{
|
||||
c_ParentHouse.Release(c_RentalMaster, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void UnconvertDoors()
|
||||
{
|
||||
if (House == null || c_ParentHouse == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (BaseDoor door in House.Doors.OfType<BaseDoor>().ToArray())
|
||||
{
|
||||
House.Doors.Remove(door);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnRentPaid()
|
||||
{
|
||||
if (c_RentalMaster == null || c_RentalClient == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Free)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
c_RentalMaster.BankBox.DropItem(new Gold(Price));
|
||||
c_RentalMaster.SendMessage("The bank has transfered your rent from {0}.", c_RentalClient.Name);
|
||||
}
|
||||
|
||||
public override void ClearHouse()
|
||||
{
|
||||
if (!Deleted)
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
|
||||
base.ClearHouse();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
ValidateOwnership();
|
||||
|
||||
if (Deleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (c_RentalMaster == null)
|
||||
{
|
||||
c_RentalMaster = m;
|
||||
}
|
||||
|
||||
var house = BaseHouse.FindHouseAt(m);
|
||||
|
||||
if (c_ParentHouse == null)
|
||||
{
|
||||
c_ParentHouse = house;
|
||||
}
|
||||
|
||||
if (house == null || (house != c_ParentHouse && house != House))
|
||||
{
|
||||
m.SendMessage("You must be in the home to view this contract.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m == c_RentalMaster && !Completed && house is TownHouse && ((TownHouse)house).ForSaleSign.PriceType != "Sale")
|
||||
{
|
||||
c_ParentHouse = null;
|
||||
m.SendMessage("You can only rent property you own.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m == c_RentalMaster && !Completed && General.EntireHouseContracted(c_ParentHouse))
|
||||
{
|
||||
m.SendMessage("This entire house already has a rental contract.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Completed)
|
||||
{
|
||||
new ContractConfirmGump(m, this);
|
||||
}
|
||||
else if (m == c_RentalMaster)
|
||||
{
|
||||
new ContractSetupGump(m, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m.SendMessage("This rental contract has not yet been completed.");
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
if (c_RentalClient != null)
|
||||
{
|
||||
list.Add("a house rental contract with " + c_RentalClient.Name);
|
||||
}
|
||||
else if (Completed)
|
||||
{
|
||||
list.Add("a completed house rental contract");
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add("an uncompleted house rental contract");
|
||||
}
|
||||
}
|
||||
|
||||
public override void Delete()
|
||||
{
|
||||
if (c_ParentHouse == null)
|
||||
{
|
||||
base.Delete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Owned && !c_ParentHouse.IsFriend(c_RentalClient))
|
||||
{
|
||||
if (c_RentalClient != null && c_RentalMaster != null)
|
||||
{
|
||||
c_RentalMaster.SendMessage(
|
||||
"{0} has ended your rental agreement. Because you revoked their access, their last payment will be refunded.",
|
||||
c_RentalMaster.Name);
|
||||
c_RentalClient.SendMessage(
|
||||
"You have ended your rental agreement with {0}. Because your access was revoked, your last payment is refunded.",
|
||||
c_RentalClient.Name);
|
||||
}
|
||||
|
||||
DepositTo(c_RentalClient);
|
||||
}
|
||||
else if (Owned)
|
||||
{
|
||||
if (c_RentalClient != null && c_RentalMaster != null)
|
||||
{
|
||||
c_RentalClient.SendMessage(
|
||||
"{0} has ended your rental agreement. Since they broke the contract, your are refunded the last payment.",
|
||||
c_RentalMaster.Name);
|
||||
c_RentalMaster.SendMessage(
|
||||
"You have ended your rental agreement with {0}. They will be refunded their last payment.",
|
||||
c_RentalClient.Name);
|
||||
}
|
||||
|
||||
DepositTo(c_RentalClient);
|
||||
|
||||
PackUpHouse();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c_RentalClient != null && c_RentalMaster != null)
|
||||
{
|
||||
c_RentalMaster.SendMessage("{0} has ended your rental agreement.", c_RentalClient.Name);
|
||||
c_RentalClient.SendMessage("You have ended your rental agreement with {0}.", c_RentalMaster.Name);
|
||||
}
|
||||
|
||||
DepositTo(c_RentalMaster);
|
||||
}
|
||||
|
||||
ClearRentTimer();
|
||||
base.Delete();
|
||||
}
|
||||
|
||||
public RentalContract(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
RecurRent = true;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(1); // version
|
||||
|
||||
// Version 1
|
||||
|
||||
writer.Write(EntireHouse);
|
||||
|
||||
writer.Write(c_RentalMaster);
|
||||
writer.Write(c_RentalClient);
|
||||
writer.Write(c_ParentHouse);
|
||||
writer.Write(Completed);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
if (version >= 1)
|
||||
{
|
||||
EntireHouse = reader.ReadBool();
|
||||
}
|
||||
|
||||
c_RentalMaster = reader.ReadMobile();
|
||||
c_RentalClient = reader.ReadMobile();
|
||||
c_ParentHouse = reader.ReadItem() as BaseHouse;
|
||||
Completed = reader.ReadBool();
|
||||
}
|
||||
}
|
||||
}
|
||||
47
Scripts/SubSystem/TownHouses/Items/RentalContractCopy.cs
Normal file
47
Scripts/SubSystem/TownHouses/Items/RentalContractCopy.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
#region References
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace Knives.TownHouses
|
||||
{
|
||||
public class RentalContractCopy : Item
|
||||
{
|
||||
private readonly RentalContract c_Contract;
|
||||
|
||||
public RentalContractCopy(RentalContract contract)
|
||||
{
|
||||
Name = "rental contract copy";
|
||||
ItemID = 0x14F0;
|
||||
c_Contract = contract;
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (c_Contract == null || c_Contract.Deleted)
|
||||
{
|
||||
Delete();
|
||||
return;
|
||||
}
|
||||
|
||||
c_Contract.OnDoubleClick(m);
|
||||
}
|
||||
|
||||
public RentalContractCopy(Serial serial)
|
||||
: base(serial)
|
||||
{ }
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
67
Scripts/SubSystem/TownHouses/Items/RentalLicense.cs
Normal file
67
Scripts/SubSystem/TownHouses/Items/RentalLicense.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
#region References
|
||||
using Server;
|
||||
#endregion
|
||||
|
||||
namespace Knives.TownHouses
|
||||
{
|
||||
public class RentalLicense : Item
|
||||
{
|
||||
private Mobile c_Owner;
|
||||
|
||||
public Mobile Owner
|
||||
{
|
||||
get { return c_Owner; }
|
||||
set
|
||||
{
|
||||
c_Owner = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public RentalLicense()
|
||||
: base(0x14F0)
|
||||
{ }
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
if (c_Owner != null)
|
||||
{
|
||||
list.Add("a renter's license belonging to " + c_Owner.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add("a renter's license");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (c_Owner == null)
|
||||
{
|
||||
c_Owner = m;
|
||||
}
|
||||
}
|
||||
|
||||
public RentalLicense(Serial serial)
|
||||
: base(serial)
|
||||
{ }
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write(c_Owner);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.ReadInt();
|
||||
|
||||
c_Owner = reader.ReadMobile();
|
||||
}
|
||||
}
|
||||
}
|
||||
316
Scripts/SubSystem/TownHouses/Items/SignHammer.cs
Normal file
316
Scripts/SubSystem/TownHouses/Items/SignHammer.cs
Normal file
@@ -0,0 +1,316 @@
|
||||
#region References
|
||||
using System.Collections;
|
||||
|
||||
using Server;
|
||||
using Server.Multis;
|
||||
using Server.Targeting;
|
||||
#endregion
|
||||
|
||||
namespace Knives.TownHouses
|
||||
{
|
||||
public enum HammerJob
|
||||
{
|
||||
Flip,
|
||||
Swap
|
||||
}
|
||||
|
||||
public class SignHammer : Item
|
||||
{
|
||||
private static readonly Hashtable s_Table = new Hashtable();
|
||||
private static readonly ArrayList s_List = new ArrayList();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
// Signs
|
||||
s_Table[0xB95] = 0xB96;
|
||||
s_Table[0xB96] = 0xB95;
|
||||
s_Table[0xBA3] = 0xBA4;
|
||||
s_Table[0xBA4] = 0xBA3;
|
||||
s_Table[0xBA5] = 0xBA6;
|
||||
s_Table[0xBA6] = 0xBA5;
|
||||
s_Table[0xBA7] = 0xBA8;
|
||||
s_Table[0xBA8] = 0xBA7;
|
||||
s_Table[0xBA9] = 0xBAA;
|
||||
s_Table[0xBAA] = 0xBA9;
|
||||
s_Table[0xBAB] = 0xBAC;
|
||||
s_Table[0xBAC] = 0xBAB;
|
||||
s_Table[0xBAD] = 0xBAE;
|
||||
s_Table[0xBAE] = 0xBAD;
|
||||
s_Table[0xBAF] = 0xBB0;
|
||||
s_Table[0xBB0] = 0xBAF;
|
||||
s_Table[0xBB1] = 0xBB2;
|
||||
s_Table[0xBB2] = 0xBB1;
|
||||
s_Table[0xBB3] = 0xBB4;
|
||||
s_Table[0xBB4] = 0xBB3;
|
||||
s_Table[0xBB5] = 0xBB6;
|
||||
s_Table[0xBB6] = 0xBB5;
|
||||
s_Table[0xBB7] = 0xBB8;
|
||||
s_Table[0xBB8] = 0xBB7;
|
||||
s_Table[0xBB9] = 0xBBA;
|
||||
s_Table[0xBBA] = 0xBB9;
|
||||
s_Table[0xBBB] = 0xBBC;
|
||||
s_Table[0xBBC] = 0xBBB;
|
||||
s_Table[0xBBD] = 0xBBE;
|
||||
s_Table[0xBBE] = 0xBBD;
|
||||
s_Table[0xBBF] = 0xBC0;
|
||||
s_Table[0xBC0] = 0xBBF;
|
||||
s_Table[0xBC1] = 0xBC2;
|
||||
s_Table[0xBC2] = 0xBC1;
|
||||
s_Table[0xBC3] = 0xBC4;
|
||||
s_Table[0xBC4] = 0xBC3;
|
||||
s_Table[0xBC5] = 0xBC6;
|
||||
s_Table[0xBC6] = 0xBC5;
|
||||
s_Table[0xBC7] = 0xBC8;
|
||||
s_Table[0xBC8] = 0xBC7;
|
||||
s_Table[0xBC9] = 0xBCA;
|
||||
s_Table[0xBCA] = 0xBC9;
|
||||
s_Table[0xBCB] = 0xBCC;
|
||||
s_Table[0xBCC] = 0xBCB;
|
||||
s_Table[0xBCD] = 0xBCE;
|
||||
s_Table[0xBCE] = 0xBCD;
|
||||
s_Table[0xBCF] = 0xBD0;
|
||||
s_Table[0xBD0] = 0xBCF;
|
||||
s_Table[0xBD1] = 0xBD2;
|
||||
s_Table[0xBD2] = 0xBD1;
|
||||
s_Table[0xBD3] = 0xBD4;
|
||||
s_Table[0xBD4] = 0xBD3;
|
||||
s_Table[0xBD5] = 0xBD6;
|
||||
s_Table[0xBD6] = 0xBD5;
|
||||
s_Table[0xBD7] = 0xBD8;
|
||||
s_Table[0xBD8] = 0xBD7;
|
||||
s_Table[0xBD9] = 0xBDA;
|
||||
s_Table[0xBDA] = 0xBD9;
|
||||
s_Table[0xBDB] = 0xBDC;
|
||||
s_Table[0xBDC] = 0xBDB;
|
||||
s_Table[0xBDD] = 0xBDE;
|
||||
s_Table[0xBDE] = 0xBDD;
|
||||
s_Table[0xBDF] = 0xBE0;
|
||||
s_Table[0xBE0] = 0xBDF;
|
||||
s_Table[0xBE1] = 0xBE2;
|
||||
s_Table[0xBE2] = 0xBE1;
|
||||
s_Table[0xBE3] = 0xBE4;
|
||||
s_Table[0xBE4] = 0xBE3;
|
||||
s_Table[0xBE5] = 0xBE6;
|
||||
s_Table[0xBE6] = 0xBE5;
|
||||
s_Table[0xBE7] = 0xBE8;
|
||||
s_Table[0xBE8] = 0xBE7;
|
||||
s_Table[0xBE9] = 0xBEA;
|
||||
s_Table[0xBEA] = 0xBE9;
|
||||
s_Table[0xBEB] = 0xBEC;
|
||||
s_Table[0xBEC] = 0xBEB;
|
||||
s_Table[0xBED] = 0xBEE;
|
||||
s_Table[0xBEE] = 0xBED;
|
||||
s_Table[0xBEF] = 0xBF0;
|
||||
s_Table[0xBF0] = 0xBEF;
|
||||
s_Table[0xBF1] = 0xBF2;
|
||||
s_Table[0xBF2] = 0xBF1;
|
||||
s_Table[0xBF3] = 0xBF4;
|
||||
s_Table[0xBF4] = 0xBF3;
|
||||
s_Table[0xBF5] = 0xBF6;
|
||||
s_Table[0xBF6] = 0xBF5;
|
||||
s_Table[0xBF7] = 0xBF8;
|
||||
s_Table[0xBF8] = 0xBF7;
|
||||
s_Table[0xBF9] = 0xBFA;
|
||||
s_Table[0xBFA] = 0xBF9;
|
||||
s_Table[0xBFB] = 0xBFC;
|
||||
s_Table[0xBFC] = 0xBFB;
|
||||
s_Table[0xBFD] = 0xBFE;
|
||||
s_Table[0xBFE] = 0xBFD;
|
||||
s_Table[0xBFF] = 0xC00;
|
||||
s_Table[0xC00] = 0xBFF;
|
||||
s_Table[0xC01] = 0xC02;
|
||||
s_Table[0xC02] = 0xC01;
|
||||
s_Table[0xC03] = 0xC04;
|
||||
s_Table[0xC04] = 0xC03;
|
||||
s_Table[0xC05] = 0xC06;
|
||||
s_Table[0xC06] = 0xC05;
|
||||
s_Table[0xC07] = 0xC08;
|
||||
s_Table[0xC08] = 0xC07;
|
||||
s_Table[0xC09] = 0xC0A;
|
||||
s_Table[0xC0A] = 0xC09;
|
||||
s_Table[0xC0B] = 0xC0C;
|
||||
s_Table[0xC0C] = 0xC0B;
|
||||
s_Table[0xC0D] = 0xC0E;
|
||||
s_Table[0xC0E] = 0xC0D;
|
||||
|
||||
// Hangers
|
||||
s_Table[0xB97] = 0xB98;
|
||||
s_Table[0xB98] = 0xB97;
|
||||
s_Table[0xB99] = 0xB9A;
|
||||
s_Table[0xB9A] = 0xB99;
|
||||
s_Table[0xB9B] = 0xB9C;
|
||||
s_Table[0xB9C] = 0xB9B;
|
||||
s_Table[0xB9D] = 0xB9E;
|
||||
s_Table[0xB9E] = 0xB9D;
|
||||
s_Table[0xB9F] = 0xBA0;
|
||||
s_Table[0xBA0] = 0xB9F;
|
||||
s_Table[0xBA1] = 0xBA2;
|
||||
s_Table[0xBA2] = 0xBA1;
|
||||
|
||||
// Hangers for swapping
|
||||
s_List.Add(0xB97);
|
||||
s_List.Add(0xB98);
|
||||
s_List.Add(0xB99);
|
||||
s_List.Add(0xB9A);
|
||||
s_List.Add(0xB9B);
|
||||
s_List.Add(0xB9C);
|
||||
s_List.Add(0xB9D);
|
||||
s_List.Add(0xB9E);
|
||||
s_List.Add(0xB9F);
|
||||
s_List.Add(0xBA0);
|
||||
s_List.Add(0xBA1);
|
||||
s_List.Add(0xBA2);
|
||||
}
|
||||
|
||||
public HammerJob Job { get; set; }
|
||||
|
||||
[Constructable]
|
||||
public SignHammer()
|
||||
: base(0x13E3)
|
||||
{
|
||||
Name = "Sign Hammer";
|
||||
}
|
||||
|
||||
public int GetFlipFor(int id)
|
||||
{
|
||||
return (s_Table[id] == null ? id : (int)s_Table[id]);
|
||||
}
|
||||
|
||||
public int GetNextSign(int id)
|
||||
{
|
||||
if (!s_List.Contains(id))
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
var idx = s_List.IndexOf(id);
|
||||
|
||||
if (idx + 2 < s_List.Count)
|
||||
{
|
||||
return (int)s_List[idx + 2];
|
||||
}
|
||||
|
||||
if (idx % 2 == 0)
|
||||
{
|
||||
return (int)s_List[0];
|
||||
}
|
||||
|
||||
return (int)s_List[1];
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile m)
|
||||
{
|
||||
if (RootParent != m)
|
||||
{
|
||||
m.SendMessage("That item must be in your backpack to use.");
|
||||
return;
|
||||
}
|
||||
|
||||
var house = BaseHouse.FindHouseAt(m);
|
||||
|
||||
if (m.AccessLevel < AccessLevel.Counselor && (house == null || house.Owner != m))
|
||||
{
|
||||
m.SendMessage("You have to be inside your house to use this.");
|
||||
return;
|
||||
}
|
||||
|
||||
m.BeginTarget(3, false, TargetFlags.None, OnTarget);
|
||||
}
|
||||
|
||||
protected void OnTarget(Mobile m, object obj)
|
||||
{
|
||||
var item = obj as Item;
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
m.SendMessage("You cannot change that with this.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (item == this)
|
||||
{
|
||||
new SignHammerGump(m, this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Job == HammerJob.Flip)
|
||||
{
|
||||
var id = GetFlipFor(item.ItemID);
|
||||
|
||||
if (id == item.ItemID)
|
||||
{
|
||||
m.SendMessage("You cannot change that with this.");
|
||||
}
|
||||
else
|
||||
{
|
||||
item.ItemID = id;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var id = GetNextSign(item.ItemID);
|
||||
|
||||
if (id == item.ItemID)
|
||||
{
|
||||
m.SendMessage("You cannot change that with this.");
|
||||
}
|
||||
else
|
||||
{
|
||||
item.ItemID = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SignHammer(Serial serial)
|
||||
: base(serial)
|
||||
{ }
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
reader.ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
public class SignHammerGump : GumpPlusLight
|
||||
{
|
||||
private readonly SignHammer c_Hammer;
|
||||
|
||||
public SignHammerGump(Mobile m, SignHammer hammer)
|
||||
: base(m, 100, 100)
|
||||
{
|
||||
c_Hammer = hammer;
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
protected override void BuildGump()
|
||||
{
|
||||
AddBackground(0, 0, 200, 200, 2600);
|
||||
|
||||
AddButton(50, 45, 2152, 2154, "Swap", Swap);
|
||||
AddHtml(90, 50, 70, "Swap Hanger");
|
||||
|
||||
AddButton(50, 95, 2152, 2154, "Flip", Flip);
|
||||
AddHtml(90, 100, 70, "Flip Sign or Hanger");
|
||||
}
|
||||
|
||||
private void Swap()
|
||||
{
|
||||
c_Hammer.Job = HammerJob.Swap;
|
||||
}
|
||||
|
||||
private void Flip()
|
||||
{
|
||||
c_Hammer.Job = HammerJob.Flip;
|
||||
}
|
||||
}
|
||||
}
|
||||
337
Scripts/SubSystem/TownHouses/Items/TownHouse.cs
Normal file
337
Scripts/SubSystem/TownHouses/Items/TownHouse.cs
Normal file
@@ -0,0 +1,337 @@
|
||||
#if ServUO58
|
||||
#define ServUOX
|
||||
#endif
|
||||
|
||||
#region References
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Server;
|
||||
using Server.Multis;
|
||||
using Server.Targeting;
|
||||
#endregion
|
||||
|
||||
namespace Knives.TownHouses
|
||||
{
|
||||
public class TownHouse : VersionHouse
|
||||
{
|
||||
public static List<TownHouse> AllTownHouses { get; private set; }
|
||||
|
||||
static TownHouse()
|
||||
{
|
||||
AllTownHouses = new List<TownHouse>();
|
||||
}
|
||||
|
||||
private readonly List<Sector> _Sectors = new List<Sector>();
|
||||
|
||||
private Item _Hanger;
|
||||
|
||||
public Item Hanger
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Hanger ?? (_Hanger = new Item(0xB98)
|
||||
{
|
||||
Movable = false,
|
||||
Location = Sign.Location,
|
||||
Map = Sign.Map
|
||||
});
|
||||
}
|
||||
set { _Hanger = value; }
|
||||
}
|
||||
|
||||
public TownHouseSign ForSaleSign { get; private set; }
|
||||
|
||||
public override Rectangle2D[] Area
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ForSaleSign == null)
|
||||
{
|
||||
return new Rectangle2D[100];
|
||||
}
|
||||
|
||||
var rects = new Rectangle2D[ForSaleSign.Blocks.Count];
|
||||
|
||||
for (var i = 0; i < ForSaleSign.Blocks.Count && i < rects.Length; ++i)
|
||||
{
|
||||
rects[i] = (Rectangle2D)ForSaleSign.Blocks[i];
|
||||
}
|
||||
|
||||
return rects;
|
||||
}
|
||||
}
|
||||
|
||||
public TownHouse(Mobile m, TownHouseSign sign, int locks, int secures)
|
||||
: base(0x1DD6 | 0x4000, m, locks, secures)
|
||||
{
|
||||
ForSaleSign = sign;
|
||||
|
||||
SetSign(0, 0, 0);
|
||||
|
||||
AllTownHouses.Add(this);
|
||||
}
|
||||
|
||||
public TownHouse(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
AllTownHouses.Add(this);
|
||||
}
|
||||
|
||||
public void InitSectorDefinition()
|
||||
{
|
||||
if (ForSaleSign == null || ForSaleSign.Blocks.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var blocks = (Rectangle2D)ForSaleSign.Blocks[0];
|
||||
|
||||
var minX = blocks.Start.X;
|
||||
var minY = blocks.Start.Y;
|
||||
var maxX = blocks.End.X;
|
||||
var maxY = blocks.End.Y;
|
||||
|
||||
foreach (Rectangle2D rect in ForSaleSign.Blocks)
|
||||
{
|
||||
if (rect.Start.X < minX)
|
||||
{
|
||||
minX = rect.Start.X;
|
||||
}
|
||||
|
||||
if (rect.Start.Y < minY)
|
||||
{
|
||||
minY = rect.Start.Y;
|
||||
}
|
||||
|
||||
if (rect.End.X > maxX)
|
||||
{
|
||||
maxX = rect.End.X;
|
||||
}
|
||||
|
||||
if (rect.End.Y > maxY)
|
||||
{
|
||||
maxY = rect.End.Y;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var sector in _Sectors)
|
||||
{
|
||||
sector.OnMultiLeave(this);
|
||||
}
|
||||
|
||||
_Sectors.Clear();
|
||||
|
||||
for (var x = minX; x < maxX; ++x)
|
||||
{
|
||||
for (var y = minY; y < maxY; ++y)
|
||||
{
|
||||
var s = Map.GetSector(new Point2D(x, y));
|
||||
|
||||
if (!_Sectors.Contains(s))
|
||||
_Sectors.Add(s);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var sector in _Sectors)
|
||||
{
|
||||
sector.OnMultiEnter(this);
|
||||
}
|
||||
|
||||
Components.Resize(maxX - minX, maxY - minY);
|
||||
Components.Add(0x520, Components.Width - 1, Components.Height - 1, -5);
|
||||
}
|
||||
|
||||
public override bool IsInside(Point3D p, int height)
|
||||
{
|
||||
if (ForSaleSign == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Map == null || Region == null)
|
||||
{
|
||||
Delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
Sector sector = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (ForSaleSign is RentalContract && Region.Contains(p))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
sector = Map.GetSector(p);
|
||||
|
||||
if (
|
||||
sector.Multis.Any(
|
||||
m =>
|
||||
m != this && m is TownHouse && ((TownHouse)m).ForSaleSign is RentalContract && ((TownHouse)m).IsInside(p, height)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Region.Contains(p);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Errors.Report("Error occured in IsInside(). More information on the console.");
|
||||
Console.WriteLine("Info:{0}, {1}, {2}, {3}", Map, sector, Region, sector != null ? "" + sector.Multis : "**");
|
||||
Console.WriteLine(e.Source);
|
||||
Console.WriteLine(e.Message);
|
||||
Console.WriteLine(e.StackTrace);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static int MaxVendors = 50;
|
||||
|
||||
#if ServUOX
|
||||
public override int GetVendorSystemMaxVendors()
|
||||
{
|
||||
return MaxVendors;
|
||||
}
|
||||
#else
|
||||
public override int GetNewVendorSystemMaxVendors()
|
||||
{
|
||||
return MaxVendors;
|
||||
}
|
||||
#endif
|
||||
|
||||
public override int GetAosMaxSecures()
|
||||
{
|
||||
return MaxSecures;
|
||||
}
|
||||
|
||||
public override int GetAosMaxLockdowns()
|
||||
{
|
||||
return MaxLockDowns;
|
||||
}
|
||||
|
||||
public override void OnMapChange()
|
||||
{
|
||||
base.OnMapChange();
|
||||
|
||||
if (_Hanger != null)
|
||||
{
|
||||
_Hanger.Map = Map;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLocationChange(Point3D oldLocation)
|
||||
{
|
||||
base.OnLocationChange(oldLocation);
|
||||
|
||||
if (_Hanger != null)
|
||||
{
|
||||
_Hanger.Location = Sign.Location;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSpeech(SpeechEventArgs e)
|
||||
{
|
||||
if (e.Mobile != Owner || !IsInside(e.Mobile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Speech.ToLower() == "check house rent")
|
||||
{
|
||||
ForSaleSign.CheckRentTimer();
|
||||
}
|
||||
|
||||
Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(AfterSpeech), e.Mobile);
|
||||
}
|
||||
|
||||
private void AfterSpeech(object o)
|
||||
{
|
||||
if (!(o is Mobile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var m = (Mobile)o;
|
||||
|
||||
if (!(m.Target is HouseBanTarget) || ForSaleSign == null || !ForSaleSign.NoBanning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m.Target.Cancel(m, TargetCancelType.Canceled);
|
||||
m.SendMessage(0x161, "You cannot ban people from this house.");
|
||||
}
|
||||
|
||||
public override void OnDelete()
|
||||
{
|
||||
if (_Hanger != null)
|
||||
{
|
||||
_Hanger.Delete();
|
||||
}
|
||||
|
||||
foreach (var item in Sign.GetItemsInRange(0).Where(item => item != Sign))
|
||||
{
|
||||
item.Visible = true;
|
||||
}
|
||||
|
||||
ForSaleSign.ClearHouse();
|
||||
Doors.Clear();
|
||||
|
||||
AllTownHouses.Remove(this);
|
||||
|
||||
base.OnDelete();
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
|
||||
AllTownHouses.Remove(this);
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(4);
|
||||
|
||||
// Version 2
|
||||
|
||||
writer.Write(_Hanger);
|
||||
|
||||
// Version 1
|
||||
|
||||
writer.Write(ForSaleSign);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
if (version >= 2)
|
||||
{
|
||||
_Hanger = reader.ReadItem();
|
||||
}
|
||||
|
||||
ForSaleSign = reader.ReadItem<TownHouseSign>();
|
||||
|
||||
if (version <= 2)
|
||||
{
|
||||
var count = reader.ReadInt();
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
reader.ReadRect2D();
|
||||
}
|
||||
}
|
||||
|
||||
ItemID = 0x1DD6 | 0x4000;
|
||||
|
||||
Price = Math.Max(1, Price);
|
||||
}
|
||||
}
|
||||
}
|
||||
1872
Scripts/SubSystem/TownHouses/Items/TownHouseSign.cs
Normal file
1872
Scripts/SubSystem/TownHouses/Items/TownHouseSign.cs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user