JohnDoeRef = OutsideMarker.PlaceAtMe(JohnDoe.GetActorBase())

Post » Sat Nov 17, 2012 6:54 am

In a script I use the following code

JohnDoeRef = OutsideMarker.PlaceAtMe(JohnDoe.GetActorBase())


I was wondering is there anyway to add a script, attach a script, give a script to the JohnDoeRef

Also it is possible more then one of these JohnDoeRef guys exist at one time.


Would I create a quest and somehow force an alias ?
User avatar
Carolyne Bolt
 
Posts: 3401
Joined: Mon Jul 10, 2006 4:56 am

Post » Sat Nov 17, 2012 8:28 am

yes you need to create a quest with alias(es)

if you need more than one at a time, create more than 1 alias.


create a blank quest, name it, select all your necessary flags etc, and select ok to save it. re-open it and create your aliases.

each alias should be set to forced ref (specific), and set to a value of None (do not specify an actor). check the "optional" flag

you can then add whatever packages, inventory, etc.

attach your script to the alias (this script must extend ReferenceAlias)



in your original script that calls the placeatme, you need to send JohnDoeRef to one of the aliases

JohnDoeAlias1.ForceRefTo(JohnDoeRef)
(if you have a ton of these, you may want to streamline your function to be able to be re-used with multiple aliases via an array or whatever)



since the filled alias' script is a referencealias script, you need to adjust your syntax for referring to actor functions.

to grab an alias' actor use GetActorRef()... so JohnDoeAlias1.GetActorRef().DoSomeActorFunction() would be the equivalent of JohnDoeActor.DoSomeActorFunction() on a script that extends Actor
just note, that since GetActorRef() is a function call, it is not recommended to use it repeatedly, just like Game.GetPlayer() should not be used repeatedly. Use an actor variable/property and set the value to the function call GetActorRef() once, and then use the actor variable/property for each multiple instance needed.
User avatar
ezra
 
Posts: 3510
Joined: Sun Aug 12, 2007 6:40 pm

Post » Sat Nov 17, 2012 7:24 am

Or ... would this work

http://www.creationkit.com/Dynamically_Attaching_Scripts

?
User avatar
Curveballs On Phoenix
 
Posts: 3365
Joined: Sun Jul 01, 2007 4:43 am

Post » Sat Nov 17, 2012 4:48 pm

if your aim is to just attach a running script, that would work for the most part. although i think it is a much more limited and less flexible way of doing it. it really depends on what you need the end script to do.

the magic effect method may or may not be 'simpler' (depending on how much you love or hate working with mgef/spell chains) but in the end it is very limited in what you can achieve, and if your script/actor needs to do something complex, you will probably end up doing more damage control than its worth.
User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am

Post » Sat Nov 17, 2012 8:47 am

Ok lets say I add a spell ability to JohnDoeRef and it has a script attached to it. the script says event ondeath(bla bla) the magic effect of the ability says No Death Dispel and the actor is then killed... will the script execute the on death ?

Or will ondeath not be allowed in a spell ?
User avatar
Sarah Evason
 
Posts: 3507
Joined: Mon Nov 13, 2006 10:47 pm

Post » Sat Nov 17, 2012 12:55 pm

I created a spell ability. I added a magic effects Constant Effect No Death Dispel with script. on the script type active magic effect I only placed the ondeath event and a debug line...
The script worked fine when the actor died...

So this method will work for some script functions.


Thanks for all the help !!!!!!!!!!!!!!
User avatar
leigh stewart
 
Posts: 3415
Joined: Mon Oct 23, 2006 8:59 am


Return to V - Skyrim