Revert "Updates Packets & Randomizer (#43)" (#61)

This reverts commit 179cb50557.
This commit is contained in:
Kamron Batman 2019-11-11 08:46:11 -08:00 committed by GitHub
parent 179cb50557
commit c2ecc76457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
588 changed files with 16260 additions and 10926 deletions

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using Server.Gumps;
using Server.Multis;
using Server.Network;
using Server.Prompts;
namespace Server.Items
{

View file

@ -26,8 +26,14 @@ namespace Server.Items
m_Timer.Start();
foreach (AddonComponent c in Components)
if (c.ItemID == 0x2DD9 || c.ItemID == 0x101C || c.ItemID == 0x10A4)
++c.ItemID;
switch (c.ItemID)
{
case 0x2DD9:
case 0x101C:
case 0x10A4:
++c.ItemID;
break;
}
}
public override void Serialize(GenericWriter writer)
@ -63,8 +69,15 @@ namespace Server.Items
m_Timer = null;
foreach (AddonComponent c in Components)
if (c.ItemID == 0x1016 || c.ItemID == 0x101A || c.ItemID == 0x101D || c.ItemID == 0x10A5)
--c.ItemID;
switch (c.ItemID)
{
case 0x1016:
case 0x101A:
case 0x101D:
case 0x10A5:
--c.ItemID;
break;
}
callback?.Invoke(this, from, hue);
}
@ -121,4 +134,4 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -26,8 +26,15 @@ namespace Server.Items
m_Timer.Start();
foreach (AddonComponent c in Components)
if (c.ItemID == 0x1015 || c.ItemID == 0x1019 || c.ItemID == 0x101C || c.ItemID == 0x10A4)
++c.ItemID;
switch (c.ItemID)
{
case 0x1015:
case 0x1019:
case 0x101C:
case 0x10A4:
++c.ItemID;
break;
}
}
public override void Serialize(GenericWriter writer)
@ -64,8 +71,15 @@ namespace Server.Items
m_Timer = null;
foreach (AddonComponent c in Components)
if (c.ItemID == 0x1016 || c.ItemID == 0x101A || c.ItemID == 0x101D || c.ItemID == 0x10A5)
--c.ItemID;
switch (c.ItemID)
{
case 0x1016:
case 0x101A:
case 0x101D:
case 0x10A5:
--c.ItemID;
break;
}
callback?.Invoke(this, from, hue);
}
@ -122,4 +136,4 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -130,10 +130,11 @@ namespace Server.Items
{
List<AddonComponent> components = Components;
int[][] stageTable = m_StageTable;
for (int i = 0; i < components.Count; ++i)
{
AddonComponent component = components[i];
if (component == null)
if (!(components[i] is AddonComponent component))
continue;
int[] itemTable = FindItemTable(component.ItemID);
@ -209,4 +210,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -118,10 +118,11 @@ namespace Server.Items
{
List<AddonComponent> components = Components;
int[][] stageTable = m_StageTable;
for (int i = 0; i < components.Count; ++i)
{
AddonComponent component = components[i];
if (component == null)
if (!(components[i] is AddonComponent component))
continue;
int[] itemTable = FindItemTable(component.ItemID);
@ -197,4 +198,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -39,7 +39,15 @@ namespace Server.Items
public override bool ShareHue => false;
private AddonComponent GetComponent(int itemID, int hue) => new AddonComponent(itemID) {Hue = hue, Name = "jack-o-lantern"};
private AddonComponent GetComponent(int itemID, int hue)
{
AddonComponent ac = new AddonComponent(itemID);
ac.Hue = hue;
ac.Name = "jack-o-lantern";
return ac;
}
public override void Serialize(GenericWriter writer)
{
@ -58,23 +66,17 @@ namespace Server.Items
Timer.DelayCall(TimeSpan.Zero, delegate
{
for (int i = 0; i < Components.Count; ++i)
{
AddonComponent ac = Components[i];
if (ac?.Hue == 2118)
if (Components[i] is AddonComponent ac && ac.Hue == 2118)
ac.Hue = 1161;
}
});
if (version <= 1)
Timer.DelayCall(TimeSpan.Zero, delegate
{
for (int i = 0; i < Components.Count; ++i)
{
AddonComponent ac = Components[i];
if (ac != null)
if (Components[i] is AddonComponent ac)
ac.Name = "jack-o-lantern";
}
});
}
}
}
}

View file

@ -34,8 +34,15 @@ namespace Server.Items
m_Timer.Start();
foreach (AddonComponent c in Components)
if (c.ItemID == 0x1015 || c.ItemID == 0x1019 || c.ItemID == 0x101C || c.ItemID == 0x10A4)
++c.ItemID;
switch (c.ItemID)
{
case 0x1015:
case 0x1019:
case 0x101C:
case 0x10A4:
++c.ItemID;
break;
}
}
public override void Serialize(GenericWriter writer)
@ -72,8 +79,15 @@ namespace Server.Items
m_Timer = null;
foreach (AddonComponent c in Components)
if (c.ItemID == 0x1016 || c.ItemID == 0x101A || c.ItemID == 0x101D || c.ItemID == 0x10A5)
--c.ItemID;
switch (c.ItemID)
{
case 0x1016:
case 0x101A:
case 0x101D:
case 0x10A5:
--c.ItemID;
break;
}
callback?.Invoke(this, from, hue);
}
@ -130,4 +144,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -26,8 +26,15 @@ namespace Server.Items
m_Timer.Start();
foreach (AddonComponent c in Components)
if (c.ItemID == 0x1015 || c.ItemID == 0x1019 || c.ItemID == 0x101C || c.ItemID == 0x10A4)
++c.ItemID;
switch (c.ItemID)
{
case 0x1015:
case 0x1019:
case 0x101C:
case 0x10A4:
++c.ItemID;
break;
}
}
public override void Serialize(GenericWriter writer)
@ -64,8 +71,15 @@ namespace Server.Items
m_Timer = null;
foreach (AddonComponent c in Components)
if (c.ItemID == 0x1016 || c.ItemID == 0x101A || c.ItemID == 0x101D || c.ItemID == 0x10A5)
--c.ItemID;
switch (c.ItemID)
{
case 0x1016:
case 0x101A:
case 0x101D:
case 0x10A5:
--c.ItemID;
break;
}
callback?.Invoke(this, from, hue);
}
@ -122,4 +136,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -597,7 +597,8 @@ namespace Server.Items
UpdateWaterState();
// reward
m_RewardAvailable |= LiveCreatures > 0;
if (LiveCreatures > 0)
m_RewardAvailable = true;
}
else
{
@ -605,12 +606,12 @@ namespace Server.Items
if (OptimalState && LiveCreatures < MaxLiveCreatures)
if (Utility.RandomDouble() < 0.005 * LiveCreatures)
{
BaseFish fish;
int message;
BaseFish fish = null;
int message = 0;
switch (Utility.Random(6))
{
default:
case 0:
{
message = 1074371; // Brine shrimp have hatched overnight in the tank.
fish = new BrineShrimp();

View file

@ -436,8 +436,9 @@ namespace Server.Items
BaseEnergyResistance + GetProtOffset() + GetResourceAttrs().ArmorEnergyResist + m_EnergyBonus;
[CommandProperty(AccessLevel.GameMaster)]
public ArmorBodyType BodyPosition =>
Layer switch
public ArmorBodyType BodyPosition
{
get
{
return Layer switch
{
@ -1143,7 +1144,8 @@ namespace Server.Items
if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
SkillBonuses = new AosSkillBonuses(this, reader);
PlayerConstructed |= GetSaveFlag(flags, SaveFlag.PlayerConstructed);
if (GetSaveFlag(flags, SaveFlag.PlayerConstructed))
PlayerConstructed = true;
break;
}
@ -1269,7 +1271,8 @@ namespace Server.Items
}
}
SkillBonuses ??= new AosSkillBonuses(this);
if (SkillBonuses == null)
SkillBonuses = new AosSkillBonuses(this);
Mobile m = Parent as Mobile;
@ -1296,11 +1299,17 @@ namespace Server.Items
m?.CheckStatTimers();
PlayerConstructed |= version < 7; // we don't know, so, assume it's crafted
if (version < 7)
PlayerConstructed = true; // we don't know, so, assume it's crafted
}
public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted) =>
Ethic.CheckTrade(@from, to, newOwner, this) && base.AllowSecureTrade(@from, to, newOwner, accepted);
public override bool AllowSecureTrade(Mobile from, Mobile to, Mobile newOwner, bool accepted)
{
if (!Ethic.CheckTrade(from, to, newOwner, this))
return false;
return base.AllowSecureTrade(from, to, newOwner, accepted);
}
public override bool CanEquip(Mobile from)
{
@ -1365,10 +1374,19 @@ namespace Server.Items
return base.CanEquip(from);
}
public override bool CheckPropertyConfliction(Mobile m) =>
base.CheckPropertyConfliction(m) || (Layer == Layer.Pants
? m.FindItemOnLayer(Layer.InnerLegs) != null
: Layer == Layer.Shirt && m.FindItemOnLayer(Layer.InnerTorso) != null);
public override bool CheckPropertyConfliction(Mobile m)
{
if (base.CheckPropertyConfliction(m))
return true;
if (Layer == Layer.Pants)
return m.FindItemOnLayer(Layer.InnerLegs) != null;
if (Layer == Layer.Shirt)
return m.FindItemOnLayer(Layer.InnerTorso) != null;
return false;
}
public override bool OnEquip(Mobile from)
{
@ -1459,9 +1477,25 @@ namespace Server.Items
}
}
public override bool AllowEquippedCast(Mobile from) => base.AllowEquippedCast(@from) || Attributes.SpellChanneling != 0;
public override bool AllowEquippedCast(Mobile from)
{
if (base.AllowEquippedCast(from))
return true;
public virtual int GetLuckBonus() => CraftResources.GetInfo(m_Resource)?.AttributeInfo?.ArmorLuck ?? 0;
return Attributes.SpellChanneling != 0;
}
public virtual int GetLuckBonus()
{
CraftResourceInfo resInfo = CraftResources.GetInfo(m_Resource);
CraftAttributeInfo attrInfo = resInfo?.AttributeInfo;
if (attrInfo == null)
return 0;
return attrInfo.ArmorLuck;
}
public override void GetProperties(ObjectPropertyList list)
{
@ -1631,7 +1665,9 @@ namespace Server.Items
if (attrs.Count == 0 && Crafter == null && Name != null)
return;
EquipmentPackets.SendDisplayEquipmentInfo(from.NetState, this, number, m_Crafter, false, attrs);
EquipmentInfo eqInfo = new EquipmentInfo(number, m_Crafter, false, attrs.ToArray());
from.Send(new DisplayEquipmentInfo(this, eqInfo));
}
[Flags]

View file

@ -1,5 +1,3 @@
using System;
namespace Server.Items
{
public class ElvenGlasses : BaseArmor
@ -122,14 +120,16 @@ namespace Server.Items
SaveFlag flags = (SaveFlag)reader.ReadInt();
WeaponAttributes = GetSaveFlag(flags, SaveFlag.WeaponAttributes) ? new AosWeaponAttributes(this, reader) : new AosWeaponAttributes(this);
if (GetSaveFlag(flags, SaveFlag.WeaponAttributes))
WeaponAttributes = new AosWeaponAttributes(this, reader);
else
WeaponAttributes = new AosWeaponAttributes(this);
}
[Flags]
private enum SaveFlag
{
None = 0x00000000,
WeaponAttributes = 0x00000001
}
}
}
}

View file

@ -33,8 +33,9 @@ namespace Server.Items
[CommandProperty(AccessLevel.GameMaster)]
public HeadType HeadType{ get; set; }
public override string DefaultName =>
PlayerName == null ? base.DefaultName : HeadType switch
public override string DefaultName
{
get
{
if (PlayerName == null)
return base.DefaultName;

View file

@ -57,17 +57,19 @@ namespace Server.Items
if (content == null)
{
Pages = new BookPageInfo[Math.Min(pageCount, 255)];
Pages = new BookPageInfo[pageCount];
for (int i = 0; i < Pages.Length; ++i)
Pages[i] = new BookPageInfo();
}
else
{
Pages = content.Copy();
}
}
// Intended for defined books only
public BaseBook(int itemID, bool writable) : this(itemID, 0, writable)
public BaseBook(int itemID, bool writable) : this(itemID, 0)
{
}
@ -228,7 +230,12 @@ namespace Server.Items
Pages[i] = new BookPageInfo(reader);
}
else
Pages = content?.Copy() ?? new BookPageInfo[0];
{
if (content != null)
Pages = content.Copy();
else
Pages = new BookPageInfo[0];
}
break;
}
@ -247,7 +254,14 @@ namespace Server.Items
Pages[i] = new BookPageInfo(reader);
}
else
Pages = DefaultContent?.Copy() ?? new BookPageInfo[0];
{
BookContent content = DefaultContent;
if (content != null)
Pages = content.Copy();
else
Pages = new BookPageInfo[0];
}
break;
}
@ -293,8 +307,8 @@ namespace Server.Items
Author = from.Name;
}
BookPackets.SendBookHeader(from.NetState, from, this);
BookPackets.SendBookPageDetails(from.NetState, this);
from.Send(new BookHeader(from, this));
from.Send(new BookPageDetails(this));
}
public static void Initialize()
@ -336,14 +350,14 @@ namespace Server.Items
if (titleLength > 60)
return;
string title = pvSrc.ReadStringSafe(titleLength);
string title = pvSrc.ReadUTF8StringSafe(titleLength);
int authorLength = pvSrc.ReadUInt16();
if (authorLength > 30)
return;
string author = pvSrc.ReadStringSafe(authorLength);
string author = pvSrc.ReadUTF8StringSafe(authorLength);
book.Title = Utility.FixHtml(title);
book.Author = Utility.FixHtml(author);
@ -366,23 +380,31 @@ namespace Server.Items
{
int index = pvSrc.ReadUInt16();
if (index < 1 || index > book.PagesCount)
return;
if (index >= 1 && index <= book.PagesCount)
{
--index;
--index;
int lineCount = pvSrc.ReadUInt16();
int lineCount = pvSrc.ReadUInt16();
if (lineCount <= 8)
{
string[] lines = new string[lineCount];
if (lineCount > 8)
return;
for (int j = 0; j < lineCount; ++j)
if ((lines[j] = pvSrc.ReadUTF8StringSafe()).Length >= 80)
return;
string[] lines = new string[lineCount];
for (int j = 0; j < lineCount; ++j)
if ((lines[j] = pvSrc.ReadUTF8StringSafe()).Length >= 80)
book.Pages[index].Lines = lines;
}
else
{
return;
book.Pages[index].Lines = lines;
}
}
else
{
return;
}
}
}
@ -396,4 +418,58 @@ namespace Server.Items
Content = 0x08
}
}
public sealed class BookPageDetails : Packet
{
public BookPageDetails(BaseBook book) : base(0x66)
{
EnsureCapacity(256);
m_Stream.Write(book.Serial);
m_Stream.Write((ushort)book.PagesCount);
for (int i = 0; i < book.PagesCount; ++i)
{
BookPageInfo page = book.Pages[i];
m_Stream.Write((ushort)(i + 1));
m_Stream.Write((ushort)page.Lines.Length);
for (int j = 0; j < page.Lines.Length; ++j)
{
byte[] buffer = Utility.UTF8.GetBytes(page.Lines[j]);
m_Stream.Write(buffer, 0, buffer.Length);
m_Stream.Write((byte)0);
}
}
}
}
public sealed class BookHeader : Packet
{
public BookHeader(Mobile from, BaseBook book) : base(0xD4)
{
string title = book.Title ?? "";
string author = book.Author ?? "";
byte[] titleBuffer = Utility.UTF8.GetBytes(title);
byte[] authorBuffer = Utility.UTF8.GetBytes(author);
EnsureCapacity(15 + titleBuffer.Length + authorBuffer.Length);
m_Stream.Write(book.Serial);
m_Stream.Write(true);
m_Stream.Write(book.Writable && from.InRange(book.GetWorldLocation(), 1));
m_Stream.Write((ushort)book.PagesCount);
m_Stream.Write((ushort)(titleBuffer.Length + 1));
m_Stream.Write(titleBuffer, 0, titleBuffer.Length);
m_Stream.Write((byte)0); // terminate
m_Stream.Write((ushort)(authorBuffer.Length + 1));
m_Stream.Write(authorBuffer, 0, authorBuffer.Length);
m_Stream.Write((byte)0); // terminate
}
}
}

View file

@ -13,8 +13,8 @@ namespace Server.Items
}
[Constructible]
public BrownBook(string title, string author, int pageCount, bool writable) :
base(0xFEF, title, author, pageCount, writable)
public BrownBook(string title, string author, int pageCount, bool writable) : base(0xFEF, title, author, pageCount,
writable)
{
}
@ -41,4 +41,4 @@ namespace Server.Items
writer.Write(0); // version
}
}
}
}

View file

@ -1,80 +0,0 @@
using System;
using Server.Buffers;
using Server.Items;
namespace Server.Network
{
public static class BookPackets
{
public static void SendBookPageDetails(NetState ns, BaseBook book)
{
if (ns == null)
return;
// 80 chars per line (240 bytes)
// 8 lines per page
// Max: 77049 bytes
int length = 9;
for (int i = 0; i < book.PagesCount; i++)
length += 1926 * book.Pages[i].Lines.Length;
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
writer.Write((byte)0x66); // Packet ID
writer.Position += 2; // Dynamic Length
writer.Write(book.Serial);
writer.Write((ushort)book.PagesCount);
for (int i = 0; i < book.PagesCount; i++)
{
BookPageInfo page = book.Pages[i];
length = Math.Min(page.Lines.Length, 8);
writer.Write((ushort)(i + 1));
writer.Write((ushort)length);
for (int j = 0; j < length; j++)
{
string line = page.Lines[j];
writer.WriteUTF8Null(line);
}
}
writer.Position = 1;
writer.Write((ushort)writer.WrittenCount);
ns.Send(writer.Span);
}
public static void SendBookHeader(NetState ns, Mobile from, BaseBook book)
{
if (ns == null)
return;
string title = book.Title ?? "";
string author = book.Author ?? "";
int length = 17 + title.Length + author.Length;
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
writer.Write((byte)0xD4); // Packet ID
writer.Position += 2; // Dynamic Length
writer.Write(book.Serial);
writer.Write((byte)0x1); // true
writer.Write(book.Writable && from.InRange(book.GetWorldLocation(), 1));
writer.Write((ushort)book.PagesCount);
writer.Write((ushort)title.Length + 1);
writer.WriteAsciiNull(title);
writer.Write((ushort)author.Length + 1);
writer.WriteAsciiNull(author);
writer.Position = 1;
writer.Write((ushort)writer.WrittenCount);
ns.Send(writer.Span);
}
}
}

View file

@ -13,8 +13,8 @@ namespace Server.Items
}
[Constructible]
public RedBook(string title, string author, int pageCount, bool writable) :
base(0xFF1, title, author, pageCount, writable)
public RedBook(string title, string author, int pageCount, bool writable) : base(0xFF1, title, author, pageCount,
writable)
{
}
@ -41,4 +41,4 @@ namespace Server.Items
writer.Write(0); // version
}
}
}
}

View file

