testiger2 Posted February 25, 2019 Share Posted February 25, 2019 Hi guys,I need a little help with retrieving properties from an activemagiceffect instance from a dynamic assigned actor. So here is the rough outline for the setup. Script A extends ActiveMagicEffect Scriptname ScriptA extends activemagiceffect Form Property FormA Auto Script B extends Objectreference Scriptname ScriptB extends ObjectReference Spell Property XSpell Auto ; XSpell contains Magiceffect with ScriptA attached Event OnEquipped(Actor akActor) if !akActor.hasSpell(XSpell) akActor.Addspell(XSpell, false) endif -- Store self(ObjRef) into FormA Property from ScriptA instance on akActor -- EndEvent I have an item and whatever actor equips the item is supposed to keep track of it in a Property in a MagicEffect. The problem i have is with casting between Activemagiceffect and Actor types as they are not compatible. Normally i would call the Property something like this ScriptA Property SomePropName Auto ;OR ScriptA ScriptVar = (whatever) as ScriptA But since the actor who can equip the item needs to be dynamic i somehow need the type cast to be associated with akActor from the OnEquipped Event. Anyone got any Ideas on this? Link to comment Share on other sites More sharing options...
foamyesque Posted February 25, 2019 Share Posted February 25, 2019 To be clear, this spell is to be added no matter what the actor equips, it isn't associated with any one particular item, and it only gets added if it doesn't already exist. You then want to track whatever the first item was that added the spell (but not subsequent changes), which means you can't put the OnEquip event in the activemagiceffect since it won't catch the equips done before the spell is added. Is that correct? There's not a default or library built way of pulling ActiveMagicEffects from an actor. The pre-built functions and events all give you the base MagicEffect, which is a different form. So, instead, you need to make your ActiveMagicEffect script talk to the Actor script yourself. In your particular case, I'd add a property to the Actor script to store the equipped item, and then, in the ActiveMagicEffect script, in your OnEffectStart(Actor akTarget, Actor akCaster) block, cast akCaster as ScriptB, then use the property wherever needed. Also take note: Your OnEquipped block is incorrect. It will compile, but nothing in the game will ever call it unless you set up other routines to do so. You want OnObjectEquipped(Form akBaseObject, ObjectReference akReference), instead, which the native game systems will talk to and which will catch the event you're trying to listen for. It will also provide the information you need about what kicked the spell off. If, instead, you're just trying to track if some specific item is added while the magic effect is active, just put the OnEquippedObject() event into the ActiveMagicEffect script, and it'll listen for it for you right there directly. Link to comment Share on other sites More sharing options...
testiger2 Posted February 26, 2019 Author Share Posted February 26, 2019 Not quite... the setup i have right now is OnEquippedObject() on the magic effect tracking the Armor i just wanted to know if it also worked the other way round so the ActiveMagicEffect passed to the Armor There's not a default or library built way of pulling ActiveMagicEffects from an actor. The pre-built functions and events all give you the base MagicEffect, which is a different form. So, instead, you need to make your ActiveMagicEffect script talk to the Actor script yourself.i think that kind of answers my question Link to comment Share on other sites More sharing options...
Recommended Posts