refactor(weapon): emit AOS attributes via AosAttributes/AosWeaponAttributes.GetProperties

This commit is contained in:
Kamron Batman 2026-06-22 08:28:59 -07:00
parent 54a512c98f
commit ea8dfd29bd
2 changed files with 47 additions and 210 deletions

View file

@ -0,0 +1,38 @@
using Server.Items;
using Xunit;
namespace UOContent.Tests;
[Collection("Sequential UOContent Tests")]
public class BaseWeaponPropertiesTests
{
[Fact]
public void Weapon_AttributeLineSet_Preserved()
{
var weapon = new Longsword();
try
{
weapon.Attributes.DefendChance = 5;
weapon.Attributes.BonusInt = 6;
weapon.Attributes.SpellChanneling = 1;
weapon.WeaponAttributes.UseBestSkill = 1;
weapon.WeaponAttributes.HitFireball = 12;
weapon.WeaponAttributes.MageWeapon = 25;
weapon.WeaponAttributes.SelfRepair = 3;
var map = ItemOplTestHelper.DecodeAttributeLines(weapon);
Assert.Equal("5", map[1060408]); // DefendChance
Assert.Equal("6", map[1060432]); // BonusInt
Assert.Equal("", map[1060482]); // SpellChanneling
Assert.Equal("", map[1060400]); // UseBestSkill
Assert.Equal("12", map[1060420]); // HitFireball
Assert.Equal("5", map[1060438]); // MageWeapon (30 - 25)
Assert.Equal("3", map[1060450]); // SelfRepair
}
finally
{
weapon.Delete();
}
}
}

View file

@ -2998,114 +2998,11 @@ public abstract partial class BaseWeapon
list.Add(1072792); // Balanced
}
if (WeaponAttributes.UseBestSkill != 0)
{
list.Add(1060400); // use best weapon skill
}
WeaponAttributes.GetProperties(list);
if ((prop = GetDamageBonus() + Attributes.WeaponDamage) != 0)
if ((prop = GetLowerStatReq()) != 0)
{
list.Add(1060401, prop); // damage increase ~1_val~%
}
if ((prop = Attributes.DefendChance) != 0)
{
list.Add(1060408, prop); // defense chance increase ~1_val~%
}
if ((prop = Attributes.EnhancePotions) != 0)
{
list.Add(1060411, prop); // enhance potions ~1_val~%
}
if ((prop = Attributes.CastRecovery) != 0)
{
list.Add(1060412, prop); // faster cast recovery ~1_val~
}
if ((prop = Attributes.CastSpeed) != 0)
{
list.Add(1060413, prop); // faster casting ~1_val~
}
if ((prop = GetHitChanceBonus() + Attributes.AttackChance) != 0)
{
list.Add(1060415, prop); // hit chance increase ~1_val~%
}
if ((prop = WeaponAttributes.HitColdArea) != 0)
{
list.Add(1060416, prop); // hit cold area ~1_val~%
}
if ((prop = WeaponAttributes.HitDispel) != 0)
{
list.Add(1060417, prop); // hit dispel ~1_val~%
}
if ((prop = WeaponAttributes.HitEnergyArea) != 0)
{
list.Add(1060418, prop); // hit energy area ~1_val~%
}
if ((prop = WeaponAttributes.HitFireArea) != 0)
{
list.Add(1060419, prop); // hit fire area ~1_val~%
}
if ((prop = WeaponAttributes.HitFireball) != 0)
{
list.Add(1060420, prop); // hit fireball ~1_val~%
}
if ((prop = WeaponAttributes.HitHarm) != 0)
{
list.Add(1060421, prop); // hit harm ~1_val~%
}
if ((prop = WeaponAttributes.HitLeechHits) != 0)
{
list.Add(1060422, prop); // hit life leech ~1_val~%
}
if ((prop = WeaponAttributes.HitLightning) != 0)
{
list.Add(1060423, prop); // hit lightning ~1_val~%
}
if ((prop = WeaponAttributes.HitLowerAttack) != 0)
{
list.Add(1060424, prop); // hit lower attack ~1_val~%
}
if ((prop = WeaponAttributes.HitLowerDefend) != 0)
{
list.Add(1060425, prop); // hit lower defense ~1_val~%
}
if ((prop = WeaponAttributes.HitMagicArrow) != 0)
{
list.Add(1060426, prop); // hit magic arrow ~1_val~%
}
if ((prop = WeaponAttributes.HitLeechMana) != 0)
{
list.Add(1060427, prop); // hit mana leech ~1_val~%
}
if ((prop = WeaponAttributes.HitPhysicalArea) != 0)
{
list.Add(1060428, prop); // hit physical area ~1_val~%
}
if ((prop = WeaponAttributes.HitPoisonArea) != 0)
{
list.Add(1060429, prop); // hit poison area ~1_val~%
}
if ((prop = WeaponAttributes.HitLeechStam) != 0)
{
list.Add(1060430, prop); // hit stamina leech ~1_val~%
list.Add(1060435, prop); // lower requirements ~1_val~%
}
if (ImmolatingWeaponSpell.IsImmolating(this))
@ -3118,110 +3015,12 @@ public abstract partial class BaseWeapon
list.Add(1072793, prop); // Velocity ~1_val~%
}
if ((prop = Attributes.BonusDex) != 0)
{
list.Add(1060409, prop); // dexterity bonus ~1_val~
}
if ((prop = Attributes.BonusHits) != 0)
{
list.Add(1060431, prop); // hit point increase ~1_val~
}
if ((prop = Attributes.BonusInt) != 0)
{
list.Add(1060432, prop); // intelligence bonus ~1_val~
}
if ((prop = Attributes.LowerManaCost) != 0)
{
list.Add(1060433, prop); // lower mana cost ~1_val~%
}
if ((prop = Attributes.LowerRegCost) != 0)
{
list.Add(1060434, prop); // lower reagent cost ~1_val~%
}
if ((prop = GetLowerStatReq()) != 0)
{
list.Add(1060435, prop); // lower requirements ~1_val~%
}
if ((prop = GetLuckBonus() + Attributes.Luck) != 0)
{
list.Add(1060436, prop); // luck ~1_val~
}
if ((prop = WeaponAttributes.MageWeapon) != 0)
{
list.Add(1060438, 30 - prop); // mage weapon -~1_val~ skill
}
if ((prop = Attributes.BonusMana) != 0)
{
list.Add(1060439, prop); // mana increase ~1_val~
}
if ((prop = Attributes.RegenMana) != 0)
{
list.Add(1060440, prop); // mana regeneration ~1_val~
}
if (Attributes.NightSight != 0)
{
list.Add(1060441); // night sight
}
if ((prop = Attributes.ReflectPhysical) != 0)
{
list.Add(1060442, prop); // reflect physical damage ~1_val~%
}
if ((prop = Attributes.RegenStam) != 0)
{
list.Add(1060443, prop); // stamina regeneration ~1_val~
}
if ((prop = Attributes.RegenHits) != 0)
{
list.Add(1060444, prop); // hit point regeneration ~1_val~
}
if ((prop = WeaponAttributes.SelfRepair) != 0)
{
list.Add(1060450, prop); // self repair ~1_val~
}
if (Attributes.SpellChanneling != 0)
{
list.Add(1060482); // spell channeling
}
if ((prop = Attributes.SpellDamage) != 0)
{
list.Add(1060483, prop); // spell damage increase ~1_val~%
}
if ((prop = Attributes.BonusStam) != 0)
{
list.Add(1060484, prop); // stamina increase ~1_val~
}
if ((prop = Attributes.BonusStr) != 0)
{
list.Add(1060485, prop); // strength bonus ~1_val~
}
if ((prop = Attributes.WeaponSpeed) != 0)
{
list.Add(1060486, prop); // swing speed increase ~1_val~%
}
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
{
list.Add(1075210, prop); // Increased Karma Loss ~1val~%
}
Attributes.GetProperties(
list,
damageBonus: GetDamageBonus(),
hitChanceBonus: GetHitChanceBonus(),
luckBonus: GetLuckBonus()
);
GetDamageTypes(
null,