Adding scripts to objects on the fly

Post » Wed Jun 20, 2012 10:49 am

Hi guys, I have two simple questions:

(1) Is there a way to attach a script to an object instance dynamically? For example, I would like to make a spell effect that spawns butterflies when the target is sitting down (i.e. attach an Actor Script with an implemented "OnSit").

(2) Is there a way to change the state variables or call functions of other scripts? For instance, I just summoned an actor with.... say a regeneration script that basically heals the actor for x pts per second. Let's say x is a variable with a setter method in the script, would I be able to have another script to talk to this script and change that through just simple coding?

Edit: For the second question, let's say you only have the pointer to the object but not the scripts attached.
User avatar
Blackdrak
 
Posts: 3451
Joined: Thu May 17, 2007 11:40 pm

Post » Wed Jun 20, 2012 3:10 pm

ActivemagicEffects attach to the actor they're affecting, and can thus catch events on that actor. So you could make the effect register for the Sitting animation events, shouldn't be all that hard...

It's catching things like when YOUR weapon hits an opponent that are hard. The OnHit event only goes off when an actor is hit, not when it hits.
User avatar
Tamara Primo
 
Posts: 3483
Joined: Fri Jul 28, 2006 7:15 am

Post » Wed Jun 20, 2012 2:12 am

Interesting. I thought activemagiceffect only listens for the effect itself and not the affected individual.
User avatar
Nany Smith
 
Posts: 3419
Joined: Sat Mar 17, 2007 5:36 pm

Post » Wed Jun 20, 2012 3:24 am

Totally off topic, but

It's catching things like when YOUR weapon hits an opponent that are hard. The OnHit event only goes off when an actor is hit, not when it hits.

I think there's an option for perk entry points called "combat apply spell" or something (it's definitely towards the beginning of the list) that shoots a spell when the perk owner successfully hits someone in combat.
User avatar
Vickey Martinez
 
Posts: 3455
Joined: Thu Apr 19, 2007 5:58 am

Post » Wed Jun 20, 2012 8:36 am

Well you can do it by just putting an Enchantment on a weapon whose OnEffectStart is effectively an "OnHitEnemy" for that particular weapon.
User avatar
Jack
 
Posts: 3483
Joined: Sat Oct 20, 2007 8:08 am


Return to V - Skyrim