leron9999 Posted September 10, 2012 Share Posted September 10, 2012 Hello all! Is there a way to dynamically attach a script to a newly created object? Say, I cast a magelight, but I want it to do something when I hit it with a spell or a weapon. Is such a thing possible? Link to comment Share on other sites More sharing options...
jshepler Posted September 10, 2012 Share Posted September 10, 2012 How about a ReferenceAlias script and calling ForceRefTo ? Link to comment Share on other sites More sharing options...
leron9999 Posted September 10, 2012 Author Share Posted September 10, 2012 That sounds like a pretty interesting solution. I'm not very familiar with using referencealias though. Do you have any tutorials or links to sample applications of referencealias? Link to comment Share on other sites More sharing options...
jshepler Posted September 10, 2012 Share Posted September 10, 2012 Well, there's http://www.creationkit.com/Dynamically_Attaching_Scripts but I didn't care very much for it. I probably don't know enough yet to, uh, properly appreciate the samples. I was thinking along the lines of having script A on the player to handle OnSpellCast that would call out to the ReferenceAlias script B passing the spell, which would do a Self.ForceRefTo(passedInSpell), at which point script B is now attached to the spell just cast. I don't know if that's how it actually works or not, it's just an idea. Link to comment Share on other sites More sharing options...
leron9999 Posted September 11, 2012 Author Share Posted September 11, 2012 Hmm... that sounds doable. I can somewhat see how that can be implemented. I'll try it out. Thanks for the assist! Link to comment Share on other sites More sharing options...
steve40 Posted September 13, 2012 Share Posted September 13, 2012 (edited) Why not make a custom magelight spell instead? An easy way might be to make a custom magelight spell that uses a *copy* of the vanilla magelight effect/object, then simply attach your script to the copied effect/object. That way your custom magelight orb will always have the script on it and you won't need to mess about with referencealiases oy dynamically attached scripts. Edited September 13, 2012 by steve40 Link to comment Share on other sites More sharing options...
leron9999 Posted September 13, 2012 Author Share Posted September 13, 2012 Oh... that's surprisingly simple haha. How can the magelight projectile tell if it's hit with something though? If I'm not mistaken, casting magelight places a magic effect on the caster. So if I use the onhit event, it'll read it as the player being hit and not the magelight itself. Link to comment Share on other sites More sharing options...
Recommended Posts