Get a Non-Actor Target of a Spell

Post » Fri Jun 14, 2013 2:05 am

Is there any way to get the Target of an Aimed spell if it isn't an Actor? I would like to get the ObjectReference of whatever it hits, like a sword, potion, etc.

TL;DR

There must be some way to do this. I mean... casting Flames at combustible materials leaves behind the various burnt decals.

http://www.creationkit.com/OnEffectStart_-_ActiveMagicEffect only provides an Actor reference to the Target. I'm thinking maybe the Projectile might have an event that would let me get ObjRefs but I http://www.creationkit.com/Projectile_Script associated with them.

I did notice that http://www.creationkit.com/ActiveMagicEffect_Script have Inventory filters! http://www.creationkit.com/AddInventoryEventFilter_-_ObjectReference and such. What would filters be used for if AMEs can't interact with items?

Out of boredom/annoyance I added a couple of other events like OnActivate and OnItemAdded with .Trace's to see if they ever fired. No luck.

Seems like such a simple thing, not sure why I'm being denied! :)

User avatar
Petr Jordy Zugar
 
Posts: 3497
Joined: Tue Jul 03, 2007 10:10 pm

Post » Fri Jun 14, 2013 4:59 pm

Spells cannot affect ObjectReferences, only actors. AddInventoryEventFilter is used for the OnItemAdded/Removed events. These are objectreference events, but they are also sent to actors since Actor extends ObjectReference. I believe they only way to dynamically attach a script to an objectreference is to use a reference alias.

There is an SKSE event OnCrosshairRefChange which can grab objectreferences. I use it to create an unlock spell which unlocks the chest/door highlighted in the player's crosshair. The spell fires a spell which targets the player and only lasts for a couple of seconds and use this script. Essentially disabling activate player controls forces the event to fire a split second later.

Spoiler
User avatar
Sabrina Steige
 
Posts: 3396
Joined: Mon Aug 20, 2007 9:51 pm

Post » Fri Jun 14, 2013 7:06 am

While I was composing a PM to JustinOther I realized that ActiveMagicEffects will never work. Since they are attached to Actors, they can only return Actors.

You read my rambling, thanks! :) But I don't agree with you. Looking at the inheritance tree it goes AMEs -> MEs -> Forms, skipping ObjRefs entirely. Which means there's no reason to expose Inventory methods. I mean really... I've never seen an AME act as a container. Why are they there?! *lol* Not really important but I found them distracting.

As to dynamically attaching scripts you're totally right, afaik. Reference Aliases are it. That was something I hadn't actually considered yet and it might actually work. If there's a way to get an object sitting in the world to fill a RefAlias. Not sure how to do that since I can't get the object my spell hit. Which is right back where I started from. :wallbash:

Basically I want my effect to be able to react to what it hits. I'd use the BaseType or maybe Keywords to play different shaders. So I shouldn't need to attach a script... in my mind there should be enough events in play already.

As to your solution... whoa! I can follow that... unregister inside the event then dispel the effect to return player control. Damn smooth--especially the three shaders for that "super green" effect! :thumbsup: Never used the CrossHair event so I will give it a whirl.

Shame though. I'm trying to keep my first stab as vanilla as possible. This should be possible! I mean... look at Telekinesis. It targets an object and allows you to manipulate it. Exactly what I need! Yet it's all hidden away in the http://www.creationkit.com/Magic_Effect#Effect_Archetypes.

User avatar
Sierra Ritsuka
 
Posts: 3506
Joined: Mon Dec 11, 2006 7:56 am

Post » Fri Jun 14, 2013 11:21 am

I remember reading a method for how to do this last year...ah, http://www.gamesas.com/topic/1410089-tutorial-how-to-cast-spells-at-non-actors/, does this help?
User avatar
jasminĪµ
 
Posts: 3511
Joined: Mon Jan 29, 2007 4:12 am


Return to V - Skyrim