Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
234
Scripts/SubSystem/ACC/ACC Yard System/Items/YardDecorator.cs
Normal file
234
Scripts/SubSystem/ACC/ACC Yard System/Items/YardDecorator.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Items;
|
||||
using Server.Network;
|
||||
using Server.Regions;
|
||||
using Server.Multis;
|
||||
using Server.Gumps;
|
||||
using Server.Targeting;
|
||||
|
||||
namespace Server.ACC.YS
|
||||
{
|
||||
public class YardDecorator : InteriorDecorator
|
||||
{
|
||||
[Constructable]
|
||||
public YardDecorator()
|
||||
: base()
|
||||
{
|
||||
Weight = 1.0;
|
||||
LootType = LootType.Blessed;
|
||||
Name = "Yard Decorator";
|
||||
ItemID = 0xFC1;
|
||||
}
|
||||
|
||||
public override int LabelNumber { get { return 1041280; } } // an interior decorator
|
||||
|
||||
public YardDecorator(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
if (Command != DecorateCommand.None)
|
||||
list.Add(1018322 + (int)Command); // Turn/Up/Down
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (!CheckUse(this, from))
|
||||
return;
|
||||
|
||||
if (Command == DecorateCommand.None)
|
||||
from.SendGump(new InternalGump(this));
|
||||
else
|
||||
from.Target = new InternalTarget(this);
|
||||
}
|
||||
|
||||
private class InternalGump : Gump
|
||||
{
|
||||
private YardDecorator m_Decorator;
|
||||
|
||||
public InternalGump(YardDecorator decorator)
|
||||
: base(150, 50)
|
||||
{
|
||||
m_Decorator = decorator;
|
||||
|
||||
AddBackground(0, 0, 200, 150, 2600);
|
||||
|
||||
AddButton(50, 47, 2152, 2154, 2, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(90, 50, 70, 40, 1018324, false, false); // Up
|
||||
|
||||
AddButton(50, 87, 2152, 2154, 3, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(90, 100, 70, 40, 1018325, false, false); // Down
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
{
|
||||
DecorateCommand command = DecorateCommand.None;
|
||||
|
||||
switch (info.ButtonID)
|
||||
{
|
||||
case 2: command = DecorateCommand.Up; break;
|
||||
case 3: command = DecorateCommand.Down; break;
|
||||
}
|
||||
|
||||
if (command != DecorateCommand.None)
|
||||
{
|
||||
m_Decorator.Command = command;
|
||||
sender.Mobile.Target = new InternalTarget(m_Decorator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class InternalTarget : Target
|
||||
{
|
||||
private YardDecorator m_Decorator;
|
||||
|
||||
public InternalTarget(YardDecorator decorator)
|
||||
: base(-1, false, TargetFlags.None)
|
||||
{
|
||||
CheckLOS = false;
|
||||
|
||||
m_Decorator = decorator;
|
||||
}
|
||||
|
||||
protected override void OnTargetNotAccessible(Mobile from, object targeted)
|
||||
{
|
||||
OnTarget(from, targeted);
|
||||
}
|
||||
|
||||
protected override void OnTarget(Mobile from, object targeted)
|
||||
{
|
||||
if (targeted == m_Decorator)
|
||||
{
|
||||
m_Decorator.Command = DecorateCommand.None;
|
||||
from.SendGump(new InternalGump(m_Decorator));
|
||||
}
|
||||
else if (targeted is Item && InteriorDecorator.CheckUse(m_Decorator, from))
|
||||
{
|
||||
BaseHouse house = BaseHouse.FindHouseAt(from);
|
||||
Item item = (Item)targeted;
|
||||
|
||||
if (item is YardPiece || item is YardItem ||
|
||||
item is YardIronGate || item is YardShortIronGate ||
|
||||
item is YardLightWoodGate || item is YardDarkWoodGate ||
|
||||
item is YardStair)
|
||||
{
|
||||
switch (m_Decorator.Command)
|
||||
{
|
||||
case DecorateCommand.Up: Up(item, from); break;
|
||||
case DecorateCommand.Down: Down(item, from); break;
|
||||
}
|
||||
}
|
||||
else if (house == null || !house.IsCoOwner(from))
|
||||
{
|
||||
from.SendLocalizedMessage(502092); // You must be in your house to do this.
|
||||
}
|
||||
else if (item.Parent != null || !house.IsInside(item))
|
||||
{
|
||||
from.SendLocalizedMessage(1042270); // That is not in your house.
|
||||
}
|
||||
else if (!house.IsLockedDown(item) && !house.IsSecure(item))
|
||||
{
|
||||
from.SendLocalizedMessage(1042271); // That is not locked down.
|
||||
}
|
||||
else if (item.TotalWeight + item.PileWeight > 100)
|
||||
{
|
||||
from.SendLocalizedMessage(1042272); // That is too heavy.
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (m_Decorator.Command)
|
||||
{
|
||||
case DecorateCommand.Up: Up(item, from); break;
|
||||
case DecorateCommand.Down: Down(item, from); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Up(Item item, Mobile from)
|
||||
{
|
||||
int floorZ = GetFloorZ(item);
|
||||
|
||||
if (item is YardPiece || item is YardItem ||
|
||||
item is YardIronGate || item is YardShortIronGate ||
|
||||
item is YardLightWoodGate || item is YardDarkWoodGate ||
|
||||
item is YardStair)
|
||||
{
|
||||
item.Location = new Point3D(item.Location, item.Z + 1);
|
||||
}
|
||||
else if (floorZ > int.MinValue && item.Z < (floorZ + 15)) // Confirmed : no height checks here
|
||||
{
|
||||
item.Location = new Point3D(item.Location, item.Z + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042274); // You cannot raise it up any higher.
|
||||
}
|
||||
}
|
||||
|
||||
private static void Down(Item item, Mobile from)
|
||||
{
|
||||
int floorZ = GetFloorZ(item);
|
||||
if (item is YardPiece || item is YardItem ||
|
||||
item is YardIronGate || item is YardShortIronGate ||
|
||||
item is YardLightWoodGate || item is YardDarkWoodGate ||
|
||||
item is YardStair)
|
||||
{
|
||||
item.Location = new Point3D(item.Location, item.Z - 1);
|
||||
}
|
||||
else if (floorZ > int.MinValue && item.Z > GetFloorZ(item))
|
||||
{
|
||||
item.Location = new Point3D(item.Location, item.Z - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(1042275); // You cannot lower it down any further.
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetFloorZ(Item item)
|
||||
{
|
||||
Map map = item.Map;
|
||||
|
||||
if (map == null)
|
||||
return int.MinValue;
|
||||
|
||||
StaticTile[] tiles = map.Tiles.GetStaticTiles(item.X, item.Y, true);
|
||||
|
||||
int z = int.MinValue;
|
||||
|
||||
for (int i = 0; i < tiles.Length; ++i)
|
||||
{
|
||||
StaticTile tile = tiles[i];
|
||||
ItemData id = TileData.ItemTable[tile.ID & 0x3FFF];
|
||||
|
||||
int top = tile.Z; // Confirmed : no height checks here
|
||||
|
||||
if (id.Surface && !id.Impassable && top > z && top <= item.Z)
|
||||
z = top;
|
||||
}
|
||||
|
||||
return z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
582
Scripts/SubSystem/ACC/ACC Yard System/Items/YardGate.cs
Normal file
582
Scripts/SubSystem/ACC/ACC Yard System/Items/YardGate.cs
Normal file
@@ -0,0 +1,582 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Commands;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.ACC.YS
|
||||
{
|
||||
public class YardGate : BaseDoor
|
||||
{
|
||||
#region Properties
|
||||
private Mobile m_Placer;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Placer
|
||||
{
|
||||
get { return m_Placer; }
|
||||
set { m_Placer = value; }
|
||||
}
|
||||
|
||||
private int m_Price;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Price
|
||||
{
|
||||
get { return m_Price; }
|
||||
set { m_Price = value; }
|
||||
}
|
||||
|
||||
private BaseHouse m_House;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BaseHouse House
|
||||
{
|
||||
get { return m_House; }
|
||||
set { m_House = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public YardGate(int itemID, Mobile placer, int price, BaseHouse house, Point3D location, DoorFacing facing)
|
||||
: base(itemID, itemID + 1, GetOpenedSound(itemID), GetClosedSound(itemID), BaseDoor.GetOffset(facing))
|
||||
{
|
||||
Placer = placer;
|
||||
Price = price;
|
||||
|
||||
Movable = false;
|
||||
MoveToWorld(location, placer.Map);
|
||||
|
||||
if (house == null)
|
||||
{
|
||||
FindHouseOfPlacer();
|
||||
}
|
||||
else
|
||||
{
|
||||
House = house;
|
||||
}
|
||||
|
||||
SetName();
|
||||
}
|
||||
|
||||
public YardGate(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
public override void Use(Mobile from)
|
||||
{
|
||||
if (Locked && from == Placer)
|
||||
{
|
||||
Locked = false;
|
||||
from.SendMessage("You quickly unlock your gate, enter, and lock it behind you");
|
||||
base.Use(from);
|
||||
Locked = true;
|
||||
}
|
||||
else if (Locked && from != Placer)
|
||||
{
|
||||
from.SendMessage("You are not wanted here. Please go away!");
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Use(from);
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, System.Collections.Generic.List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
if (m_Placer == null || from == m_Placer || from.AccessLevel >= AccessLevel.GameMaster)
|
||||
{
|
||||
list.Add(new YardSecurityEntry(from, this));
|
||||
list.Add(new RefundEntry(from, this, m_Price));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
|
||||
if (House == null || House.Deleted)
|
||||
{
|
||||
writer.Write(false);
|
||||
YardSystem.AddOrphanedItem(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(true);
|
||||
writer.Write(House);
|
||||
}
|
||||
|
||||
writer.WriteMobile(Placer);
|
||||
writer.Write(Price);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if (reader.ReadBool())
|
||||
{
|
||||
House = reader.ReadItem() as BaseHouse;
|
||||
}
|
||||
|
||||
Placer = reader.ReadMobile();
|
||||
Price = reader.ReadInt();
|
||||
|
||||
if (House == null)
|
||||
{
|
||||
FindHouseOfPlacer();
|
||||
if (House == null)
|
||||
{
|
||||
Refund();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public void SetName()
|
||||
{
|
||||
switch (ItemID)
|
||||
{
|
||||
case 0x824:
|
||||
Name = Placer.Name + "'s Gate"; break;
|
||||
case 0x84C:
|
||||
Name = Placer.Name + "'s Gate"; break;
|
||||
case 0x839:
|
||||
Name = Placer.Name + "'s Gate"; break;
|
||||
case 0x866:
|
||||
Name = Placer.Name + "'s Gate"; break;
|
||||
case 0x675:
|
||||
Name = Placer.Name + "'s Door"; break;
|
||||
case 0x6C5:
|
||||
Name = Placer.Name + "'s Door"; break;
|
||||
case 0x685:
|
||||
Name = Placer.Name + "'s Door"; break;
|
||||
case 0x1FED:
|
||||
Name = Placer.Name + "'s Door"; break;
|
||||
case 0x695:
|
||||
Name = Placer.Name + "'s Door"; break;
|
||||
case 0x6A5:
|
||||
Name = Placer.Name + "'s Door"; break;
|
||||
case 0x6B5:
|
||||
Name = Placer.Name + "'s Door"; break;
|
||||
case 0x6D5:
|
||||
Name = Placer.Name + "'s Door"; break;
|
||||
case 0x6EF:
|
||||
Name = Placer.Name + "'s Door"; break;
|
||||
default:
|
||||
Name = Placer.Name + "'s Gate"; break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Refund()
|
||||
{
|
||||
Gold toGive = new Gold(Price);
|
||||
if (Placer.BankBox.TryDropItem(Placer, toGive, false))
|
||||
{
|
||||
Delete();
|
||||
Placer.SendLocalizedMessage(1060397, toGive.Amount.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box.
|
||||
}
|
||||
else
|
||||
{
|
||||
toGive.Delete();
|
||||
Placer.SendMessage("Your bankbox is full!");
|
||||
}
|
||||
}
|
||||
|
||||
public void FindHouseOfPlacer()
|
||||
{
|
||||
if (Placer == null || House != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IPooledEnumerable eable = Map.GetItemsInRange(Location, 20);
|
||||
foreach (Item item in eable)
|
||||
{
|
||||
if (item is BaseHouse)
|
||||
{
|
||||
BaseHouse house = (BaseHouse)item;
|
||||
if (house.Owner == Placer)
|
||||
{
|
||||
House = house;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Static
|
||||
public static int GetClosedSound(int itemID)
|
||||
{
|
||||
if ((itemID >= 2084 && itemID <= 2098) ||
|
||||
(itemID >= 2124 && itemID <= 2138))
|
||||
{
|
||||
return 243;
|
||||
}
|
||||
else if ((itemID >= 2105 && itemID <= 2119) ||
|
||||
(itemID >= 2150 && itemID <= 2162))
|
||||
{
|
||||
return 242;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 243;
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetOpenedSound(int itemID)
|
||||
{
|
||||
if ((itemID >= 2084 && itemID <= 2098) ||
|
||||
(itemID >= 2124 && itemID <= 2138))
|
||||
{
|
||||
return 236;
|
||||
}
|
||||
else if ((itemID >= 2105 && itemID <= 2119) ||
|
||||
(itemID >= 2150 && itemID <= 2162))
|
||||
{
|
||||
return 235;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 236;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Old Gates
|
||||
public class YardIronGate : IronGate
|
||||
{
|
||||
private Mobile m_Placer;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Placer
|
||||
{
|
||||
get { return m_Placer; }
|
||||
set { m_Placer = value; }
|
||||
}
|
||||
|
||||
private int m_Price;
|
||||
public int Price
|
||||
{
|
||||
get { return m_Price; }
|
||||
set { m_Price = value; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public YardIronGate(Mobile from, int price, DoorFacing facing, Point3D loc)
|
||||
: base(facing)
|
||||
{
|
||||
Price = price;
|
||||
Placer = from;
|
||||
Movable = false;
|
||||
MoveToWorld(loc, from.Map);
|
||||
Name = from.Name + "'s Gate";
|
||||
}
|
||||
|
||||
public override void Use(Mobile from)
|
||||
{
|
||||
if (((BaseDoor)this).Locked && from == Placer)
|
||||
{
|
||||
((BaseDoor)this).Locked = false;
|
||||
from.SendMessage("You quickly unlock your gate, enter, and lock it behind you");
|
||||
base.Use(from);
|
||||
((BaseDoor)this).Locked = true;
|
||||
}
|
||||
else if (((BaseDoor)this).Locked && from != Placer)
|
||||
{
|
||||
from.SendMessage("You are not wanted here. Please go away!");
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Use(from);
|
||||
}
|
||||
}
|
||||
|
||||
public YardIronGate(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
writer.WriteMobile(Placer);
|
||||
writer.Write(Price);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
Placer = reader.ReadMobile();
|
||||
Price = reader.ReadInt();
|
||||
Console.WriteLine();
|
||||
Console.Write("Updating YardIronGate...");
|
||||
YardGate newGate = new YardGate(2084, Placer, Price, null, Location, (DoorFacing)((ClosedID - 2084) / 2));
|
||||
newGate.Map = Map;
|
||||
if (newGate != null)
|
||||
{
|
||||
Console.WriteLine(String.Format("New gate = {0}, ItemID = {1}, Location = {2}", newGate.Serial.ToString(), newGate.ItemID, newGate.Location));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Null");
|
||||
}
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public class YardShortIronGate : IronGateShort
|
||||
{
|
||||
private Mobile m_Placer;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Placer
|
||||
{
|
||||
get { return m_Placer; }
|
||||
set { m_Placer = value; }
|
||||
}
|
||||
|
||||
private int m_Price;
|
||||
public int Price
|
||||
{
|
||||
get { return m_Price; }
|
||||
set { m_Price = value; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public YardShortIronGate(Mobile from, int price, DoorFacing facing, Point3D loc)
|
||||
: base(facing)
|
||||
{
|
||||
Price = price;
|
||||
Placer = from;
|
||||
Movable = false;
|
||||
MoveToWorld(loc, from.Map);
|
||||
Name = from.Name + "'s Gate";
|
||||
}
|
||||
|
||||
public override void Use(Mobile from)
|
||||
{
|
||||
if (((BaseDoor)this).Locked && from == Placer)
|
||||
{
|
||||
((BaseDoor)this).Locked = false;
|
||||
from.SendMessage("You quickly unlock your gate, enter, and lock it behind you");
|
||||
base.Use(from);
|
||||
((BaseDoor)this).Locked = true;
|
||||
}
|
||||
else if (((BaseDoor)this).Locked && from != Placer)
|
||||
{
|
||||
from.SendMessage("You are not wanted here. Please go away!");
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Use(from);
|
||||
}
|
||||
}
|
||||
|
||||
public YardShortIronGate(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
writer.WriteMobile(Placer);
|
||||
writer.Write(Price);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
Placer = reader.ReadMobile();
|
||||
Price = reader.ReadInt();
|
||||
Console.WriteLine();
|
||||
Console.Write("Updating YardShortIronGate...");
|
||||
YardGate newGate = new YardGate(2124, Placer, Price, null, Location, (DoorFacing)((ClosedID - 2124) / 2));
|
||||
newGate.Map = Map;
|
||||
if (newGate != null)
|
||||
{
|
||||
Console.WriteLine(String.Format("New gate = {0}, ItemID = {1}, Location = {2}", newGate.Serial.ToString(), newGate.ItemID, newGate.Location));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Null");
|
||||
}
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public class YardLightWoodGate : LightWoodGate
|
||||
{
|
||||
private Mobile m_Placer;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Placer
|
||||
{
|
||||
get { return m_Placer; }
|
||||
set { m_Placer = value; }
|
||||
}
|
||||
|
||||
private int m_Price;
|
||||
public int Price
|
||||
{
|
||||
get { return m_Price; }
|
||||
set { m_Price = value; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public YardLightWoodGate(Mobile from, int price, DoorFacing facing, Point3D loc)
|
||||
: base(facing)
|
||||
{
|
||||
Price = price;
|
||||
Placer = from;
|
||||
Movable = false;
|
||||
MoveToWorld(loc, from.Map);
|
||||
Name = from.Name + "'s Gate";
|
||||
}
|
||||
|
||||
public override void Use(Mobile from)
|
||||
{
|
||||
if (((BaseDoor)this).Locked && from == Placer)
|
||||
{
|
||||
((BaseDoor)this).Locked = false;
|
||||
from.SendMessage("You quickly unlock your gate, enter, and lock it behind you");
|
||||
base.Use(from);
|
||||
((BaseDoor)this).Locked = true;
|
||||
}
|
||||
else if (((BaseDoor)this).Locked && from != Placer)
|
||||
{
|
||||
from.SendMessage("You are not wanted here. Please go away!");
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Use(from);
|
||||
}
|
||||
}
|
||||
|
||||
public YardLightWoodGate(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
writer.WriteMobile(Placer);
|
||||
writer.Write(Price);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
Placer = reader.ReadMobile();
|
||||
Price = reader.ReadInt();
|
||||
Console.WriteLine();
|
||||
Console.Write("Updating YardLightWoodGate...");
|
||||
YardGate newGate = new YardGate(2105, Placer, Price, null, Location, (DoorFacing)((ClosedID - 2105) / 2));
|
||||
newGate.Map = Map;
|
||||
if (newGate != null)
|
||||
{
|
||||
Console.WriteLine(String.Format("New gate = {0}, ItemID = {1}, Location = {2}", newGate.Serial.ToString(), newGate.ItemID, newGate.Location));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Null");
|
||||
}
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public class YardDarkWoodGate : DarkWoodGate
|
||||
{
|
||||
private Mobile m_Placer;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Placer
|
||||
{
|
||||
get { return m_Placer; }
|
||||
set { m_Placer = value; }
|
||||
}
|
||||
|
||||
private int m_Price;
|
||||
public int Price
|
||||
{
|
||||
get { return m_Price; }
|
||||
set { m_Price = value; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public YardDarkWoodGate(Mobile from, int price, DoorFacing facing, Point3D loc)
|
||||
: base(facing)
|
||||
{
|
||||
Price = price;
|
||||
Placer = from;
|
||||
Movable = false;
|
||||
MoveToWorld(loc, from.Map);
|
||||
Name = from.Name + "'s Gate";
|
||||
}
|
||||
|
||||
public override void Use(Mobile from)
|
||||
{
|
||||
if (((BaseDoor)this).Locked && from == Placer)
|
||||
{
|
||||
((BaseDoor)this).Locked = false;
|
||||
from.SendMessage("You quickly unlock your gate, enter, and lock it behind you");
|
||||
base.Use(from);
|
||||
((BaseDoor)this).Locked = true;
|
||||
}
|
||||
else if (((BaseDoor)this).Locked && from != Placer)
|
||||
{
|
||||
from.SendMessage("You are not wanted here. Please go away!");
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Use(from);
|
||||
}
|
||||
}
|
||||
|
||||
public YardDarkWoodGate(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
writer.Write(Placer);
|
||||
writer.Write(Price);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
Placer = reader.ReadMobile();
|
||||
Price = reader.ReadInt();
|
||||
Console.WriteLine();
|
||||
Console.Write("Updating YardDarkWoodGate...");
|
||||
YardGate newGate = new YardGate(2150, Placer, Price, null, Location, (DoorFacing)((ClosedID - 2150) / 2));
|
||||
newGate.Map = Map;
|
||||
if (newGate != null)
|
||||
{
|
||||
Console.WriteLine(String.Format("New gate = {0}, ItemID = {1}, Location = {2}", newGate.Serial.ToString(), newGate.ItemID, newGate.Location));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Null");
|
||||
}
|
||||
Delete();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
365
Scripts/SubSystem/ACC/ACC Yard System/Items/YardItem.cs
Normal file
365
Scripts/SubSystem/ACC/ACC Yard System/Items/YardItem.cs
Normal file
@@ -0,0 +1,365 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.ACC.YS
|
||||
{
|
||||
public class YardMultiInfo
|
||||
{
|
||||
public int ItemID;
|
||||
public Point3D Offset;
|
||||
|
||||
public YardMultiInfo(int itemID, Point3D offset)
|
||||
{
|
||||
ItemID = itemID;
|
||||
Offset = offset;
|
||||
}
|
||||
}
|
||||
|
||||
public class YardItem : YardPiece
|
||||
{
|
||||
#region Properties
|
||||
private Mobile m_Placer;
|
||||
public Mobile Placer
|
||||
{
|
||||
get { return m_Placer; }
|
||||
set { m_Placer = value; }
|
||||
}
|
||||
|
||||
private int m_Price;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public int Price
|
||||
{
|
||||
get { return m_Price; }
|
||||
set { m_Price = value; }
|
||||
}
|
||||
|
||||
private BaseHouse m_House;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public BaseHouse House
|
||||
{
|
||||
get { return m_House; }
|
||||
set { m_House = value; }
|
||||
}
|
||||
|
||||
private List<YardPiece> m_Pieces;
|
||||
public List<YardPiece> Pieces
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Pieces == null)
|
||||
{
|
||||
m_Pieces = new List<YardPiece>();
|
||||
}
|
||||
return m_Pieces;
|
||||
}
|
||||
set { m_Pieces = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public YardItem(int itemID, Mobile from, string itemName, Point3D location, int price, BaseHouse house)
|
||||
: base(itemID, from.Name + "'s " + itemName)
|
||||
{
|
||||
Price = price;
|
||||
Placer = from;
|
||||
|
||||
Movable = false;
|
||||
HasMoved = true;
|
||||
MoveToWorld(location, from.Map);
|
||||
|
||||
if (house == null)
|
||||
{
|
||||
FindHouseOfPlacer();
|
||||
}
|
||||
else
|
||||
{
|
||||
House = house;
|
||||
}
|
||||
|
||||
Pieces = new List<YardPiece>();
|
||||
ParentYardItem = this;
|
||||
Pieces.Add(this);
|
||||
|
||||
if (YardRegistry.YardMultiIDs.ContainsKey(ItemID) && YardRegistry.YardMultiIDs[ItemID] != null)
|
||||
{
|
||||
YardPiece piece;
|
||||
foreach (YardMultiInfo info in YardRegistry.YardMultiIDs[ItemID])
|
||||
{
|
||||
piece = new YardPiece(info.ItemID, Name, this);
|
||||
piece.HasMoved = true;
|
||||
piece.MoveToWorld(new Point3D(Location.X + info.Offset.X,
|
||||
Location.Y + info.Offset.Y,
|
||||
Location.Z + info.Offset.Z),
|
||||
from.Map);
|
||||
Pieces.Add(piece);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < Pieces.Count; i++)
|
||||
{
|
||||
Pieces[i].HasMoved = false;
|
||||
}
|
||||
}
|
||||
|
||||
public YardItem(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
for (int i = 0; i < Pieces.Count; ++i)
|
||||
{
|
||||
Pieces[i].Delete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.InRange(this.GetWorldLocation(), 10))
|
||||
{
|
||||
if (Placer == null || from == Placer || from.AccessLevel >= AccessLevel.GameMaster)
|
||||
{
|
||||
Refund();
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("Stay out of my yard!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("The item is too far away");
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)1); // version
|
||||
|
||||
//Version 1
|
||||
if (House == null || House.Deleted)
|
||||
{
|
||||
writer.Write(false);
|
||||
YardSystem.AddOrphanedItem(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(true);
|
||||
writer.Write(House);
|
||||
}
|
||||
|
||||
//Version 0
|
||||
writer.WriteMobile(Placer);
|
||||
writer.Write(Price);
|
||||
writer.WriteItemList(Pieces);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
if (reader.ReadBool())
|
||||
{
|
||||
House = reader.ReadItem() as BaseHouse;
|
||||
}
|
||||
goto case 0;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
Placer = reader.ReadMobile();
|
||||
Price = reader.ReadInt();
|
||||
|
||||
Pieces = new List<YardPiece>();
|
||||
foreach (YardPiece item in reader.ReadItemList())
|
||||
{
|
||||
Pieces.Add(item);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (House == null)
|
||||
{
|
||||
FindHouseOfPlacer();
|
||||
if (House == null)
|
||||
{
|
||||
Refund();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public void Refund()
|
||||
{
|
||||
Gold toGive = new Gold(Price);
|
||||
if (Placer.BankBox.TryDropItem(Placer, toGive, false))
|
||||
{
|
||||
Delete();
|
||||
Placer.SendLocalizedMessage(1060397, toGive.Amount.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box.
|
||||
}
|
||||
else
|
||||
{
|
||||
toGive.Delete();
|
||||
Placer.SendMessage("Your bankbox is full!");
|
||||
}
|
||||
}
|
||||
|
||||
public void FindHouseOfPlacer()
|
||||
{
|
||||
if (Placer == null || House != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IPooledEnumerable eable = Map.GetItemsInRange(Location, 20);
|
||||
foreach (Item item in eable)
|
||||
{
|
||||
if (item is BaseHouse)
|
||||
{
|
||||
BaseHouse house = (BaseHouse)item;
|
||||
if (house.Owner == Placer)
|
||||
{
|
||||
House = house;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class YardPiece : Item
|
||||
{
|
||||
private YardItem m_ParentYardItem;
|
||||
public YardItem ParentYardItem
|
||||
{
|
||||
get { return m_ParentYardItem; }
|
||||
set { m_ParentYardItem = value; }
|
||||
}
|
||||
|
||||
private bool m_HasMoved;
|
||||
public bool HasMoved
|
||||
{
|
||||
get { return m_HasMoved; }
|
||||
set { m_HasMoved = value; }
|
||||
}
|
||||
|
||||
public YardPiece(int itemID, string name)
|
||||
: this(itemID, name, null)
|
||||
{
|
||||
}
|
||||
|
||||
public YardPiece(int itemID, string name, YardItem multiParent)
|
||||
: base(itemID)
|
||||
{
|
||||
Movable = false;
|
||||
Name = name;
|
||||
ItemID = itemID;
|
||||
Light = LightType.Circle150;
|
||||
|
||||
if (multiParent != null)
|
||||
{
|
||||
ParentYardItem = multiParent;
|
||||
}
|
||||
}
|
||||
|
||||
public YardPiece(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnAfterDelete()
|
||||
{
|
||||
if (ParentYardItem != null)
|
||||
{
|
||||
ParentYardItem.OnAfterDelete();
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnAfterDelete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (ParentYardItem != null)
|
||||
{
|
||||
ParentYardItem.OnDoubleClick(from);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnDoubleClick(from);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLocationChange(Point3D oldLocation)
|
||||
{
|
||||
if (HasMoved)
|
||||
{
|
||||
base.OnLocationChange(oldLocation);
|
||||
return;
|
||||
}
|
||||
|
||||
int xOff = 0, yOff = 0, zOff = 0;
|
||||
|
||||
xOff = Location.X - oldLocation.X;
|
||||
yOff = Location.Y - oldLocation.Y;
|
||||
zOff = Location.Z - oldLocation.Z;
|
||||
|
||||
if (ParentYardItem != null && ParentYardItem.Pieces != null)
|
||||
{
|
||||
HasMoved = true;
|
||||
|
||||
for (int i = 0; i < ParentYardItem.Pieces.Count; i++)
|
||||
{
|
||||
if (!ParentYardItem.Pieces[i].HasMoved)
|
||||
{
|
||||
ParentYardItem.Pieces[i].HasMoved = true;
|
||||
ParentYardItem.Pieces[i].MoveToWorld(new Point3D(ParentYardItem.Pieces[i].Location.X + xOff,
|
||||
ParentYardItem.Pieces[i].Location.Y + yOff,
|
||||
ParentYardItem.Pieces[i].Location.Z + zOff),
|
||||
Map);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < ParentYardItem.Pieces.Count; i++)
|
||||
{
|
||||
ParentYardItem.Pieces[i].HasMoved = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
writer.Write(ParentYardItem);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
ParentYardItem = reader.ReadItem() as YardItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
99
Scripts/SubSystem/ACC/ACC Yard System/Items/YardShovel.cs
Normal file
99
Scripts/SubSystem/ACC/ACC Yard System/Items/YardShovel.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using Server.Network;
|
||||
using Server.Items;
|
||||
using Server.Gumps;
|
||||
using Server.Misc;
|
||||
|
||||
namespace Server.ACC.YS
|
||||
{
|
||||
public class YardShovel : Item
|
||||
{
|
||||
private string m_Category;
|
||||
public string Category
|
||||
{
|
||||
get { return m_Category; }
|
||||
set { m_Category = value; }
|
||||
}
|
||||
|
||||
private int m_Page;
|
||||
public int Page
|
||||
{
|
||||
get { return m_Page; }
|
||||
set { m_Page = value; }
|
||||
}
|
||||
|
||||
private int m_XStart;
|
||||
public int XStart
|
||||
{
|
||||
get { return m_XStart < 0 ? 0 : m_XStart; }
|
||||
set { m_XStart = value < 0 ? 0 : value; }
|
||||
}
|
||||
|
||||
private int m_YStart;
|
||||
public int YStart
|
||||
{
|
||||
get { return m_YStart < 0 ? 0 : m_YStart; }
|
||||
set { m_YStart = value < 0 ? 0 : value; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public YardShovel()
|
||||
: base(3897)
|
||||
{
|
||||
Movable = true;
|
||||
Name = "Yard Shovel";
|
||||
XStart = 50;
|
||||
YStart = 10;
|
||||
Category = "";
|
||||
Page = 0;
|
||||
}
|
||||
|
||||
public YardShovel(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
YardTarget yt;
|
||||
|
||||
if (m_Category != null)
|
||||
{
|
||||
yt = new YardTarget(this, from, 0, 0, Category, Page);
|
||||
}
|
||||
else
|
||||
{
|
||||
yt = new YardTarget(this, from, 0, 0, "", 0);
|
||||
}
|
||||
|
||||
yt.GumpUp();
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); // version
|
||||
writer.Write(Category);
|
||||
writer.Write(Page);
|
||||
writer.Write(XStart);
|
||||
writer.Write(YStart);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
Category = reader.ReadString();
|
||||
Page = reader.ReadInt();
|
||||
XStart = reader.ReadInt();
|
||||
YStart = reader.ReadInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
126
Scripts/SubSystem/ACC/ACC Yard System/Items/YardStair.cs
Normal file
126
Scripts/SubSystem/ACC/ACC Yard System/Items/YardStair.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.ACC.YS
|
||||
{
|
||||
public class YardStair : YardItem
|
||||
{
|
||||
#region Properties
|
||||
private int m_DefaultID;
|
||||
public int DefaultID
|
||||
{
|
||||
get { return m_DefaultID; }
|
||||
set { m_DefaultID = value; }
|
||||
}
|
||||
|
||||
//private Mobile m_Placer;
|
||||
//public Mobile Placer
|
||||
//{
|
||||
// get { return m_Placer; }
|
||||
// set { m_Placer = value; }
|
||||
//}
|
||||
|
||||
//private int m_Price;
|
||||
//public int Price
|
||||
//{
|
||||
// get { return m_Price; }
|
||||
// set { m_Price = value; }
|
||||
//}
|
||||
|
||||
//private BaseHouse m_House;
|
||||
//public BaseHouse House
|
||||
//{
|
||||
// get { return m_House; }
|
||||
// set { m_House = value; }
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
[Constructable]
|
||||
public YardStair(Mobile placer, int defaultID, Point3D loc, int price, BaseHouse house)
|
||||
: base(defaultID, placer, "Stairs", loc, price, house)
|
||||
{
|
||||
DefaultID = defaultID;
|
||||
//Placer = placer;
|
||||
//Name = placer.Name + "'s Yard";
|
||||
|
||||
//Light = LightType.Circle150;
|
||||
|
||||
//Movable = false;
|
||||
//MoveToWorld(loc, placer.Map);
|
||||
//if (house == null)
|
||||
//{
|
||||
// FindHouseOfPlacer();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// House = house;
|
||||
//}
|
||||
}
|
||||
|
||||
public YardStair(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Overrides
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
writer.Write((int)0); //version
|
||||
|
||||
writer.Write((int)DefaultID);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
int version = reader.ReadInt();
|
||||
|
||||
DefaultID = reader.ReadInt();
|
||||
}
|
||||
|
||||
public override void GetContextMenuEntries(Mobile from, System.Collections.Generic.List<ContextMenuEntry> list)
|
||||
{
|
||||
base.GetContextMenuEntries(from, list);
|
||||
if (Placer == null || from == Placer || from.AccessLevel >= AccessLevel.GameMaster)
|
||||
{
|
||||
list.Add(new StairRefundEntry(from, this, Price));
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (from.InRange(this.GetWorldLocation(), 10))
|
||||
{
|
||||
if (Placer == null || from == Placer || from.AccessLevel >= AccessLevel.GameMaster)
|
||||
{
|
||||
if (YardRegistry.YardStairIDGroups.ContainsKey(DefaultID) && YardRegistry.YardStairIDGroups[DefaultID] != null && YardRegistry.YardStairIDGroups[DefaultID].Length > 0)
|
||||
{
|
||||
int index;
|
||||
for (index = 0; index < YardRegistry.YardStairIDGroups[DefaultID].Length; index++)
|
||||
{
|
||||
if (YardRegistry.YardStairIDGroups[DefaultID][index] == ItemID)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
ItemID = (index == YardRegistry.YardStairIDGroups[DefaultID].Length - 1 ? YardRegistry.YardStairIDGroups[DefaultID][0] : YardRegistry.YardStairIDGroups[DefaultID][index+1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("Stay out of my yard!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage("The item is too far away");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user