From 862d14cdff6b60081c07e39621d4b81f2a831abb Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 22 Jun 2026 08:03:51 -0700 Subject: [PATCH] feat(aos): add AosWeaponAttributes.GetProperties(IPropertyList) --- .../AosWeaponAttributesPropertiesTests.cs | 60 ++++++++++++ Projects/UOContent/Misc/AOS.cs | 95 +++++++++++++++++++ 2 files changed, 155 insertions(+) create mode 100644 Projects/UOContent.Tests/Tests/PropertyList/AosWeaponAttributesPropertiesTests.cs diff --git a/Projects/UOContent.Tests/Tests/PropertyList/AosWeaponAttributesPropertiesTests.cs b/Projects/UOContent.Tests/Tests/PropertyList/AosWeaponAttributesPropertiesTests.cs new file mode 100644 index 000000000..d59939146 --- /dev/null +++ b/Projects/UOContent.Tests/Tests/PropertyList/AosWeaponAttributesPropertiesTests.cs @@ -0,0 +1,60 @@ +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using Server; +using Server.Items; +using Xunit; + +namespace UOContent.Tests; + +[Collection("Sequential UOContent Tests")] +public class AosWeaponAttributesPropertiesTests +{ + private static Dictionary Decode(ObjectPropertyList opl) + { + opl.Terminate(); + var buffer = opl.Buffer; + var map = new Dictionary(); + var pos = 15; + while (true) + { + var cliloc = BinaryPrimitives.ReadInt32BigEndian(buffer.AsSpan(pos)); + pos += 4; + if (cliloc == 0) + { + break; + } + + var byteLen = BinaryPrimitives.ReadUInt16BigEndian(buffer.AsSpan(pos)); + pos += 2; + map[cliloc] = Encoding.Unicode.GetString(buffer, pos, byteLen); + pos += byteLen; + } + + return map; + } + + [Fact] + public void EmitsHitEffectsUseBestSkillMageWeaponSelfRepair() + { + var attrs = new AosWeaponAttributes(null) + { + UseBestSkill = 1, + HitFireball = 12, + HitLeechHits = 20, + MageWeapon = 25, + SelfRepair = 3 + }; + + var opl = new ObjectPropertyList(null); + attrs.GetProperties(opl); + var map = Decode(opl); + + Assert.Equal("", map[1060400]); // UseBestSkill (no-arg) + Assert.Equal("12", map[1060420]); // HitFireball + Assert.Equal("20", map[1060422]); // HitLeechHits + Assert.Equal("5", map[1060438]); // MageWeapon => 30 - 25 + Assert.Equal("3", map[1060450]); // SelfRepair + } +} diff --git a/Projects/UOContent/Misc/AOS.cs b/Projects/UOContent/Misc/AOS.cs index 48f081634..62b714dc3 100644 --- a/Projects/UOContent/Misc/AOS.cs +++ b/Projects/UOContent/Misc/AOS.cs @@ -1010,6 +1010,101 @@ namespace Server return value; } + public void GetProperties(IPropertyList list) + { + int prop; + + if (UseBestSkill != 0) + { + list.Add(1060400); // use best weapon skill + } + + if ((prop = HitColdArea) != 0) + { + list.Add(1060416, prop); // hit cold area ~1_val~% + } + + if ((prop = HitDispel) != 0) + { + list.Add(1060417, prop); // hit dispel ~1_val~% + } + + if ((prop = HitEnergyArea) != 0) + { + list.Add(1060418, prop); // hit energy area ~1_val~% + } + + if ((prop = HitFireArea) != 0) + { + list.Add(1060419, prop); // hit fire area ~1_val~% + } + + if ((prop = HitFireball) != 0) + { + list.Add(1060420, prop); // hit fireball ~1_val~% + } + + if ((prop = HitHarm) != 0) + { + list.Add(1060421, prop); // hit harm ~1_val~% + } + + if ((prop = HitLeechHits) != 0) + { + list.Add(1060422, prop); // hit life leech ~1_val~% + } + + if ((prop = HitLightning) != 0) + { + list.Add(1060423, prop); // hit lightning ~1_val~% + } + + if ((prop = HitLowerAttack) != 0) + { + list.Add(1060424, prop); // hit lower attack ~1_val~% + } + + if ((prop = HitLowerDefend) != 0) + { + list.Add(1060425, prop); // hit lower defense ~1_val~% + } + + if ((prop = HitMagicArrow) != 0) + { + list.Add(1060426, prop); // hit magic arrow ~1_val~% + } + + if ((prop = HitLeechMana) != 0) + { + list.Add(1060427, prop); // hit mana leech ~1_val~% + } + + if ((prop = HitPhysicalArea) != 0) + { + list.Add(1060428, prop); // hit physical area ~1_val~% + } + + if ((prop = HitPoisonArea) != 0) + { + list.Add(1060429, prop); // hit poison area ~1_val~% + } + + if ((prop = HitLeechStam) != 0) + { + list.Add(1060430, prop); // hit stamina leech ~1_val~% + } + + if ((prop = MageWeapon) != 0) + { + list.Add(1060438, 30 - prop); // mage weapon -~1_val~ skill + } + + if ((prop = SelfRepair) != 0) + { + list.Add(1060450, prop); // self repair ~1_val~ + } + } + public override string ToString() => "..."; }