Storing Actor In a Quest Script, Please Help!

Post » Wed Jun 20, 2012 4:11 pm

Here is what I am trying to do.

I have an activemagiceffect script. When the effect lands, I want to retrieve the reference of the actor it lands on. I then want to cast to a second script, which is a quest script, to "store" the actor's reference. Then, when the player casts a second spell with a third script (another activemagiceffect script) I want to retrieve the variable with the actor's reference to use it in the second activemagiceffect script.

I am very confused about how the casting works for this. So far, this is what I have come up with, but obviously doesn't work. Can someone point me in the right direction or at least help me understand this a little better?


Magic Effect script 1 (The magic effect that is finding the Actor Reference)
Scriptname ESG_SaveActorToQuest extends activemagiceffectEvent OnEffectStart(Actor akTarget, Actor akCaster)	ESG_MyQuestScript.StoreActor(akTarget)EndEvent
Quest script (The quest script that is storing the Actor Reference)
Scriptname ESG_MyQuestScript extends questActor StoredActorFunction StoreActor(Actor NewActor)      StoredActor = NewActorEndFunctionActor Function RetrieveActor()     Return StoredActorEndFuntion
Magic Effect script 2 (The magic effect that is retrieving the Actor Reference from the script and casting a new spell from the player to the actor.)
Scriptname ESG_GetActorAndCastAtIt extends activemagiceffectSpell Property SpellToCast AutoActor ActorToCastAtEvent OnEffectStart(Actor akTarget, Actor akCaster)	ActorToCastAt = ESG_MyQuestScript.RetrieveActor()SpellToCast.Cast(akCaster, ActorToCastAt)EndEvent
User avatar
Nicola
 
Posts: 3365
Joined: Wed Jul 19, 2006 7:57 am

Post » Wed Jun 20, 2012 6:48 pm

You need to declare a property in your magic effect scripts which points to the quest holding the reference.
User avatar
sarah
 
Posts: 3430
Joined: Wed Jul 05, 2006 1:53 pm

Post » Wed Jun 20, 2012 2:06 pm

Still wont compile once I did that. Says unknown function StoreActor

I tried instead doing (akTarget as ESG_SaveActorQuest).StoreActor() and that didn't work either, tried several variations of that, gave me some errors like: ESG_SaveActorQuest is not a known user defined type.

At a loss here. If only global variables could hold more than just floats and integers....
User avatar
(G-yen)
 
Posts: 3385
Joined: Thu Oct 11, 2007 11:10 pm

Post » Wed Jun 20, 2012 7:24 pm

As RandomNoob said, in both magic effect scripts you need to declare the quest as a property:

Quest Property MyQuest Auto

And set that to the quest that the quest script is assigned to.

Then in the body of each magic effect script, change "ESG_MyQuestScript.yourfunction" to "(MyQuest as ESG_MyQuestScript).yourfunction"
User avatar
NIloufar Emporio
 
Posts: 3366
Joined: Tue Dec 19, 2006 6:18 pm

Post » Wed Jun 20, 2012 10:44 am

Thanks! That looks like it works. Looks like I have mad dyslexia cause I was getting that casting stuff backwards.


So basically we are casting the Quest property as the extends quest script attached to it?
User avatar
Prisca Lacour
 
Posts: 3375
Joined: Thu Mar 15, 2007 9:25 am

Post » Wed Jun 20, 2012 5:50 am

So basically we are casting the Quest property as the extends quest script attached to it?

Exactly. The quest script really creates its own datatype, which your functions are members of. You need to specify both the underlying quest and the quest script because a script can be applied to more than one quest.
User avatar
Queen of Spades
 
Posts: 3383
Joined: Fri Dec 08, 2006 12:06 pm


Return to V - Skyrim