Talk:SetEnchantment

Active discussions

Works on ArrowsEdit

It's supposed to work on arrows in 14a, but wasn't it brought up in one of the first threads that it was still broken?--Speedo 12:21, 3 April 2008 (EDT)

Yes it was, reverted.--Haama 13:57, 3 April 2008 (EDT)
As of v17 it works on arrows, so i think the "doensn't work" note should be removed.

Enchantment disapearanceEdit

Hello,

I use setenchantment in one of my mods and after a few quit/reload the enchantment that was on my weapon disappears. any idea how to fix that? I also have another problem the charge of the weapon enchantment is blocked. example: the charge is 1/1. I hit a creature and after the charge is still 1/1.

here is my script:

scn abukaienchspellscript

ref weapon ref clone ref script ref caster short kk

begin scripteffectstart

if player.getitemcount aaatorturedsoul > 9 && aaaokariscythecasterref.kk > 9

set caster to getself set weapon to caster.GetEquippedObject 16

if weapon == 0 || player.GetEquipped aaasoulextractor3t == 1 message "Soul injection has failed", 3 else

player.removeitem aaatorturedsoul 10 set kk to aaaokariscythecasterref.kk - 10 set aaaokariscythecasterref.kk to kk

set clone to CloneForm weapon player.removeitem weapon 1 player.additem clone 1 SetObjectCharge 1 clone SetEnchantment aaauuudaggerench clone SetWeaponReach 100000000 clone player.equipitem clone

endif

else message "I don't have enough torured souls", 3 endif

end

Tests on usage of this functionEdit

I've been (trying to) use this function extensively and noticed that there seems to be some limitations that may cause grief for modders.

  • If an item is already equipped when its enchantment is changed, the new enchantment will only affect the actor after the item is unequipped and then re-equipped (according to the magic effects page in the journal).
  • Changes to enchantments are not saved. Any items modified with this function will revert to their default enchantment on loading a saved game

The workaround seems to be a clunky un-equip and re-equip whenever the enchantment is changed. An object or quest script may be needed to check for a "wrong" enchantment on reloading a saved game and then force a re-equip. Lanceor 01:18, 29 September 2011 (EDT)

On the first, thanks, that's good (frustrating) to know. A fair few things work that way, but I didn't realize this was one. Do weapons update immediately? Seem like they would (which helps because you can't un/re-equip weapons as easily due to sheathing/unsheathing issues).
On the second, that's actually because of how this function works. It changes the base object, rather than an individual instance. A lot of OBSE functions do that. The thing is, vanilla Oblivion functions never did that, and so Bethesda doesn't have Oblivion save those things. However, if a form is a part of the savefile anyway (a so-called dynamic form, such as player-made potions and enchantments, or more usefully, things made with CloneForm), then the changes do save. So the answer to the second issue is to use CloneForm before making those changes (which is usually a good idea anyway, to avoid changing every instance of the object).
That issue is known, but it's a difficult thing to teach people on the Wiki because it applies to so many functions; it's hard to say where that info should go...
Dragoon Wraith TALK 13:11, 29 September 2011 (EDT)
I did further testing using custom items with obvious effects: a sword that alternates between fire and shock damage and a helmet that alternates between fortify speed and drain speed. A quest script toggles the enchantments every 10 seconds. Here's what I found:
  • Armour enchantments won't update until reequipped. The magic effects page in the journal is correct.
  • Weapon enchantments will update instantly. However, the enchantment shader (e.g. the orange edge glow for fire damage) will remain whatever it was when it was equipped.
  • This might be an easy way to give weapons any enchantment shader desired, simply by specifying a default enchantment with the desired shader, then updating it to the enchantment that you really want.
I've updated the main page to reflect these findings. :)
Lanceor 04:05, 30 September 2011 (EDT)
Interesting. I wonder if Update3D will cause the enchantment to update? It's designed for updating models and textures (the usual things that don't update), but it might trigger the update.
Also, if you wanted to mix'n'match shaders and enchantments, it'd be a bit more work — but more... not relying on undefined behavior? — to use JRoush's OBME.
Dragoon Wraith TALK 10:04, 30 September 2011 (EDT)
I tried update3D... no luck unfortunately. Even with:
set Weapon to player.GetEquippedObject 16
Weapon.Update3D
...the shader didn't update on the equipped item (I might add that it also doesn't work after SetModelPath either). It was kind of expected as I understand that an item that is in an inventory or container is no longer a reference and technically doesn't exist in the game world, isn't that right?
Lanceor 09:24, 3 October 2011 (EDT)
You should be calling Update3D on the actor holding the weapon (because yes, items in inventories are not references).
Dragoon Wraith TALK 23:17, 3 October 2011 (EDT)
Unfortunately Update3D called on the player doesn't work (this is already documented in the wiki). I haven't tried it on an NPC yet though. Interestingly, using the console to select the player and applying the command Update3D does work. Lanceor 11:59, 10 November 2011 (EST)
Return to "SetEnchantment" page.