fix(ui): #267 character panel reflects vitae/buffed skills and attributes
Retail CACQualities::EnchantAttribute (0x00594570), EnchantAttribute2nd (0x00594670, already ported for #6), and EnchantSkill (0x005947b0) are the three enchantment-composition functions the Character window's Attributes and Skills tabs depend on. Primary attributes never reference the vitae singleton in retail (only Attribute2nd/Skill do) — confirmed directly from the decompiled function bodies, not assumed. EnchantmentMath.GetMod gains requiredType/includeVitae parameters (default to the prior behavior) so a numeric StatMod key collision across domains (e.g. key=1 is both Strength and MaxHealth) can't leak a buff into the wrong computation. Spellbook.GetAttributeMod/GetSkillMod and LocalPlayerState.GetEffectiveAttribute/GetEffectiveSkill/ GetSkillVitaeModifier wire the retail chain through to the panel. CharacterSheetProvider now reports the effective value as the main number and CharacterSkill.CurrentLevel is no longer an alias of BaseLevel (this also activates the previously-dead SkillValueColor buffed/debuffed row coloring). CharacterStatController's footer-title parenthetical is cited from gmAttributeUI::DisplaySelectionFooter_Attribute (0x0049d280) and gmSkillUI::DisplaySelectionFooter_Trained (0x0049b860) + SkillInfoRegion::GetVitaeModifier (0x004f0fa0): skills show up to two segments (vitae's own contribution, then the buff-only residual), while vitae-immune attributes show at most one; no parenthetical when the delta is zero. The panel now refreshes on Spellbook.EnchantmentsChanged, not only raw property/attribute updates. Core goldens cover the user-reported 33% vitae example (303->203, "(-100)" exactly), buff+vitae composition, and the attribute vitae-immunity finding. Provider/controller tests cover the full row-click -> footer-title path and live refresh. Full solution suite passes with zero failures. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f6275f4501
commit
cf2605fa4a
11 changed files with 1089 additions and 53 deletions
|
|
@ -24,6 +24,8 @@ public sealed class Spellbook
|
|||
private readonly Dictionary<uint, ActiveEnchantmentRecord> _activeById = new();
|
||||
private readonly Dictionary<uint, List<uint>> _enchantmentOrderByBucket = new();
|
||||
private readonly Dictionary<uint, EnchantmentMath.VitalMod> _vitalModCache = new();
|
||||
private readonly Dictionary<uint, EnchantmentMath.VitalMod> _attributeModCache = new();
|
||||
private readonly Dictionary<uint, EnchantmentMath.VitalMod> _skillModCache = new();
|
||||
private readonly List<uint>[] _favoriteSpells = Enumerable.Range(0, 8)
|
||||
.Select(_ => new List<uint>()).ToArray();
|
||||
private readonly Dictionary<uint, uint> _desiredComponents = new();
|
||||
|
|
@ -102,6 +104,61 @@ public sealed class Spellbook
|
|||
return calculated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Issue #267 — combined buff modifier for a primary attribute
|
||||
/// (Strength/Endurance/Coordination/Quickness/Focus/Self; ACE
|
||||
/// <c>PropertyAttribute</c> id 1-6). Retail
|
||||
/// <c>CEnchantmentRegistry::EnchantAttribute</c> (0x00594570) never
|
||||
/// references the vitae singleton, so this excludes vitae —
|
||||
/// primary attributes are vitae-immune in retail. Feed the result
|
||||
/// through <see cref="EnchantmentMath.EnchantAttribute"/> with the
|
||||
/// base value to get the final displayed int.
|
||||
/// </summary>
|
||||
public EnchantmentMath.VitalMod GetAttributeMod(uint attributeId)
|
||||
{
|
||||
if (_attributeModCache.TryGetValue(
|
||||
attributeId,
|
||||
out EnchantmentMath.VitalMod cached))
|
||||
{
|
||||
return cached;
|
||||
}
|
||||
|
||||
EnchantmentMath.VitalMod calculated = EnchantmentMath.GetMod(
|
||||
ActiveEnchantments,
|
||||
_table,
|
||||
attributeId,
|
||||
EnchantmentMath.EnchantmentTypeFlag.Attribute,
|
||||
includeVitae: false);
|
||||
_attributeModCache.Add(attributeId, calculated);
|
||||
return calculated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Issue #267 — combined (vitae-inclusive) buff modifier for a skill
|
||||
/// (ACE <c>SkillId</c>). Retail <c>CEnchantmentRegistry::EnchantSkill</c>
|
||||
/// (0x005947b0) applies the vitae singleton before the mult/add buff
|
||||
/// lists. Feed the result through <see cref="EnchantmentMath.EnchantSkill"/>
|
||||
/// with the base skill level to get the final displayed int.
|
||||
/// </summary>
|
||||
public EnchantmentMath.VitalMod GetSkillMod(uint skillId)
|
||||
{
|
||||
if (_skillModCache.TryGetValue(
|
||||
skillId,
|
||||
out EnchantmentMath.VitalMod cached))
|
||||
{
|
||||
return cached;
|
||||
}
|
||||
|
||||
EnchantmentMath.VitalMod calculated = EnchantmentMath.GetMod(
|
||||
ActiveEnchantments,
|
||||
_table,
|
||||
skillId,
|
||||
EnchantmentMath.EnchantmentTypeFlag.Skill,
|
||||
includeVitae: true);
|
||||
_skillModCache.Add(skillId, calculated);
|
||||
return calculated;
|
||||
}
|
||||
|
||||
/// <summary>Fires when a spell is added to the player's spellbook.</summary>
|
||||
public event Action<uint>? SpellLearned;
|
||||
|
||||
|
|
@ -356,6 +413,8 @@ public sealed class Spellbook
|
|||
_activeById.Clear();
|
||||
_enchantmentOrderByBucket.Clear();
|
||||
_vitalModCache.Clear();
|
||||
_attributeModCache.Clear();
|
||||
_skillModCache.Clear();
|
||||
foreach (ActiveEnchantmentRecord enchantment in enchantments)
|
||||
UpsertManifestEnchantment(enchantment);
|
||||
|
||||
|
|
@ -430,6 +489,8 @@ public sealed class Spellbook
|
|||
_activeById.Clear();
|
||||
_enchantmentOrderByBucket.Clear();
|
||||
_vitalModCache.Clear();
|
||||
_attributeModCache.Clear();
|
||||
_skillModCache.Clear();
|
||||
foreach (List<uint> tab in _favoriteSpells) tab.Clear();
|
||||
_desiredComponents.Clear();
|
||||
_spellbookFilters = 0x3FFFu;
|
||||
|
|
@ -448,6 +509,8 @@ public sealed class Spellbook
|
|||
private void NotifyEnchantmentsChanged()
|
||||
{
|
||||
_vitalModCache.Clear();
|
||||
_attributeModCache.Clear();
|
||||
_skillModCache.Clear();
|
||||
EnchantmentsChanged?.Invoke();
|
||||
StateChanged?.Invoke();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue