Talk:SetNthEffectItemMagnitude

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

Changing Enchantments on Equipped Items[edit source]

From what I can tell if this is called on an enchantment on an item that is already equipped (at least by the player, I did not test NPCs), the item has to be unequipped and re-equipped in order for the new values to take effect. The same appears to be true with ModNthEffectItemMagnitude. This is not just a matter of waiting a few frames for it to update - the values on the player never update until the item is re-equipped. Equipping other items in different locations doesn't seem to have an effect. Can anyone confirm? And I'd love it if we could find a workaround.--Puf the majic dragon 18:24, 4 November 2009 (EST)

My results with this function seem to agree with you. I've tried changing the magnitude of an effect that was already being applied to the player (via an added ability-type spell) and the applied effect magnitude didn't change. In order for the change to register, I ended up needing to remove the effect and then add it again. TFM

I can corroborate these results. For the new magnitude to take effect the ability needs to be removed from the player/NPC first and then re-added.--Five Alpha Reductase 10:55, December 31 2012 (EST)


Permanent Value Changes[edit source]

For spell effects at least, I can confirm any changes made using this function via scripting will be forgotten once the player reloads the game. For example, you may have an Ability that checks if the player gained a level and then modifies the magnitude of all magic items of a certain spell to +1. This works fine while playing, but any changes will be completely erased and all effect values of the spell set back to mod default when player reloads a game. A link to a permanant solution is needed.

But 'one' possible fix would be to hard-code the base values of all effects of the spell you're monitoring to local script variables. Then with these base values known and hard-coded in script, validate the values of the 1st effect item in the spell to see if it should match the player's current level, and if this value is less than it should be, then mod all effect item values to be current. Then again, hard-coding values makes your mod much more difficult for others to mod. --- 2011/12/19 8asrun6aer

There is no way to permanently alter the magnitudes of vanilla magic items. The save format is simply not designed to accommodate it. The best you can do at present is keep a list of all magic items you've modified and re-apply the changes every time the game restarts. For non-Ability magic items targeting the player, you need to remove and reapply the items as well.
An alternative is to clone the magic item using CloneForm and adjust the magnitudes of that. Scripted changes to cloned forms (and player-created enchantments and spells) are truly permanent.
JRoush 22:33, 19 December 2011 (EST)
Thanks, JRoush. Although I didn't try cloning, I did try checking if the game just started (GetGameRestarted) or was reloaded (GetGameLoaded) with...
if ( Player.GetLevel == lastKnownPlayerLevel ) if ( GetGameRestarted || GetGameLoaded ) set lastKnownPlayerLevel to 0 else return endif endif set levelsAdvanced to Player.GetLevel - lastKnownPlayerLevel set lastKnownPlayerLevel to Player.GetLevel ...continue modifying magnitudes of various spells
This should in theory let one handle leveling spells with just a single, continuously-running ability script, rather than with a quest script and several spells for various ranks.
8asrun6aer 21 December 2011