Skip to content

Commit

Permalink
WIP - Fix up for T2A
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman committed Jan 9, 2025
1 parent 858f071 commit fb311c7
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 157 deletions.
12 changes: 1 addition & 11 deletions Projects/Server/Items/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4124,17 +4124,7 @@ public virtual void OnAosSingleClick(Mobile from)
}
}

public static void AppendWithSpace(StringBuilder builder, string text)
{
if (!string.IsNullOrEmpty(text))
{
return;
}
if (builder.Length > 0) builder.Append(" ");
builder.Append(text);
}

public virtual void OnSingleClickPreAOS(Mobile from)
public virtual void OnSingleClickPreUOTD(Mobile from)
{
return;
}
Expand Down
15 changes: 15 additions & 0 deletions Projects/Server/Text/StringHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Server.Buffers;
using Server.Text;

namespace Server;

Expand Down Expand Up @@ -286,4 +287,18 @@ public static char[] ToPooledArray(this string str)
str.CopyTo(chars);
return chars;
}

public static void AppendWithArticle(this ref ValueStringBuilder builder, string text, bool articleAn)
{
if (builder.Length == 0)
{
builder.Append(articleAn ? "an " : "a ");
}
else
{
builder.Append(' ');
}

builder.Append(text);
}
}
4 changes: 2 additions & 2 deletions Projects/UOContent/Items/Armor/BaseArmor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ public override void OnSingleClick(Mobile from)
{
if (!Core.AOS)
{
OnSingleClickPreAOS(from);
OnSingleClickPreUOTD(from);
return;
}

Expand Down Expand Up @@ -1520,7 +1520,7 @@ public override void OnSingleClick(Mobile from)
from.NetState.SendDisplayEquipmentInfo(Serial, number, _crafter, false, attrs);
}

public override void OnSingleClickPreAOS(Mobile from)
public override void OnSingleClickPreUOTD(Mobile from)
{
string prefix = null;
string suffix = null;
Expand Down
4 changes: 2 additions & 2 deletions Projects/UOContent/Items/Clothing/BaseClothing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ public override void OnSingleClick(Mobile from)
{
if (!Core.AOS)
{
OnSingleClickPreAOS(from);
OnSingleClickPreUOTD(from);
return;
}
var attrs = new List<EquipInfoAttribute>();
Expand All @@ -936,7 +936,7 @@ public override void OnSingleClick(Mobile from)
from.NetState.SendDisplayEquipmentInfo(Serial, number, _crafter, false, attrs);
}

public override void OnSingleClickPreAOS(Mobile from)
public override void OnSingleClickPreUOTD(Mobile from)
{
var qualityText = Quality != ClothingQuality.Regular
? Localization.GetText(1018305 - (int)Quality, from.Language)?.ToLowerInvariant() ?? "" : "";
Expand Down
4 changes: 2 additions & 2 deletions Projects/UOContent/Items/Wands/BaseWand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public override void OnSingleClick(Mobile from)
{
if (!Core.AOS)
{
OnSingleClickPreAOS(from);
OnSingleClickPreUOTD(from);
return;
}

Expand Down Expand Up @@ -237,7 +237,7 @@ public override void OnSingleClick(Mobile from)
from.NetState.SendDisplayEquipmentInfo(Serial, number, Crafter, false, attrs);
}

public override void OnSingleClickPreAOS(Mobile from)
public override void OnSingleClickPreUOTD(Mobile from)
{
string prefix = null;
string suffix = null;
Expand Down
155 changes: 90 additions & 65 deletions Projects/UOContent/Items/Weapons/BaseWeapon.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using ModernUO.Serialization;
using Server.Collections;
using Server.Engines.Craft;
Expand All @@ -18,6 +17,7 @@
using Server.Spells.Ninjitsu;
using Server.Spells.Sixth;
using Server.Spells.Spellweaving;
using Server.Text;

namespace Server.Items;

Expand Down Expand Up @@ -3333,9 +3333,9 @@ out var direct

public override void OnSingleClick(Mobile from)
{
if (!Core.AOS)
if (Core.Expansion < Expansion.UOTD)
{
OnSingleClickPreAOS(from);
OnSingleClickPreUOTD(from);
return;
}

Expand Down Expand Up @@ -3430,91 +3430,116 @@ public override void OnSingleClick(Mobile from)
from.NetState.SendDisplayEquipmentInfo(Serial, number, _crafter, false, attrs);
}

public override void OnSingleClickPreAOS(Mobile from)
public override void OnSingleClickPreUOTD(Mobile from)
{
string prefix = null;
string suffix = null;
string slayerSuffix = SlayerNameExtensions.GetSlayerNamePreAOS(_slayer, from);

var isMagicItem = _durabilityLevel != WeaponDurabilityLevel.Regular ||
_accuracyLevel != WeaponAccuracyLevel.Regular ||
_damageLevel != WeaponDamageLevel.Regular ||
slayerSuffix != "none";

// Construct prefix and suffix
var prefixBuilder = new StringBuilder();
var suffixBuilder = new StringBuilder();
var articleAnName = (TileData.ItemTable[ItemID].Flags & TileFlag.ArticleAn) != 0;

if (isMagicItem && !_identified)
if (!_identified)
{
prefix = Localization.GetText(1038000, from.Language)?.ToLowerInvariant();
LabelTo(from, $"an unidentified {Name ?? Localization.GetText(LabelNumber)}");
return;
}
else

var isMagicItem = _durabilityLevel > WeaponDurabilityLevel.Regular ||
_accuracyLevel > WeaponAccuracyLevel.Regular ||
_damageLevel > WeaponDamageLevel.Regular;

if (isMagicItem)
{
var qualityText = Quality != WeaponQuality.Regular
? Localization.GetText(1018305 - (int)Quality, from.Language)?.ToLowerInvariant() ?? "" : "";
var builder = ValueStringBuilder.Create(128);

var durabilityText = _durabilityLevel != WeaponDurabilityLevel.Regular
? Localization.GetText(1038000 + (int)_durabilityLevel, from.Language)?.ToLowerInvariant() ?? "" : "";
var durabilityText = DurabilityText(out var articleAnDurability);
if (durabilityText != null)
{
builder.AppendWithArticle(durabilityText, articleAnDurability);
}

var accuracyText = _accuracyLevel != WeaponAccuracyLevel.Regular
? Localization.GetText(1038010 + (int)_accuracyLevel, from.Language)?.ToLowerInvariant() ?? "" : "";
var accuracyText = AccuracyText(out var articleAnAccuracy);
if (accuracyText != null)
{
builder.AppendWithArticle(accuracyText, articleAnAccuracy);
}

var damageText = _damageLevel != WeaponDamageLevel.Regular
? Localization.GetText(1038015 + (int)_damageLevel, from.Language)?.ToLowerInvariant() ?? "" : "";
var slayerText = SlayerGroup.GetEntryByName(_slayer).SlayerText(out var articleAnSlayer);
if (slayerText != null)
{
builder.AppendWithArticle(slayerText, articleAnSlayer);
}

// Append text
AppendWithSpace(prefixBuilder, qualityText);
AppendWithSpace(prefixBuilder, durabilityText);
AppendWithSpace(prefixBuilder, accuracyText);
AppendWithSpace(suffixBuilder, damageText);
builder.AppendWithArticle(Name ?? Localization.GetText(LabelNumber), articleAnName);

// Append slayer type
if (!string.Equals(slayerSuffix, "none", StringComparison.OrdinalIgnoreCase))
var weaponLevelText = WeaponLevelText();
if (weaponLevelText != null)
{
if (suffixBuilder.Length > 0)
{
suffixBuilder.Append(" and ");
}
suffixBuilder.Append(slayerSuffix);
builder.Append($" of {weaponLevelText}");
}

// Convert to strings
prefix = prefixBuilder.Length > 0 ? prefixBuilder.ToString() : null;
suffix = suffixBuilder.Length > 0 ? suffixBuilder.ToString() : null;
}
// TODO: Spells (of Ghoul's Touch)

// Add any unique name
if (Name != null && _identified)
{
LabelTo(from, Name);
LabelTo(from, builder.ToString());
builder.Dispose();
return;
}

// Add label
if (prefix != null && suffix != null) // ~1_PREFIX~ ~2_ITEM~ of ~3_SUFFIX~
{
LabelTo(from, 1151756, $"{prefix}\t#{LabelNumber}\t{suffix}");
}
else if (prefix != null && suffix == null) // ~1_PREFIX~ ~2_ITEM~
{
LabelTo(from, 1151757, $"{prefix}\t#{LabelNumber}");
}
else if (prefix == null && suffix != null) // ~1_ITEM~ of ~2_SUFFIX~
var name = Name ??
$"{(articleAnName ? "an" : "a")} {Localization.GetText(LabelNumber)}";

if (Crafter == null)
{
LabelTo(from, 1151758, $"#{LabelNumber}\t{suffix}");
LabelTo(from, Quality == WeaponQuality.Exceptional ? $"{name} of exceptional quality" : name);
return;
}
else

LabelTo(
from,
Quality == WeaponQuality.Exceptional
? $"{name} crafted with exceptional quality by {Crafter}"
: $"{name} crafted by {Crafter}"
);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private string DurabilityText(out bool articleAn)
{
articleAn = _durabilityLevel is WeaponDurabilityLevel.Indestructible;
return _durabilityLevel switch
{
LabelTo(from, LabelNumber);
}
WeaponDurabilityLevel.Durable => "durable",
WeaponDurabilityLevel.Substantial => "substantial",
WeaponDurabilityLevel.Massive => "massive",
WeaponDurabilityLevel.Fortified => "fortified",
WeaponDurabilityLevel.Indestructible => "indestructible",
_ => null
};
}

// Add maker's mark
if (PlayerConstructed && Crafter != null)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private string AccuracyText(out bool articleAn)
{
articleAn = _accuracyLevel is WeaponAccuracyLevel.Accurate or WeaponAccuracyLevel.Eminently;
return _accuracyLevel switch
{
LabelTo(from, 1050043, Crafter.ToString()); // crafted by ~1_NAME~
}
WeaponAccuracyLevel.Accurate => "accurate",
WeaponAccuracyLevel.Surpassingly => "surpassingly accurate",
WeaponAccuracyLevel.Eminently => "eminently accurate",
WeaponAccuracyLevel.Exceedingly => "exceedingly accurate",
WeaponAccuracyLevel.Supremely => "supremely accurate",
_ => null
};
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private string WeaponLevelText() =>
_damageLevel switch
{
WeaponDamageLevel.Ruin => "ruin",
WeaponDamageLevel.Might => "might",
WeaponDamageLevel.Force => "force",
WeaponDamageLevel.Power => "power",
WeaponDamageLevel.Vanq => "vanquishing",
_ => null
};

public virtual int GetHitAttackSound(Mobile attacker, Mobile defender)
{
var sound = attacker.GetAttackSound();
Expand Down
14 changes: 14 additions & 0 deletions Projects/UOContent/Items/Weapons/SlayerEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ public int Title
}
}

public string SlayerText(out bool articleAn)
{
if (Name == SlayerName.None)
{
articleAn = false;
return null;
}

articleAn = Name is SlayerName.OrcSlaying or SlayerName.OgreTrashing or SlayerName.Exorcism or SlayerName.Ophidian
or SlayerName.ArachnidDoom or SlayerName.ElementalBan or SlayerName.ElementalHealth or SlayerName.EarthShatter;

return Localization.GetText(Title)?.ToLowerInvariant();
}

public bool Slays(Mobile m)
{
var t = m.GetType();
Expand Down
Loading

0 comments on commit fb311c7

Please sign in to comment.