@ -13,8 +13,8 @@ namespace Server.Items
}
[Constructible]
public TanBook(string title, string author, int pageCount, bool writable) :
base(0xFF0, title, author, pageCount, writable)
public TanBook(string title, string author, int pageCount, bool writable) : base(0xFF0, title, author, pageCount,
writable)
{
}
@ -41,4 +41,4 @@ namespace Server.Items
writer.Write(0); // version
}
}
}
}

View file

@ -724,7 +724,9 @@ namespace Server.Items
int number;
if (Name == null)
{
number = LabelNumber;
}
else
{
LabelTo(from, Name);
@ -734,7 +736,9 @@ namespace Server.Items
if (attrs.Count == 0 && Crafter == null && Name != null)
return;
EquipmentPackets.SendDisplayEquipmentInfo(from.NetState, this, number, m_Crafter, false, attrs);
EquipmentInfo eqInfo = new EquipmentInfo(number, m_Crafter, false, attrs.ToArray());
from.Send(new DisplayEquipmentInfo(this, eqInfo));
}
public virtual void AddEquipInfoAttributes(Mobile from, List<EquipInfoAttribute> attrs)
@ -900,13 +904,25 @@ namespace Server.Items
else
m_Resource = DefaultResource;
Attributes = GetSaveFlag(flags, SaveFlag.Attributes) ? new AosAttributes(this, reader) : new AosAttributes(this);
if (GetSaveFlag(flags, SaveFlag.Attributes))
Attributes = new AosAttributes(this, reader);
else
Attributes = new AosAttributes(this);
ClothingAttributes = GetSaveFlag(flags, SaveFlag.ClothingAttributes) ? new AosArmorAttributes(this, reader) : new AosArmorAttributes(this);
if (GetSaveFlag(flags, SaveFlag.ClothingAttributes))
ClothingAttributes = new AosArmorAttributes(this, reader);
else
ClothingAttributes = new AosArmorAttributes(this);
SkillBonuses = GetSaveFlag(flags, SaveFlag.SkillBonuses) ? new AosSkillBonuses(this, reader) : new AosSkillBonuses(this);
if (GetSaveFlag(flags, SaveFlag.SkillBonuses))
SkillBonuses = new AosSkillBonuses(this, reader);
else
SkillBonuses = new AosSkillBonuses(this);
Resistances = GetSaveFlag(flags, SaveFlag.Resistances) ? new AosElementAttributes(this, reader) : new AosElementAttributes(this);
if (GetSaveFlag(flags, SaveFlag.Resistances))
Resistances = new AosElementAttributes(this, reader);
else
Resistances = new AosElementAttributes(this);
if (GetSaveFlag(flags, SaveFlag.MaxHitPoints))
m_MaxHitPoints = reader.ReadEncodedInt();
@ -927,7 +943,8 @@ namespace Server.Items
else
m_StrReq = -1;
PlayerConstructed |= GetSaveFlag(flags, SaveFlag.PlayerConstructed);
if (GetSaveFlag(flags, SaveFlag.PlayerConstructed))
PlayerConstructed = true;
break;
}
@ -965,7 +982,8 @@ namespace Server.Items
}
}
PlayerConstructed |= version < 2; // we don't know, so, assume it's crafted
if (version < 2)
PlayerConstructed = true; // we don't know, so, assume it's crafted
if (version < 3)
{

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using Server.Engines.Craft;
using Server.Misc;
using Server.Network;
namespace Server.Items
{

View file

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Server.ContextMenus;
using Server.Mobiles;
using Server.Multis;
@ -17,17 +16,40 @@ namespace Server.Items
{
}
public override int DefaultMaxWeight => IsSecure ? 0 : base.DefaultMaxWeight;
public override int DefaultMaxWeight
{
get
{
if (IsSecure)
return 0;
public override bool IsAccessibleTo(Mobile m) =>
BaseHouse.CheckAccessible(m, this) && base.IsAccessibleTo(m);
return base.DefaultMaxWeight;
}
}
public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) =>
(!IsSecure || BaseHouse.CheckHold(m, this, item, message, checkItems, plusItems, plusWeight)) &&
base.CheckHold(m, item, message, checkItems, plusItems, plusWeight);
public override bool IsAccessibleTo(Mobile m)
{
if (!BaseHouse.CheckAccessible(m, this))
return false;
public override bool CheckItemUse(Mobile from, Item item) =>
IsDecoContainer && item is BaseBook || base.CheckItemUse(from, item);
return base.IsAccessibleTo(m);
}
public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight)
{
if (IsSecure && !BaseHouse.CheckHold(m, this, item, message, checkItems, plusItems, plusWeight))
return false;
return base.CheckHold(m, item, message, checkItems, plusItems, plusWeight);
}
public override bool CheckItemUse(Mobile from, Item item)
{
if (IsDecoContainer && item is BaseBook)
return true;
return base.CheckItemUse(from, item);
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{
@ -57,8 +79,13 @@ namespace Server.Items
List<Item> list = Items;
if (list.Any(item => !(item is Container) && item.StackWith(from, dropped, false)))
return true;
for (int i = 0; i < list.Count; ++i)
{
Item item = list[i];
if (!(item is Container) && item.StackWith(from, dropped, false))
return true;
}
DropItem(dropped);
@ -909,4 +936,4 @@ namespace Server.Items
Weight = -1;
}
}
}
}

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Mobiles;
namespace Server.Items
@ -96,7 +95,14 @@ namespace Server.Items
}
}
public int GetItemsCount() => Items.Sum(item => item.Amount);
public int GetItemsCount()
{
int count = 0;
foreach (Item item in Items) count += item.Amount;
return count;
}
public void CheckRespawn()
{
@ -1501,9 +1507,7 @@ namespace Server.Items
Mobile nearest = null;
FillableContent content = null;
IPooledEnumerable eable = map.GetMobilesInRange(loc, 20);
foreach (Mobile mob in eable)
foreach (Mobile mob in map.GetMobilesInRange(loc, 20))
{
if (nearest != null && mob.GetDistanceToSqrt(loc) > nearest.GetDistanceToSqrt(loc) &&
!(nearest is Cobbler && mob is Provisioner))
@ -1516,8 +1520,6 @@ namespace Server.Items
}
}
eable.Free();
return content;
}
}

View file

@ -264,7 +264,7 @@ namespace Server.Items
inaccessible = true;
}
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, number);
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, number, "", ""));
}
return inaccessible;
@ -323,4 +323,4 @@ namespace Server.Items
LabelTo(from, 1041645); //recovered from a shipwreck
}
}
}
}

View file

@ -126,11 +126,16 @@ namespace Server.Items
#region Checks
private bool Resmeltables() => //Where context menu checks for metal items and dragon barding deeds
Items.Select(i => i?.Deleted == false &&
(i is BaseWeapon weapon && CraftResources.GetType(weapon.Resource) == CraftResourceType.Metal ||
i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Metal ||
i is DragonBardingDeed)).FirstOrDefault();
private bool Resmeltables() //Where context menu checks for metal items and dragon barding deeds
{
foreach (Item i in Items)
return i?.Deleted == false && (
i is BaseWeapon weapon && CraftResources.GetType(weapon.Resource) == CraftResourceType.Metal ||
i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Metal ||
i is DragonBardingDeed);
return false;
}
private bool Scissorables() //Where context menu checks for Leather items and cloth items
{

View file

@ -46,7 +46,7 @@ namespace Server.Items
if (Deleted || !to.CanSee(this))
return;
Packets.SendMessageLocalized(to.NetState, Serial, ItemID, MessageType.Regular, hue, 3, number);
to.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, hue, 3, number, "", ""));
}
private void SendMessageTo(Mobile to, string text, int hue)
@ -54,7 +54,7 @@ namespace Server.Items
if (Deleted || !to.CanSee(this))
return;
Packets.SendUnicodeMessage(to.NetState,Serial, ItemID, MessageType.Regular, hue, 3, "ENU", "", text);
to.Send(new UnicodeMessage(Serial, ItemID, MessageType.Regular, hue, 3, "ENU", "", text));
}
public virtual bool ExecuteTrap(Mobile from)
@ -91,7 +91,7 @@ namespace Server.Items
from.LocalOverheadMessage(MessageType.Regular, 0x2A, 503000);
}
Effects.SendLocationEffect(loc, facet, 0x36BD, 15);
Effects.SendLocationEffect(loc, facet, 0x36BD, 15, 10);
Effects.PlaySound(loc, facet, 0x307);
break;
@ -129,7 +129,7 @@ namespace Server.Items
AOS.Damage(from, damage, 100, 0, 0, 0, 0);
// A dart embeds itself in your flesh!
// A dart imbeds itself in your flesh!
from.LocalOverheadMessage(MessageType.Regular, 0x62, 502998);
}
@ -221,4 +221,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.ContextMenus;
using Server.Engines.PartySystem;
using Server.Gumps;
@ -40,7 +39,7 @@ namespace Server.Items
public override int LabelNumber => 3000541;
public static Type[] Artifacts { get; } =
public static Type[] Artifacts{ get; } =
{
typeof(CandelabraOfSouls), typeof(GoldBricks), typeof(PhillipsWoodenSteed),
typeof(ArcticDeathDealer), typeof(BlazeOfDeath), typeof(BurglarsBandana),
@ -52,18 +51,18 @@ namespace Server.Items
};
[CommandProperty(AccessLevel.GameMaster)]
public int Level { get; set; }
public int Level{ get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Owner { get; set; }
public Mobile Owner{ get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime DeleteTime { get; private set; }
public DateTime DeleteTime{ get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool Temporary { get; set; }
public bool Temporary{ get; set; }
public List<Mobile> Guardians { get; private set; }
public List<Mobile> Guardians{ get; private set; }
public override bool IsDecoContainer => false;
@ -197,11 +196,18 @@ namespace Server.Items
};
}
else
{
numberItems = level * 6;
}
for (int i = 0; i < numberItems; ++i)
{
Item item = Core.AOS ? Loot.RandomArmorOrShieldOrWeaponOrJewelry() : Loot.RandomArmorOrShieldOrWeapon();
Item item;
if (Core.AOS)
item = Loot.RandomArmorOrShieldOrWeaponOrJewelry();
else
item = Loot.RandomArmorOrShieldOrWeapon();
if (item is BaseWeapon weapon)
{
@ -290,12 +296,13 @@ namespace Server.Items
if (Level == 0 && from.AccessLevel < AccessLevel.GameMaster)
{
if (Guardians.Any(m => m.Alive))
{
from.SendLocalizedMessage(
1046448); // You must first kill the guardians before you may open this chest.
return true;
}
foreach (Mobile m in Guardians)
if (m.Alive)
{
from.SendLocalizedMessage(
1046448); // You must first kill the guardians before you may open this chest.
return true;
}
LockPick(from);
return false;
@ -388,29 +395,29 @@ namespace Server.Items
switch (version)
{
case 2:
{
Guardians = reader.ReadStrongMobileList();
Temporary = reader.ReadBool();
{
Guardians = reader.ReadStrongMobileList();
Temporary = reader.ReadBool();
goto case 1;
}
goto case 1;
}
case 1:
{
Owner = reader.ReadMobile();
{
Owner = reader.ReadMobile();
goto case 0;
}
goto case 0;
}
case 0:
{
Level = reader.ReadInt();
DeleteTime = reader.ReadDeltaTime();
m_Lifted = reader.ReadStrongItemList();
{
Level = reader.ReadInt();
DeleteTime = reader.ReadDeltaTime();
m_Lifted = reader.ReadStrongItemList();
if (version < 2)
Guardians = new List<Mobile>();
if (version < 2)
Guardians = new List<Mobile>();
break;
}
break;
}
}
if (!Temporary)

View file

@ -56,7 +56,9 @@ namespace Server.Items
new[] { 1074393, 1074390, 0x2fd0, 0x2fcd, 0xedde, 0xc6cb } // buns, long
};
// racial arrays are: cliloc_F, cliloc_M, ItemID_F, ItemID_M, gump_img_F, gump_img_M
/*
racial arrays are: cliloc_F, cliloc_M, ItemID_F, ItemID_M, gump_img_F, gump_img_M
*/
private int[][] HumanArray = /* why on earth cant these utilies be consistent with hex/dec */
{
new[] { 0 },
@ -71,8 +73,10 @@ namespace Server.Items
new[] { 1011050, 1011050, 0x204A, 0x204A, 0xED29, 0xED29 }, // Topknot
new[] { 1011396, 1011396, 0x2047, 0x2047, 0xed25, 0xc618 } // Curly
};
/*
gump data: bgX, bgY, htmlX, htmlY, imgX, imgY, butX, butY
*/
// gump data: bgX, bgY, htmlX, htmlY, imgX, imgY, butX, butY
private int[][] LayoutArray =
{
new[] { 0 }, /* padding: its more efficient than code to ++ the index/buttonid */

View file

@ -91,11 +91,11 @@ namespace Server.Items
Point3D loc = new Point3D(p);
if (p is StaticTarget target)
loc.Z -= TileData.ItemTable[target.ItemID].CalcHeight;
/* NOTE: OSI does not properly normalize Z positioning here.
* A side affect is that you can only place on floors (due to the CanFit call).
* That functionality may be desired. And so, it's included in this script.
*/
loc.Z -= TileData.ItemTable[target.ItemID]
.CalcHeight; /* NOTE: OSI does not properly normalize Z positioning here.
* A side affect is that you can only place on floors (due to the CanFit call).
* That functionality may be desired. And so, it's included in this script.
*/
if (ValidatePlacement(from, loc))
EndPlace(from, type, loc);

View file

@ -1,15 +0,0 @@
namespace Server.Items
{
public class EquipInfoAttribute
{
public EquipInfoAttribute(int number, int charges = -1)
{
Number = number;
Charges = charges;
}
public int Number { get; }
public int Charges { get; }
}
}

View file

@ -1,56 +0,0 @@
using System.Collections.Generic;
using Server.Buffers;
using Server.Items;
namespace Server.Network
{
public static class EquipmentPackets
{
public static void SendDisplayEquipmentInfo(NetState ns, Item item, int number, Mobile crafter, bool unidentified, ICollection<EquipInfoAttribute> attrs)
{
int packetLength = 17 +
(crafter != null ? 6 + crafter.RawName?.Length ?? 0 : 0) +
(unidentified ? 4 : 0) + attrs.Count * 6;
SpanWriter writer = new SpanWriter(stackalloc byte[packetLength]);
writer.Write((byte)0xBF); // Extended Command Packet ID
writer.Write((ushort)packetLength); // Dynamic Length
writer.Write((short)0x10); // Command
writer.Write(item.Serial);
writer.Write(number);
if (crafter != null)
{
// TODO: We should not be referencing the crafter.
// They could have been deleted and the crafted by should still show up.
string name = crafter.RawName;
writer.Write(-3);
if (name == null)
writer.Write((ushort)0);
else
{
int length = name.Length;
writer.Write((ushort)length);
writer.WriteAsciiFixed(name, length);
}
}
if (unidentified)
writer.Write(-4);
foreach (EquipInfoAttribute attr in attrs)
{
writer.Write(attr.Number);
writer.Write((short)attr.Charges);
}
writer.Write(-1);
ns.Send(writer.Span);
}
}
}

View file

@ -43,13 +43,13 @@ namespace Server.Items
}
#if false
public override void OnDoubleClick( Mobile from )
{
if ( !Movable )
return;
public override void OnDoubleClick( Mobile from )
{
if ( !Movable )
return;
from.Target = new InternalTarget( this );
}
from.Target = new InternalTarget( this );
}
#endif
public static bool IsHeatSource(object targeted)
@ -63,13 +63,22 @@ namespace Server.Items
else
return false;
return itemID == 0xFAC ||
itemID >= 0xDE3 && itemID <= 0xDE9 ||
itemID >= 0x461 && itemID <= 0x48E ||
itemID >= 0x92B && itemID <= 0x96C ||
itemID >= 0x184A && itemID <= 0x184C ||
itemID >= 0x184E && itemID <= 0x1850 ||
itemID >= 0x398C && itemID <= 0x399F;
if (itemID >= 0xDE3 && itemID <= 0xDE9)
return true; // Campfire
if (itemID >= 0x461 && itemID <= 0x48E)
return true; // Sandstone oven/fireplace
if (itemID >= 0x92B && itemID <= 0x96C)
return true; // Stone oven/fireplace
if (itemID == 0xFAC)
return true; // Firepit
if (itemID >= 0x184A && itemID <= 0x184C)
return true; // Heating stand (left)
if (itemID >= 0x184E && itemID <= 0x1850)
return true; // Heating stand (right)
if (itemID >= 0x398C && itemID <= 0x399F)
return true; // Fire field
return false;
}
private class InternalTarget : Target
@ -94,7 +103,9 @@ namespace Server.Items
t.Start();
}
else
{
from.SendLocalizedMessage(500119); // You must wait to perform another action
}
}
}
@ -132,7 +143,9 @@ namespace Server.Items
m_From.PlaySound(0x57);
}
else
{
m_From.SendLocalizedMessage(500686); // You burn the food to a crisp! It's ruined.
}
}
}
}

View file

@ -47,13 +47,13 @@ namespace Server.Items
}
#if false
public override void OnDoubleClick( Mobile from )
{
if ( !Movable )
return;
public override void OnDoubleClick( Mobile from )
{
if ( !Movable )
return;
from.Target = new InternalTarget( this );
}
from.Target = new InternalTarget( this );
}
#endif
private class InternalTarget : Target
@ -135,13 +135,13 @@ namespace Server.Items
}
#if false
public override void OnDoubleClick( Mobile from )
{
if ( !Movable )
return;
public override void OnDoubleClick( Mobile from )
{
if ( !Movable )
return;
from.Target = new InternalTarget( this );
}
from.Target = new InternalTarget( this );
}
#endif
private class InternalTarget : Target
@ -454,9 +454,9 @@ namespace Server.Items
++ItemID;
#if false
this.Delete();
this.Delete();
from.AddToBackpack( new SackFlourOpen() );
from.AddToBackpack( new SackFlourOpen() );
#endif
}
}

View file

@ -72,13 +72,17 @@ namespace Server.Items
{
if (dropped is BasePiece piece && piece.Board == this && base.OnDragDropInto(from, dropped, point))
{
Point3D loc = GetWorldLocation();
Packet p = new PlaySound(0x127, GetWorldLocation());
p.Acquire();
if (RootParent == from)
Packets.SendPlaySound(from.NetState, 0x127, loc);
from.Send(p);
else
foreach (NetState state in GetClientsInRange(2))
Packets.SendPlaySound(state, 0x127, loc);
state.Send(p);
p.Release();
return true;
}

View file

@ -21,8 +21,10 @@ namespace Server.Items
public override void OnDoubleClick(Mobile from)
{
if (from.InRange(GetWorldLocation(), 2))
Roll(from);
if (!from.InRange(GetWorldLocation(), 2))
return;
Roll(from);
}
public void Roll(Mobile from)
@ -43,4 +45,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -76,7 +76,7 @@ namespace Server.Engines.Mahjong
m_SpectatorVision = value;
if (Players.IsInGamePlayer(Players.DealerPosition))
MahjongPackets.SendMahjongGeneralInfo(Players.Dealer.NetState, this);
Players.Dealer.Send(new MahjongGeneralInfo(this));
Players.SendTilesPacket(false, true);
@ -292,4 +292,4 @@ namespace Server.Engines.Mahjong
}
}
}
}
}

