fix: Codegens house/vendors (#1767)
### Summary - Cleans up ShardPoller - Breaks up player vendor file - Codegens houses/vendors
This commit is contained in:
parent
8fd04ac5aa
commit
fb8563aa60
20 changed files with 4801 additions and 4858 deletions
|
|
@ -105,10 +105,6 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Deserialize(IGenericReader reader, int version)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnHit(Mobile attacker, Mobile defender, double damageBonus = 1)
|
public override void OnHit(Mobile attacker, Mobile defender, double damageBonus = 1)
|
||||||
{
|
{
|
||||||
base.OnHit(attacker, defender, damageBonus);
|
base.OnHit(attacker, defender, damageBonus);
|
||||||
|
|
|
||||||
4
Projects/UOContent/Migrations/Server.Items.HousePlacementTool.v0.json
generated
Normal file
4
Projects/UOContent/Migrations/Server.Items.HousePlacementTool.v0.json
generated
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"version": 0,
|
||||||
|
"type": "Server.Items.HousePlacementTool"
|
||||||
|
}
|
||||||
16
Projects/UOContent/Migrations/Server.Items.HouseTeleporter.v2.json
generated
Normal file
16
Projects/UOContent/Migrations/Server.Items.HouseTeleporter.v2.json
generated
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"type": "Server.Items.HouseTeleporter",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"name": "Level",
|
||||||
|
"type": "Server.Multis.SecureLevel",
|
||||||
|
"rule": "EnumMigrationRule"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Target",
|
||||||
|
"type": "Server.Item",
|
||||||
|
"rule": "SerializableInterfaceMigrationRule"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
30
Projects/UOContent/Migrations/Server.Items.ToggleItem.v0.json
generated
Normal file
30
Projects/UOContent/Migrations/Server.Items.ToggleItem.v0.json
generated
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"version": 0,
|
||||||
|
"type": "Server.Items.ToggleItem",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"name": "InactiveItemId",
|
||||||
|
"type": "int",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ActiveItemId",
|
||||||
|
"type": "int",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "PlayersCanToggle",
|
||||||
|
"type": "bool",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
23
Projects/UOContent/Migrations/Server.Misc.ShardPollOption.v1.json
generated
Normal file
23
Projects/UOContent/Migrations/Server.Misc.ShardPollOption.v1.json
generated
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"type": "Server.Misc.ShardPollOption",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"name": "Title",
|
||||||
|
"type": "string",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Voters",
|
||||||
|
"type": "System.Net.IPAddress[]",
|
||||||
|
"rule": "ArrayMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
"System.Net.IPAddress",
|
||||||
|
"PrimitiveTypeMigrationRule"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
45
Projects/UOContent/Migrations/Server.Misc.ShardPoller.v1.json
generated
Normal file
45
Projects/UOContent/Migrations/Server.Misc.ShardPoller.v1.json
generated
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"type": "Server.Misc.ShardPoller",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"name": "Title",
|
||||||
|
"type": "string",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Duration",
|
||||||
|
"type": "System.TimeSpan",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "StartTime",
|
||||||
|
"type": "System.DateTime",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Active",
|
||||||
|
"type": "bool",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Options",
|
||||||
|
"type": "Server.Misc.ShardPollOption[]",
|
||||||
|
"rule": "ArrayMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
"Server.Misc.ShardPollOption",
|
||||||
|
"RawSerializableMigrationRule",
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
62
Projects/UOContent/Migrations/Server.Mobiles.PlayerVendor.v3.json
generated
Normal file
62
Projects/UOContent/Migrations/Server.Mobiles.PlayerVendor.v3.json
generated
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"type": "Server.Mobiles.PlayerVendor",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"name": "ShopName",
|
||||||
|
"type": "string",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "NextPayTime",
|
||||||
|
"type": "System.DateTime",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
"DeltaTime"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "House",
|
||||||
|
"type": "Server.Multis.BaseHouse",
|
||||||
|
"rule": "SerializableInterfaceMigrationRule"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Owner",
|
||||||
|
"type": "Server.Mobile",
|
||||||
|
"rule": "SerializableInterfaceMigrationRule"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BankAccount",
|
||||||
|
"type": "int",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "HoldGold",
|
||||||
|
"type": "int",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "SellItems",
|
||||||
|
"type": "System.Collections.Generic.Dictionary\u003CServer.Item, Server.Mobiles.VendorItem\u003E",
|
||||||
|
"rule": "DictionaryMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
"Server.Item",
|
||||||
|
"SerializableInterfaceMigrationRule",
|
||||||
|
"0",
|
||||||
|
"Server.Mobiles.VendorItem",
|
||||||
|
"RawSerializableMigrationRule",
|
||||||
|
"1",
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
11
Projects/UOContent/Migrations/Server.Mobiles.PlayerVendorPlaceholder.v0.json
generated
Normal file
11
Projects/UOContent/Migrations/Server.Mobiles.PlayerVendorPlaceholder.v0.json
generated
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"version": 0,
|
||||||
|
"type": "Server.Mobiles.PlayerVendorPlaceholder",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"name": "Vendor",
|
||||||
|
"type": "Server.Mobiles.PlayerVendor",
|
||||||
|
"rule": "SerializableInterfaceMigrationRule"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
4
Projects/UOContent/Migrations/Server.Mobiles.VendorBackpack.v0.json
generated
Normal file
4
Projects/UOContent/Migrations/Server.Mobiles.VendorBackpack.v0.json
generated
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"version": 0,
|
||||||
|
"type": "Server.Mobiles.VendorBackpack"
|
||||||
|
}
|
||||||
35
Projects/UOContent/Migrations/Server.Mobiles.VendorItem.v0.json
generated
Normal file
35
Projects/UOContent/Migrations/Server.Mobiles.VendorItem.v0.json
generated
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"version": 0,
|
||||||
|
"type": "Server.Mobiles.VendorItem",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"name": "Item",
|
||||||
|
"type": "Server.Item",
|
||||||
|
"rule": "SerializableInterfaceMigrationRule"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Price",
|
||||||
|
"type": "int",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Description",
|
||||||
|
"type": "string",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Created",
|
||||||
|
"type": "System.DateTime",
|
||||||
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
|
"ruleArguments": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
16
Projects/UOContent/Migrations/Server.Multis.HouseSign.v0.json
generated
Normal file
16
Projects/UOContent/Migrations/Server.Multis.HouseSign.v0.json
generated
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"version": 0,
|
||||||
|
"type": "Server.Multis.HouseSign",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"name": "Owner",
|
||||||
|
"type": "Server.Multis.BaseHouse",
|
||||||
|
"rule": "SerializableInterfaceMigrationRule"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "OriginalOwner",
|
||||||
|
"type": "Server.Mobile",
|
||||||
|
"rule": "SerializableInterfaceMigrationRule"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,109 +1,87 @@
|
||||||
|
using ModernUO.Serialization;
|
||||||
using Server.Commands.Generic;
|
using Server.Commands.Generic;
|
||||||
|
|
||||||
namespace Server.Items
|
namespace Server.Items;
|
||||||
|
|
||||||
|
[SerializationGenerator(0, false)]
|
||||||
|
public partial class ToggleItem : Item
|
||||||
{
|
{
|
||||||
public class ToggleItem : Item
|
[SerializableField(0)]
|
||||||
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||||
|
private int _inactiveItemId;
|
||||||
|
|
||||||
|
[SerializableField(1)]
|
||||||
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||||
|
private int _activeItemId;
|
||||||
|
|
||||||
|
[SerializableField(2)]
|
||||||
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||||
|
private bool _playersCanToggle;
|
||||||
|
|
||||||
|
[Constructible]
|
||||||
|
public ToggleItem(int inactiveItemID, int activeItemID, bool playersCanToggle = false) : base(inactiveItemID)
|
||||||
{
|
{
|
||||||
[Constructible]
|
Movable = false;
|
||||||
public ToggleItem(int inactiveItemID, int activeItemID, bool playersCanToggle = false)
|
|
||||||
: base(inactiveItemID)
|
|
||||||
{
|
|
||||||
Movable = false;
|
|
||||||
|
|
||||||
InactiveItemID = inactiveItemID;
|
_inactiveItemId = inactiveItemID;
|
||||||
ActiveItemID = activeItemID;
|
_activeItemId = activeItemID;
|
||||||
PlayersCanToggle = playersCanToggle;
|
_playersCanToggle = playersCanToggle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Configure()
|
||||||
|
{
|
||||||
|
TargetCommands.Register(new ToggleCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnDoubleClick(Mobile from)
|
||||||
|
{
|
||||||
|
if (from.AccessLevel >= AccessLevel.GameMaster)
|
||||||
|
{
|
||||||
|
Toggle();
|
||||||
|
}
|
||||||
|
else if (!PlayersCanToggle)
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToggleItem(Serial serial)
|
if (from.InRange(GetWorldLocation(), 1))
|
||||||
: base(serial)
|
|
||||||
{
|
{
|
||||||
|
Toggle();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
from.SendLocalizedMessage(500446); // That is too far away.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Toggle()
|
||||||
|
{
|
||||||
|
ItemID = ItemID == _activeItemId ? _inactiveItemId : _activeItemId;
|
||||||
|
Visible = ItemID != 0x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ToggleCommand : BaseCommand
|
||||||
|
{
|
||||||
|
public ToggleCommand()
|
||||||
|
{
|
||||||
|
AccessLevel = AccessLevel.GameMaster;
|
||||||
|
Supports = CommandSupport.AllItems;
|
||||||
|
Commands = ["Toggle"];
|
||||||
|
ObjectTypes = ObjectTypes.Items;
|
||||||
|
Usage = "Toggle";
|
||||||
|
Description = "Toggles a targeted ToggleItem.";
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
public override void Execute(CommandEventArgs e, object obj)
|
||||||
public int InactiveItemID { get; set; }
|
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
|
||||||
public int ActiveItemID { get; set; }
|
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
|
||||||
public bool PlayersCanToggle { get; set; }
|
|
||||||
|
|
||||||
public static void Configure()
|
|
||||||
{
|
{
|
||||||
TargetCommands.Register(new ToggleCommand());
|
if (obj is ToggleItem item)
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnDoubleClick(Mobile from)
|
|
||||||
{
|
|
||||||
if (from.AccessLevel >= AccessLevel.GameMaster)
|
|
||||||
{
|
{
|
||||||
Toggle();
|
item.Toggle();
|
||||||
|
AddResponse("The item has been toggled.");
|
||||||
}
|
}
|
||||||
else if (PlayersCanToggle)
|
else
|
||||||
{
|
{
|
||||||
if (from.InRange(GetWorldLocation(), 1))
|
LogFailure("That is not a ToggleItem.");
|
||||||
{
|
|
||||||
Toggle();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
from.SendLocalizedMessage(500446); // That is too far away.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Toggle()
|
|
||||||
{
|
|
||||||
ItemID = ItemID == ActiveItemID ? InactiveItemID : ActiveItemID;
|
|
||||||
Visible = ItemID != 0x1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Serialize(IGenericWriter writer)
|
|
||||||
{
|
|
||||||
base.Serialize(writer);
|
|
||||||
|
|
||||||
writer.Write(0); // version
|
|
||||||
|
|
||||||
writer.Write(InactiveItemID);
|
|
||||||
writer.Write(ActiveItemID);
|
|
||||||
writer.Write(PlayersCanToggle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Deserialize(IGenericReader reader)
|
|
||||||
{
|
|
||||||
base.Deserialize(reader);
|
|
||||||
|
|
||||||
var version = reader.ReadInt();
|
|
||||||
|
|
||||||
InactiveItemID = reader.ReadInt();
|
|
||||||
ActiveItemID = reader.ReadInt();
|
|
||||||
PlayersCanToggle = reader.ReadBool();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ToggleCommand : BaseCommand
|
|
||||||
{
|
|
||||||
public ToggleCommand()
|
|
||||||
{
|
|
||||||
AccessLevel = AccessLevel.GameMaster;
|
|
||||||
Supports = CommandSupport.AllItems;
|
|
||||||
Commands = new[] { "Toggle" };
|
|
||||||
ObjectTypes = ObjectTypes.Items;
|
|
||||||
Usage = "Toggle";
|
|
||||||
Description = "Toggles a targeted ToggleItem.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Execute(CommandEventArgs e, object obj)
|
|
||||||
{
|
|
||||||
if (obj is ToggleItem item)
|
|
||||||
{
|
|
||||||
item.Toggle();
|
|
||||||
AddResponse("The item has been toggled.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogFailure("That is not a ToggleItem.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,52 @@
|
||||||
|
using System;
|
||||||
|
using ModernUO.Serialization;
|
||||||
|
|
||||||
|
namespace Server.Mobiles;
|
||||||
|
|
||||||
|
[SerializationGenerator(0)]
|
||||||
|
public partial class PlayerVendorPlaceholder : Item
|
||||||
|
{
|
||||||
|
private readonly Timer _timer;
|
||||||
|
|
||||||
|
[SerializableField(0, setter: "private")]
|
||||||
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||||
|
private PlayerVendor _vendor;
|
||||||
|
|
||||||
|
public PlayerVendorPlaceholder(PlayerVendor vendor) : base(0x1F28)
|
||||||
|
{
|
||||||
|
Hue = 0x672;
|
||||||
|
Movable = false;
|
||||||
|
|
||||||
|
_vendor = vendor;
|
||||||
|
|
||||||
|
_timer = Timer.DelayCall(TimeSpan.FromMinutes(2.0), Delete);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void GetProperties(IPropertyList list)
|
||||||
|
{
|
||||||
|
base.GetProperties(list);
|
||||||
|
|
||||||
|
if (Vendor != null)
|
||||||
|
{
|
||||||
|
list.Add(1062498, Vendor.Name); // reserved for vendor ~1_NAME~
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RestartTimer()
|
||||||
|
{
|
||||||
|
_timer.Stop();
|
||||||
|
_timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnDelete()
|
||||||
|
{
|
||||||
|
if (Vendor?.Deleted == false)
|
||||||
|
{
|
||||||
|
Vendor.MoveToWorld(Location, Map);
|
||||||
|
Vendor.Placeholder = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[AfterDeserialization(false)]
|
||||||
|
private void AfterDeserialization() => Delete();
|
||||||
|
}
|
||||||
188
Projects/UOContent/Mobiles/Vendors/VendorBackpack.cs
Normal file
188
Projects/UOContent/Mobiles/Vendors/VendorBackpack.cs
Normal file
|
|
@ -0,0 +1,188 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using ModernUO.Serialization;
|
||||||
|
using Server.ContextMenus;
|
||||||
|
using Server.Engines.BulkOrders;
|
||||||
|
using Server.Ethics;
|
||||||
|
using Server.Items;
|
||||||
|
using Server.Multis;
|
||||||
|
using Server.Targeting;
|
||||||
|
|
||||||
|
namespace Server.Mobiles;
|
||||||
|
|
||||||
|
[SerializationGenerator(0, false)]
|
||||||
|
public partial class VendorBackpack : Backpack
|
||||||
|
{
|
||||||
|
public VendorBackpack()
|
||||||
|
{
|
||||||
|
Layer = Layer.Backpack;
|
||||||
|
Weight = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int DefaultMaxWeight => 0;
|
||||||
|
|
||||||
|
public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight)
|
||||||
|
{
|
||||||
|
if (!base.CheckHold(m, item, message, checkItems, plusItems, plusWeight))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Ethic.IsImbued(item, true))
|
||||||
|
{
|
||||||
|
if (message)
|
||||||
|
{
|
||||||
|
m.SendMessage("Imbued items may not be sold here.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!BaseHouse.NewVendorSystem && Parent is PlayerVendor vendor)
|
||||||
|
{
|
||||||
|
var house = vendor.House;
|
||||||
|
|
||||||
|
if (house?.IsAosRules == true && !house.CheckAosStorage(1 + item.TotalItems + plusItems))
|
||||||
|
{
|
||||||
|
if (message)
|
||||||
|
{
|
||||||
|
m.SendLocalizedMessage(1061839); // This action would exceed the secure storage limit of the house.
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool IsAccessibleTo(Mobile m) => true;
|
||||||
|
|
||||||
|
public override bool CheckItemUse(Mobile from, Item item)
|
||||||
|
{
|
||||||
|
if (!base.CheckItemUse(from, item))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item is Container or BulkOrderBook)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
from.SendLocalizedMessage(500447); // That is not accessible.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CheckTarget(Mobile from, Target targ, object targeted) =>
|
||||||
|
base.CheckTarget(from, targ, targeted) &&
|
||||||
|
(from.AccessLevel >= AccessLevel.GameMaster ||
|
||||||
|
targ.GetType().IsDefined(typeof(PlayerVendorTargetAttribute), false));
|
||||||
|
|
||||||
|
public override void GetChildContextMenuEntries(Mobile from, List<ContextMenuEntry> list, Item item)
|
||||||
|
{
|
||||||
|
base.GetChildContextMenuEntries(from, list, item);
|
||||||
|
|
||||||
|
if (RootParent is not PlayerVendor pv || pv.IsOwner(from))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var vi = pv.GetVendorItem(item);
|
||||||
|
|
||||||
|
if (vi != null)
|
||||||
|
{
|
||||||
|
list.Add(new BuyEntry(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void GetChildNameProperties(IPropertyList list, Item item)
|
||||||
|
{
|
||||||
|
base.GetChildNameProperties(list, item);
|
||||||
|
|
||||||
|
var pv = RootParent as PlayerVendor;
|
||||||
|
|
||||||
|
var vi = pv?.GetVendorItem(item);
|
||||||
|
|
||||||
|
if (vi == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vi.IsForSale)
|
||||||
|
{
|
||||||
|
list.Add(1043307); // Price: Not for sale.
|
||||||
|
}
|
||||||
|
else if (vi.IsForFree)
|
||||||
|
{
|
||||||
|
list.Add(1043306); // Price: FREE!
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list.Add(1043304, vi.FormattedPrice); // Price: ~1_COST~
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void GetChildProperties(IPropertyList list, Item item)
|
||||||
|
{
|
||||||
|
base.GetChildProperties(list, item);
|
||||||
|
|
||||||
|
var pv = RootParent as PlayerVendor;
|
||||||
|
|
||||||
|
var vi = pv?.GetVendorItem(item);
|
||||||
|
|
||||||
|
if (vi?.Description?.Length > 0)
|
||||||
|
{
|
||||||
|
list.Add(1043305, vi.Description); // <br>Seller's Description:<br>"~1_DESC~"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnSingleClickContained(Mobile from, Item item)
|
||||||
|
{
|
||||||
|
if (RootParent is PlayerVendor vendor)
|
||||||
|
{
|
||||||
|
var vi = vendor.GetVendorItem(item);
|
||||||
|
|
||||||
|
if (vi != null)
|
||||||
|
{
|
||||||
|
if (!vi.IsForSale)
|
||||||
|
{
|
||||||
|
item.LabelTo(from, 1043307); // Price: Not for sale.
|
||||||
|
}
|
||||||
|
else if (vi.IsForFree)
|
||||||
|
{
|
||||||
|
item.LabelTo(from, 1043306); // Price: FREE!
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.LabelTo(from, 1043304, vi.FormattedPrice); // Price: ~1_COST~
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(vi.Description))
|
||||||
|
{
|
||||||
|
item.LabelTo(from, $"Description: {vi.Description}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
base.OnSingleClickContained(from, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BuyEntry : ContextMenuEntry
|
||||||
|
{
|
||||||
|
private readonly Item m_Item;
|
||||||
|
|
||||||
|
public BuyEntry(Item item) : base(6103) => m_Item = item;
|
||||||
|
|
||||||
|
public override bool NonLocalUse => true;
|
||||||
|
|
||||||
|
public override void OnClick()
|
||||||
|
{
|
||||||
|
if (m_Item.Deleted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerVendor.TryToBuy(m_Item, Owner.From);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
64
Projects/UOContent/Mobiles/Vendors/VendorItem.cs
Normal file
64
Projects/UOContent/Mobiles/Vendors/VendorItem.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using ModernUO.Serialization;
|
||||||
|
|
||||||
|
namespace Server.Mobiles;
|
||||||
|
|
||||||
|
[SerializationGenerator(0, false)]
|
||||||
|
public partial class VendorItem
|
||||||
|
{
|
||||||
|
[SerializableField(0)]
|
||||||
|
private Item _item;
|
||||||
|
|
||||||
|
[SerializableField(1)]
|
||||||
|
private int _price;
|
||||||
|
|
||||||
|
[SerializableField(3)]
|
||||||
|
private DateTime _created;
|
||||||
|
|
||||||
|
public VendorItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public VendorItem(Item item, int price, string description, DateTime created)
|
||||||
|
{
|
||||||
|
_item = item;
|
||||||
|
_price = price;
|
||||||
|
_description = description ?? "";
|
||||||
|
_created = created;
|
||||||
|
Valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FormattedPrice =>
|
||||||
|
Core.ML ? Price.ToString("N0", CultureInfo.GetCultureInfo("en-US")) : Price.ToString();
|
||||||
|
|
||||||
|
[SerializableProperty(2)]
|
||||||
|
public string Description
|
||||||
|
{
|
||||||
|
get => _description;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_description = value ?? "";
|
||||||
|
|
||||||
|
if (Valid)
|
||||||
|
{
|
||||||
|
Item.InvalidateProperties();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsForSale => Price >= 0;
|
||||||
|
public bool IsForFree => Price == 0;
|
||||||
|
public bool Valid { get; private set; }
|
||||||
|
|
||||||
|
public void Invalidate() => Valid = false;
|
||||||
|
|
||||||
|
[AfterDeserialization]
|
||||||
|
private void AfterDeserialization()
|
||||||
|
{
|
||||||
|
if (_price > 100000000)
|
||||||
|
{
|
||||||
|
_price = 100000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,311 +1,274 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using ModernUO.Serialization;
|
||||||
using Server.ContextMenus;
|
using Server.ContextMenus;
|
||||||
using Server.Gumps;
|
using Server.Gumps;
|
||||||
|
|
||||||
namespace Server.Multis
|
namespace Server.Multis;
|
||||||
|
|
||||||
|
[SerializationGenerator(0, false)]
|
||||||
|
public partial class HouseSign : Item
|
||||||
{
|
{
|
||||||
public class HouseSign : Item
|
[SerializableField(0, setter: "private")]
|
||||||
|
private BaseHouse _owner;
|
||||||
|
|
||||||
|
[SerializableField(1, setter: "private")]
|
||||||
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||||
|
private Mobile _originalOwner;
|
||||||
|
|
||||||
|
public HouseSign(BaseHouse owner) : base(0xBD2)
|
||||||
{
|
{
|
||||||
public HouseSign(BaseHouse owner) : base(0xBD2)
|
Owner = owner;
|
||||||
{
|
OriginalOwner = Owner.Owner;
|
||||||
Owner = owner;
|
Movable = false;
|
||||||
OriginalOwner = Owner.Owner;
|
}
|
||||||
Movable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HouseSign(Serial serial) : base(serial)
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
{
|
public bool RestrictDecay
|
||||||
}
|
{
|
||||||
|
get => Owner?.RestrictDecay == true;
|
||||||
public BaseHouse Owner { get; private set; }
|
set
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
|
||||||
public bool RestrictDecay
|
|
||||||
{
|
|
||||||
get => Owner?.RestrictDecay == true;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (Owner != null)
|
|
||||||
{
|
|
||||||
Owner.RestrictDecay = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
|
||||||
public Mobile OriginalOwner { get; private set; }
|
|
||||||
|
|
||||||
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
|
|
||||||
|
|
||||||
public bool GettingProperties { get; private set; }
|
|
||||||
|
|
||||||
public string GetName() => Name ?? "An Unnamed House";
|
|
||||||
|
|
||||||
public override void OnAfterDelete()
|
|
||||||
{
|
|
||||||
base.OnAfterDelete();
|
|
||||||
|
|
||||||
if (Owner?.Deleted == false)
|
|
||||||
{
|
|
||||||
Owner.Delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void AddNameProperty(IPropertyList list)
|
|
||||||
{
|
|
||||||
list.Add(1061638); // A House Sign
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void GetProperties(IPropertyList list)
|
|
||||||
{
|
|
||||||
base.GetProperties(list);
|
|
||||||
|
|
||||||
list.Add(1061639, GetName().FixHtml()); // Name: ~1_NAME~
|
|
||||||
list.Add(1061640, Owner?.Owner == null ? "nobody" : Owner.Owner.Name); // Owner: ~1_OWNER~
|
|
||||||
|
|
||||||
if (Owner != null)
|
|
||||||
{
|
|
||||||
list.Add(Owner.Public ? 1061641 : 1061642); // This House is Open to the Public : This is a Private Home
|
|
||||||
|
|
||||||
GettingProperties = true;
|
|
||||||
var level = Owner.DecayLevel;
|
|
||||||
GettingProperties = false;
|
|
||||||
|
|
||||||
if (level == DecayLevel.DemolitionPending)
|
|
||||||
{
|
|
||||||
list.Add(1062497); // Demolition Pending
|
|
||||||
}
|
|
||||||
else if (level != DecayLevel.Ageless)
|
|
||||||
{
|
|
||||||
if (level == DecayLevel.Collapsed)
|
|
||||||
{
|
|
||||||
level = DecayLevel.IDOC;
|
|
||||||
}
|
|
||||||
|
|
||||||
list.AddLocalized(1062028, 1043009 + (int)level); // Condition: This structure is ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnSingleClick(Mobile from)
|
|
||||||
{
|
|
||||||
if (BaseHouse.DecayEnabled && Owner != null && Owner.DecayPeriod != TimeSpan.Zero)
|
|
||||||
{
|
|
||||||
var message = Owner.DecayLevel switch
|
|
||||||
{
|
|
||||||
DecayLevel.Ageless => "ageless",
|
|
||||||
DecayLevel.Fairly => "fairly worn",
|
|
||||||
DecayLevel.Greatly => "greatly worn",
|
|
||||||
DecayLevel.LikeNew => "like new",
|
|
||||||
DecayLevel.Slightly => "slightly worn",
|
|
||||||
DecayLevel.Somewhat => "somewhat worn",
|
|
||||||
_ => "in danger of collapsing"
|
|
||||||
};
|
|
||||||
|
|
||||||
LabelTo(from, $"This house is {message}.");
|
|
||||||
}
|
|
||||||
|
|
||||||
base.OnSingleClick(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ShowSign(Mobile m)
|
|
||||||
{
|
{
|
||||||
if (Owner != null)
|
if (Owner != null)
|
||||||
{
|
{
|
||||||
if (Owner.IsFriend(m) && m.AccessLevel < AccessLevel.GameMaster)
|
Owner.RestrictDecay = value;
|
||||||
{
|
|
||||||
if (Core.ML && Owner.IsOwner(m) || !Core.ML)
|
|
||||||
{
|
|
||||||
Owner.RefreshDecay();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Core.AOS)
|
|
||||||
{
|
|
||||||
m.SendLocalizedMessage(501293); // Welcome back to the house, friend!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Owner.IsAosRules)
|
|
||||||
{
|
|
||||||
m.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Information, m, Owner));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m.SendGump(new HouseGump(m, Owner));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ClaimGump_Callback(Mobile from, bool okay)
|
public int LabelNumber => 1061638; // A House Sign
|
||||||
|
|
||||||
|
public override bool ForceShowProperties => ObjectPropertyList.Enabled;
|
||||||
|
|
||||||
|
public bool GettingProperties { get; private set; }
|
||||||
|
|
||||||
|
public string GetName() => Name ?? "An Unnamed House";
|
||||||
|
|
||||||
|
public override void OnAfterDelete()
|
||||||
|
{
|
||||||
|
base.OnAfterDelete();
|
||||||
|
|
||||||
|
if (Owner?.Deleted == false)
|
||||||
{
|
{
|
||||||
if (okay && Owner != null && Owner.Owner == null && Owner.DecayLevel != DecayLevel.DemolitionPending)
|
Owner.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void GetProperties(IPropertyList list)
|
||||||
|
{
|
||||||
|
base.GetProperties(list);
|
||||||
|
|
||||||
|
list.Add(1061639, GetName().FixHtml()); // Name: ~1_NAME~
|
||||||
|
list.Add(1061640, Owner?.Owner?.Name ?? "nobody"); // Owner: ~1_OWNER~
|
||||||
|
|
||||||
|
if (Owner != null)
|
||||||
|
{
|
||||||
|
list.Add(Owner.Public ? 1061641 : 1061642); // This House is Open to the Public : This is a Private Home
|
||||||
|
|
||||||
|
GettingProperties = true;
|
||||||
|
var level = Owner.DecayLevel;
|
||||||
|
GettingProperties = false;
|
||||||
|
|
||||||
|
if (level == DecayLevel.DemolitionPending)
|
||||||
{
|
{
|
||||||
var canClaim = Owner.CoOwners?.Count > 0 && Owner.IsCoOwner(from) || Owner.IsFriend(from);
|
list.Add(1062497); // Demolition Pending
|
||||||
|
|
||||||
if (canClaim && !BaseHouse.HasAccountHouse(from))
|
|
||||||
{
|
|
||||||
Owner.Owner = from;
|
|
||||||
Owner.LastTraded = Core.Now;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (level != DecayLevel.Ageless)
|
||||||
|
{
|
||||||
|
if (level == DecayLevel.Collapsed)
|
||||||
|
{
|
||||||
|
level = DecayLevel.IDOC;
|
||||||
|
}
|
||||||
|
|
||||||
ShowSign(from);
|
list.AddLocalized(1062028, 1043009 + (int)level); // Condition: This structure is ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnSingleClick(Mobile from)
|
||||||
|
{
|
||||||
|
if (BaseHouse.DecayEnabled && Owner != null && Owner.DecayPeriod != TimeSpan.Zero)
|
||||||
|
{
|
||||||
|
var message = Owner.DecayLevel switch
|
||||||
|
{
|
||||||
|
DecayLevel.Ageless => "ageless",
|
||||||
|
DecayLevel.Fairly => "fairly worn",
|
||||||
|
DecayLevel.Greatly => "greatly worn",
|
||||||
|
DecayLevel.LikeNew => "like new",
|
||||||
|
DecayLevel.Slightly => "slightly worn",
|
||||||
|
DecayLevel.Somewhat => "somewhat worn",
|
||||||
|
_ => "in danger of collapsing"
|
||||||
|
};
|
||||||
|
|
||||||
|
LabelTo(from, $"This house is {message}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDoubleClick(Mobile m)
|
base.OnSingleClick(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowSign(Mobile m)
|
||||||
|
{
|
||||||
|
if (Owner == null)
|
||||||
{
|
{
|
||||||
if (Owner == null)
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Owner.IsFriend(m) && m.AccessLevel < AccessLevel.GameMaster)
|
||||||
|
{
|
||||||
|
if (Core.ML && Owner.IsOwner(m) || !Core.ML)
|
||||||
|
{
|
||||||
|
Owner.RefreshDecay();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Core.AOS)
|
||||||
|
{
|
||||||
|
m.SendLocalizedMessage(501293); // Welcome back to the house, friend!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Owner.IsAosRules)
|
||||||
|
{
|
||||||
|
m.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Information, m, Owner));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m.SendGump(new HouseGump(m, Owner));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClaimGump_Callback(Mobile from, bool okay)
|
||||||
|
{
|
||||||
|
if (okay && Owner != null && Owner.Owner == null && Owner.DecayLevel != DecayLevel.DemolitionPending)
|
||||||
|
{
|
||||||
|
var canClaim = Owner.CoOwners?.Count > 0 && Owner.IsCoOwner(from) || Owner.IsFriend(from);
|
||||||
|
|
||||||
|
if (canClaim && !BaseHouse.HasAccountHouse(from))
|
||||||
|
{
|
||||||
|
Owner.Owner = from;
|
||||||
|
Owner.LastTraded = Core.Now;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowSign(from);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnDoubleClick(Mobile m)
|
||||||
|
{
|
||||||
|
if (Owner == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m.AccessLevel < AccessLevel.GameMaster && Owner.Owner == null &&
|
||||||
|
Owner.DecayLevel != DecayLevel.DemolitionPending)
|
||||||
|
{
|
||||||
|
var canClaim = Owner.IsCoOwner(m) || Owner.IsFriend(m);
|
||||||
|
|
||||||
|
if (canClaim && !BaseHouse.HasAccountHouse(m))
|
||||||
|
{
|
||||||
|
m.SendGump(
|
||||||
|
new ClaimHouseWarningGump(okay => ClaimGump_Callback(m, okay))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowSign(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ClaimHouseWarningGump : StaticWarningGump<ClaimHouseWarningGump>
|
||||||
|
{
|
||||||
|
public override int Header => 501036; // Claim house
|
||||||
|
public override int HeaderColor => 0x7F00;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* You do not currently own any house on any shard with this account, and this house currently does not have an owner.
|
||||||
|
* If you wish, you may choose to claim this house and become its rightful owner.
|
||||||
|
* If you do this, it will become your Primary house and automatically refresh.
|
||||||
|
* If you claim this house, you will be unable to place another house or have another house transferred to you for the next 7 days.
|
||||||
|
* Do you wish to claim this house?
|
||||||
|
*/
|
||||||
|
public override int StaticLocalizedContent => 1049719;
|
||||||
|
|
||||||
|
public override int Width => 420;
|
||||||
|
public override int Height => 280;
|
||||||
|
|
||||||
|
public ClaimHouseWarningGump(Action<bool> callback) : base(callback)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||||
|
{
|
||||||
|
base.GetContextMenuEntries(from, list);
|
||||||
|
|
||||||
|
if (!BaseHouse.NewVendorSystem || !from.Alive || Owner?.IsAosRules != true)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Owner.AreThereAvailableVendorsFor(from))
|
||||||
|
{
|
||||||
|
list.Add(new VendorsEntry(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Owner.VendorInventories.Count > 0)
|
||||||
|
{
|
||||||
|
list.Add(new ReclaimVendorInventoryEntry(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class VendorsEntry : ContextMenuEntry
|
||||||
|
{
|
||||||
|
private readonly HouseSign m_Sign;
|
||||||
|
|
||||||
|
public VendorsEntry(HouseSign sign) : base(6211) => m_Sign = sign;
|
||||||
|
|
||||||
|
public override void OnClick()
|
||||||
|
{
|
||||||
|
var from = Owner.From;
|
||||||
|
|
||||||
|
if (!from.CheckAlive() || m_Sign.Deleted || m_Sign.Owner?.AreThereAvailableVendorsFor(from) != true)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m.AccessLevel < AccessLevel.GameMaster && Owner.Owner == null &&
|
if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5))
|
||||||
Owner.DecayLevel != DecayLevel.DemolitionPending)
|
|
||||||
{
|
{
|
||||||
var canClaim = Owner.IsCoOwner(m) || Owner.IsFriend(m);
|
// You must be within five paces of the house sign to use this option.
|
||||||
|
from.SendLocalizedMessage(1062429);
|
||||||
if (canClaim && !BaseHouse.HasAccountHouse(m))
|
|
||||||
{
|
|
||||||
m.SendGump(
|
|
||||||
new ClaimHouseWarningGump(okay => ClaimGump_Callback(m, okay))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
ShowSign(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ClaimHouseWarningGump : StaticWarningGump<ClaimHouseWarningGump>
|
|
||||||
{
|
|
||||||
public override int Header => 501036; // Claim house
|
|
||||||
public override int HeaderColor => 0x7F00;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* You do not currently own any house on any shard with this account, and this house currently does not have an owner.
|
|
||||||
* If you wish, you may choose to claim this house and become its rightful owner.
|
|
||||||
* If you do this, it will become your Primary house and automatically refresh.
|
|
||||||
* If you claim this house, you will be unable to place another house or have another house transferred to you for the next 7 days.
|
|
||||||
* Do you wish to claim this house?
|
|
||||||
*/
|
|
||||||
public override int StaticLocalizedContent => 1049719;
|
|
||||||
|
|
||||||
public override int Width => 420;
|
|
||||||
public override int Height => 280;
|
|
||||||
|
|
||||||
public ClaimHouseWarningGump(Action<bool> callback) : base(callback)
|
|
||||||
{
|
{
|
||||||
|
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Vendors, from, m_Sign.Owner));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
private class ReclaimVendorInventoryEntry : ContextMenuEntry
|
||||||
|
{
|
||||||
|
private readonly HouseSign m_Sign;
|
||||||
|
|
||||||
|
public ReclaimVendorInventoryEntry(HouseSign sign) : base(6213) => m_Sign = sign;
|
||||||
|
|
||||||
|
public override void OnClick()
|
||||||
{
|
{
|
||||||
base.GetContextMenuEntries(from, list);
|
var from = Owner.From;
|
||||||
|
|
||||||
if (!BaseHouse.NewVendorSystem || !from.Alive || Owner?.IsAosRules != true)
|
if (m_Sign.Deleted || m_Sign.Owner == null || m_Sign.Owner.VendorInventories.Count == 0 ||
|
||||||
|
!from.CheckAlive())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Owner.AreThereAvailableVendorsFor(from))
|
if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5))
|
||||||
{
|
{
|
||||||
list.Add(new VendorsEntry(this));
|
// You must be within five paces of the house sign to use this option.
|
||||||
|
from.SendLocalizedMessage(1062429);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (Owner.VendorInventories.Count > 0)
|
|
||||||
{
|
{
|
||||||
list.Add(new ReclaimVendorInventoryEntry(this));
|
from.CloseGump<VendorInventoryGump>();
|
||||||
}
|
from.SendGump(new VendorInventoryGump(m_Sign.Owner, from));
|
||||||
}
|
|
||||||
|
|
||||||
public override void Serialize(IGenericWriter writer)
|
|
||||||
{
|
|
||||||
base.Serialize(writer);
|
|
||||||
|
|
||||||
writer.Write(0); // version
|
|
||||||
|
|
||||||
writer.Write(Owner);
|
|
||||||
writer.Write(OriginalOwner);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Deserialize(IGenericReader reader)
|
|
||||||
{
|
|
||||||
base.Deserialize(reader);
|
|
||||||
|
|
||||||
var version = reader.ReadInt();
|
|
||||||
|
|
||||||
switch (version)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
Owner = reader.ReadEntity<BaseHouse>();
|
|
||||||
OriginalOwner = reader.ReadEntity<Mobile>();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Name == "a house sign")
|
|
||||||
{
|
|
||||||
Name = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class VendorsEntry : ContextMenuEntry
|
|
||||||
{
|
|
||||||
private readonly HouseSign m_Sign;
|
|
||||||
|
|
||||||
public VendorsEntry(HouseSign sign) : base(6211) => m_Sign = sign;
|
|
||||||
|
|
||||||
public override void OnClick()
|
|
||||||
{
|
|
||||||
var from = Owner.From;
|
|
||||||
|
|
||||||
if (!from.CheckAlive() || m_Sign.Deleted || m_Sign.Owner?.AreThereAvailableVendorsFor(from) != true)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5))
|
|
||||||
{
|
|
||||||
from.SendLocalizedMessage(
|
|
||||||
1062429
|
|
||||||
); // You must be within five paces of the house sign to use this option.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Vendors, from, m_Sign.Owner));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ReclaimVendorInventoryEntry : ContextMenuEntry
|
|
||||||
{
|
|
||||||
private readonly HouseSign m_Sign;
|
|
||||||
|
|
||||||
public ReclaimVendorInventoryEntry(HouseSign sign) : base(6213) => m_Sign = sign;
|
|
||||||
|
|
||||||
public override void OnClick()
|
|
||||||
{
|
|
||||||
var from = Owner.From;
|
|
||||||
|
|
||||||
if (m_Sign.Deleted || m_Sign.Owner == null || m_Sign.Owner.VendorInventories.Count == 0 ||
|
|
||||||
!from.CheckAlive())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (from.Map != m_Sign.Map || !from.InRange(m_Sign, 5))
|
|
||||||
{
|
|
||||||
from.SendLocalizedMessage(
|
|
||||||
1062429
|
|
||||||
); // You must be within five paces of the house sign to use this option.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
from.CloseGump<VendorInventoryGump>();
|
|
||||||
from.SendGump(new VendorInventoryGump(m_Sign.Owner, from));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,198 +1,163 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using ModernUO.Serialization;
|
||||||
using Server.ContextMenus;
|
using Server.ContextMenus;
|
||||||
using Server.Gumps;
|
using Server.Gumps;
|
||||||
using Server.Mobiles;
|
using Server.Mobiles;
|
||||||
using Server.Multis;
|
using Server.Multis;
|
||||||
|
|
||||||
namespace Server.Items
|
namespace Server.Items;
|
||||||
|
|
||||||
|
[SerializationGenerator(2, false)]
|
||||||
|
public partial class HouseTeleporter : Item, ISecurable
|
||||||
{
|
{
|
||||||
public class HouseTeleporter : Item, ISecurable
|
[SerializableField(0)]
|
||||||
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||||
|
private SecureLevel _level;
|
||||||
|
|
||||||
|
[SerializableField(1)]
|
||||||
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||||
|
private Item _target;
|
||||||
|
|
||||||
|
public HouseTeleporter(int itemID, Item target = null) : base(itemID)
|
||||||
{
|
{
|
||||||
public HouseTeleporter(int itemID, Item target = null) : base(itemID)
|
Movable = false;
|
||||||
|
_level = SecureLevel.Anyone;
|
||||||
|
_target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckAccess(Mobile m)
|
||||||
|
{
|
||||||
|
var house = BaseHouse.FindHouseAt(this);
|
||||||
|
|
||||||
|
return (house == null || house.Public && !house.IsBanned(m) || house.HasAccess(m)) &&
|
||||||
|
house?.HasSecureAccess(m, Level) == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnMoveOver(Mobile m)
|
||||||
|
{
|
||||||
|
if (Target?.Deleted != false)
|
||||||
{
|
{
|
||||||
Movable = false;
|
|
||||||
|
|
||||||
Level = SecureLevel.Anyone;
|
|
||||||
|
|
||||||
Target = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HouseTeleporter(Serial serial) : base(serial)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
|
||||||
public Item Target { get; set; }
|
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
|
||||||
public SecureLevel Level { get; set; }
|
|
||||||
|
|
||||||
public bool CheckAccess(Mobile m)
|
|
||||||
{
|
|
||||||
var house = BaseHouse.FindHouseAt(this);
|
|
||||||
|
|
||||||
return (house == null || house.Public && !house.IsBanned(m) || house.HasAccess(m)) &&
|
|
||||||
house?.HasSecureAccess(m, Level) == true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool OnMoveOver(Mobile m)
|
|
||||||
{
|
|
||||||
if (Target?.Deleted == false)
|
|
||||||
{
|
|
||||||
if (CheckAccess(m))
|
|
||||||
{
|
|
||||||
if (!m.Hidden || m.AccessLevel == AccessLevel.Player)
|
|
||||||
{
|
|
||||||
new EffectTimer(Location, Map, 2023, 0x1F0, TimeSpan.FromSeconds(0.4)).Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
new DelayTimer(this, m).Start();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m.SendLocalizedMessage(1061637); // You are not allowed to access this.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
if (!CheckAccess(m))
|
||||||
{
|
{
|
||||||
base.GetContextMenuEntries(from, list);
|
m.SendLocalizedMessage(1061637); // You are not allowed to access this.
|
||||||
SetSecureLevelEntry.AddTo(from, this, list);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Serialize(IGenericWriter writer)
|
if (!m.Hidden || m.AccessLevel == AccessLevel.Player)
|
||||||
{
|
{
|
||||||
base.Serialize(writer);
|
new EffectTimer(Location, Map, 2023, 0x1F0, TimeSpan.FromSeconds(0.4)).Start();
|
||||||
|
|
||||||
writer.Write(1); // version
|
|
||||||
|
|
||||||
writer.Write((int)Level);
|
|
||||||
|
|
||||||
writer.Write(Target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Deserialize(IGenericReader reader)
|
new DelayTimer(this, m).Start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
|
||||||
|
{
|
||||||
|
base.GetContextMenuEntries(from, list);
|
||||||
|
SetSecureLevelEntry.AddTo(from, this, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Deserialize(IGenericReader reader, int version)
|
||||||
|
{
|
||||||
|
Level = (SecureLevel)reader.ReadInt();
|
||||||
|
Target = reader.ReadEntity<Item>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EffectTimer : Timer
|
||||||
|
{
|
||||||
|
private readonly int _effectId;
|
||||||
|
private readonly Point3D _location;
|
||||||
|
private readonly Map _map;
|
||||||
|
private readonly int _soundId;
|
||||||
|
|
||||||
|
public EffectTimer(Point3D p, Map map, int effectID, int soundID, TimeSpan delay) : base(delay)
|
||||||
{
|
{
|
||||||
base.Deserialize(reader);
|
_location = p;
|
||||||
|
_map = map;
|
||||||
var version = reader.ReadInt();
|
_effectId = effectID;
|
||||||
|
_soundId = soundID;
|
||||||
switch (version)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
Level = (SecureLevel)reader.ReadInt();
|
|
||||||
goto case 0;
|
|
||||||
}
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
Target = reader.ReadEntity<Item>();
|
|
||||||
|
|
||||||
if (version < 1)
|
|
||||||
{
|
|
||||||
Level = SecureLevel.Anyone;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class EffectTimer : Timer
|
protected override void OnTick()
|
||||||
{
|
{
|
||||||
private readonly int m_EffectID;
|
Effects.SendLocationParticles(
|
||||||
private readonly Point3D m_Location;
|
EffectItem.Create(_location, _map, EffectItem.DefaultDuration),
|
||||||
private readonly Map m_Map;
|
0x3728,
|
||||||
private readonly int m_SoundID;
|
10,
|
||||||
|
10,
|
||||||
|
_effectId,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
public EffectTimer(Point3D p, Map map, int effectID, int soundID, TimeSpan delay) : base(delay)
|
if (_soundId != -1)
|
||||||
{
|
{
|
||||||
m_Location = p;
|
Effects.PlaySound(_location, _map, _soundId);
|
||||||
m_Map = map;
|
|
||||||
m_EffectID = effectID;
|
|
||||||
m_SoundID = soundID;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnTick()
|
|
||||||
{
|
|
||||||
Effects.SendLocationParticles(
|
|
||||||
EffectItem.Create(m_Location, m_Map, EffectItem.DefaultDuration),
|
|
||||||
0x3728,
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
m_EffectID,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
if (m_SoundID != -1)
|
|
||||||
{
|
|
||||||
Effects.PlaySound(m_Location, m_Map, m_SoundID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DelayTimer : Timer
|
|
||||||
{
|
|
||||||
private readonly Mobile m_Mobile;
|
|
||||||
private readonly HouseTeleporter m_Teleporter;
|
|
||||||
|
|
||||||
public DelayTimer(HouseTeleporter tp, Mobile m) : base(TimeSpan.FromSeconds(1.0))
|
|
||||||
{
|
|
||||||
m_Teleporter = tp;
|
|
||||||
m_Mobile = m;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnTick()
|
|
||||||
{
|
|
||||||
var target = m_Teleporter.Target;
|
|
||||||
|
|
||||||
if (target?.Deleted != false)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Mobile.Location != m_Teleporter.Location || m_Mobile.Map != m_Teleporter.Map)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var p = target.GetWorldTop();
|
|
||||||
var map = target.Map;
|
|
||||||
|
|
||||||
BaseCreature.TeleportPets(m_Mobile, p, map);
|
|
||||||
|
|
||||||
m_Mobile.MoveToWorld(p, map);
|
|
||||||
|
|
||||||
if (m_Mobile.Hidden && m_Mobile.AccessLevel != AccessLevel.Player)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Effects.PlaySound(target.Location, target.Map, 0x1FE);
|
|
||||||
|
|
||||||
Effects.SendLocationParticles(
|
|
||||||
EffectItem.Create(m_Teleporter.Location, m_Teleporter.Map, EffectItem.DefaultDuration),
|
|
||||||
0x3728,
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
2023,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
Effects.SendLocationParticles(
|
|
||||||
EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration),
|
|
||||||
0x3728,
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
5023,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
|
|
||||||
new EffectTimer(target.Location, target.Map, 2023, -1, TimeSpan.FromSeconds(0.4)).Start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class DelayTimer : Timer
|
||||||
|
{
|
||||||
|
private readonly Mobile _mobile;
|
||||||
|
private readonly HouseTeleporter _teleporter;
|
||||||
|
|
||||||
|
public DelayTimer(HouseTeleporter tp, Mobile m) : base(TimeSpan.FromSeconds(1.0))
|
||||||
|
{
|
||||||
|
_teleporter = tp;
|
||||||
|
_mobile = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnTick()
|
||||||
|
{
|
||||||
|
var target = _teleporter.Target;
|
||||||
|
|
||||||
|
if (target?.Deleted != false)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_mobile.Location != _teleporter.Location || _mobile.Map != _teleporter.Map)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var p = target.GetWorldTop();
|
||||||
|
var map = target.Map;
|
||||||
|
|
||||||
|
BaseCreature.TeleportPets(_mobile, p, map);
|
||||||
|
|
||||||
|
_mobile.MoveToWorld(p, map);
|
||||||
|
|
||||||
|
if (_mobile.Hidden && _mobile.AccessLevel != AccessLevel.Player)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Effects.PlaySound(target.Location, target.Map, 0x1FE);
|
||||||
|
|
||||||
|
Effects.SendLocationParticles(
|
||||||
|
EffectItem.Create(_teleporter.Location, _teleporter.Map, EffectItem.DefaultDuration),
|
||||||
|
0x3728,
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
2023,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
Effects.SendLocationParticles(
|
||||||
|
EffectItem.Create(target.Location, target.Map, EffectItem.DefaultDuration),
|
||||||
|
0x3728,
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
5023,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
new EffectTimer(target.Location, target.Map, 2023, -1, TimeSpan.FromSeconds(0.4)).Start();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue