I released a mod some time ago called "BFG's Armor Health Scales Enchantments". Basically, the mod changes the strength of enchantments on armor based on the health (condition) of the armor.
Unfortunately, I learned through in-game testing that my old method doesn't always work. I've completely revamped the approach to correct this problem but, after 8 hours of work, I can't seem to overcome the final obstacle!
OLD METHOD:
I used GetNthActiveEffectEnchantObject and SetNthActiveEffectMagnitude to search through the Active Effects on the player (the magic effects displayed on the last tab of the Magic Menu) and modify the armor-specific enchantments. Unfortunately, even though the Active Effects page would update with the new magnitude, the new magnitude often didn't actually work. For example, if I modified a piece of armor that gives Resist Magic 20% to Resist Magic 50%, the Active Effects would say 50%, but it would only block 20% in-game.
CURRENT METHOD:
I am using SetNthEffectItemMagnitude to directly change the magnitude on the armor (the armor wasn't touched in the old method). The magnitude (as displayed in that armor's enchantments list in inventory) does change. For example, the piece of armor mentioned above does read Resist Magic 50% when I select it in inventory. But the Active Effect page does not update, and the game still only uses Resist Magic 20% (the old magnitude).
But unequipping and reequipping the armor does update the Active Effects page, and also causes the game to use Resist Magic 50%. In other words, the game apparently only looks at armor enchantments at the moment it's equipped.
HYBRID APPROACH:
I also tried changing the magnitudes both on the armor directly, and in the player's Active Effects. That didn't work consistently, unfortunately.
THE PROBLEM:
Since the game normally only updates enchantments when armor is equipped, I have to find a way either (1) to force the armor to unequip and reequip in a way that is invisible to the player, or (2) force the game to update the player's Active Effects at times other than when the armor is equipped.
I've tried the first approach, with the following commands:
Player.UnequipItem ArmorObj
Player.EquipItem ArmorObj
The armor does unequip but then it fails to reequip. (I get a "This enchanted item cannot be equipped right now" message.)
And I have no idea how to do the second approach.
Any help is appreciated! This is the only thing I need to work out before I can release the mod! Thanks in advance.