View file

@ -6,7 +6,7 @@ namespace Server.Engines.Mahjong
public sealed class MahjongPacketHandlers
{
private static readonly OnMahjongPacketReceive[] m_SubCommandDelegates = new OnMahjongPacketReceive[0x100];
private static OnMahjongPacketReceive[] m_SubCommandDelegates = new OnMahjongPacketReceive[0x100];
public static void RegisterSubCommand(int subCmd, OnMahjongPacketReceive onReceive)
{
@ -80,7 +80,12 @@ namespace Server.Engines.Mahjong
public static void ExitGame(MahjongGame game, NetState state, PacketReader pvSrc)
{
game?.Players.LeaveGame(state.Mobile);
if (game == null)
return;
Mobile from = state.Mobile;
game.Players.LeaveGame(from);
}
public static void GivePoints(MahjongGame game, NetState state, PacketReader pvSrc)
@ -225,4 +230,4 @@ namespace Server.Engines.Mahjong
game.DealerIndicator.Move(new Point2D(x, y), direction, wind);
}
}
}
}

View file

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
namespace Server.Engines.Mahjong
{
@ -83,13 +82,28 @@ namespace Server.Engines.Mahjong
return m_InGame[index];
}
public bool IsInGamePlayer(Mobile mobile) => IsInGamePlayer(GetPlayerIndex(mobile));
public bool IsInGamePlayer(Mobile mobile)
{
int index = GetPlayerIndex(mobile);
return IsInGamePlayer(index);
}
public bool IsSpectator(Mobile mobile) => m_Spectators.Contains(mobile);
public bool IsSpectator(Mobile mobile) => m_Spectators.Contains(mobile);
public int GetScore(int index)
{
if (index < 0 || index >= m_Scores.Length)
return 0;
return m_Scores[index];
}
public bool IsPublic(int index) => index >= 0 && index < m_PublicHand.Length && m_PublicHand[index];
public bool IsPublic(int index)
{
if (index < 0 || index >= m_PublicHand.Length)
return false;
return m_PublicHand[index];
}
public void SetPublic(int index, bool value)
{
@ -108,7 +122,10 @@ namespace Server.Engines.Mahjong
{
List<Mobile> list = new List<Mobile>();
if (players) list.AddRange(m_Players.Where((t, i) => IsInGamePlayer(i)));
if (players)
for (int i = 0; i < m_Players.Length; i++)
if (IsInGamePlayer(i))
list.Add(m_Players[i]);
if (spectators)
list.AddRange(m_Spectators);
@ -152,7 +169,7 @@ namespace Server.Engines.Mahjong
{
m_InGame[i] = false;
MahjongPackets.SendMahjongRelieve(player.NetState, Game);
player.Send(new MahjongRelieve(Game));
SendPlayerExitMessage(player);
UpdateDealer(true);
@ -167,16 +184,20 @@ namespace Server.Engines.Mahjong
Mobile mobile = m_Spectators[i];
if (mobile.NetState == null || mobile.Deleted)
{
m_Spectators.RemoveAt(i);
}
else if (!Game.IsAccessibleTo(mobile) || mobile.Map != Game.Map ||
!mobile.InRange(Game.GetWorldLocation(), 5))
{
m_Spectators.RemoveAt(i);
MahjongPackets.SendMahjongRelieve(mobile.NetState, Game);
mobile.Send(new MahjongRelieve(Game));
}
else
{
i++;
}
}
if (removed && !UpdateSpectators())
@ -255,12 +276,12 @@ namespace Server.Engines.Mahjong
UpdateDealer(false);
if (sendJoinGame)
MahjongPackets.SendMahjongJoinGame(player.NetState, Game);
player.Send(new MahjongJoinGame(Game));
SendPlayersPacket(true, true);
MahjongPackets.SendMahjongGeneralInfo(player.NetState, Game);
MahjongPackets.SendMahjongTilesInfo(player.NetState, Game, player);
player.Send(new MahjongGeneralInfo(Game));
player.Send(new MahjongTilesInfo(Game, player));
if (DealerPosition == index)
SendLocalizedMessage(1062773, player.Name); // ~1_name~ has entered the game as the dealer.
@ -268,14 +289,14 @@ namespace Server.Engines.Mahjong
SendLocalizedMessage(1062772, player.Name); // ~1_name~ has entered the game as a player.
}
private void AddSpectator(Mobile m)
private void AddSpectator(Mobile mobile)
{
if (!IsSpectator(m)) m_Spectators.Add(m);
if (!IsSpectator(mobile)) m_Spectators.Add(mobile);
MahjongPackets.SendMahjongJoinGame(m.NetState, Game);
MahjongPackets.SendMahjongPlayersInfo(m.NetState, Game, m);
MahjongPackets.SendMahjongGeneralInfo(m.NetState, Game);
MahjongPackets.SendMahjongTilesInfo(m.NetState, Game, m);
mobile.Send(new MahjongJoinGame(Game));
mobile.Send(new MahjongPlayersInfo(Game, mobile));
mobile.Send(new MahjongGeneralInfo(Game));
mobile.Send(new MahjongTilesInfo(Game, mobile));
}
public void Join(Mobile mobile)
@ -283,7 +304,9 @@ namespace Server.Engines.Mahjong
int index = GetPlayerIndex(mobile);
if (index >= 0)
{
AddPlayer(mobile, index, true);
}
else
{
int nextSeat = GetNextSeat();
@ -308,7 +331,9 @@ namespace Server.Engines.Mahjong
SendPlayersPacket(true, true);
}
else
{
m_Spectators.Remove(player);
}
}
public void ResetScores(int value)
@ -332,11 +357,13 @@ namespace Server.Engines.Mahjong
m_Scores[toPosition] += amount;
if (Game.ShowScores)
{
SendPlayersPacket(true, true);
}
else
{
MahjongPackets.SendMahjongPlayersInfo(from.NetState, Game, from);
MahjongPackets.SendMahjongPlayersInfo(to.NetState, Game, to);
from.Send(new MahjongPlayersInfo(Game, from));
to.Send(new MahjongPlayersInfo(Game, to));
}
SendLocalizedMessage(1062774,
@ -350,7 +377,7 @@ namespace Server.Engines.Mahjong
return;
if (m_InGame[index])
MahjongPackets.SendMahjongRelieve(player.NetState, Game);
player.Send(new MahjongRelieve(Game));
m_Players[index] = null;
@ -374,9 +401,9 @@ namespace Server.Engines.Mahjong
DealerPosition = index;
if (IsInGamePlayer(oldDealer))
MahjongPackets.SendMahjongPlayersInfo(m_Players[oldDealer].NetState, Game, m_Players[oldDealer]);
m_Players[oldDealer].Send(new MahjongPlayersInfo(Game, m_Players[oldDealer]));
MahjongPackets.SendMahjongPlayersInfo(to.NetState, Game, to);
to.Send(new MahjongPlayersInfo(Game, to));
SendDealerChangedMessage();
}
@ -395,25 +422,36 @@ namespace Server.Engines.Mahjong
public void SendPlayersPacket(bool players, bool spectators)
{
foreach (Mobile mobile in GetInGameMobiles(players, spectators))
MahjongPackets.SendMahjongPlayersInfo(mobile.NetState, Game, mobile);
mobile.Send(new MahjongPlayersInfo(Game, mobile));
}
public void SendGeneralPacket(bool players, bool spectators)
{
foreach (Mobile mobile in GetInGameMobiles(players, spectators))
MahjongPackets.SendMahjongGeneralInfo(mobile.NetState, Game);
List<Mobile> mobiles = GetInGameMobiles(players, spectators);
if (mobiles.Count == 0)
return;
MahjongGeneralInfo generalInfo = new MahjongGeneralInfo(Game);
generalInfo.Acquire();
foreach (Mobile mobile in mobiles)
mobile.Send(generalInfo);
generalInfo.Release();
}
public void SendTilesPacket(bool players, bool spectators)
{
foreach (Mobile mobile in GetInGameMobiles(players, spectators))
MahjongPackets.SendMahjongTilesInfo(mobile.NetState, Game, mobile);
mobile.Send(new MahjongTilesInfo(Game, mobile));
}
public void SendTilePacket(MahjongTile tile, bool players, bool spectators)
{
foreach (Mobile mobile in GetInGameMobiles(players, spectators))
MahjongPackets.SendMahjongTileInfo(mobile.NetState, tile, mobile);
mobile.Send(new MahjongTileInfo(tile, mobile));
}
public void SendRelievePacket(bool players, bool spectators)
@ -423,8 +461,14 @@ namespace Server.Engines.Mahjong
if (mobiles.Count == 0)
return;
MahjongRelieve relieve = new MahjongRelieve(Game);
relieve.Acquire();
foreach (Mobile mobile in mobiles)
MahjongPackets.SendMahjongRelieve(mobile.NetState, Game);
mobile.Send(relieve);
relieve.Release();
}
public void SendLocalizedMessage(int number)

View file

@ -1,78 +1,76 @@
using Server.Buffers;
using System.IO;
using Server.Network;
namespace Server.Engines.Mahjong
{
public static class MahjongPackets
public sealed class MahjongJoinGame : Packet
{
public static void SendMahjongJoinGame(NetState ns, MahjongGame game)
public MahjongJoinGame(MahjongGame game) : base(0xDA)
{
if (ns == null)
return;
EnsureCapacity(9);
SpanWriter writer = new SpanWriter(stackalloc byte[9]);
writer.Write((byte)0xDA); // Packet ID
writer.Write((ushort)0x09); // Dynamic Length
writer.Write(game.Serial);
writer.Write((short)0x19);
ns.Send(writer.Span);
m_Stream.Write(game.Serial);
m_Stream.Write((byte)0);
m_Stream.Write((byte)0x19);
}
}
public static void SendMahjongPlayersInfo(NetState ns, MahjongGame game, Mobile to)
public sealed class MahjongPlayersInfo : Packet
{
public MahjongPlayersInfo(MahjongGame game, Mobile to) : base(0xDA)
{
if (ns == null)
return;
MahjongPlayers players = game.Players;
SpanWriter writer = new SpanWriter(stackalloc byte[11 + 45 * players.Seats]);
writer.Write((byte)0xDA); // Packet ID
writer.Position += 2; // Dynamic Length
writer.Write(game.Serial);
writer.Write((short)0x02);
writer.Write((short)players.Seats);
EnsureCapacity(11 + 45 * players.Seats);
short n = 0;
m_Stream.Write(game.Serial);
m_Stream.Write((byte)0);
m_Stream.Write((byte)0x2);
m_Stream.Write((byte)0);
m_Stream.Write((byte)players.Seats);
int n = 0;
for (int i = 0; i < players.Seats; i++)
{
Mobile mobile = players.GetPlayer(i);
if (mobile != null)
{
writer.Write(mobile.Serial);
writer.Write(players.DealerPosition == i ? (byte)0x1 : (byte)0x2);
writer.Write((byte)i);
m_Stream.Write(mobile.Serial);
m_Stream.Write(players.DealerPosition == i ? (byte)0x1 : (byte)0x2);
m_Stream.Write((byte)i);
if (game.ShowScores || mobile == to)
writer.Write(players.GetScore(i));
m_Stream.Write(players.GetScore(i));
else
writer.Position++; // writer.Write(0);
m_Stream.Write(0);
writer.Position += 3;
m_Stream.Write((short)0);
m_Stream.Write((byte)0);
writer.Write(players.IsPublic(i));
m_Stream.Write(players.IsPublic(i));
writer.WriteAsciiFixed(mobile.Name, 30);
writer.Write(!players.IsInGamePlayer(i));
m_Stream.WriteAsciiFixed(mobile.Name, 30);
m_Stream.Write(!players.IsInGamePlayer(i));
n++;
}
else if (game.ShowScores)
{
writer.Position++; // writer.Write(0);
writer.Write((byte)0x2);
writer.Write((byte)i);
m_Stream.Write(0);
m_Stream.Write((byte)0x2);
m_Stream.Write((byte)i);
writer.Write(players.GetScore(i));
m_Stream.Write(players.GetScore(i));
writer.Position += 3;
m_Stream.Write((short)0);
m_Stream.Write((byte)0);
writer.Write(players.IsPublic(i));
m_Stream.Write(players.IsPublic(i));
writer.Position += 30; //writer.WriteAsciiFixed("", 30);
writer.Write((byte)0x1); // true
m_Stream.WriteAsciiFixed("", 30);
m_Stream.Write(true);
n++;
}
@ -80,66 +78,58 @@ namespace Server.Engines.Mahjong
if (n != players.Seats)
{
writer.Position = 9;
writer.Write(n);
m_Stream.Seek(10, SeekOrigin.Begin);
m_Stream.Write((byte)n);
}
writer.Position = 1;
writer.Write((short)writer.WrittenCount);
ns.Send(writer.Span);
}
}
public static void SendMahjongGeneralInfo(NetState ns, MahjongGame game)
public sealed class MahjongGeneralInfo : Packet
{
public MahjongGeneralInfo(MahjongGame game) : base(0xDA)
{
if (ns == null)
return;
EnsureCapacity(13);
SpanWriter writer = new SpanWriter(stackalloc byte[25]);
writer.Write((byte)0xDA); // Packet ID
writer.Write((ushort)25); // Dynamic Length
m_Stream.Write(game.Serial);
m_Stream.Write((byte)0);
m_Stream.Write((byte)0x5);
writer.Write(game.Serial);
writer.Write((short)0x05);
m_Stream.Write((short)0);
m_Stream.Write((byte)0);
writer.Position += 3;
m_Stream.Write((byte)((game.ShowScores ? 0x1 : 0x0) | (game.SpectatorVision ? 0x2 : 0x0)));
writer.Write((byte)((game.ShowScores ? 0x1 : 0x0) | (game.SpectatorVision ? 0x2 : 0x0)));
m_Stream.Write((byte)game.Dices.First);
m_Stream.Write((byte)game.Dices.Second);
writer.Write((byte)game.Dices.First);
writer.Write((byte)game.Dices.Second);
m_Stream.Write((byte)game.DealerIndicator.Wind);
m_Stream.Write((short)game.DealerIndicator.Position.Y);
m_Stream.Write((short)game.DealerIndicator.Position.X);
m_Stream.Write((byte)game.DealerIndicator.Direction);
writer.Write((byte)game.DealerIndicator.Wind);
writer.Write((short)game.DealerIndicator.Position.Y);
writer.Write((short)game.DealerIndicator.Position.X);
writer.Write((byte)game.DealerIndicator.Direction);
writer.Write((short)game.WallBreakIndicator.Position.Y);
writer.Write((short)game.WallBreakIndicator.Position.X);
ns.Send(writer.Span);
m_Stream.Write((short)game.WallBreakIndicator.Position.Y);
m_Stream.Write((short)game.WallBreakIndicator.Position.X);
}
}
public static void SendMahjongTilesInfo(NetState ns, MahjongGame game, Mobile to)
public sealed class MahjongTilesInfo : Packet
{
public MahjongTilesInfo(MahjongGame game, Mobile to) : base(0xDA)
{
if (ns == null)
return;
MahjongTile[] tiles = game.Tiles;
MahjongPlayers players = game.Players;
int length = 11 + 9 * tiles.Length;
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
writer.Write((byte)0xDA); // Packet ID
writer.Write((short)length); // Dynamic Length
EnsureCapacity(11 + 9 * tiles.Length);
writer.Write(game.Serial);
writer.Write((short)0x4);
m_Stream.Write(game.Serial);
m_Stream.Write((byte)0);
m_Stream.Write((byte)0x4);
writer.Write((short)tiles.Length);
m_Stream.Write((short)tiles.Length);
foreach (MahjongTile tile in tiles)
{
writer.Write((byte)tile.Number);
m_Stream.Write((byte)tile.Number);
if (tile.Flipped)
{
@ -147,40 +137,39 @@ namespace Server.Engines.Mahjong
if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to ||
game.SpectatorVision && players.IsSpectator(to))
writer.Write((byte)tile.Value);
m_Stream.Write((byte)tile.Value);
else
writer.Position++;
m_Stream.Write((byte)0);
}
else
writer.Position++;
{
m_Stream.Write((byte)0);
}
writer.Write((short)tile.Position.Y);
writer.Write((short)tile.Position.X);
writer.Write((byte)tile.StackLevel);
writer.Write((byte)tile.Direction);
m_Stream.Write((short)tile.Position.Y);
m_Stream.Write((short)tile.Position.X);
m_Stream.Write((byte)tile.StackLevel);
m_Stream.Write((byte)tile.Direction);
writer.Write(tile.Flipped ? (byte)0x10 : (byte)0x0);
m_Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0);
}
ns.Send(writer.Span);
}
}
public static void SendMahjongTileInfo(NetState ns, MahjongTile tile, Mobile to)
public sealed class MahjongTileInfo : Packet
{
public MahjongTileInfo(MahjongTile tile, Mobile to) : base(0xDA)
{
if (ns == null)
return;
MahjongGame game = tile.Game;
MahjongPlayers players = game.Players;
SpanWriter writer = new SpanWriter(stackalloc byte[18]);
writer.Write((byte)0xDA); // Packet ID
writer.Write((short)18); // Dynamic Length
EnsureCapacity(18);
writer.Write(game.Serial);
writer.Write((short)0x3);
m_Stream.Write(tile.Game.Serial);
m_Stream.Write((byte)0);
m_Stream.Write((byte)0x3);
writer.Write((byte)tile.Number);
m_Stream.Write((byte)tile.Number);
if (tile.Flipped)
{
@ -188,36 +177,33 @@ namespace Server.Engines.Mahjong
if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to ||
game.SpectatorVision && players.IsSpectator(to))
writer.Write((byte)tile.Value);
m_Stream.Write((byte)tile.Value);
else
writer.Position++;
m_Stream.Write((byte)0);
}
else
writer.Position++;
{
m_Stream.Write((byte)0);
}
writer.Write((short)tile.Position.Y);
writer.Write((short)tile.Position.X);
writer.Write((byte)tile.StackLevel);
writer.Write((byte)tile.Direction);
m_Stream.Write((short)tile.Position.Y);
m_Stream.Write((short)tile.Position.X);
m_Stream.Write((byte)tile.StackLevel);
m_Stream.Write((byte)tile.Direction);
writer.Write(tile.Flipped ? (byte)0x10 : (byte)0x0);
ns.Send(writer.Span);
}
public static void SendMahjongRelieve(NetState ns, MahjongGame game)
{
if (ns == null)
return;
SpanWriter writer = new SpanWriter(stackalloc byte[18]);
writer.Write((byte)0xDA); // Packet ID
writer.Write((short)18); // Dynamic Length
writer.Write(game.Serial);
writer.Write((short)0x1A);
ns.Send(writer.Span);
m_Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0);
}
}
}
public sealed class MahjongRelieve : Packet
{
public MahjongRelieve(MahjongGame game) : base(0xDA)
{
EnsureCapacity(9);
m_Stream.Write(game.Serial);
m_Stream.Write((byte)0);
m_Stream.Write((byte)0x1A);
}
}
}

View file

@ -1,5 +1,6 @@
using Server.Guilds;
using Server.Multis;
using Server.Prompts;
namespace Server.Items
{

View file

@ -143,7 +143,8 @@ namespace Server.Items
if (Guild.NewGuildSystem && ItemID == 0xED4)
ItemID = 0xED6;
m_BeforeChangeover |= version <= 2;
if (version <= 2)
m_BeforeChangeover = true;
if (Guild.NewGuildSystem && m_BeforeChangeover)
Timer.DelayCall(TimeSpan.Zero, AddToHouse);
@ -250,8 +251,10 @@ namespace Server.Items
from.SendGump(new GuildGump(from, Guild));
}
else if (from.AccessLevel < AccessLevel.GameMaster && !Guild.IsMember(from))
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3,
501158); // You are not a member ...
{
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, 501158, "",
"")); // You are not a member ...
}
else
{
GuildGump.EnsureClosed(from);
@ -259,6 +262,8 @@ namespace Server.Items
}
}
#region IAddon Members
public Item Deed => new GuildstoneDeed(Guild, m_GuildName, m_GuildAbbrev);
public bool CouldFit(IPoint3D p, Map map) => map.CanFit(p.X, p.Y, p.Z, ItemData.Height);
@ -371,7 +376,9 @@ namespace Server.Items
list.Add(1060802, $"{Utility.FixHtml(name)} [{Utility.FixHtml(abbr)}]");
}
else if (m_GuildName != null && m_GuildAbbrev != null)
{
list.Add(1060802, $"{Utility.FixHtml(m_GuildName)} [{Utility.FixHtml(m_GuildAbbrev)}]");
}
}
public override void OnDoubleClick(Mobile from)
@ -386,10 +393,14 @@ namespace Server.Items
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget);
}
else
{
from.SendLocalizedMessage(502092); // You must be in your house to do this.
}
}
else
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
}
public void Placement_OnTarget(Mobile from, object targeted)
@ -413,10 +424,14 @@ namespace Server.Items
Delete();
}
else
{
from.SendLocalizedMessage(1042036); // That location is not in your house.
}
}
else
{
from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it.
}
}
}
}

View file

@ -3,7 +3,13 @@ namespace Server.Items
public class IndecipherableMap : MapItem
{
[Constructible]
public IndecipherableMap() => Hue = Utility.RandomDouble() < 0.2 ? 0x965 : 0x961;
public IndecipherableMap()
{
if (Utility.RandomDouble() < 0.2)
Hue = 0x965;
else
Hue = 0x961;
}
public IndecipherableMap(Serial serial) : base(serial)
{
@ -30,4 +36,4 @@ namespace Server.Items
int version = reader.ReadEncodedInt();
}
}
}
}

View file

@ -10,16 +10,14 @@ namespace Server.Items
{
private const int MaxUserPins = 50;
private bool m_Editable;
private Map m_Facet;
[Constructible]
public MapItem(Map facet = null) : base(0x14EC)
public MapItem() : base(0x14EC)
{
Weight = 1.0;
Width = 200;
Height = 200;
m_Facet = facet;
}
public MapItem(Serial serial) : base(serial)
@ -40,13 +38,6 @@ namespace Server.Items
public List<Point2D> Pins{ get; } = new List<Point2D>();
[CommandProperty(AccessLevel.GameMaster)]
public virtual Map Facet
{
get => m_Facet;
set => m_Facet = value;
}
#region ICraftable Members
public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
@ -92,24 +83,13 @@ namespace Server.Items
public virtual void DisplayTo(Mobile from)
{
NetState ns = from.NetState;
if (ns.NewCharacterList) // 7.0.13.0+ supports maps on all facets
MapItemPackets.SendMapDetailsNew(ns, this);
else if (Facet != null && Facet != Map.Felucca && Facet != Map.Trammel) // Is it Felucca and Trammel, or just Felucca?
{
from.SendMessage("You must have client 7.0.13.0 or higher to display this map.");
return;
}
else
MapItemPackets.SendMapDetailsOld(ns, this);
MapItemPackets.SendMapDisplay(from.NetState, this);
from.Send(new MapDetails(this));
from.Send(new MapDisplay(this));
for (int i = 0; i < Pins.Count; ++i)
MapItemPackets.SendMapAddPin(from.NetState, this, Pins[i]);
from.Send(new MapAddPin(this, Pins[i]));
MapItemPackets.SendMapSetEditable(from.NetState, this, ValidateEdit(from));
from.Send(new MapSetEditable(this, ValidateEdit(from)));
}
public virtual void OnAddPin(Mobile from, int x, int y)
@ -164,7 +144,7 @@ namespace Server.Items
if (Validate(from))
m_Editable = !m_Editable;
MapItemPackets.SendMapSetEditable(from.NetState, this, m_Editable && ValidateEdit(from));
from.Send(new MapSetEditable(this, Validate(from) && m_Editable));
}
public virtual void Validate(ref int x, ref int y)
@ -246,9 +226,7 @@ namespace Server.Items
{
base.Serialize(writer);
writer.Write(1);
writer.Write(m_Facet);
writer.Write(0);
writer.Write(Bounds);
@ -270,9 +248,6 @@ namespace Server.Items
switch (version)
{
case 1:
m_Facet = reader.ReadMap();
goto case 0;
case 0:
{
Bounds = reader.ReadRect2D();
@ -331,5 +306,71 @@ namespace Server.Items
break;
}
}
private sealed class MapDetails : Packet
{
public MapDetails(MapItem map) : base(0x90, 19)
{
m_Stream.Write(map.Serial);
m_Stream.Write((short)0x139D);
m_Stream.Write((short)map.Bounds.Start.X);
m_Stream.Write((short)map.Bounds.Start.Y);
m_Stream.Write((short)map.Bounds.End.X);
m_Stream.Write((short)map.Bounds.End.Y);
m_Stream.Write((short)map.Width);
m_Stream.Write((short)map.Height);
}
}
/*
private sealed class MapDetailsNew : Packet
{
public MapDetailsNew( MapItem map ) : base ( 0xF5, 21 )
{
m_Stream.Write( (int) map.Serial );
m_Stream.Write( (short) 0x139D );
m_Stream.Write( (short) map.Bounds.Start.X );
m_Stream.Write( (short) map.Bounds.Start.Y );
m_Stream.Write( (short) map.Bounds.End.X );
m_Stream.Write( (short) map.Bounds.End.Y );
m_Stream.Write( (short) map.Width );
m_Stream.Write( (short) map.Height );
m_Stream.Write( (short) ( map.Facet == null ? 0 : map.Facet.MapID ) );
}
}
*/
private abstract class MapCommand : Packet
{
public MapCommand(MapItem map, int command, int number, int x, int y) : base(0x56, 11)
{
m_Stream.Write(map.Serial);
m_Stream.Write((byte)command);
m_Stream.Write((byte)number);
m_Stream.Write((short)x);
m_Stream.Write((short)y);
}
}
private sealed class MapDisplay : MapCommand
{
public MapDisplay(MapItem map) : base(map, 5, 0, 0, 0)
{
}
}
private sealed class MapAddPin : MapCommand
{
public MapAddPin(MapItem map, Point2D point) : base(map, 1, 0, point.X, point.Y)
{
}
}
private sealed class MapSetEditable : MapCommand
{
public MapSetEditable(MapItem map, bool editable) : base(map, 7, editable ? 1 : 0, 0, 0)
{
}
}
}
}

View file

@ -1,81 +0,0 @@
using Server.Buffers;
using Server.Items;
namespace Server.Network
{
public static class MapItemPackets
{
public static void SendMapDetailsOld(NetState ns, MapItem map)
{
if (ns == null)
return;
SpanWriter writer = new SpanWriter(stackalloc byte[19]);
writer.Write((byte)0x90); // Packet ID
writer.Write(map.Serial);
writer.Write((short)0x139D);
writer.Write((short)map.Bounds.Start.X);
writer.Write((short)map.Bounds.Start.Y);
writer.Write((short)map.Bounds.End.X);
writer.Write((short)map.Bounds.End.Y);
writer.Write((short)map.Width);
writer.Write((short)map.Height);
ns.Send(writer.Span);
}
public static void SendMapDetailsNew(NetState ns, MapItem map)
{
if (ns == null)
return;
SpanWriter writer = new SpanWriter(stackalloc byte[21]);
writer.Write((byte)0xF5); // Packet ID
writer.Write(map.Serial);
writer.Write((short)0x139D);
writer.Write((short)map.Bounds.Start.X);
writer.Write((short)map.Bounds.Start.Y);
writer.Write((short)map.Bounds.End.X);
writer.Write((short)map.Bounds.End.Y);
writer.Write((short)map.Width);
writer.Write((short)map.Height);
writer.Write( (short)(map.Facet?.MapID ?? 0) );
ns.Send(writer.Span);
}
public static void SendMapDisplay(NetState ns, MapItem map)
{
SendMapCommand(ns, map, 5);
}
public static void SendMapAddPin(NetState ns, MapItem map, Point2D p)
{
SendMapCommand(ns, map, 1, 0, p.X, p.Y);
}
public static void SendMapSetEditable(NetState ns, MapItem map, bool editable)
{
SendMapCommand(ns, map, 7, editable ? 1 : 0);
}
public static void SendMapCommand(NetState ns, MapItem map, int command, int number = 0, int x = 0, int y = 0)
{
if (ns == null)
return;
SpanWriter writer = new SpanWriter(stackalloc byte[11]);
writer.Write((byte)0x56); // Packet ID
writer.Write(map.Serial);
writer.Write((byte)command);
writer.Write((byte)number);
writer.Write((short)x);
writer.Write((short)y);
ns.Send(writer.Span);
}
}
}

View file

@ -78,7 +78,7 @@ namespace Server.Items
public Rectangle2D Bounds{ get; }
public static readonly PresetMapEntry[] Table =
public static PresetMapEntry[] Table{ get; } =
{
new PresetMapEntry(1041189, 200, 200, 1092, 1396, 1736, 1924), // map of Britain
new PresetMapEntry(1041203, 200, 200, 0256, 1792, 1736, 2560), // map of Britain to Skara Brae
@ -142,4 +142,4 @@ namespace Server.Items
Yew,
YewToBritain
}
}
}

View file

@ -17,7 +17,7 @@ namespace Server.Items
private static Point2D[] m_Locations;
private static Point2D[] m_HavenLocations;
private static readonly Type[][] m_SpawnTypes =
private static Type[][] m_SpawnTypes =
{
new[] { typeof(HeadlessOne), typeof(Skeleton) },
new[] { typeof(Mongbat), typeof(Ratman), typeof(HeadlessOne), typeof(Skeleton), typeof(Zombie) },
@ -32,13 +32,18 @@ namespace Server.Items
private Mobile m_CompletedBy;
private Mobile m_Decoder;
private int m_Level;
private Map m_Map;
[Constructible]
public TreasureMap(int level, Map facet = null) : base(facet)
public TreasureMap(int level, Map map)
{
m_Level = level;
m_Map = map;
ChestLocation = level == 0 ? GetRandomHavenLocation() : GetRandomLocation();
if (level == 0)
ChestLocation = GetRandomHavenLocation();
else
ChestLocation = GetRandomLocation();
Width = 300;
Height = 300;
@ -122,12 +127,12 @@ namespace Server.Items
}
[CommandProperty(AccessLevel.GameMaster)]
public override Map Facet
public Map ChestMap
{
get => base.Facet;
get => m_Map;
set
{
base.Facet = value;
m_Map = value;
InvalidateProperties();
}
}
@ -140,9 +145,15 @@ namespace Server.Items
get
{
if (m_Decoder != null)
return m_Level == 6 ? 1063453 : 1041516 + m_Level;
{
if (m_Level == 6)
return 1063453;
return 1041516 + m_Level;
}
return m_Level == 6 ? 1063452 : 1041510 + m_Level;
if (m_Level == 6)
return 1063452;
return 1041510 + m_Level;
}
}
@ -151,8 +162,10 @@ namespace Server.Items
if (m_Locations == null)
LoadLocations();
// ReSharper disable once PossibleNullReferenceException
return m_Locations.Length > 0 ? m_Locations[Utility.Random(m_Locations.Length)] : Point2D.Zero;
if (m_Locations.Length > 0)
return m_Locations[Utility.Random(m_Locations.Length)];
return Point2D.Zero;
}
public static Point2D GetRandomHavenLocation()
@ -160,8 +173,10 @@ namespace Server.Items
if (m_HavenLocations == null)
LoadLocations();
// ReSharper disable once PossibleNullReferenceException
return m_HavenLocations.Length > 0 ? m_HavenLocations[Utility.Random(m_HavenLocations.Length)] : Point2D.Zero;
if (m_HavenLocations.Length > 0)
return m_HavenLocations[Utility.Random(m_HavenLocations.Length)];
return Point2D.Zero;
}
private static void LoadLocations()
@ -310,7 +325,7 @@ namespace Server.Items
{
from.SendLocalizedMessage(503020); // You are already digging treasure.
}
else if (from.Map != Facet)
else if (from.Map != m_Map)
{
from.SendLocalizedMessage(1010479); // You seem to be in the right place, but may be on the wrong facet!
}
@ -458,7 +473,7 @@ namespace Server.Items
{
base.GetProperties(list);
list.Add(Facet == Map.Felucca ? 1041502 : 1041503); // for somewhere in Felucca : for somewhere in Trammel
list.Add(m_Map == Map.Felucca ? 1041502 : 1041503); // for somewhere in Felucca : for somewhere in Trammel
if (m_Completed)
list.Add(1041507, m_CompletedBy == null ? "someone" : m_CompletedBy.Name); // completed by ~1_val~
@ -468,8 +483,9 @@ namespace Server.Items
{
if (m_Completed)
{
Packets.SendMessageLocalizedAffix(from.NetState, Serial, ItemID, MessageType.Label, 0x3B2, 3, 1048030, "",
AffixType.Append, $" completed by {m_CompletedBy?.Name ?? "someone"}");
from.Send(new MessageLocalizedAffix(Serial, ItemID, MessageType.Label, 0x3B2, 3, 1048030, "",
AffixType.Append,
$" completed by {(m_CompletedBy == null ? "someone" : m_CompletedBy.Name)}", ""));
}
else if (m_Decoder != null)
{
@ -480,10 +496,10 @@ namespace Server.Items
}
else
{
LabelTo(from, 1041522,
m_Level == 6
? $"#{1063452}\t \t#{(Facet == Map.Felucca ? 1041502 : 1041503)}"
: $"#{1041510 + m_Level}\t \t#{(Facet == Map.Felucca ? 1041502 : 1041503)}");
if (m_Level == 6)
LabelTo(from, 1041522, $"#{1063452}\t \t#{(m_Map == Map.Felucca ? 1041502 : 1041503)}");
else
LabelTo(from, 1041522, $"#{1041510 + m_Level}\t \t#{(m_Map == Map.Felucca ? 1041502 : 1041503)}");
}
}
@ -491,13 +507,14 @@ namespace Server.Items
{
base.Serialize(writer);
writer.Write(2);
writer.Write(1);
writer.Write(m_CompletedBy);
writer.Write(m_Level);
writer.Write(m_Completed);
writer.Write(m_Decoder);
writer.Write(m_Map);
writer.Write(ChestLocation);
}
@ -520,8 +537,7 @@ namespace Server.Items
m_Level = reader.ReadInt();
m_Completed = reader.ReadBool();
m_Decoder = reader.ReadMobile();
if (version < 2)
Facet = reader.ReadMap();
m_Map = reader.ReadMap();
ChestLocation = reader.ReadPoint2D();
if (version == 0 && m_Completed)
@ -546,10 +562,12 @@ namespace Server.Items
if (m_Map.Deleted)
return;
Map facet = m_Map.Facet;
Map map = m_Map.m_Map;
if (m_Map.m_Completed)
{
from.SendLocalizedMessage(503028); // The treasure for this map has already been found.
}
/*
else if ( from != m_Map.m_Decoder )
{
@ -557,14 +575,22 @@ namespace Server.Items
}
*/
else if (m_Map.m_Decoder != from && !m_Map.HasRequiredSkill(from))
{
from.SendLocalizedMessage(
503031); // You did not decode this map and have no clue where to look for the treasure.
}
else if (!from.CanBeginAction<TreasureMap>())
{
from.SendLocalizedMessage(503020); // You are already digging treasure.
}
else if (!HasDiggingTool(from))
from.SendLocalizedMessage(1114416); // You must have a digging tool to dig for treasure.
else if (from.Map != facet)
{
from.SendMessage("You must have a digging tool to dig for treasure.");
}
else if (from.Map != map)
{
from.SendLocalizedMessage(1010479); // You seem to be in the right place, but may be on the wrong facet!
}
else
{
IPoint3D p = targeted as IPoint3D;
@ -591,17 +617,19 @@ namespace Server.Items
if (Utility.InRange(targ3D, chest3D0, maxRange))
{
if (from.Location.X == x && from.Location.Y == y)
{
from.SendLocalizedMessage(
503030); // The chest can't be dug up because you are standing on top of it.
else if (facet != null)
}
else if (map != null)
{
int z = facet.GetAverageZ(x, y);
int z = map.GetAverageZ(x, y);
if (!facet.CanFit(x, y, z, 16, true))
if (!map.CanFit(x, y, z, 16, true))
from.SendLocalizedMessage(
503021); // You have found the treasure chest but something is keeping it from being dug up.
else if (from.BeginAction<TreasureMap>())
new DigTimer(from, m_Map, new Point3D(x, y, z), facet).Start();
new DigTimer(from, m_Map, new Point3D(x, y, z), map).Start();
else
from.SendLocalizedMessage(503020); // You are already digging treasure.
}
@ -616,7 +644,9 @@ namespace Server.Items
else
{
if (Utility.InRange(targ3D, chest3D0, 8)) // We're close, but not quite
from.SendLocalizedMessage(1080030, "", 0x44); // The treasure chest is very close!
{
from.SendAsciiMessage(0x44, "The treasure chest is very close!");
}
else
{
Direction dir = Utility.GetDirection(targ3D, chest3D0);

View file

@ -1,5 +1,6 @@
using System;
using System.Globalization;
using Server.Accounting;
using Server.Engines.Quests;
using Server.Engines.Quests.Haven;
using Server.Engines.Quests.Necro;

View file

@ -1,4 +1,3 @@
using Server.Buffers;
using Server.Network;
namespace Server.Items
@ -14,21 +13,14 @@ namespace Server.Items
public override int LabelNumber => 503057; // Impassable!
protected override void SendWorldPacketFor(NetState state)
protected override Packet GetWorldPacketFor(NetState state)
{
Mobile mob = state.Mobile;
if (mob?.AccessLevel >= AccessLevel.GameMaster)
{
if (state.HighSeas)
SendGMItemHS(state);
else if (state.StygianAbyss)
SendGMItemSA(state);
else
SendGMItem(state);
}
return new GMItemPacket(this);
base.SendWorldPacketFor(state);
return base.GetWorldPacketFor(state);
}
public override void Serialize(GenericWriter writer)
@ -45,138 +37,66 @@ namespace Server.Items
int version = reader.ReadInt();
}
private void SendGMItem(NetState ns)
public sealed class GMItemPacket : Packet
{
if (ns == null)
return;
public GMItemPacket(Item item) : base(0x1A)
{
EnsureCapacity(20);
SpanWriter w = new SpanWriter(stackalloc byte[20]);
w.Write((byte)0x1A); // Packet ID
w.Position += 2; // Dynamic Length
// 14 base length
// +2 - Amount
// +2 - Hue
// +1 - Flags
uint serial = Serial.Value;
int itemId = 0x1183;
int amount = Amount;
Point3D loc = Location;
int x = loc.X;
int y = loc.Y;
int hue = Hue;
int flags = GetPacketFlags();
int direction = (int)Direction;
uint serial = item.Serial.Value;
int itemID = 0x1183;
int amount = item.Amount;
Point3D loc = item.Location;
int x = loc.X;
int y = loc.Y;
int hue = item.Hue;
int flags = item.GetPacketFlags();
int direction = (int)item.Direction;
if (amount != 0)
serial |= 0x80000000;
else
serial &= 0x7FFFFFFF;
if (amount != 0)
serial |= 0x80000000;
else
serial &= 0x7FFFFFFF;
w.Write(serial);
m_Stream.Write(serial);
m_Stream.Write((short)(itemID & 0x7FFF));
w.Write((short)itemId);
if (amount != 0)
m_Stream.Write((short)amount);
if (amount != 0)
w.Write((short)amount);
x &= 0x7FFF;
x &= 0x7FFF;
if (direction != 0)
x |= 0x8000;
if (direction != 0) x |= 0x8000;
m_Stream.Write((short)x);
w.Write((short)x);
y &= 0x3FFF;
y &= 0x3FFF;
if (hue != 0)
y |= 0x8000;
if (hue != 0) y |= 0x8000;
if (flags != 0)
y |= 0x4000;
if (flags != 0) y |= 0x4000;
m_Stream.Write((short)y);
w.Write((short)y);
if (direction != 0)
m_Stream.Write((byte)direction);
if (direction != 0)
w.Write((byte)direction);
m_Stream.Write((sbyte)loc.Z);
w.Write((sbyte)loc.Z);
if (hue != 0)
m_Stream.Write((ushort)hue);
if (hue != 0)
w.Write((ushort)hue);
if (flags != 0)
w.Write((byte)flags);
w.Position = 1;
w.Write((ushort)w.WrittenCount);
ns.Send(w.Span);
}
public void SendGMItemSA(NetState ns)
{
if (ns == null)
return;
SpanWriter w = new SpanWriter(stackalloc byte[24]);
w.Write((byte)0xF3); // Packet ID
w.Write((short)0x01);
int itemId = 0x1183;
w.Position++; // w.Write((byte)0);
w.Write(Serial);
w.Write((short)itemId);
w.Write((byte)Direction);
short amount = (short)Amount;
w.Write(amount);
w.Write(amount);
Point3D loc = Location;
w.Write((short)(loc.X & 0x7FFF));
w.Write((short)(loc.Y & 0x3FFF));
w.Write((sbyte)loc.Z);
w.Write((byte)Light);
w.Write((short)Hue);
w.Write((byte)GetPacketFlags());
ns.Send(w.RawSpan);
}
public void SendGMItemHS(NetState ns)
{
if (ns == null)
return;
SpanWriter w = new SpanWriter(stackalloc byte[26]);
w.Write((byte)0xF3); // Packet ID
w.Write((short)0x01);
int itemId = 0x1183;
w.Position++; // w.Write((byte)0);
w.Write(Serial);
w.Write((short)itemId);
w.Write((byte)Direction);
short amount = (short)Amount;
w.Write(amount);
w.Write(amount);
Point3D loc = Location;
w.Write((short)(loc.X & 0x7FFF));
w.Write((short)(loc.Y & 0x3FFF));
w.Write((sbyte)loc.Z);
w.Write((byte)Light);
w.Write((short)Hue);
w.Write((byte)GetPacketFlags());
ns.Send(w.RawSpan);
if (flags != 0)
m_Stream.Write((byte)flags);
}
}
}
}

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Server.Buffers;
using Server.Network;
using Server.Targeting;
@ -55,7 +54,7 @@ namespace Server.Items
}
[CommandProperty(AccessLevel.GameMaster)]
public string BoardName { get; set; }
public string BoardName{ get; set; }
public static bool CheckTime(DateTime time, TimeSpan range) => time + range < DateTime.UtcNow;
@ -67,10 +66,8 @@ namespace Server.Items
if (minutes != 0 && seconds != 0)
return $"{minutes} minute{(minutes == 1 ? "" : "s")} and {seconds} second{(seconds == 1 ? "" : "s")}";
if (minutes != 0)
return $"{minutes} minute{(minutes == 1 ? "" : "s")}";
return $"{seconds} second{(seconds == 1 ? "" : "s")}";
}
@ -149,8 +146,11 @@ namespace Server.Items
NetState state = from.NetState;
BBPackets.SendBBDisplayBoard(state, this);
Packets.SendContainerContent(state, from, this);
state.Send(new BBDisplayBoard(this));
if (state.ContainerGridLines)
state.Send(new ContainerContent6017(from, this));
else
state.Send(new ContainerContent(from, this));
}
else
{
@ -232,14 +232,18 @@ namespace Server.Items
public static void BBRequestContent(Mobile from, BaseBulletinBoard board, PacketReader pvSrc)
{
if (World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg && msg.Parent == board)
BBPackets.SendBBMessageContent(from.NetState, board, msg);
if (!(World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg) || msg.Parent != board)
return;
from.Send(new BBMessageContent(board, msg));
}
public static void BBRequestHeader(Mobile from, BaseBulletinBoard board, PacketReader pvSrc)
{
if (World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg && msg.Parent == board)
BBPackets.SendBBMessageHeader(from.NetState, board, msg);
if (!(World.FindItem(pvSrc.ReadUInt32()) is BulletinMessage msg) || msg.Parent != board)
return;
from.Send(new BBMessageHeader(board, msg));
}
public static void BBPostMessage(Mobile from, BaseBulletinBoard board, PacketReader pvSrc)
@ -267,7 +271,7 @@ namespace Server.Items
return;
}
string subject = pvSrc.ReadStringSafe(pvSrc.ReadByte());
string subject = pvSrc.ReadUTF8StringSafe(pvSrc.ReadByte());
if (subject.Length == 0)
return;
@ -278,7 +282,7 @@ namespace Server.Items
return;
for (int i = 0; i < lines.Length; ++i)
lines[i] = pvSrc.ReadStringSafe(pvSrc.ReadByte());
lines[i] = pvSrc.ReadUTF8StringSafe(pvSrc.ReadByte());
board.PostMessage(from, thread, subject, lines);
}
@ -340,25 +344,25 @@ namespace Server.Items
{
}
public Mobile Poster { get; private set; }
public Mobile Poster{ get; private set; }
public BulletinMessage Thread { get; private set; }
public BulletinMessage Thread{ get; private set; }
public string Subject { get; private set; }
public string Subject{ get; private set; }
public DateTime Time { get; private set; }
public DateTime Time{ get; private set; }
public DateTime LastPostTime { get; set; }
public DateTime LastPostTime{ get; set; }
public string PostedName { get; private set; }
public string PostedName{ get; private set; }
public int PostedBody { get; private set; }
public int PostedBody{ get; private set; }
public int PostedHue { get; private set; }
public int PostedHue{ get; private set; }
public BulletinEquip[] PostedEquip { get; private set; }
public BulletinEquip[] PostedEquip{ get; private set; }
public string[] Lines { get; private set; }
public string[] Lines{ get; private set; }
public string GetTimeAsString() => Time.ToString("MMM dd, yyyy");
@ -448,64 +452,70 @@ namespace Server.Items
}
}
public static class BBPackets
public class BBDisplayBoard : Packet
{
public static void SendBBDisplayBoard(NetState ns, BaseBulletinBoard board)
public BBDisplayBoard(BaseBulletinBoard board) : base(0x71)
{
SpanWriter writer = new SpanWriter(stackalloc byte[38]);
writer.Write((byte)0x71); // Packet ID
writer.Write((ushort)38); // Dynamic Length
EnsureCapacity(38);
writer.Position++; // writer.Write((byte)0); // Command
writer.Write(board.Serial);
writer.WriteAsciiNull(board.BoardName ?? "", 29);
byte[] buffer = Utility.UTF8.GetBytes(board.BoardName ?? "");
ns.Send(writer.Span);
m_Stream.Write((byte)0x00); // PacketID
m_Stream.Write(board.Serial); // Bulletin board serial
// Bulletin board name
if (buffer.Length >= 29)
{
m_Stream.Write(buffer, 0, 29);
m_Stream.Write((byte)0);
}
else
{
m_Stream.Write(buffer, 0, buffer.Length);
m_Stream.Fill(30 - buffer.Length);
}
}
}
public class BBMessageHeader : Packet
{
public BBMessageHeader(BaseBulletinBoard board, BulletinMessage msg) : base(0x71)
{
string poster = SafeString(msg.PostedName);
string subject = SafeString(msg.Subject);
string time = SafeString(msg.GetTimeAsString());
EnsureCapacity(22 + poster.Length + subject.Length + time.Length);
m_Stream.Write((byte)0x01); // PacketID
m_Stream.Write(board.Serial); // Bulletin board serial
m_Stream.Write(msg.Serial); // Message serial
BulletinMessage thread = msg.Thread;
if (thread == null)
m_Stream.Write(0); // Thread serial--root
else
m_Stream.Write(thread.Serial); // Thread serial--parent
WriteString(poster);
WriteString(subject);
WriteString(time);
}
public static void SendBBMessageHeader(NetState ns, BaseBulletinBoard board, BulletinMessage msg)
public void WriteString(string v)
{
string poster = msg.PostedName ?? "";
string subject = msg.Subject ?? "";
string time = msg.GetTimeAsString() ?? "";
byte[] buffer = Utility.UTF8.GetBytes(v);
int len = buffer.Length + 1;
byte posterLength = Math.Min((byte)poster.Length, (byte)254);
byte subjectLength = Math.Min((byte)subject.Length, (byte)254);
byte timeLength = Math.Min((byte)time.Length, (byte)254);
if (len > 255)
len = 255;
int length = 22 + posterLength + subjectLength + timeLength;
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
writer.Write((byte)0x71); // Packet ID
writer.Write((ushort)length); // Dynamic Length
writer.Write((byte)0x01); // Command
writer.Write(board.Serial); // Bulletin board serial
writer.Write(msg.Serial); // Message serial
writer.Write(msg.Thread?.Serial ?? 0);
writer.Write(posterLength);
writer.WriteAsciiNull(poster, posterLength + 1);
writer.Write(subjectLength);
writer.WriteAsciiNull(subject, subjectLength + 1);
writer.Write(timeLength);
writer.WriteAsciiNull(time, timeLength + 1);
ns.Send(writer.Span);
m_Stream.Write((byte)len);
m_Stream.Write(buffer, 0, len - 1);
m_Stream.Write((byte)0);
}
public static void SendBBMessageContent(NetState ns, BaseBulletinBoard board, BulletinMessage msg)
{
string poster = msg.PostedName ?? "";
string subject = msg.Subject ?? "";
string time = msg.GetTimeAsString() ?? "";
byte posterLength = Math.Min((byte)poster.Length, (byte)254);
byte subjectLength = Math.Min((byte)subject.Length, (byte)254);
byte timeLength = Math.Min((byte)time.Length, (byte)254);
int equipLength = Math.Min(msg.PostedEquip.Length, 255);
int msgLength = Math.Min(msg.Lines.Length, 255);
public string SafeString(string v) => v ?? string.Empty;
}
@ -519,43 +529,72 @@ namespace Server.Items
EnsureCapacity(22 + poster.Length + subject.Length + time.Length);
writer.Write((byte)0x02); // Command
writer.Write(board.Serial); // Bulletin board serial
writer.Write(msg.Serial); // Message serial
m_Stream.Write((byte)0x02); // PacketID
m_Stream.Write(board.Serial); // Bulletin board serial
m_Stream.Write(msg.Serial); // Message serial
writer.Write(posterLength);
writer.WriteAsciiNull(poster, posterLength + 1);
writer.Write(subjectLength);
writer.WriteAsciiNull(subject, subjectLength + 1);
writer.Write(timeLength);
writer.WriteAsciiNull(time, timeLength + 1);
WriteString(poster);
WriteString(subject);
WriteString(time);
writer.Write((short)msg.PostedBody);
writer.Write((short)msg.PostedHue);
m_Stream.Write((short)msg.PostedBody);
m_Stream.Write((short)msg.PostedHue);
writer.Write((byte)equipLength);
int len = msg.PostedEquip.Length;
for (int i = 0; i < equipLength; ++i)
if (len > 255)
len = 255;
m_Stream.Write((byte)len);
for (int i = 0; i < len; ++i)
{
BulletinEquip eq = msg.PostedEquip[i];
writer.Write((short)eq.itemID);
writer.Write((short)eq.hue);
m_Stream.Write((short)eq.itemID);
m_Stream.Write((short)eq.hue);
}
writer.Write((byte)msgLength);
len = msg.Lines.Length;
for (int i = 0; i < msgLength; ++i)
{
string line = msg.Lines[i];
byte len = Math.Min((byte)line.Length, (byte)254);
writer.WriteAsciiNull(line, len);
}
if (len > 255)
len = 255;
writer.Position = 1;
writer.Write((ushort)writer.WrittenCount);
m_Stream.Write((byte)len);
ns.Send(writer.Span);
for (int i = 0; i < len; ++i)
WriteString(msg.Lines[i], true);
}
public void WriteString(string v)
{
WriteString(v, false);
}
public void WriteString(string v, bool padding)
{
byte[] buffer = Utility.UTF8.GetBytes(v);
int tail = padding ? 2 : 1;
int len = buffer.Length + tail;
if (len > 255)
len = 255;
m_Stream.Write((byte)len);
m_Stream.Write(buffer, 0, len - tail);
if (padding)
m_Stream.Write((short)0); // padding compensates for a client bug
else
m_Stream.Write((byte)0);
}
public string SafeString(string v)
{
if (v == null)
return string.Empty;
return v;
}
}
}

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Network;
using Server.Targeting;
@ -30,7 +29,14 @@ namespace Server.Items
public int Amount{ get; }
public static CrystalRechargeInfo Get(Type type) => Table.FirstOrDefault(info => info.Type == type);
public static CrystalRechargeInfo Get(Type type)
{
foreach (CrystalRechargeInfo info in Table)
if (info.Type == type)
return info;
return null;
}
}
public class BroadcastCrystal : Item

View file

@ -100,7 +100,7 @@ namespace Server.Items
public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> equipItems)
: base(0x2006)
{
// To suppress console warnings, stackable must be true
// To supress console warnings, stackable must be true
Stackable = true;
Amount = owner.Body; // protocol defines that for itemid 0x2006, amount=body
Stackable = false;
@ -193,7 +193,16 @@ namespace Server.Items
}
[CommandProperty(AccessLevel.GameMaster)]
public virtual bool InstancedCorpse => Core.SE && DateTime.UtcNow < TimeOfDeath + InstancedCorpseTime;
public virtual bool InstancedCorpse
{
get
{
if (!Core.SE)
return false;
return DateTime.UtcNow < TimeOfDeath + InstancedCorpseTime;
}
}
public override bool IsDecoContainer => false;
@ -293,7 +302,9 @@ namespace Server.Items
Mobile dead = Owner;
if (GetFlag(CorpseFlag.Carved) || dead == null)
{
from.SendLocalizedMessage(500485); // You see nothing useful to carve from the corpse.
}
else if (((Body)Amount).IsHuman && ItemID == 0x2006)
{
new Blood(0x122D).MoveToWorld(Location, Map);
@ -317,9 +328,13 @@ namespace Server.Items
from.CriminalAction(true);
}
else if (dead is BaseCreature creature)
{
creature.OnCarve(from, this, item);
}
else
{
from.SendLocalizedMessage(500485); // You see nothing useful to carve from the corpse.
}
}
public override bool IsChildVisibleTo(Mobile m, Item child) =>
@ -332,7 +347,8 @@ namespace Server.Items
if (Aggressors.Count == 0 || Items.Count == 0)
return;
m_InstancedItems ??= new Dictionary<Item, InstancedItemInfo>();
if (m_InstancedItems == null)
m_InstancedItems = new Dictionary<Item, InstancedItemInfo>();
List<Item> m_Stackables = new List<Item>();
List<Item> m_Unstackables = new List<Item>();
@ -385,7 +401,7 @@ namespace Server.Items
}
if (remainder == 0)
m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[^1]));
m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[attackers.Count - 1]));
else
m_Unstackables.Add(item);
}
@ -411,7 +427,9 @@ namespace Server.Items
if (InstancedCorpse)
{
m_InstancedItems ??= new Dictionary<Item, InstancedItemInfo>();
if (m_InstancedItems == null)
m_InstancedItems = new Dictionary<Item, InstancedItemInfo>();
m_InstancedItems.Add(carved, new InstancedItemInfo(carved, carver));
}
}
@ -446,6 +464,7 @@ namespace Server.Items
public override void OnAfterDelete()
{
m_DecayTimer?.Stop();
m_DecayTimer = null;
}
@ -524,23 +543,29 @@ namespace Server.Items
writer.WriteDeltaTime(TimeOfDeath);
if (m_RestoreTable == null)
writer.Write(0);
else
List<KeyValuePair<Item, Point3D>> list = m_RestoreTable == null
? null
: new List<KeyValuePair<Item, Point3D>>(m_RestoreTable);
int count = list?.Count ?? 0;
writer.Write(count);
for (int i = 0; i < count; ++i)
{
writer.Write(m_RestoreTable.Count);
KeyValuePair<Item, Point3D> kvp = list[i];
Item item = kvp.Key;
Point3D loc = kvp.Value;
foreach (var (item, loc) in m_RestoreTable)
writer.Write(item);
if (item.Location == loc)
{
writer.Write(item);
if (item.Location == loc)
writer.Write(false);
else
{
writer.Write(true);
writer.Write(loc);
}
writer.Write(false);
}
else
{
writer.Write(true);
writer.Write(loc);
}
}
@ -732,8 +757,12 @@ namespace Server.Items
if (!(((Body)Amount).IsHuman && ItemID == 0x2006))
return;
CorpsePackets.SendCorpseContent(state, state.Mobile, this);
CorpsePackets.SendCorpseEquip(state, state.Mobile, this);
if (state.ContainerGridLines)
state.Send(new CorpseContent6017(state.Mobile, this));
else
state.Send(new CorpseContent(state.Mobile, this));
state.Send(new CorpseEquip(state.Mobile, this));
}
public bool IsCriminalAction(Mobile from)
@ -807,7 +836,8 @@ namespace Server.Items
if (item == null)
return;
m_RestoreTable ??= new Dictionary<Item, Point3D>();
if (m_RestoreTable == null)
m_RestoreTable = new Dictionary<Item, Point3D>();
m_RestoreTable[item] = loc;
}
@ -1035,7 +1065,7 @@ namespace Server.Items
ObjectPropertyList opl = PropertyList;
if (opl.Header > 0)
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, opl.Header, Name, opl.HeaderArgs);
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, hue, 3, opl.Header, Name, opl.HeaderArgs));
}
public override void OnSingleClick(Mobile from)
@ -1045,12 +1075,14 @@ namespace Server.Items
if (ItemID == 0x2006) // Corpse form
{
if (m_CorpseName != null)
Packets.SendAsciiMessage(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, "", m_CorpseName);
from.Send(new AsciiMessage(Serial, ItemID, MessageType.Label, hue, 3, "", m_CorpseName));
else
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name);
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name));
}
else // Bone form
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name);
{
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name));
}
}
private class InstancedItemInfo

View file

@ -1,29 +1,24 @@
using System.Collections.Generic;
using Server.Buffers;
using System.IO;
using Server.Items;
namespace Server.Network
{
public static class CorpsePackets
public sealed class CorpseEquip : Packet
{
public static void SendCorpseEquip(NetState ns, Mobile beholder, Corpse beheld)
public CorpseEquip(Mobile beholder, Corpse beheld) : base(0x89)
{
if (ns == null)
return;
List<Item> list = beheld.EquipItems;
int length = 8 + list.Count * 5;
if (beheld.Hair?.ItemID > 0)
length += 5;
if (beheld.FacialHair?.ItemID > 0)
length += 5;
int count = list.Count;
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
count++;
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
count++;
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
writer.Write((byte)0x89); // Packet ID
writer.Write((ushort)length); // Dynamic Length
EnsureCapacity(8 + count * 5);
writer.Write(beheld.Serial);
m_Stream.Write(beheld.Serial);
for (int i = 0; i < list.Count; ++i)
{
@ -31,180 +26,173 @@ namespace Server.Network
if (!item.Deleted && beholder.CanSee(item) && item.Parent == beheld)
{
writer.Write((byte)(item.Layer + 1));
writer.Write(item.Serial);
m_Stream.Write((byte)(item.Layer + 1));
m_Stream.Write(item.Serial);
}
}
if (beheld.Hair?.ItemID > 0)
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
{
writer.Write((byte)(Layer.Hair + 1));
writer.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
m_Stream.Write((byte)(Layer.Hair + 1));
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
}
if (beheld.FacialHair?.ItemID > 0)
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
{
writer.Write((byte)(Layer.FacialHair + 1));
writer.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
m_Stream.Write((byte)(Layer.FacialHair + 1));
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
}
writer.Position++; // writer.Write((byte)Layer.Invalid);
ns.Send(writer.Span);
}
public static void SendCorpseContent(NetState ns, Mobile beholder, Corpse corpse)
{
if (ns == null)
return;
if (ns.ContainerGridLines)
SendCorpseContentNew(ns, beholder, corpse);
else
SendCorpseContentOld(ns, beholder, corpse);
}
public static void SendCorpseContentOld(NetState ns, Mobile beholder, Corpse corpse)
{
if (ns == null)
return;
List<Item> items = corpse.EquipItems;
int length = 5 + items.Count * 19;
if (corpse.Hair?.ItemID > 0)
length += 19;
if (corpse.FacialHair?.ItemID > 0)
length += 19;
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
writer.Write((byte)0x3C); // Packet ID
writer.Write((ushort)length); // Dynamic Length
writer.Position += 2;
ushort written = 0;
for (int i = 0; i < items.Count; ++i)
{
Item child = items[i];
if (!child.Deleted && child.Parent == corpse && beholder.CanSee(child))
{
writer.Write(child.Serial);
writer.Write((ushort)child.ItemID);
writer.Position++; // signed, itemID offset
writer.Write((ushort)child.Amount);
writer.Write((short)child.X);
writer.Write((short)child.Y);
writer.Write(corpse.Serial);
writer.Write((ushort)child.Hue);
++written;
}
}
if (corpse.Hair?.ItemID > 0)
{
writer.Write(HairInfo.FakeSerial(corpse.Owner.Serial) - 2);
writer.Write((ushort)corpse.Hair.ItemID);
writer.Position++; // signed, itemID offset
writer.Write((ushort)1);
writer.Position += 4;
writer.Write(corpse.Serial);
writer.Write((ushort)corpse.Hair.Hue);
++written;
}
if (corpse.FacialHair?.ItemID > 0)
{
writer.Write(FacialHairInfo.FakeSerial(corpse.Owner.Serial) - 2);
writer.Write((ushort)corpse.FacialHair.ItemID);
writer.Position++; // signed, itemID offset
writer.Write((ushort)1);
writer.Position += 4;
writer.Write(corpse.Serial);
writer.Write((ushort)corpse.FacialHair.Hue);
++written;
}
writer.Position = 3;
writer.Write(written);
ns.Send(writer.Span);
}
public static void SendCorpseContentNew(NetState ns, Mobile beholder, Corpse corpse)
{
if (ns == null)
return;
List<Item> items = corpse.EquipItems;
int length = 5 + items.Count * 20;
if (corpse.Hair?.ItemID > 0)
length += 20;
if (corpse.FacialHair?.ItemID > 0)
length += 20;
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
writer.Write((byte)0x3C); // Packet ID
writer.Write((ushort)length); // Dynamic Length
writer.Position += 2;
ushort written = 0;
for (int i = 0; i < items.Count; ++i)
{
Item child = items[i];
if (!child.Deleted && child.Parent == corpse && beholder.CanSee(child))
{
writer.Write(child.Serial);
writer.Write((ushort)child.ItemID);
writer.Position++; // signed, itemID offset
writer.Write((ushort)child.Amount);
writer.Write((short)child.X);
writer.Write((short)child.Y);
writer.Position++; // grid location
writer.Write(corpse.Serial);
writer.Write((ushort)child.Hue);
++written;
}
}
if (corpse.Hair?.ItemID > 0)
{
writer.Write(HairInfo.FakeSerial(corpse.Owner.Serial) - 2);
writer.Write((ushort)corpse.Hair.ItemID);
writer.Position++; // signed, itemID offset
writer.Write((ushort)1);
writer.Position += 5;
writer.Write(corpse.Serial);
writer.Write((ushort)corpse.Hair.Hue);
++written;
}
if (corpse.FacialHair?.ItemID > 0)
{
writer.Write(FacialHairInfo.FakeSerial(corpse.Owner.Serial) - 2);
writer.Write((ushort)corpse.FacialHair.ItemID);
writer.Position++; // signed, itemID offset
writer.Write((ushort)1);
writer.Position += 5;
writer.Write(corpse.Serial);
writer.Write((ushort)corpse.FacialHair.Hue);
++written;
}
writer.Position = 3;
writer.Write(written);
ns.Send(writer.Span);
m_Stream.Write((byte)Layer.Invalid);
}
}
}
public sealed class CorpseContent : Packet
{
public CorpseContent(Mobile beholder, Corpse beheld)
: base(0x3C)
{
List<Item> items = beheld.EquipItems;
int count = items.Count;
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
count++;
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
count++;
EnsureCapacity(5 + count * 19);
long pos = m_Stream.Position;
int written = 0;
m_Stream.Write((ushort)0);
for (int i = 0; i < items.Count; ++i)
{
Item child = items[i];
if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
{
m_Stream.Write(child.Serial);
m_Stream.Write((ushort)child.ItemID);
m_Stream.Write((byte)0); // signed, itemID offset
m_Stream.Write((ushort)child.Amount);
m_Stream.Write((short)child.X);
m_Stream.Write((short)child.Y);
m_Stream.Write(beheld.Serial);
m_Stream.Write((ushort)child.Hue);
++written;
}
}
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
{
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
m_Stream.Write((ushort)beheld.Hair.ItemID);
m_Stream.Write((byte)0); // signed, itemID offset
m_Stream.Write((ushort)1);
m_Stream.Write((short)0);
m_Stream.Write((short)0);
m_Stream.Write(beheld.Serial);
m_Stream.Write((ushort)beheld.Hair.Hue);
++written;
}
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
{
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
m_Stream.Write((ushort)beheld.FacialHair.ItemID);
m_Stream.Write((byte)0); // signed, itemID offset
m_Stream.Write((ushort)1);
m_Stream.Write((short)0);
m_Stream.Write((short)0);
m_Stream.Write(beheld.Serial);
m_Stream.Write((ushort)beheld.FacialHair.Hue);
++written;
}
m_Stream.Seek(pos, SeekOrigin.Begin);
m_Stream.Write((ushort)written);
}
}
public sealed class CorpseContent6017 : Packet
{
public CorpseContent6017(Mobile beholder, Corpse beheld)
: base(0x3C)
{
List<Item> items = beheld.EquipItems;
int count = items.Count;
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
count++;
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
count++;
EnsureCapacity(5 + count * 20);
long pos = m_Stream.Position;
int written = 0;
m_Stream.Write((ushort)0);
for (int i = 0; i < items.Count; ++i)
{
Item child = items[i];
if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
{
m_Stream.Write(child.Serial);
m_Stream.Write((ushort)child.ItemID);
m_Stream.Write((byte)0); // signed, itemID offset
m_Stream.Write((ushort)child.Amount);
m_Stream.Write((short)child.X);
m_Stream.Write((short)child.Y);
m_Stream.Write((byte)0); // Grid Location?
m_Stream.Write(beheld.Serial);
m_Stream.Write((ushort)child.Hue);
++written;
}
}
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
{
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
m_Stream.Write((ushort)beheld.Hair.ItemID);
m_Stream.Write((byte)0); // signed, itemID offset
m_Stream.Write((ushort)1);
m_Stream.Write((short)0);
m_Stream.Write((short)0);
m_Stream.Write((byte)0); // Grid Location?
m_Stream.Write(beheld.Serial);
m_Stream.Write((ushort)beheld.Hair.Hue);
++written;
}
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
{
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
m_Stream.Write((ushort)beheld.FacialHair.ItemID);
m_Stream.Write((byte)0); // signed, itemID offset
m_Stream.Write((ushort)1);
m_Stream.Write((short)0);
m_Stream.Write((short)0);
m_Stream.Write((byte)0); // Grid Location?
m_Stream.Write(beheld.Serial);
m_Stream.Write((ushort)beheld.FacialHair.Hue);
++written;
}
m_Stream.Seek(pos, SeekOrigin.Begin);
m_Stream.Write((ushort)written);
}
}
}

View file

@ -304,7 +304,7 @@ namespace Server.Items
{
case ECEffectType.Lightning:
{
Effects.SendBoltEffect(from, false);
Effects.SendBoltEffect(from, false, EffectHue);
break;
}
case ECEffectType.Location:
@ -334,4 +334,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -83,4 +83,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -66,7 +66,8 @@ namespace Server.Items
from.SendLocalizedMessage(1060581); // You've already lit it! Better throw it now!
}
m_Users ??= new List<Mobile>();
if (m_Users == null)
m_Users = new List<Mobile>();
if (!m_Users.Contains(from))
m_Users.Add(from);

View file

@ -1,4 +1,5 @@
using System;
using Server.Accounting;
namespace Server.Items
{

View file

@ -182,7 +182,8 @@ namespace Server.Items
if (addon != null)
{
isDecorableComponent |= count == 1 && Core.SE;
if (count == 1 && Core.SE)
isDecorableComponent = true;
if (m_Decorator.Command == DecorateCommand.Turn)
{
@ -190,7 +191,8 @@ namespace Server.Items
(FlippableAddonAttribute[])addon.GetType()
.GetCustomAttributes(typeof(FlippableAddonAttribute), false);
isDecorableComponent = attributes.Length > 0;
if (attributes.Length > 0)
isDecorableComponent = true;
}
}

View file

@ -1,4 +1,5 @@
using Server.Network;
using Server.Prompts;
using Server.Targeting;
namespace Server.Items
@ -203,9 +204,14 @@ namespace Server.Items
{
base.GetProperties(list);
string desc = m_KeyVal == 0 ? "(blank)" : m_Description?.Trim() ?? "";
string desc;
if (desc != "")
if (m_KeyVal == 0)
desc = "(blank)";
else if ((desc = m_Description) == null || (desc = desc.Trim()).Length <= 0)
desc = null;
if (desc != null)
list.Add(desc);
}
@ -213,10 +219,15 @@ namespace Server.Items
{
base.OnSingleClick(from);
string desc = m_KeyVal == 0 ? "(blank)" : m_Description?.Trim() ?? "";
string desc;
if (m_KeyVal == 0)
desc = "(blank)";
else if ((desc = m_Description) == null || (desc = desc.Trim()).Length <= 0)
desc = "";
if (desc.Length > 0)
Packets.SendUnicodeMessage(from.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, "ENU", "", desc);
from.Send(new UnicodeMessage(Serial, ItemID, MessageType.Regular, 0x3B2, 3, "ENU", "", desc));
}
public bool UseOn(Mobile from, ILockable o)

View file

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using Server.Targeting;
namespace Server.Items
@ -110,7 +109,14 @@ namespace Server.Items
UpdateItemID();
}
public bool ContainsKey(uint keyValue) => Keys.Any(key => key.KeyValue == keyValue);
public bool ContainsKey(uint keyValue)
{
foreach (Key key in Keys)
if (key.KeyValue == keyValue)
return true;
return false;
}
private void UpdateItemID()
{
@ -163,7 +169,9 @@ namespace Server.Items
}
else if (targeted is ILockable o)
{
if (m_KeyRing.Keys.Any(key => key.UseOn(from, o))) return;
foreach (Key key in m_KeyRing.Keys)
if (key.UseOn(from, o))
return;
from.SendLocalizedMessage(1008140); // You do not have a key for that.
}
@ -174,4 +182,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -1,4 +1,3 @@
using Server.Buffers;
using Server.Network;
namespace Server.Items
@ -20,21 +19,13 @@ namespace Server.Items
TileData.ItemTable[0x21A2].Height = 20;
}
protected override void SendWorldPacketFor(NetState state)
protected override Packet GetWorldPacketFor(NetState state)
{
Mobile mob = state.Mobile;
if (mob?.AccessLevel >= AccessLevel.GameMaster)
{
if (state.HighSeas)
SendGMItemHS(state);
else if (state.StygianAbyss)
SendGMItemSA(state);
else
SendGMItem(state);
}
if (mob?.AccessLevel >= AccessLevel.GameMaster) return new GMItemPacket(this);
base.SendWorldPacketFor(state);
return base.GetWorldPacketFor(state);
}
public override void Serialize(GenericWriter writer)
@ -54,138 +45,66 @@ namespace Server.Items
ItemID = 0x21A2;
}
private void SendGMItem(NetState ns)
public sealed class GMItemPacket : Packet
{
if (ns == null)
return;
public GMItemPacket(Item item) : base(0x1A)
{
EnsureCapacity(20);
SpanWriter w = new SpanWriter(stackalloc byte[20]);
w.Write((byte)0x1A); // Packet ID
w.Position += 2; // Dynamic Length
// 14 base length
// +2 - Amount
// +2 - Hue
// +1 - Flags
uint serial = Serial.Value;
int itemId = 0x36FF;
int amount = Amount;
Point3D loc = Location;
int x = loc.X;
int y = loc.Y;
int hue = Hue;
int flags = GetPacketFlags();
int direction = (int)Direction;
uint serial = item.Serial.Value;
int itemID = 0x36FF;
int amount = item.Amount;
Point3D loc = item.Location;
int x = loc.X;
int y = loc.Y;
int hue = item.Hue;
int flags = item.GetPacketFlags();
int direction = (int)item.Direction;
if (amount != 0)
serial |= 0x80000000;
else
serial &= 0x7FFFFFFF;
if (amount != 0)
serial |= 0x80000000;
else
serial &= 0x7FFFFFFF;
w.Write(serial);
m_Stream.Write(serial);
m_Stream.Write((short)(itemID & 0x7FFF));
w.Write((short)itemId);
if (amount != 0)
m_Stream.Write((short)amount);
if (amount != 0)
w.Write((short)amount);
x &= 0x7FFF;
x &= 0x7FFF;
if (direction != 0)
x |= 0x8000;
if (direction != 0) x |= 0x8000;
m_Stream.Write((short)x);
w.Write((short)x);
y &= 0x3FFF;
y &= 0x3FFF;
if (hue != 0)
y |= 0x8000;
if (hue != 0) y |= 0x8000;
if (flags != 0)
y |= 0x4000;
if (flags != 0) y |= 0x4000;
m_Stream.Write((short)y);
w.Write((short)y);
if (direction != 0)
m_Stream.Write((byte)direction);
if (direction != 0)
w.Write((byte)direction);
m_Stream.Write((sbyte)loc.Z);
w.Write((sbyte)loc.Z);
if (hue != 0)
m_Stream.Write((ushort)hue);
if (hue != 0)
w.Write((ushort)hue);
if (flags != 0)
w.Write((byte)flags);
w.Position = 1;
w.Write((ushort)w.WrittenCount);
ns.Send(w.Span);
}
public void SendGMItemSA(NetState ns)
{
if (ns == null)
return;
SpanWriter w = new SpanWriter(stackalloc byte[24]);
w.Write((byte)0xF3); // Packet ID
w.Write((short)0x01);
int itemId = 0x36FF;
w.Position++; // w.Write((byte)0);
w.Write(Serial);
w.Write((short)itemId);
w.Write((byte)Direction);
short amount = (short)Amount;
w.Write(amount);
w.Write(amount);
Point3D loc = Location;
w.Write((short)(loc.X & 0x7FFF));
w.Write((short)(loc.Y & 0x3FFF));
w.Write((sbyte)loc.Z);
w.Write((byte)Light);
w.Write((short)Hue);
w.Write((byte)GetPacketFlags());
ns.Send(w.RawSpan);
}
public void SendGMItemHS(NetState ns)
{
if (ns == null)
return;
SpanWriter w = new SpanWriter(stackalloc byte[26]);
w.Write((byte)0xF3); // Packet ID
w.Write((short)0x01);
int itemId = 0x36FF;
w.Position++; // w.Write((byte)0);
w.Write(Serial);
w.Write((short)itemId);
w.Write((byte)Direction);
short amount = (short)Amount;
w.Write(amount);
w.Write(amount);
Point3D loc = Location;
w.Write((short)(loc.X & 0x7FFF));
w.Write((short)(loc.Y & 0x3FFF));
w.Write((sbyte)loc.Z);
w.Write((byte)Light);
w.Write((short)Hue);
w.Write((byte)GetPacketFlags());
ns.Send(w.RawSpan);
if (flags != 0)
m_Stream.Write((byte)flags);
}
}
}
}

View file

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using Server.Gumps;
using Server.Multis;
using Server.Prompts;
using Server.Mobiles;
using Server.Network;
using Server.ContextMenus;

View file

@ -31,7 +31,11 @@ namespace Server.Items
private void AddGeneratorComponent(int itemID, int x, int y, int z)
{
AddComponent(new AddonComponent(itemID){ Name = "a power generator", Hue = 0x451 }, x, y, z);
AddonComponent component = new AddonComponent(itemID);
component.Name = "a power generator";
component.Hue = 0x451;
AddComponent(component, x, y, z);
}
public override void Serialize(GenericWriter writer)
@ -144,7 +148,9 @@ namespace Server.Items
visited[current.X, current.Y] = true;
}
else
{
current = stack[--stackSize - 1];
}
}
Path = new Node[stackSize];
@ -191,8 +197,9 @@ namespace Server.Items
public void DoDamage(Mobile to)
{
Packets.SendMessageLocalized(to.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, 1152372); // The Nexus shoots an arc of energy at you!
to.BoltEffect();
to.Send(new UnicodeMessage(Serial, ItemID, MessageType.Regular, 0x3B2, 3, "", "",
"The generator shoots an arc of electricity at you!"));
to.BoltEffect(0);
to.LocalOverheadMessage(MessageType.Regular, 0xC9, true, "* Your body convulses from electric shock *");
to.NonlocalOverheadMessage(MessageType.Regular, 0xC9, true, $"* {to.Name} spasms from electric shock *");
@ -351,7 +358,7 @@ namespace Server.Items
hues[n.X, n.Y] = NodeHue.Blue;
}
Node lastNode = path[^1];
Node lastNode = path[path.Length - 1];
hues[lastNode.X, lastNode.Y] = NodeHue.Red;
for (int i = 0; i < sideLength; i++)

View file

@ -119,7 +119,11 @@ namespace Server.Items
private static void DeleteAll()
{
List<Item> list = World.Items.Values.OfType<PublicMoongate>().Cast<Item>().ToList();
List<Item> list = new List<Item>();
foreach (Item item in World.Items.Values)
if (item is PublicMoongate)
list.Add(item);
foreach (Item item in list)
item.Delete();
@ -345,7 +349,7 @@ namespace Server.Items
}
}
public override void OnResponse(NetState sender, RelayInfo info)
public override void OnResponse(NetState state, RelayInfo info)
{
if (info.ButtonID == 0) // Cancel
return;

View file

@ -157,7 +157,10 @@ namespace Server.Items
{
base.GetProperties(list);
list.Add(m_Active ? 1060742 : 1060743);
if (m_Active)
list.Add(1060742); // active
else
list.Add(1060743); // inactive
if (m_MapDest != null)
list.Add(1060658, "Map\t{0}", m_MapDest);
@ -231,12 +234,12 @@ namespace Server.Items
bool sendEffect = !m.Hidden || m.AccessLevel == AccessLevel.Player;
if (m_SourceEffect && sendEffect)
Effects.SendLocationEffect(m.Location, m.Map, 0x3728, 10);
Effects.SendLocationEffect(m.Location, m.Map, 0x3728, 10, 10);
m.MoveToWorld(p, map);
if (m_DestEffect && sendEffect)
Effects.SendLocationEffect(m.Location, m.Map, 0x3728, 10);
Effects.SendLocationEffect(m.Location, m.Map, 0x3728, 10, 10);
if (m_SoundID > 0 && sendEffect)
Effects.PlaySound(m.Location, m.Map, m_SoundID);
@ -392,10 +395,11 @@ namespace Server.Items
if (m.BeginAction(this))
{
if (m_MessageString != null)
Packets.SendUnicodeMessage(m.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, "ENU", "",
m_MessageString);
m.Send(new UnicodeMessage(Serial, ItemID, MessageType.Regular, 0x3B2, 3, "ENU", null,
m_MessageString));
else if (m_MessageNumber != 0)
Packets.SendMessageLocalized(m.NetState, Serial, ItemID, MessageType.Regular, 0x3B2, 3, m_MessageNumber);
m.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, m_MessageNumber, null,
""));
Timer.DelayCall(TimeSpan.FromSeconds(5.0), () => m.EndAction(this));
}
@ -521,7 +525,12 @@ namespace Server.Items
if (!m.InRange(GetWorldLocation(), m_Range))
return;
bool isMatch = m_Keyword >= 0 && e.HasKeyword(m_Keyword) || m_Substring != null && e.Speech.ToLower().IndexOf(m_Substring.ToLower()) >= 0;
bool isMatch = false;
if (m_Keyword >= 0 && e.HasKeyword(m_Keyword))
isMatch = true;
else if (m_Substring != null && e.Speech.ToLower().IndexOf(m_Substring.ToLower()) >= 0)
isMatch = true;
if (!isMatch || !CanTeleport(m))
return;
@ -811,10 +820,10 @@ namespace Server.Items
writer.Write(TimeoutDelay);
writer.Write(m_Teleporting.Count);
foreach (var (key, value) in m_Teleporting)
foreach (KeyValuePair<Mobile, Timer> kvp in m_Teleporting)
{
writer.Write(key);
writer.Write(value.Next);
writer.Write(kvp.Key);
writer.Write(kvp.Value.Next);
}
}
@ -1054,7 +1063,9 @@ namespace Server.Items
case Layer.Backpack:
case Layer.Mount:
case Layer.Bank:
{
continue; // ignore
}
default:
{
m.SendMessage("You must remove all of your equipment before proceeding.");

View file

@ -112,7 +112,7 @@ namespace Server.Items
if (items.Count > 0)
{
PublicOverheadMessage(MessageType.Regular, 0x3B2, message);
PublicOverheadMessage(MessageType.Regular, 0x3B2, message, "");
for (int i = items.Count - 1; i >= 0; --i)
{

View file

@ -26,7 +26,7 @@ namespace Server.Items
public void Carve(Mobile from, Item item)
{
Effects.PlaySound(GetWorldLocation(), Map, 0x48F);
Effects.SendLocationEffect(GetWorldLocation(), Map, 0x3728, 10);
Effects.SendLocationEffect(GetWorldLocation(), Map, 0x3728, 10, 10, 0, 0);
if (0.3 > Utility.RandomDouble())
{

View file

@ -302,7 +302,7 @@ namespace Server.Items
if ((prop = Attributes.RegenMana) != 0)
list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~
if (Attributes.NightSight != 0)
if ((prop = Attributes.NightSight) != 0)
list.Add(1060441); // night sight
if ((prop = Attributes.ReflectPhysical) != 0)

View file

@ -54,8 +54,10 @@ namespace Server.Items
public override void OnSingleClick(Mobile from)
{
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, 0x3B2, 3,
Amount == 1 ? 1049122 : 1049121, "", (Amount * 50).ToString());
int number = Amount == 1 ? 1049122 : 1049121;
from.Send(
new MessageLocalized(Serial, ItemID, MessageType.Label, 0x3B2, 3, number, "", (Amount * 50).ToString()));
}
}
}

View file

@ -55,8 +55,9 @@ namespace Server.Items
public override void OnSingleClick(Mobile from)
{
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, 0x3B2, 3,
Amount == 1 ? 1049124 : 1049123, "", Amount.ToString());
int number = Amount == 1 ? 1049124 : 1049123;
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, number, "", Amount.ToString()));
}
}
}

View file

@ -29,10 +29,16 @@ namespace Server.Items
}
}
public override int LabelNumber =>
m_Resource >= CraftResource.SpinedLeather && m_Resource <= CraftResource.BarbedLeather
? 1049684 + (m_Resource - CraftResource.SpinedLeather)
: 1047022;
public override int LabelNumber
{
get
{
if (m_Resource >= CraftResource.SpinedLeather && m_Resource <= CraftResource.BarbedLeather)
return 1049684 + (m_Resource - CraftResource.SpinedLeather);
return 1047022;
}
}
int ICommodity.DescriptionNumber => LabelNumber;
bool ICommodity.IsDeedable => true;

View file

@ -55,8 +55,9 @@ namespace Server.Items
public override void OnSingleClick(Mobile from)
{
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, 0x3B2, 3,
Amount == 1 ? 1049124 : 1049123, "", Amount.ToString());
int number = Amount == 1 ? 1049124 : 1049123;
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Regular, 0x3B2, 3, number, "", Amount.ToString()));
}
}
}

View file

@ -44,7 +44,7 @@ namespace Server.Items
[CommandProperty(AccessLevel.GameMaster)]
public CampfireStatus Status
{
get => ItemID switch
get
{
return ItemID switch
{

View file

@ -233,19 +233,21 @@ namespace Server.Items
bool xEast = false, ySouth = false;
string fmt;
fmt = Sextant.Format(loc, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth) ?
$"{yLat}°{yMins}'{(ySouth ? "S" : "N")},{xLong}°{xMins}'{(xEast ? "E" : "W")}" : "?????";
if (Sextant.Format(loc, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth))
fmt = $"{yLat}°{yMins}'{(ySouth ? "S" : "N")},{xLong}°{xMins}'{(xEast ? "E" : "W")}";
else
fmt = "?????";
AddPage(0);
AddBackground(0, 40, 350, 300, 2520);
AddHtmlLocalized(30, 80, 285, 160, 1018326, true, true);
/* This is a message hastily scribbled by a passenger aboard a sinking ship.
* While it is probably too late to save the passengers and crew,
* perhaps some treasure went down with the ship!
* The message gives the ship's last known sextant co-ordinates.=
*/
AddHtmlLocalized(30, 80, 285, 160, 1018326, true,
true); /* This is a message hastily scribbled by a passenger aboard a sinking ship.
* While it is probably too late to save the passengers and crew,
* perhaps some treasure went down with the ship!
* The message gives the ship's last known sextant co-ordinates.
*/
AddHtml(35, 240, 230, 20, fmt);

View file

@ -200,6 +200,7 @@ namespace Server.Items
switch (Utility.Random(8))
{
default:
case 0:
x = -1;
y = -1;
break;
@ -404,4 +405,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -159,7 +159,9 @@ namespace Server.Items
if (!(from is PlayerMobile pm))
return;
list.Add(new ContextMenuEntry(pm.ToggleMiningStone ? 6179 : 6178) {Color = 0x421F});
ContextMenuEntry miningEntry = new ContextMenuEntry(pm.ToggleMiningStone ? 6179 : 6178);
miningEntry.Color = 0x421F;
list.Add(miningEntry);
list.Add(new ToggleMiningStoneEntry(pm, false, 6176));
list.Add(new ToggleMiningStoneEntry(pm, true, 6177));

View file

@ -167,7 +167,7 @@ namespace Server.Items
from.Map != Map.Felucca && TargetMap == Map.Felucca && ShowFeluccaWarning)
{
if (from.AccessLevel == AccessLevel.Player || !from.Hidden)
Packets.SendPlaySound(from.NetState, 0x20E, from.Location);
from.Send(new PlaySound(0x20E, from.Location));
from.CloseGump<MoongateConfirmGump>();
from.SendGump(new MoongateConfirmGump(from, this));
}
@ -381,7 +381,7 @@ namespace Server.Items
}
}
public override void OnResponse(NetState sender, RelayInfo info)
public override void OnResponse(NetState state, RelayInfo info)
{
if (info.ButtonID == 1)
m_Gate.EndConfirmation(m_From);

View file

@ -1,4 +1,5 @@
using Server.Multis;
using Server.Prompts;
using Server.Regions;
namespace Server.Items

View file

@ -76,7 +76,8 @@ namespace Server.Items
from.RevealingAction();
Users ??= new List<Mobile>();
if (Users == null)
Users = new List<Mobile>();
if (!Users.Contains(from))
Users.Add(from);
@ -168,7 +169,7 @@ namespace Server.Items
Effects.PlaySound(loc, map, 0x307);
Effects.SendLocationEffect(loc, map, 0x36B0, 9);
Effects.SendLocationEffect(loc, map, 0x36B0, 9, 10, 0, 0);
int alchemyBonus = 0;
if (direct)

View file

@ -29,7 +29,7 @@ namespace Server.Items
public override void Drink(Mobile from)
{
if (from.BeginAction<LightCycle.NightSightTimer>())
if (from.BeginAction<LightCycle>())
{
new LightCycle.NightSightTimer(from).Start();
from.LightLevel = LightCycle.DungeonLevel / 2;
@ -43,7 +43,9 @@ namespace Server.Items
Consume();
}
else
{
from.SendMessage("You already have nightsight.");
}
}
}
}
}

View file

@ -355,9 +355,13 @@ namespace Server.Items
if (dropped is RecallRune rune)
{
if (IsLockedDown && from.AccessLevel < AccessLevel.GameMaster)
{
from.SendLocalizedMessage(502413, null, 0x35); // That cannot be done while the book is locked down.
}
else if (IsOpen(from))
{
from.SendLocalizedMessage(1005571); // You cannot place objects in the book while viewing the contents.
}
else if (Entries.Count < 16)
{
if (rune.Marked && rune.TargetMap != null)
@ -366,12 +370,12 @@ namespace Server.Items
rune.Delete();
Packets.SendPlaySound(from.NetState, 0x42, GetWorldLocation());
from.Send(new PlaySound(0x42, GetWorldLocation()));
string desc = rune.Description;
if (desc == null || (desc = desc.Trim()).Length == 0)
desc = "(nondescript)";
desc = "(indescript)";
from.SendMessage(desc);
@ -381,13 +385,15 @@ namespace Server.Items
from.SendLocalizedMessage(502409); // This rune does not have a marked location.
}
else
{
from.SendLocalizedMessage(502401); // This runebook is full.
}
}
else if (dropped is RecallScroll)
{
if (CurCharges < MaxCharges)
{
Packets.SendPlaySound(from.NetState, 0x259, GetWorldLocation());
from.Send(new PlaySound(0x249, GetWorldLocation()));
int amount = dropped.Amount;
@ -405,7 +411,9 @@ namespace Server.Items
}
}
else
{
from.SendLocalizedMessage(502410); // This book already has the maximum amount of charges.
}
}
return false;

View file

@ -491,7 +491,7 @@ namespace Server.Items
scroll.Delete();
Packets.SendPlaySound(from.NetState, 0x249, GetWorldLocation());
from.Send(new PlaySound(0x249, GetWorldLocation()));
return true;
}
}
@ -569,16 +569,49 @@ namespace Server.Items
return;
if (Parent == null)
SendWorldPacketFor(ns);
{
to.Send(WorldPacket);
}
else if (Parent is Item)
{
// What will happen if the client doesn't know about our parent?
Packets.SendContainerContentUpdate(ns, this);
if (ns.ContainerGridLines)
to.Send(new ContainerContentUpdate6017(this));
else
to.Send(new ContainerContentUpdate(this));
}
else if (Parent is Mobile)
{
// What will happen if the client doesn't know about our parent?
Packets.SendEquipUpdate(ns, this);
to.Send(new EquipUpdate(this));
}
Packets.SendDisplayContainer(ns, Serial);
Packets.SendSpellbookContent(ns, Serial, ItemID, BookOffset + 1, m_Content);
if (ns.HighSeas)
to.Send(new DisplaySpellbookHS(this));
else
to.Send(new DisplaySpellbook(this));
if (ObjectPropertyList.Enabled)
{
if (ns.NewSpellbook)
{
to.Send(new NewSpellbookContent(this, ItemID, BookOffset + 1, m_Content));
}
else
{
if (ns.ContainerGridLines)
to.Send(new SpellbookContent6017(SpellCount, BookOffset + 1, m_Content, this));
else
to.Send(new SpellbookContent(SpellCount, BookOffset + 1, m_Content, this));
}
}
else
{
if (ns.ContainerGridLines)
to.Send(new SpellbookContent6017(SpellCount, BookOffset + 1, m_Content, this));
else
to.Send(new SpellbookContent(SpellCount, BookOffset + 1, m_Content, this));
}
}
public override void GetProperties(ObjectPropertyList list)
@ -777,9 +810,11 @@ namespace Server.Items
}
}
Attributes ??= new AosAttributes(this);
if (Attributes == null)
Attributes = new AosAttributes(this);
SkillBonuses ??= new AosSkillBonuses(this);
if (SkillBonuses == null)
SkillBonuses = new AosSkillBonuses(this);
if (Core.AOS && Parent is Mobile mobile)
SkillBonuses.AddTo(mobile);

View file

@ -387,7 +387,7 @@ namespace Server.Items
double toHeal = min + Utility.RandomDouble() * (max - min);
if (Patient.Body.IsMonster || Patient.Body.IsAnimal)
toHeal += Patient.HitsMax / 100.0;
toHeal += Patient.HitsMax / 100;
if (Core.AOS)
toHeal -= toHeal * Slips * 0.35; // TODO: Verify algorithm

View file

@ -79,8 +79,9 @@ namespace Server.Items
from.Backpack.ConsumeUpTo(typeof(SulfurousAsh), sulfAsh);
from.PlaySound(0x15F);
Effects.SendMovingEffect(from, loc, from.Map, 0x36D4, 5, 0, false, true);
Effects.SendPacket(from, from.Map,
new HuedEffect(EffectType.Moving, from.Serial, Serial.Zero, 0x36D4, from.Location, loc, 5, 0, false, true, 0,
0));
IPooledEnumerable<Mobile> eable = from.Map.GetMobilesInRange(new Point3D(loc), 2);
@ -91,9 +92,11 @@ namespace Server.Items
|| Core.AOS && !from.InLOS(m))
return false;
playerVsPlayer |= m.Player;
if (m.Player)
playerVsPlayer = true;
return true;
}).ToList();
eable.Free();

View file

@ -406,8 +406,13 @@ namespace Server.Items
number = 1041000;
}
if (attrs.Count > 0 || Crafter != null || Name == null)
EquipmentPackets.SendDisplayEquipmentInfo(from.NetState, this, number, m_Crafter, false, attrs);
if (attrs.Count == 0 && Crafter == null && Name != null)
return;
EquipmentInfo eqInfo = new EquipmentInfo(number, m_Crafter, false,
attrs.ToArray());
from.Send(new DisplayEquipmentInfo(this, eqInfo));
}
public override void Serialize(GenericWriter writer)

View file

