How do I get close actor?

Post » Tue Jun 19, 2012 5:39 am

Hi Guys,
My goal is to get an actor who is close to an activation lever, and then run an effect on them.
I'm completely lost on how to do this... Here is what I have on the level script - looking forward to any guidance.

Scriptname SetEffectxyz extends ObjectReference EffectShader Property FX  Auto event OnActivate(ObjectReference akActionRef)ObjectReference FindAct = game.FindClosestReferenceOfTypeFromRef(-NEED HELP FOR REF-, game.GetPlayer(), 10.0)if (FindAct == None)  Debug.MessageBox("There is no near")else  Debug.MessageBox("Actor Found")  DoEffect(FindAct)  ' This will need to change from ObjectReference to ActorendifendEventfunction DoEffect(Actor act)FX.Play(act)act.SetAlpha(0.2) endFunction

So I'd like to find on line 5, the reference of type (Which I imagine is a base type?) within a close proximity of the player.
Then - set a shader effect on that specific actor.

It's been a long time since I script in Oblivion, but I could swear it was easier than this...

Thanks!
User avatar
Avril Louise
 
Posts: 3408
Joined: Thu Jun 15, 2006 10:37 pm

Post » Tue Jun 19, 2012 3:05 am

You could always create an explosion type that applies the effect, then just do a PlaceAtme for the lever? Of course that would affect more than one potentially...

I have yet to get a Find function to work right. Setting an object type property to find wants you to pick an object from a render window..but what if your mod has no cells to render?
User avatar
JD bernal
 
Posts: 3450
Joined: Sun Sep 02, 2007 8:10 am

Post » Mon Jun 18, 2012 5:40 pm

Hey all, I found a way to get this working (after many hours and much lost hair...) So I'll post my findings for the next person who searches for this...

Scriptname SetEffectxyz extends ObjectReference import gameEffectShader Property FX  Auto ActorBase  Property ActorRef  AutoObjectReference FindActorevent OnActivate(ObjectReference akActionRef)FindActor = FindClosestReferenceOfTypeFromRef(ActorRef, getPlayer(), 10.0)DoEffect(FindActor as Actor)endEventfunction DoEffect(actor aRef)FX.Play(aRef)aRef.SetAlpha(0.2)endFunction

The property for ActorRef is defined as type ActorBase, so in the editor window for the object this script is attached to, right-click properties on the script and set this property to the base object type.

Happy days!
User avatar
Emily Graham
 
Posts: 3447
Joined: Sat Jul 22, 2006 11:34 am

Post » Tue Jun 19, 2012 8:01 am

If you're looking just for any old actor, then you can also use http://www.creationkit.com/FindClosestActorFromRef_-_Game.

Cipscis
User avatar
Charlotte X
 
Posts: 3318
Joined: Thu Dec 07, 2006 2:53 am


Return to V - Skyrim