This is universal scripted system for items with "cast when used" enchantments.
How it works?
When an enchanted item with my script attached is equipped on player it copies the properties of enchantment to a dummy spell which is then selected as player active spell. Enchantment itself is immediately dispeled from the player (important for On Self enchantments, to prevent them from acting like Constant Effect)
Each item has a charge which is displayed in inventory UI and can be recharged normally with soulgems or using NPC services.
Known issues and limitations:
- On Target Enchantments fire once when item is equipped. This seems to be an engine issue and I haven't found any workaround yet.
- Enchantments effects will affect the player for a fraction of a second before being dispeled. This can become noticeable with high magnitudes.
- If you have more than one copy of the same item, UI popup can display wrong charge amount. HUD bar will display the correct value, though.
- You cannot enchant new items with "Cast When Used"
- There's a debug print in console which shows use count for every affected item (use tdt if you want to see it real-time)
- If anyone uses HUD Status Bars mod, it is possible to create a custom bar with use count for currently used item. See my post below for details.