fix: Codegens treasure/paragon chests & strongboxes (#948)
This commit is contained in:
parent
9bc6d5bdb8
commit
17f8d3563a
6 changed files with 431 additions and 518 deletions
|
|
@ -1,214 +1,138 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Items
|
||||
namespace Server.Items;
|
||||
|
||||
[Serializable(1, false)]
|
||||
public partial class BaseTreasureChest : LockableContainer
|
||||
{
|
||||
public class BaseTreasureChest : LockableContainer
|
||||
public enum TreasureLevel
|
||||
{
|
||||
public enum TreasureLevel
|
||||
Level1,
|
||||
Level2,
|
||||
Level3,
|
||||
Level4,
|
||||
Level5,
|
||||
Level6
|
||||
}
|
||||
|
||||
private TimerExecutionToken _resetTimer;
|
||||
|
||||
public BaseTreasureChest(int itemID, TreasureLevel level = TreasureLevel.Level2) : base(itemID)
|
||||
{
|
||||
_level = level;
|
||||
_minSpawnTime = TimeSpan.FromMinutes(10);
|
||||
_maxSpawnTime = TimeSpan.FromMinutes(60);
|
||||
|
||||
Locked = true;
|
||||
Movable = false;
|
||||
|
||||
SetLockLevel();
|
||||
GenerateTreasure();
|
||||
}
|
||||
|
||||
[SerializableField(0)]
|
||||
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
|
||||
private TreasureLevel _level;
|
||||
|
||||
[SerializableField(1)]
|
||||
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
|
||||
private TimeSpan _minSpawnTime;
|
||||
|
||||
[SerializableField(2)]
|
||||
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
|
||||
private TimeSpan _maxSpawnTime;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public override bool Locked
|
||||
{
|
||||
get => base.Locked;
|
||||
set
|
||||
{
|
||||
Level1,
|
||||
Level2,
|
||||
Level3,
|
||||
Level4,
|
||||
Level5,
|
||||
Level6
|
||||
}
|
||||
|
||||
private TreasureResetTimer m_ResetTimer;
|
||||
|
||||
public BaseTreasureChest(int itemID, TreasureLevel level = TreasureLevel.Level2)
|
||||
: base(itemID)
|
||||
{
|
||||
Level = level;
|
||||
Locked = true;
|
||||
Movable = false;
|
||||
|
||||
SetLockLevel();
|
||||
GenerateTreasure();
|
||||
}
|
||||
|
||||
public BaseTreasureChest(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public TreasureLevel Level { get; set; }
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public short MaxSpawnTime { get; set; } = 60;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public short MinSpawnTime { get; set; } = 10;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public override bool Locked
|
||||
{
|
||||
get => base.Locked;
|
||||
set
|
||||
if (base.Locked != value)
|
||||
{
|
||||
if (base.Locked != value)
|
||||
base.Locked = value;
|
||||
|
||||
if (!value)
|
||||
{
|
||||
base.Locked = value;
|
||||
|
||||
if (!value)
|
||||
{
|
||||
StartResetTimer();
|
||||
}
|
||||
StartResetTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsDecoContainer => false;
|
||||
|
||||
public override string DefaultName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Locked)
|
||||
{
|
||||
return "a locked treasure chest";
|
||||
}
|
||||
|
||||
return "a treasure chest";
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0);
|
||||
writer.Write((byte)Level);
|
||||
writer.Write(MinSpawnTime);
|
||||
writer.Write(MaxSpawnTime);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
Level = (TreasureLevel)reader.ReadByte();
|
||||
MinSpawnTime = reader.ReadShort();
|
||||
MaxSpawnTime = reader.ReadShort();
|
||||
|
||||
if (!Locked)
|
||||
{
|
||||
StartResetTimer();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void SetLockLevel()
|
||||
{
|
||||
RequiredSkill = Level switch
|
||||
{
|
||||
TreasureLevel.Level1 => LockLevel = 5,
|
||||
TreasureLevel.Level2 => LockLevel = 20,
|
||||
TreasureLevel.Level3 => LockLevel = 50,
|
||||
TreasureLevel.Level4 => LockLevel = 70,
|
||||
TreasureLevel.Level5 => LockLevel = 90,
|
||||
TreasureLevel.Level6 => LockLevel = 100,
|
||||
_ => RequiredSkill
|
||||
};
|
||||
}
|
||||
|
||||
private void StartResetTimer()
|
||||
{
|
||||
if (m_ResetTimer == null)
|
||||
{
|
||||
m_ResetTimer = new TreasureResetTimer(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ResetTimer.Delay = TimeSpan.FromMinutes(Utility.Random(MinSpawnTime, MaxSpawnTime));
|
||||
}
|
||||
|
||||
m_ResetTimer.Start();
|
||||
}
|
||||
|
||||
protected virtual void GenerateTreasure()
|
||||
{
|
||||
var MinGold = 1;
|
||||
var MaxGold = 2;
|
||||
|
||||
switch (Level)
|
||||
{
|
||||
case TreasureLevel.Level1:
|
||||
MinGold = 100;
|
||||
MaxGold = 300;
|
||||
break;
|
||||
|
||||
case TreasureLevel.Level2:
|
||||
MinGold = 300;
|
||||
MaxGold = 600;
|
||||
break;
|
||||
|
||||
case TreasureLevel.Level3:
|
||||
MinGold = 600;
|
||||
MaxGold = 900;
|
||||
break;
|
||||
|
||||
case TreasureLevel.Level4:
|
||||
MinGold = 900;
|
||||
MaxGold = 1200;
|
||||
break;
|
||||
|
||||
case TreasureLevel.Level5:
|
||||
MinGold = 1200;
|
||||
MaxGold = 5000;
|
||||
break;
|
||||
|
||||
case TreasureLevel.Level6:
|
||||
MinGold = 5000;
|
||||
MaxGold = 9000;
|
||||
break;
|
||||
}
|
||||
|
||||
DropItem(new Gold(MinGold, MaxGold));
|
||||
}
|
||||
|
||||
public void ClearContents()
|
||||
{
|
||||
for (var i = Items.Count - 1; i >= 0; --i)
|
||||
{
|
||||
if (i < Items.Count)
|
||||
{
|
||||
Items[i].Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (m_ResetTimer != null)
|
||||
{
|
||||
if (m_ResetTimer.Running)
|
||||
{
|
||||
m_ResetTimer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
Locked = true;
|
||||
ClearContents();
|
||||
GenerateTreasure();
|
||||
}
|
||||
|
||||
private class TreasureResetTimer : Timer
|
||||
{
|
||||
private readonly BaseTreasureChest m_Chest;
|
||||
|
||||
public TreasureResetTimer(BaseTreasureChest chest) : base(
|
||||
TimeSpan.FromMinutes(Utility.Random(chest.MinSpawnTime, chest.MaxSpawnTime))
|
||||
)
|
||||
{
|
||||
m_Chest = chest;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_Chest.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsDecoContainer => false;
|
||||
|
||||
public override string DefaultName => Locked ? "a locked treasure chest" : "a treasure chest";
|
||||
|
||||
[AfterDeserialization]
|
||||
private void AfterDeserialization()
|
||||
{
|
||||
if (!Locked)
|
||||
{
|
||||
StartResetTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private void Deserialize(IGenericReader reader, int version)
|
||||
{
|
||||
_level = (TreasureLevel)reader.ReadByte();
|
||||
_minSpawnTime = TimeSpan.FromMinutes(reader.ReadShort());
|
||||
_maxSpawnTime = TimeSpan.FromMinutes(reader.ReadShort());
|
||||
}
|
||||
|
||||
protected virtual void SetLockLevel()
|
||||
{
|
||||
RequiredSkill = _level switch
|
||||
{
|
||||
TreasureLevel.Level1 => LockLevel = 5,
|
||||
TreasureLevel.Level2 => LockLevel = 20,
|
||||
TreasureLevel.Level3 => LockLevel = 50,
|
||||
TreasureLevel.Level4 => LockLevel = 70,
|
||||
TreasureLevel.Level5 => LockLevel = 90,
|
||||
TreasureLevel.Level6 => LockLevel = 100,
|
||||
_ => LockLevel = 120
|
||||
};
|
||||
}
|
||||
|
||||
private void StartResetTimer()
|
||||
{
|
||||
_resetTimer.Cancel();
|
||||
|
||||
var randomDuration = Utility.RandomMinMax(_minSpawnTime.Ticks, _maxSpawnTime.Ticks);
|
||||
Timer.StartTimer(TimeSpan.FromTicks(randomDuration), Reset, out _resetTimer);
|
||||
}
|
||||
|
||||
protected virtual void GenerateTreasure()
|
||||
{
|
||||
var gold = _level switch
|
||||
{
|
||||
TreasureLevel.Level1 => Utility.RandomMinMax(100, 300),
|
||||
TreasureLevel.Level2 => Utility.RandomMinMax(300, 600),
|
||||
TreasureLevel.Level3 => Utility.RandomMinMax(600, 900),
|
||||
TreasureLevel.Level4 => Utility.RandomMinMax(900, 1200),
|
||||
TreasureLevel.Level5 => Utility.RandomMinMax(1200, 5000),
|
||||
_ => Utility.RandomMinMax(5000, 9000),
|
||||
};
|
||||
|
||||
DropItem(new Gold(gold));
|
||||
}
|
||||
|
||||
public void ClearContents()
|
||||
{
|
||||
for (var i = Items.Count - 1; i >= 0; --i)
|
||||
{
|
||||
if (i < Items.Count)
|
||||
{
|
||||
Items[i].Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
_resetTimer.Cancel();
|
||||
Locked = true;
|
||||
ClearContents();
|
||||
GenerateTreasure();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,216 +1,187 @@
|
|||
namespace Server.Items
|
||||
namespace Server.Items;
|
||||
|
||||
[Flippable]
|
||||
[Serializable(0, false)]
|
||||
public partial class ParagonChest : LockableContainer
|
||||
{
|
||||
[Flippable]
|
||||
public class ParagonChest : LockableContainer
|
||||
private static readonly int[] _itemIDs =
|
||||
{
|
||||
private static readonly int[] m_ItemIDs =
|
||||
0x9AB, 0xE40, 0xE41, 0xE7C
|
||||
};
|
||||
|
||||
private static readonly int[] _hues =
|
||||
{
|
||||
0x0, 0x455, 0x47E, 0x89F, 0x8A5, 0x8AB,
|
||||
0x966, 0x96D, 0x972, 0x973, 0x979
|
||||
};
|
||||
|
||||
[InternString]
|
||||
[SerializableField(0, "private", "private")]
|
||||
private string _name;
|
||||
|
||||
[Constructible]
|
||||
public ParagonChest(string name, int level) : base(_itemIDs.RandomElement())
|
||||
{
|
||||
_name = name;
|
||||
Hue = _hues.RandomElement();
|
||||
Fill(level);
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
LabelTo(from, 1063449, _name);
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1063449, _name);
|
||||
}
|
||||
|
||||
private static void GetRandomAOSStats(out int attributeCount, out int min, out int max)
|
||||
{
|
||||
var rnd = Utility.Random(15);
|
||||
|
||||
if (rnd < 1)
|
||||
{
|
||||
0x9AB, 0xE40, 0xE41, 0xE7C
|
||||
attributeCount = Utility.RandomMinMax(2, 6);
|
||||
min = 20;
|
||||
max = 70;
|
||||
}
|
||||
else if (rnd < 3)
|
||||
{
|
||||
attributeCount = Utility.RandomMinMax(2, 4);
|
||||
min = 20;
|
||||
max = 50;
|
||||
}
|
||||
else if (rnd < 6)
|
||||
{
|
||||
attributeCount = Utility.RandomMinMax(2, 3);
|
||||
min = 20;
|
||||
max = 40;
|
||||
}
|
||||
else if (rnd < 10)
|
||||
{
|
||||
attributeCount = Utility.RandomMinMax(1, 2);
|
||||
min = 10;
|
||||
max = 30;
|
||||
}
|
||||
else
|
||||
{
|
||||
attributeCount = 1;
|
||||
min = 10;
|
||||
max = 20;
|
||||
}
|
||||
}
|
||||
|
||||
public void Flip()
|
||||
{
|
||||
ItemID = ItemID switch
|
||||
{
|
||||
0x9AB => 0xE7C,
|
||||
0xE7C => 0x9AB,
|
||||
0xE40 => 0xE41,
|
||||
0xE41 => 0xE40,
|
||||
_ => ItemID
|
||||
};
|
||||
}
|
||||
|
||||
private void Fill(int level)
|
||||
{
|
||||
TrapType = TrapType.ExplosionTrap;
|
||||
TrapPower = level * 25;
|
||||
TrapLevel = level;
|
||||
Locked = true;
|
||||
|
||||
RequiredSkill = level switch
|
||||
{
|
||||
1 => 36,
|
||||
2 => 76,
|
||||
3 => 84,
|
||||
4 => 92,
|
||||
5 => 100,
|
||||
_ => RequiredSkill
|
||||
};
|
||||
|
||||
private static readonly int[] m_Hues =
|
||||
{
|
||||
0x0, 0x455, 0x47E, 0x89F, 0x8A5, 0x8AB,
|
||||
0x966, 0x96D, 0x972, 0x973, 0x979
|
||||
};
|
||||
LockLevel = RequiredSkill - 10;
|
||||
MaxLockLevel = RequiredSkill + 40;
|
||||
|
||||
private string m_Name;
|
||||
DropItem(new Gold(level * 200));
|
||||
|
||||
[Constructible]
|
||||
public ParagonChest(string name, int level) : base(m_ItemIDs.RandomElement())
|
||||
for (var i = 0; i < level; ++i)
|
||||
{
|
||||
m_Name = name;
|
||||
Hue = m_Hues.RandomElement();
|
||||
Fill(level);
|
||||
DropItem(Loot.RandomScroll(0, 63, SpellbookType.Regular));
|
||||
}
|
||||
|
||||
public ParagonChest(Serial serial) : base(serial)
|
||||
for (var i = 0; i < level * 2; ++i)
|
||||
{
|
||||
}
|
||||
var item = Core.AOS ? Loot.RandomArmorOrShieldOrWeaponOrJewelry() : Loot.RandomArmorOrShieldOrWeapon();
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
LabelTo(from, 1063449, m_Name);
|
||||
}
|
||||
|
||||
public override void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
base.GetProperties(list);
|
||||
|
||||
list.Add(1063449, m_Name);
|
||||
}
|
||||
|
||||
private static void GetRandomAOSStats(out int attributeCount, out int min, out int max)
|
||||
{
|
||||
var rnd = Utility.Random(15);
|
||||
|
||||
if (rnd < 1)
|
||||
if (item is BaseWeapon weapon)
|
||||
{
|
||||
attributeCount = Utility.RandomMinMax(2, 6);
|
||||
min = 20;
|
||||
max = 70;
|
||||
}
|
||||
else if (rnd < 3)
|
||||
{
|
||||
attributeCount = Utility.RandomMinMax(2, 4);
|
||||
min = 20;
|
||||
max = 50;
|
||||
}
|
||||
else if (rnd < 6)
|
||||
{
|
||||
attributeCount = Utility.RandomMinMax(2, 3);
|
||||
min = 20;
|
||||
max = 40;
|
||||
}
|
||||
else if (rnd < 10)
|
||||
{
|
||||
attributeCount = Utility.RandomMinMax(1, 2);
|
||||
min = 10;
|
||||
max = 30;
|
||||
}
|
||||
else
|
||||
{
|
||||
attributeCount = 1;
|
||||
min = 10;
|
||||
max = 20;
|
||||
}
|
||||
}
|
||||
|
||||
public void Flip()
|
||||
{
|
||||
ItemID = ItemID switch
|
||||
{
|
||||
0x9AB => 0xE7C,
|
||||
0xE7C => 0x9AB,
|
||||
0xE40 => 0xE41,
|
||||
0xE41 => 0xE40,
|
||||
_ => ItemID
|
||||
};
|
||||
}
|
||||
|
||||
private void Fill(int level)
|
||||
{
|
||||
TrapType = TrapType.ExplosionTrap;
|
||||
TrapPower = level * 25;
|
||||
TrapLevel = level;
|
||||
Locked = true;
|
||||
|
||||
RequiredSkill = level switch
|
||||
{
|
||||
1 => 36,
|
||||
2 => 76,
|
||||
3 => 84,
|
||||
4 => 92,
|
||||
5 => 100,
|
||||
_ => RequiredSkill
|
||||
};
|
||||
|
||||
LockLevel = RequiredSkill - 10;
|
||||
MaxLockLevel = RequiredSkill + 40;
|
||||
|
||||
DropItem(new Gold(level * 200));
|
||||
|
||||
for (var i = 0; i < level; ++i)
|
||||
{
|
||||
DropItem(Loot.RandomScroll(0, 63, SpellbookType.Regular));
|
||||
}
|
||||
|
||||
for (var i = 0; i < level * 2; ++i)
|
||||
{
|
||||
Item item;
|
||||
|
||||
if (Core.AOS)
|
||||
{
|
||||
item = Loot.RandomArmorOrShieldOrWeaponOrJewelry();
|
||||
GetRandomAOSStats(out var attributeCount, out var min, out var max);
|
||||
BaseRunicTool.ApplyAttributesTo(weapon, attributeCount, min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = Loot.RandomArmorOrShieldOrWeapon();
|
||||
weapon.DamageLevel = (WeaponDamageLevel)Utility.Random(6);
|
||||
weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random(6);
|
||||
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random(6);
|
||||
}
|
||||
|
||||
if (item is BaseWeapon weapon)
|
||||
{
|
||||
if (Core.AOS)
|
||||
{
|
||||
GetRandomAOSStats(out var attributeCount, out var min, out var max);
|
||||
BaseRunicTool.ApplyAttributesTo(weapon, attributeCount, min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
weapon.DamageLevel = (WeaponDamageLevel)Utility.Random(6);
|
||||
weapon.AccuracyLevel = (WeaponAccuracyLevel)Utility.Random(6);
|
||||
weapon.DurabilityLevel = (WeaponDurabilityLevel)Utility.Random(6);
|
||||
}
|
||||
|
||||
DropItem(weapon);
|
||||
}
|
||||
else if (item is BaseArmor armor)
|
||||
{
|
||||
if (Core.AOS)
|
||||
{
|
||||
GetRandomAOSStats(out var attributeCount, out var min, out var max);
|
||||
BaseRunicTool.ApplyAttributesTo(armor, attributeCount, min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random(6);
|
||||
armor.Durability = (ArmorDurabilityLevel)Utility.Random(6);
|
||||
}
|
||||
|
||||
DropItem(armor);
|
||||
}
|
||||
else if (item is BaseHat hat)
|
||||
{
|
||||
if (Core.AOS)
|
||||
{
|
||||
GetRandomAOSStats(out var attributeCount, out var min, out var max);
|
||||
BaseRunicTool.ApplyAttributesTo(hat, attributeCount, min, max);
|
||||
}
|
||||
|
||||
DropItem(hat);
|
||||
}
|
||||
else if (item is BaseJewel jewel)
|
||||
DropItem(weapon);
|
||||
}
|
||||
else if (item is BaseArmor armor)
|
||||
{
|
||||
if (Core.AOS)
|
||||
{
|
||||
GetRandomAOSStats(out var attributeCount, out var min, out var max);
|
||||
BaseRunicTool.ApplyAttributesTo(jewel, attributeCount, min, max);
|
||||
|
||||
DropItem(jewel);
|
||||
BaseRunicTool.ApplyAttributesTo(armor, attributeCount, min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
armor.ProtectionLevel = (ArmorProtectionLevel)Utility.Random(6);
|
||||
armor.Durability = (ArmorDurabilityLevel)Utility.Random(6);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < level; i++)
|
||||
DropItem(armor);
|
||||
}
|
||||
else if (item is BaseHat hat)
|
||||
{
|
||||
var item = Loot.RandomPossibleReagent();
|
||||
item.Amount = Utility.RandomMinMax(40, 60);
|
||||
DropItem(item);
|
||||
}
|
||||
if (Core.AOS)
|
||||
{
|
||||
GetRandomAOSStats(out var attributeCount, out var min, out var max);
|
||||
BaseRunicTool.ApplyAttributesTo(hat, attributeCount, min, max);
|
||||
}
|
||||
|
||||
for (var i = 0; i < level; i++)
|
||||
DropItem(hat);
|
||||
}
|
||||
else if (item is BaseJewel jewel)
|
||||
{
|
||||
var item = Loot.RandomGem();
|
||||
DropItem(item);
|
||||
GetRandomAOSStats(out var attributeCount, out var min, out var max);
|
||||
BaseRunicTool.ApplyAttributesTo(jewel, attributeCount, min, max);
|
||||
|
||||
DropItem(jewel);
|
||||
}
|
||||
|
||||
DropItem(new TreasureMap(level + 1, Utility.RandomBool() ? Map.Felucca : Map.Trammel));
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
for (var i = 0; i < level; i++)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(m_Name);
|
||||
var item = Loot.RandomPossibleReagent();
|
||||
item.Amount = Utility.RandomMinMax(40, 60);
|
||||
DropItem(item);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
for (var i = 0; i < level; i++)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
m_Name = Utility.Intern(reader.ReadString());
|
||||
var item = Loot.RandomGem();
|
||||
DropItem(item);
|
||||
}
|
||||
|
||||
DropItem(new TreasureMap(level + 1, Utility.RandomBool() ? Map.Felucca : Map.Trammel));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,147 +2,114 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Items
|
||||
namespace Server.Items;
|
||||
|
||||
[Flippable(0xE80, 0x9A8)]
|
||||
[Serializable(0, false)]
|
||||
public partial class StrongBox : BaseContainer, IChoppable
|
||||
{
|
||||
[Flippable(0xE80, 0x9A8)]
|
||||
public class StrongBox : BaseContainer, IChoppable
|
||||
[InvalidateProperties]
|
||||
[SerializableField(0)]
|
||||
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
|
||||
private Mobile _owner;
|
||||
|
||||
[InvalidateProperties]
|
||||
[SerializableField(1)]
|
||||
[SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
|
||||
private BaseHouse _house;
|
||||
|
||||
public StrongBox(Mobile owner, BaseHouse house) : base(0xE80)
|
||||
{
|
||||
private BaseHouse m_House;
|
||||
private Mobile m_Owner;
|
||||
_owner = owner;
|
||||
_house = house;
|
||||
|
||||
public StrongBox(Mobile owner, BaseHouse house) : base(0xE80)
|
||||
MaxItems = 25;
|
||||
}
|
||||
|
||||
public override double DefaultWeight => 100;
|
||||
public override int LabelNumber => 1023712;
|
||||
|
||||
public override int DefaultMaxWeight => 0;
|
||||
|
||||
public override bool Decays => _house == null || _owner?.Deleted != false || !_house.IsCoOwner(_owner);
|
||||
|
||||
public override TimeSpan DecayTime => TimeSpan.FromMinutes(30.0);
|
||||
|
||||
public void OnChop(Mobile from)
|
||||
{
|
||||
if (_house?.Deleted != false || _owner?.Deleted != false || from == _owner || _house.IsOwner(from))
|
||||
{
|
||||
m_Owner = owner;
|
||||
m_House = house;
|
||||
|
||||
MaxItems = 25;
|
||||
}
|
||||
|
||||
public StrongBox(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override double DefaultWeight => 100;
|
||||
public override int LabelNumber => 1023712;
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public Mobile Owner
|
||||
{
|
||||
get => m_Owner;
|
||||
set
|
||||
{
|
||||
m_Owner = value;
|
||||
InvalidateProperties();
|
||||
}
|
||||
}
|
||||
|
||||
public override int DefaultMaxWeight => 0;
|
||||
|
||||
public override bool Decays => m_House == null || m_Owner?.Deleted != false || !m_House.IsCoOwner(m_Owner);
|
||||
|
||||
public override TimeSpan DecayTime => TimeSpan.FromMinutes(30.0);
|
||||
|
||||
public void OnChop(Mobile from)
|
||||
{
|
||||
if (m_House?.Deleted != false || m_Owner?.Deleted != false || from == m_Owner || m_House.IsOwner(from))
|
||||
{
|
||||
Chop(from);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(IGenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
|
||||
writer.Write(m_Owner);
|
||||
writer.Write(m_House);
|
||||
}
|
||||
|
||||
public override void Deserialize(IGenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
var version = reader.ReadInt();
|
||||
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
m_Owner = reader.ReadEntity<Mobile>();
|
||||
m_House = reader.ReadEntity<BaseHouse>();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), Validate);
|
||||
}
|
||||
|
||||
private void Validate()
|
||||
{
|
||||
if (m_Owner != null && m_House?.IsCoOwner(m_Owner) == false)
|
||||
{
|
||||
Console.WriteLine("Warning: Destroying strongbox of {0}", m_Owner.Name);
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddNameProperty(ObjectPropertyList list)
|
||||
{
|
||||
if (m_Owner != null)
|
||||
{
|
||||
list.Add(1042887, m_Owner.Name); // a strong box owned by ~1_OWNER_NAME~
|
||||
}
|
||||
else
|
||||
{
|
||||
base.AddNameProperty(list);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
if (m_Owner != null)
|
||||
{
|
||||
LabelTo(from, 1042887, m_Owner.Name); // a strong box owned by ~1_OWNER_NAME~
|
||||
|
||||
if (CheckContentDisplay(from))
|
||||
{
|
||||
LabelTo(from, "({0} items, {1} stones)", TotalItems, TotalWeight);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsAccessibleTo(Mobile m) =>
|
||||
m_Owner?.Deleted != false || m_House?.Deleted != false ||
|
||||
m.AccessLevel >= AccessLevel.GameMaster ||
|
||||
m == m_Owner && m_House.IsCoOwner(m) && base.IsAccessibleTo(m);
|
||||
|
||||
private void Chop(Mobile from)
|
||||
{
|
||||
Effects.PlaySound(Location, Map, 0x3B3);
|
||||
from.SendLocalizedMessage(500461); // You destroy the item.
|
||||
Destroy();
|
||||
}
|
||||
|
||||
public Container ConvertToStandardContainer()
|
||||
{
|
||||
Container metalBox = new MetalBox();
|
||||
var subItems = new List<Item>(Items);
|
||||
|
||||
foreach (var subItem in subItems)
|
||||
{
|
||||
metalBox.AddItem(subItem);
|
||||
}
|
||||
|
||||
Delete();
|
||||
|
||||
return metalBox;
|
||||
Chop(from);
|
||||
}
|
||||
}
|
||||
|
||||
[AfterDeserialization]
|
||||
private void AfterDeserialization()
|
||||
{
|
||||
Timer.StartTimer(TimeSpan.FromSeconds(1.0), Validate);
|
||||
}
|
||||
|
||||
private void Validate()
|
||||
{
|
||||
if (_owner != null && _house?.IsCoOwner(_owner) == false)
|
||||
{
|
||||
Console.WriteLine("Warning: Destroying strongbox of {0}", _owner.Name);
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddNameProperty(ObjectPropertyList list)
|
||||
{
|
||||
if (_owner != null)
|
||||
{
|
||||
list.Add(1042887, _owner.Name); // a strong box owned by ~1_OWNER_NAME~
|
||||
}
|
||||
else
|
||||
{
|
||||
base.AddNameProperty(list);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
if (_owner == null)
|
||||
{
|
||||
base.OnSingleClick(from);
|
||||
return;
|
||||
}
|
||||
|
||||
LabelTo(from, 1042887, _owner.Name); // a strong box owned by ~1_OWNER_NAME~
|
||||
|
||||
if (CheckContentDisplay(from))
|
||||
{
|
||||
LabelTo(from, "({0} items, {1} stones)", TotalItems, TotalWeight);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsAccessibleTo(Mobile m) =>
|
||||
_owner?.Deleted != false || _house?.Deleted != false ||
|
||||
m.AccessLevel >= AccessLevel.GameMaster ||
|
||||
m == _owner && _house.IsCoOwner(m) && base.IsAccessibleTo(m);
|
||||
|
||||
private void Chop(Mobile from)
|
||||
{
|
||||
Effects.PlaySound(Location, Map, 0x3B3);
|
||||
from.SendLocalizedMessage(500461); // You destroy the item.
|
||||
Destroy();
|
||||
}
|
||||
|
||||
public Container ConvertToStandardContainer()
|
||||
{
|
||||
Container metalBox = new MetalBox();
|
||||
var subItems = new List<Item>(Items);
|
||||
|
||||
foreach (var subItem in subItems)
|
||||
{
|
||||
metalBox.AddItem(subItem);
|
||||
}
|
||||
|
||||
Delete();
|
||||
|
||||
return metalBox;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"version": 1,
|
||||
"type": "Server.Items.BaseTreasureChest",
|
||||
"properties": [
|
||||
{
|
||||
"name": "Level",
|
||||
"type": "Server.Items.BaseTreasureChest.TreasureLevel",
|
||||
"rule": "EnumMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "MinSpawnTime",
|
||||
"type": "System.TimeSpan",
|
||||
"rule": "PrimitiveTypeMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "MaxSpawnTime",
|
||||
"type": "System.TimeSpan",
|
||||
"rule": "PrimitiveTypeMigrationRule"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.ParagonChest",
|
||||
"properties": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "string",
|
||||
"rule": "PrimitiveTypeMigrationRule",
|
||||
"ruleArguments": [
|
||||
"InternString"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
16
Projects/UOContent/Migrations/Server.Items.StrongBox.v0.json
Normal file
16
Projects/UOContent/Migrations/Server.Items.StrongBox.v0.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"version": 0,
|
||||
"type": "Server.Items.StrongBox",
|
||||
"properties": [
|
||||
{
|
||||
"name": "Owner",
|
||||
"type": "Server.Mobile",
|
||||
"rule": "SerializableInterfaceMigrationRule"
|
||||
},
|
||||
{
|
||||
"name": "House",
|
||||
"type": "Server.Multis.BaseHouse",
|
||||
"rule": "SerializableInterfaceMigrationRule"
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue