feat: Adds Pre-UOTD single click support for weapons, armor, wands, and clothing (#2053)
This commit is contained in:
parent
863b4b5460
commit
3b698de556
7 changed files with 350 additions and 12 deletions
|
|
@ -1,10 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Engines.Craft;
|
||||
using Server.Ethics;
|
||||
using Server.Factions;
|
||||
using Server.Network;
|
||||
using Server.Text;
|
||||
using AMA = Server.Items.ArmorMeditationAllowance;
|
||||
using AMT = Server.Items.ArmorMaterialType;
|
||||
|
||||
|
|
@ -559,6 +561,7 @@ namespace Server.Items
|
|||
|
||||
Resource = CraftResources.GetFromType(resourceType);
|
||||
PlayerConstructed = true;
|
||||
Identified = true;
|
||||
|
||||
var context = craftSystem.GetContext(from);
|
||||
|
||||
|
|
@ -1451,6 +1454,12 @@ namespace Server.Items
|
|||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
{
|
||||
if (!Core.UOTD)
|
||||
{
|
||||
OnSingleClickPreUOTD(from);
|
||||
return;
|
||||
}
|
||||
|
||||
var attrs = new List<EquipInfoAttribute>();
|
||||
|
||||
if (DisplayLootType)
|
||||
|
|
@ -1482,13 +1491,12 @@ namespace Server.Items
|
|||
attrs.Add(new EquipInfoAttribute(1038000 + (int)_durability));
|
||||
}
|
||||
|
||||
if (_protectionLevel > ArmorProtectionLevel.Regular && _protectionLevel <= ArmorProtectionLevel.Invulnerability)
|
||||
if (_protectionLevel != ArmorProtectionLevel.Regular)
|
||||
{
|
||||
attrs.Add(new EquipInfoAttribute(1038005 + (int)_protectionLevel));
|
||||
}
|
||||
}
|
||||
else if (_durability != ArmorDurabilityLevel.Regular || _protectionLevel > ArmorProtectionLevel.Regular &&
|
||||
_protectionLevel <= ArmorProtectionLevel.Invulnerability)
|
||||
else if (_durability != ArmorDurabilityLevel.Regular || _protectionLevel != ArmorProtectionLevel.Regular)
|
||||
{
|
||||
attrs.Add(new EquipInfoAttribute(1038000)); // Unidentified
|
||||
}
|
||||
|
|
@ -1513,6 +1521,100 @@ namespace Server.Items
|
|||
from.NetState.SendDisplayEquipmentInfo(Serial, number, _crafter, false, attrs);
|
||||
}
|
||||
|
||||
public void OnSingleClickPreUOTD(Mobile from)
|
||||
{
|
||||
var isMagicItem = _durability != ArmorDurabilityLevel.Regular ||
|
||||
_protectionLevel != ArmorProtectionLevel.Regular;
|
||||
|
||||
if (isMagicItem && !_identified)
|
||||
{
|
||||
LabelTo(from, $"an unidentified {Name ?? Localization.GetText(LabelNumber).ToLowerInvariant()}");
|
||||
return;
|
||||
}
|
||||
|
||||
var name = Name;
|
||||
var articleAnName = (TileData.ItemTable[ItemID].Flags & TileFlag.ArticleAn) != 0;
|
||||
|
||||
if (isMagicItem)
|
||||
{
|
||||
var builder = ValueStringBuilder.Create(128);
|
||||
|
||||
var durabilityText = DurabilityText(out var articleAnDurability);
|
||||
if (durabilityText != null)
|
||||
{
|
||||
builder.AppendSpaceWithArticle(durabilityText, articleAnDurability);
|
||||
}
|
||||
|
||||
if (name == null)
|
||||
{
|
||||
builder.AppendSpaceWithArticle(Localization.GetText(LabelNumber).ToLowerInvariant(), articleAnName);
|
||||
}
|
||||
else if (builder.Length != 0)
|
||||
{
|
||||
builder.Append($" {name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Append(name);
|
||||
}
|
||||
|
||||
var protectionText = ProtectionText;
|
||||
if (protectionText != null)
|
||||
{
|
||||
builder.Append($" of {protectionText}");
|
||||
}
|
||||
|
||||
LabelTo(from, builder.ToString());
|
||||
builder.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
name ??= $"{(articleAnName ? "an" : "a")} {Localization.GetText(LabelNumber).ToLowerInvariant()}";
|
||||
|
||||
if (Crafter == null)
|
||||
{
|
||||
LabelTo(from, Quality == ArmorQuality.Exceptional ? $"{name} of exceptional quality" : name);
|
||||
return;
|
||||
}
|
||||
|
||||
LabelTo(
|
||||
from,
|
||||
Quality == ArmorQuality.Exceptional
|
||||
? $"{name} crafted with exceptional quality by {Crafter}"
|
||||
: $"{name} crafted by {Crafter}"
|
||||
);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private string DurabilityText(out bool articleAn)
|
||||
{
|
||||
articleAn = _durability is ArmorDurabilityLevel.Indestructible;
|
||||
return _durability switch
|
||||
{
|
||||
ArmorDurabilityLevel.Durable => "durable",
|
||||
ArmorDurabilityLevel.Substantial => "substantial",
|
||||
ArmorDurabilityLevel.Massive => "massive",
|
||||
ArmorDurabilityLevel.Fortified => "fortified",
|
||||
ArmorDurabilityLevel.Indestructible => "indestructable",
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
private string ProtectionText
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get =>
|
||||
_protectionLevel switch
|
||||
{
|
||||
ArmorProtectionLevel.Defense => "defense",
|
||||
ArmorProtectionLevel.Guarding => "guarding",
|
||||
ArmorProtectionLevel.Hardening => "hardening",
|
||||
ArmorProtectionLevel.Fortification => "fortification",
|
||||
ArmorProtectionLevel.Invulnerability => "invulnerability",
|
||||
_ => null
|
||||
};
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum OldSaveFlag
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue