I am implementing a script that responds to various ActiveMagicEffects when they are applied to the player via enchanted items. I have already written a version of the script that can be attached to every individual magic effect, and it achieves the desired results. I am a bit concerned, however, that such a method will be very unfriendly to uninstallation--since the script will be attached to so many individual magic effects, and will likely throw up log errors whenever any of those effects is active.
Assuming that this concern is justified, I would like to make a version of the script that instead can be attached to a single player-filled reference alias, and still respond to all the different effects.
However, I am having trouble finding the necessary functions/events. After looking through ObjectReference, Actor, and ReferenceAlias scripts, the only thing that looks promising is ObjectReference's OnMagicEffectApply()--but this only returns the base MagicEffect, not the specific reference of the ActiveMagicEffect applied to the player, from what I can tell. I need to be able to gain access to ActiveMagicEffect's script functions after detecting a new effect on the player, so that I can manipulate that active effect. Is there any way to use this event (or another method) to detect and respond to ActiveMagicEffects applied to the player, or to somehow detect the active effect?
Or else: would an alternative method of making all the enchantments I want to manipulate use new, custom, magic effects duplicated from the originals work? (I assume all these custom effects along with their scripts would then be removed upon uninstall, when the enchantments revert to using vanilla effects?)