@ -6,7 +6,7 @@ using Server.Mobiles;
namespace Server.Items
{
[Flippable(0x2790, 0x27DB)]
public class LeatherNinjaBelt : BaseWaist, INinjaWeapon
public class LeatherNinjaBelt : BaseWaist, IDyable, INinjaWeapon
{
private Poison m_Poison;
private int m_PoisonCharges;
@ -27,18 +27,18 @@ namespace Server.Items
public override CraftResource DefaultResource => CraftResource.RegularLeather;
public int WrongAmmoMessage => 1063301; //You can only place shuriken in a ninja belt.
public int NoFreeHandMessage => 1063299; //You must have a free hand to throw shuriken.
public int EmptyWeaponMessage => 1063297; //You have no shuriken in your ninja belt!
public int RecentlyUsedMessage => 1063298; //You cannot throw another shuriken yet.
public int FullWeaponMessage => 1063302; //You cannot add any more shuriken.
public virtual int WrongAmmoMessage => 1063301; //You can only place shuriken in a ninja belt.
public virtual int NoFreeHandMessage => 1063299; //You must have a free hand to throw shuriken.
public virtual int EmptyWeaponMessage => 1063297; //You have no shuriken in your ninja belt!
public virtual int RecentlyUsedMessage => 1063298; //You cannot throw another shuriken yet.
public virtual int FullWeaponMessage => 1063302; //You cannot add any more shuriken.
public int WeaponMinRange => 2;
public int WeaponMaxRange => 10;
public virtual int WeaponMinRange => 2;
public virtual int WeaponMaxRange => 10;
public int WeaponDamage => Utility.RandomMinMax(3, 5);
public virtual int WeaponDamage => Utility.RandomMinMax(3, 5);
public Type AmmoType => typeof(Shuriken);
public virtual Type AmmoType => typeof(Shuriken);
[CommandProperty(AccessLevel.GameMaster)]
public int UsesRemaining
@ -81,8 +81,7 @@ namespace Server.Items
public void AttackAnimation(Mobile from, Mobile to)
{
if (from.Body.IsHuman)
from.Animate(from.Mounted ? 26 : 9, 7, 1, true, false, 0);
if (from.Body.IsHuman) from.Animate(from.Mounted ? 26 : 9, 7, 1, true, false, 0);
from.PlaySound(0x23A);
from.MovingEffect(to, 0x27AC, 1, 0, false, false);
@ -157,4 +156,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -1,3 +1,4 @@
using Server.HuePickers;
using Server.Targeting;
namespace Server.Items

View file

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
namespace Server.Items
{
@ -30,10 +31,12 @@ namespace Server.Items
writer.Write(timerCount);
foreach (var (m, value) in DisguiseTimers.Timers)
foreach (KeyValuePair<Mobile, Timer> entry in DisguiseTimers.Timers)
{
Mobile m = entry.Key;
writer.Write(m);
writer.Write(value.Next - DateTime.UtcNow);
writer.Write(entry.Value.Next - DateTime.UtcNow);
writer.Write(m.NameMod);
}
}

View file

@ -20,10 +20,10 @@ namespace Server.Items
from.LocalOverheadMessage(MessageType.Regular, 0x3B2,
1008155); // You peer into the heavens, seeking the moons...
Packets.SendMessageLocalizedAffix(from.NetState, from.Serial, from.Body, MessageType.Regular, 0x3B2, 3,
1008146 + (int)Clock.GetMoonPhase(Map.Trammel, from.X, from.Y), "", AffixType.Prepend, "Trammel : ");
Packets.SendMessageLocalizedAffix(from.NetState, from.Serial, from.Body, MessageType.Regular, 0x3B2, 3,
1008146 + (int)Clock.GetMoonPhase(Map.Felucca, from.X, from.Y), "", AffixType.Prepend, "Felucca : ");
from.Send(new MessageLocalizedAffix(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3,
1008146 + (int)Clock.GetMoonPhase(Map.Trammel, from.X, from.Y), "", AffixType.Prepend, "Trammel : ", ""));
from.Send(new MessageLocalizedAffix(from.Serial, from.Body, MessageType.Regular, 0x3B2, 3,
1008146 + (int)Clock.GetMoonPhase(Map.Felucca, from.X, from.Y), "", AffixType.Prepend, "Felucca : ", ""));
if (from is PlayerMobile player)
{
@ -33,7 +33,7 @@ namespace Server.Items
return;
FindIngredientObjective obj = qs.FindObjective<FindIngredientObjective>();
if (obj?.Completed == false && obj.Ingredient == Ingredient.StarChart)
{
Clock.GetTime(from.Map, from.X, from.Y, out int hours, out int _);
@ -68,4 +68,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -7,6 +7,16 @@ using Server.Network;
namespace Server.Items
{
public sealed class StopMusic : Packet
{
public static readonly Packet Instance = SetStatic(new StopMusic());
public StopMusic() : base(0x6D, 3)
{
m_Stream.Write((short)0x1FFF);
}
}
[Flippable(0x2AF9, 0x2AFD)]
public class DawnsMusicBox : Item, ISecurable
{
@ -148,7 +158,7 @@ namespace Server.Items
else
m_ItemID = ItemID;
Packets.SendPlayMusic(m.NetState, music);
m.Send(new PlayMusic(music));
m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5), 4, Animate);
}
@ -157,7 +167,7 @@ namespace Server.Items
if (m_Timer?.Running == true)
m_Timer.Stop();
Packets.SendStopMusic(m.NetState);
m.Send(StopMusic.Instance);
if (m_Count > 0)
ItemID = m_ItemID;

View file

@ -108,7 +108,7 @@ namespace Server.Items
Point3D location = Location;
location.Z += 10;
Effects.SendLocationEffect(location, Map, 0x3709, 10, 10, 0x356);
Effects.SendLocationEffect(location, Map, 0x3709, 10, 10, 0x356, 0);
Effects.PlaySound(location, Map, 0x32E);
if (Items.Count > 0)

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using Server.Accounting;
@ -291,9 +290,22 @@ namespace Server.Items
}
}
private bool HasEntered(Mobile from) =>
from.Account is Account acc &&
(from entry in Entries select entry.From?.Account as Account).Any(entryAcc => entryAcc == acc);
private bool HasEntered(Mobile from)
{
if (!(from.Account is Account acc))
return false;
foreach (RaffleEntry entry in Entries)
if (entry.From != null)
{
Account entryAcc = entry.From.Account as Account;
if (entryAcc == acc)
return true;
}
return false;
}
private bool IsAtIPLimit(Mobile from)
{
@ -303,7 +315,12 @@ namespace Server.Items
IPAddress address = from.NetState.Address;
int tickets = 0;
return Entries.Where(entry => Utility.IPMatchClassC(entry.Address, address)).Any(entry => ++tickets >= EntryLimitPerIP);
foreach (RaffleEntry entry in Entries)
if (Utility.IPMatchClassC(entry.Address, address))
if (++tickets >= EntryLimitPerIP)
return true;
return false;
}
public static string FormatLocation(Point3D loc, Map map, bool displayMap)

View file

@ -219,34 +219,54 @@ namespace Server.Items
return;
if (from.Region.IsPartOf<Jail>())
{
from.SendMessage("You may not do that in jail.");
}
else if (!m_Bag.IsChildOf(from.Backpack))
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054107,
0x59); // This item must be in your backpack.
{
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1062334,
0x59); // The bag of sending must be in your backpack. 1054107 is gone from client, using generic response
}
else if (m_Bag.Charges == 0)
{
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1042544, 0x59); // This item is out of charges.
}
else if (targeted is Item item)
{
int reqCharges = (int)Math.Max(1, Math.Ceiling(item.TotalWeight / 10.0));
if (!item.IsChildOf(from.Backpack))
{
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054152,
0x59); // You may only send items from your backpack to your bank box.
}
else if (item is BagOfSending || item is Container)
Packets.SendAsciiMessage(from.NetState, m_Bag.Serial, m_Bag.ItemID, MessageType.Regular, 0x3B2, 3, "",
"You cannot send a container through the bag of sending." );
{
from.Send(new AsciiMessage(m_Bag.Serial, m_Bag.ItemID, MessageType.Regular, 0x3B2, 3, "",
"You cannot send a container through the bag of sending."));
}
else if (item.LootType == LootType.Cursed)
{
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054108,
0x59); // The bag of sending rejects the cursed item.
}
else if (!item.VerifyMove(from) || item is QuestItem || item.Nontransferable)
{
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054109,
0x59); // The bag of sending rejects that item.
}
else if (SpellHelper.IsDoomGauntlet(from.Map, from.Location))
{
from.SendLocalizedMessage(1062089); // You cannot use that here.
}
else if (!from.BankBox.TryDropItem(from, item, false))
{
MessageHelper.SendLocalizedMessageTo(m_Bag, from, 1054110, 0x59); // Your bank box is full.
}
else if (Core.ML && reqCharges > m_Bag.Charges)
{
from.SendLocalizedMessage(1079932); //You don't have enough charges to send that much weight
}
else
{
m_Bag.Charges -= Core.ML ? reqCharges : 1;
@ -258,4 +278,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -177,27 +177,41 @@ namespace Server.Items
return;
if (Charges == 0)
{
SendLocalizedMessageTo(from,
1054122); // The Crystal Ball darkens. It must be charged before it can be used again.
}
else if (pet is BaseMount mount && mount.Rider == from)
{
MessageHelper.SendLocalizedMessageTo(this, from, 1054124,
0x36); // The Crystal Ball fills with a yellow mist. Why would you summon your pet while riding it?
}
else if (pet.Map == Map.Internal && (!pet.IsStabled || from.Followers + pet.ControlSlots > from.FollowersMax))
{
MessageHelper.SendLocalizedMessageTo(this, from, 1054125,
0x5); // The Crystal Ball fills with a blue mist. Your pet is not responding to the summons.
}
else if ((!pet.Controlled || pet.ControlMaster != from) && !from.Stabled.Contains(pet))
{
MessageHelper.SendLocalizedMessageTo(this, from, 1054126,
0x8FD); // The Crystal Ball fills with a grey mist. You are not the owner of the pet you are attempting to summon.
}
else if (!pet.IsBonded)
{
MessageHelper.SendLocalizedMessageTo(this, from, 1054127,
0x22); // The Crystal Ball fills with a red mist. You appear to have let your bond to your pet deteriorate.
}
else if (from.Map == Map.Ilshenar || from.Region.IsPartOf<DungeonRegion>() ||
from.Region.IsPartOf<Jail>() || from.Region.IsPartOf<SafeZone>())
Packets.SendAsciiMessage(from.NetState, Serial, ItemID, MessageType.Regular, 0x22, 3, "",
"You cannot summon your pet to this location.");
{
from.Send(new AsciiMessage(Serial, ItemID, MessageType.Regular, 0x22, 3, "",
"You cannot summon your pet to this location."));
}
else if (Core.ML && from is PlayerMobile mobile && DateTime.UtcNow < mobile.LastPetBallTime.AddSeconds(15.0))
{
MessageHelper.SendLocalizedMessageTo(this, mobile, 1080072,
0x22); // You must wait a few seconds before you can summon your pet.
}
else
{
if (Core.ML)

View file

@ -5,6 +5,7 @@ using Server.Factions;
using Server.Misc;
using Server.Mobiles;
using Server.Network;
using Server.Prompts;
using Server.Regions;
using Server.Spells;
using Server.Targeting;

View file

@ -0,0 +1,22 @@
using Server.Network;
namespace Server
{
public class MessageHelper
{
public static void SendLocalizedMessageTo(Item from, Mobile to, int number, int hue)
{
SendLocalizedMessageTo(from, to, number, "", hue);
}
public static void SendLocalizedMessageTo(Item from, Mobile to, int number, string args, int hue)
{
to.Send(new MessageLocalized(from.Serial, from.ItemID, MessageType.Regular, hue, 3, number, "", args));
}
public static void SendMessageTo(Item from, Mobile to, string text, int hue)
{
to.Send(new UnicodeMessage(from.Serial, from.ItemID, MessageType.Regular, hue, 3, "ENU", "", text));
}
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Linq;
using Server.Accounting;
using Server.Engines.VeteranRewards;
using Server.Factions;
@ -580,6 +579,7 @@ namespace Server.Items
return;
}
SkillName skill = m_Stone.Skill;
double skillValue = m_Stone.SkillValue;
Skill fromSkill = from.Skills[m_Stone.Skill];
@ -589,8 +589,27 @@ namespace Server.Items
*/
int requiredAmount = (int)(skillValue * 10) - fromSkill.BaseFixedPoint - (from.SkillsCap - from.SkillsTotal);
bool cannotAbsorb = fromSkill.Lock != SkillLock.Up || requiredAmount > 0 &&
requiredAmount > from.Skills.Where(t => t.Lock == SkillLock.Down).Sum(t => t.BaseFixedPoint);
bool cannotAbsorb = false;
if (fromSkill.Lock != SkillLock.Up)
{
cannotAbsorb = true;
}
else if (requiredAmount > 0)
{
int available = 0;
for (int i = 0; i < from.Skills.Length; ++i)
{
if (from.Skills[i].Lock != SkillLock.Down)
continue;
available += from.Skills[i].BaseFixedPoint;
}
if (requiredAmount > available)
cannotAbsorb = true;
}
if (cannotAbsorb)
{

View file

@ -81,12 +81,10 @@ namespace Server.Items
}
public override int Message =>
1049469;
/* Using a scroll increases the maximum amount of a specific skill or your maximum statistics.
* When used, the effect is not immediately seen without a gain of points with that skill or statistics.
* You can view your maximum skill values in your skills window.
* You can view your maximum statistic value in your statistics window.
*/
1049469; /* Using a scroll increases the maximum amount of a specific skill or your maximum statistics.
* When used, the effect is not immediately seen without a gain of points with that skill or statistics.
* You can view your maximum skill values in your skills window.
* You can view your maximum statistic value in your statistics window. */
public override int Title
{
@ -95,12 +93,10 @@ namespace Server.Items
double level = (Value - 105.0) / 5.0;
if (level >= 0.0 && level <= 3.0 && Value % 5.0 == 0.0)
return 1049635 + (int)level;
/* Wonderous Scroll (105 Skill): OR
* Exalted Scroll (110 Skill): OR
* Mythical Scroll (115 Skill): OR
* Legendary Scroll (120 Skill):
*/
return 1049635 + (int)level; /* Wonderous Scroll (105 Skill): OR
* Exalted Scroll (110 Skill): OR
* Mythical Scroll (115 Skill): OR
* Legendary Scroll (120 Skill): */
return 0;
}
@ -158,12 +154,10 @@ namespace Server.Items
double level = (Value - 105.0) / 5.0;
if (level >= 0.0 && level <= 3.0 && Value % 5.0 == 0.0)
list.Add(1049639 + (int)level, GetNameLocalized());
/* a wonderous scroll of ~1_type~ (105 Skill) OR
* an exalted scroll of ~1_type~ (110 Skill) OR
* a mythical scroll of ~1_type~ (115 Skill) OR
* a legendary scroll of ~1_type~ (120 Skill)
*/
list.Add(1049639 + (int)level, GetNameLocalized()); /* a wonderous scroll of ~1_type~ (105 Skill) OR
* an exalted scroll of ~1_type~ (110 Skill) OR
* a mythical scroll of ~1_type~ (115 Skill) OR
* a legendary scroll of ~1_type~ (120 Skill) */
else
list.Add("a power scroll of {0} ({1} Skill)", GetName(), Value);
}

View file

@ -1,5 +1,4 @@
using System;
using System.Linq;
using Server.Engines.MLQuests;
using Server.Engines.MLQuests.Objectives;
using Server.Mobiles;
@ -22,11 +21,9 @@ namespace Server.Items
public override int LabelNumber => 1078604; // Scroll of Alacrity
public override int Message =>
1078602;
/* Using a Scroll of Transcendence for a given skill will permanently increase your current
* level in that skill by the amount of points displayed on the scroll.
* As you may not gain skills beyond your maximum skill cap, any excess points will be lost.
*/
1078602; /*Using a Scroll of Transcendence for a given skill will permanently increase your current
*level in that skill by the amount of points displayed on the scroll.
*As you may not gain skills beyond your maximum skill cap, any excess points will be lost.*/
public override string DefaultTitle => "<basefont color=#FFFFFF>Scroll of Alacrity:</basefont>";
@ -77,10 +74,8 @@ namespace Server.Items
if (tskill >= tcap || from.Skills[Skill].Lock != SkillLock.Up)
{
from.SendLocalizedMessage(
1094935);
/* You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu.
* If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap.
*/
1094935); /*You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu.
*If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap.*/
return;
}

View file

@ -1,5 +1,4 @@
using System;
using System.Linq;
using Server.Engines.MLQuests;
using Server.Engines.MLQuests.Objectives;
using Server.Mobiles;
@ -22,11 +21,9 @@ namespace Server.Items
public override int LabelNumber => 1094934; // Scroll of Transcendence
public override int Message =>
1094933;
/* Using a Scroll of Transcendence for a given skill will permanently increase your current
* level in that skill by the amount of points displayed on the scroll.
* As you may not gain skills beyond your maximum skill cap, any excess points will be lost.
*/
1094933; /*Using a Scroll of Transcendence for a given skill will permanently increase your current
*level in that skill by the amount of points displayed on the scroll.
*As you may not gain skills beyond your maximum skill cap, any excess points will be lost.*/
public override string DefaultTitle =>
$"<basefont color=#FFFFFF>Scroll of Transcendence ({Value} Skill):</basefont>";
@ -115,10 +112,8 @@ namespace Server.Items
if (!canGain)
{
from.SendLocalizedMessage(
1094935);
/* You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu.
* If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap.
*/
1094935); /*You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu.
*If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap.*/
return;
}

View file

@ -158,7 +158,7 @@ namespace Server.Items
AddHtmlLocalized(310, 20, 120, 20, AosSkillBonuses.GetLabel(m_Scroll.Skill), 0xFFFFFF);
}
public override void OnResponse(NetState sender, RelayInfo info)
public override void OnResponse(NetState state, RelayInfo info)
{
if (info.ButtonID == 1)
m_Scroll.Use(m_Mobile);

View file

@ -12,12 +12,10 @@ namespace Server.Items
}
public override int Message =>
1049469;
/* Using a scroll increases the maximum amount of a specific skill or your maximum statistics.
* When used, the effect is not immediately seen without a gain of points with that skill or statistics.
* You can view your maximum skill values in your skills window.
* You can view your maximum statistic value in your statistics window.
*/
1049469; /* Using a scroll increases the maximum amount of a specific skill or your maximum statistics.
* When used, the effect is not immediately seen without a gain of points with that skill or statistics.
* You can view your maximum skill values in your skills window.
* You can view your maximum statistic value in your statistics window. */
public override int Title
{
@ -26,13 +24,11 @@ namespace Server.Items
int level = ((int)Value - 230) / 5;
if (level >= 0 && level <= 4 && Value % 5 == 0)
return 1049458 + level;
/* Wonderous Scroll (+5 Maximum Stats): OR
* Exalted Scroll (+10 Maximum Stats): OR
* Mythical Scroll (+15 Maximum Stats): OR
* Legendary Scroll (+20 Maximum Stats): OR
* Ultimate Scroll (+25 Maximum Stats):
*/
return 1049458 + level; /* Wonderous Scroll (+5 Maximum Stats): OR
* Exalted Scroll (+10 Maximum Stats): OR
* Mythical Scroll (+15 Maximum Stats): OR
* Legendary Scroll (+20 Maximum Stats): OR
* Ultimate Scroll (+25 Maximum Stats): */
return 0;
}
@ -46,13 +42,11 @@ namespace Server.Items
int level = ((int)Value - 230) / 5;
if (level >= 0 && level <= 4 && (int)Value % 5 == 0)
list.Add(1049463 + level, "#1049476");
/* a wonderous scroll of ~1_type~ (+5 Maximum Stats) OR
* an exalted scroll of ~1_type~ (+10 Maximum Stats) OR
* a mythical scroll of ~1_type~ (+15 Maximum Stats) OR
* a legendary scroll of ~1_type~ (+20 Maximum Stats) OR
* an ultimate scroll of ~1_type~ (+25 Maximum Stats)
*/
list.Add(1049463 + level, "#1049476"); /* a wonderous scroll of ~1_type~ (+5 Maximum Stats) OR
* an exalted scroll of ~1_type~ (+10 Maximum Stats) OR
* a mythical scroll of ~1_type~ (+15 Maximum Stats) OR
* a legendary scroll of ~1_type~ (+20 Maximum Stats) OR
* an ultimate scroll of ~1_type~ (+25 Maximum Stats) */
else
list.Add("a scroll of power ({0}{1} Maximum Stats)", Value - 225 >= 0 ? "+" : "", Value - 225);
}

View file

@ -135,9 +135,9 @@ namespace Server.Items
{
}
public override void OnResponse(NetState sender, RelayInfo info)
public override void OnResponse(NetState state, RelayInfo info)
{
Mobile from = sender.Mobile;
Mobile from = state.Mobile;
if (info.ButtonID == 1 || info.ButtonID == 2)
{
@ -147,10 +147,9 @@ namespace Server.Items
return;
}
if (from is PlayerMobile mobile)
mobile.AnkhNextUse = DateTime.UtcNow + TimeSpan.FromHours(1);
if (from is PlayerMobile mobile) mobile.AnkhNextUse = DateTime.UtcNow + TimeSpan.FromHours(1);
base.OnResponse(sender, info);
base.OnResponse(state, info);
}
}
}

Some files were not shown because too many files have changed in this diff Show more