Setting a quest actor reference property from a magic effect

Post » Thu Jun 21, 2012 10:56 am

I am trying to get the syntax worked out for setting actor references from a magic effect script. For this simple test, I attempt to set a quest script ActorBase property (declared in the quest script in question) to the LeveledActorBase of the effect target.

Scriptname phitamecastS extends ActiveMagicEffectphitametrackerS Property phiQuestRef autoEvent OnEffectStart(Actor akTarget, Actor akCaster)	phiQuestRef.phiTameBase1 = akTarget.GetLeveledActorBase()	Debug.Notification("Quest slot set to" +phiQuestRef.phiTameBase1)	akTarget.PlaceAtMe(phiQuestRef.phiTameBase1)EndEvent

This compiles, yet appears to fail. The result of the debug is: "Quest slot set toNone"

This is the quest text:

Scriptname phitametrackerS extends QuestActorBase Property phiTameBase1 auto

The goal of this would be to use PlaceAtMe() elsewhere, so basically to store an actor's base reference (or the created leveled actor base reference) in a quest script for later use with PlaceAtMe.

The placed reference would then be grabbed by condition as an alias of a separate started quest...

I'm sure it must be something obvious but I'm new to this language, so please be kind!
User avatar
Joey Bel
 
Posts: 3487
Joined: Sun Jan 07, 2007 9:44 am

Post » Thu Jun 21, 2012 4:25 pm

So just to test I tried this:

Event OnEffectStart(Actor akTarget, Actor akCaster)    Debug.Notification("What is this" +akTarget)    akTarget.PlaceAtMe(akTarget)EndEvent

That returns "What is this[lvlpredatorscript" which doesn't seem right. It is almost like the "target" argument from the OnEffectStart is sending a pointer rather than the actual reference value?

Anyway of course PlaceAtMe did nothing without a valid reference.

I am thinking now this must be something about how I have set up my Spell or MagicEffect that this script is attached to.

I have set up the spell as a lesser power, Fire and Forget at target, with a custom magic effect.

The magic effect I set up as archetype script, again Fire and Forget at target actor, and pretty much the rest the defaults, with the above (top) script under the Papyrus section.

I'm really not sure why it isn't working at this point.
User avatar
DAVId MArtInez
 
Posts: 3410
Joined: Fri Aug 10, 2007 1:16 am

Post » Thu Jun 21, 2012 11:22 am

Aw man nobody knows? I really labored over this one all morning! XD

EDIT: Following the outline http://www.creationkit.com/Variables_and_Properties#Getting_Properties_of_a_Quest_Script.

Quest variable still shows as None.
User avatar
Nymph
 
Posts: 3487
Joined: Thu Sep 21, 2006 1:17 pm

Post » Thu Jun 21, 2012 7:38 pm

Just tried this:

Scriptname phitamecastS extends ActiveMagicEffectphitametrackerS Property phiQuestRef autoEvent OnEffectStart(Actor akTarget, Actor akCaster)	phiQuestRef.SetQuestValue(akTarget)	Debug.Notification("Quest slot set to" +phiQuestRef.phiTameBase1)EndEvent

With this as the quest script:

Scriptname phitametrackerS extends QuestActorBase Property phiTameBase1 autoFunction SetQuestValue(Actor akTarget)	phiTameBase1 = akTarget.GetLeveledActorBase()EndFunction

That seems right, but even having the function in the quest that gets the variable doesn't work. The value still shows as None.
User avatar
Ebony Lawson
 
Posts: 3504
Joined: Fri Feb 16, 2007 11:00 am

Post » Thu Jun 21, 2012 3:37 pm

:ahhh: OMG OMG OMG! SO MUCH TYPING :ahhh:

Whew. Okay. You might need to give us more time in-between posts. It's hard to keep up. :tongue:

First off I'd try changing your Magic Effect's property definition. Make it a quest so Papyrus knows what methods it has available and the concatenate in the Debug will know what to pull out.

Scriptname phitamecastS extends ActiveMagicEffectQuest Property phiQuestRef autoEvent OnEffectStart(Actor akTarget, Actor akCaster)        phiQuestRef.SetQuestValue(akTarget)        Debug.Notification("Quest slot set to" +phiQuestRef.phiTameBase1)EndEvent

You then edit the property on the script, setting the questRef by browsing to phitametrackerS.

I haven't done something like this but it's an interesting idea. Using GetLeveledActorBase() is a good catch, but be ready for that on subsequent uses.

Specifically you mentioned using PlaceAtMe later on. If you do that on an ActorBase you're going to be placing a new reference--which will not be the same actor that the ActiveMagicEffect was cast on originally. Maybe that's what you want... ??
User avatar
Crystal Clarke
 
Posts: 3410
Joined: Mon Dec 11, 2006 5:55 am

Post » Thu Jun 21, 2012 1:07 pm

Magic effect scripts do not store variables, so you need to define you properties in your quest script, then apply them.

Also I'm pretty sure you don't need the property in the magic effect script, you just extend the quest you want and then all of that quests properties are available to use in your magic effect script.
User avatar
Connie Thomas
 
Posts: 3362
Joined: Sun Nov 19, 2006 9:58 am

Post » Thu Jun 21, 2012 4:23 pm

:ahhh: OMG OMG OMG! SO MUCH TYPING :ahhh:

Aw, lol! Sorry, that's just me. I'm a typer! =P

I tried changing the MagicEffect script's property definition as you suggested, and linking it up under the magic effect window (which was helpful to know to do so thanks!), however when I do the compiler complains saying:

\Data\Scripts\Source\phitamecastS.psc(6,13): SetQuestValue is not a function or does not exist
\Data\Scripts\Source\phitamecastS.psc(7,53): phiTameBase1 is not a property on script quest or one of its parents

It is like it sees the quest but not the script attached? Anyway I was meaning to ask madmole how they came to declare a quest in that way, "questscript Property questname auto" since I saw them do it over on http://www.gamesas.com/topic/1376147-trying-to-set-a-quest-variable-from-a-magic-effect/page__hl__variable+in+message+text__fromsearch__1

In my mind is it saying the property questname is of type questscript, which after you link up the property under the MagicEffect dialogue would let the MagicEffect script access all of the quest's functions from that script. Might have to declare multiple quest variables if you had and wanted to access functions/properties of multiple scripts?

Also I realize it isn't actually "questscript Property questname auto" but rather "questscript Property anyoldvariablename auto" where the 2nd variable could be anything you want to refer to the quest itself by in the MagicEffect script, since you are linking up to the actual quest itself under the MagicEffect window script properties.

Whew, lot of typing indeed!


Magic effect scripts do not store variables, so you need to define you properties in your quest script, then apply them.

Also I'm pretty sure you don't need the property in the magic effect script, you just extend the quest you want and then all of that quests properties are available to use in your magic effect script.

I am not exactly certain about all of what you are saying, but I'm glad you stopped by since I've been following your related threads. =)

When you say a MagicEffect script doesn't store references, I am unclear what you mean. However that may well be the problem. Are you saying that the "akTarget" Actor value from the OnEffectStart event doesn't actually carry an actor reference?

What is it then, some sort of pointer string to a reference? How then would I pull out the actual reference, from elsewhere as you say?

This is the closest I came up with:

Scriptname phitamecastS extends ActiveMagicEffectphitametrackerS Property phitametracker autoEvent OnEffectStart(Actor akTarget, Actor akCaster)	phitametracker.SetQuestValue(akTarget)EndEvent

Scriptname phitametrackerS extends QuestphitametrackerS Property phitametracker AutoFunction SetQuestValue(Actor akTarget)    Game.GetPlayer().PlaceAtMe(akTarget.GetLeveledActorBase())EndFunction

Even passing akTarget straight to a Quest script function to call GetLeveledActorBase() on, it still seems to be getting a string. (My debug text reads 'Quest slot set to[ActorBase'" which is obviously wrong.)

I am wondering if even though it compiles fine, I need some extra step in here to search out the ACTUAL reference akTarget is pointing to, BEFORE I run GetLeveledActorBase() on the result.

Also, I am wondering if I need to cast that command, or import Actor to use the GetLeveledActorBase() command in the first place?

So many questions... Thanks very much for both of your ideas though, I'm definitely getting closer to understanding this stuff. :wink:
User avatar
Andres Lechuga
 
Posts: 3406
Joined: Sun Aug 12, 2007 8:47 pm

Post » Thu Jun 21, 2012 1:54 pm

What I meant was variables are not stored in magic effect scripts. So if you set any values in a magic effect script and want to save them, you need to set them in your quest script from the magic effect script. I don't know the name of your quest, but I do mine like:

QuestScriptName Property QuestName Auto

I would use a naming convention like Bethesda does. Like MyQuestName would use a script called MyQuestNameScript

MyMagicEffect would have a script called MyMagicEffectScript
Makes it easier to understand your stuff.

I think you have everything about right, but you are trying to pass an int into a string it looks like? Maybe you should try

Int property phitametrackersS Auto
User avatar
DAVId MArtInez
 
Posts: 3410
Joined: Fri Aug 10, 2007 1:16 am

Post » Thu Jun 21, 2012 9:38 am

Well, I do it pretty much like you/Bethesda, only instead of MyQuestName/MyQuestNameScript I usually just do MyQuestName/MyQuestNameS (I know, lazy!)

So, in the above examples phitametrackerS is my quest script and phitametracker is the quest.

OK, sorry if this sounds terribly dense, but in the MagicEffect script, in the event "Event OnEffectStart(Actor akTarget, Actor akCaster)" what exactly is "akTarget"? Is that the int I am trying to pass to a string?

I think my big question right now is, how do I get the ACTUAL reference from the OnEffectStart event? Is it even possible?
User avatar
Jordan Moreno
 
Posts: 3462
Joined: Thu May 10, 2007 4:47 pm

Post » Thu Jun 21, 2012 4:41 pm

Even passing akTarget straight to a Quest script function to call GetLeveledActorBase() on, it still seems to be getting a string. (My debug text reads 'Quest slot set to[ActorBase'" which is obviously wrong.)

Actually it isn't obviously wrong--it isn't a string, it's an object. A better way to see that would be to use MessageBox rather than Notification; Notification truncates the message, but if you use MessageBox you'd see that it was a object type ("ActorBase") followed by the object ID. The bracket notation is just what the game does when you try to print out an object.

So the fact that you're getting an ActorBase object is a good sign, that's what you want.
User avatar
Manuela Ribeiro Pereira
 
Posts: 3423
Joined: Fri Nov 17, 2006 10:24 pm

Post » Thu Jun 21, 2012 1:11 pm

Ah, you're right it IS working! I added "Game.GetPlayer().PlaceAtMe(phiTameBase1)" to the end of my function on the Quest script and it does indeed spawn a new creature! Plus I actually understand most of the notation now, so thanks so much all for the help!

The only thind I'm seeing now might be an issue is whether to use GetLeveledActorBase() or just use the reference itself for making duplicates, since the base is actually a leveled list in many cases, and instead of a duplicate wolf in my test I was also getting skeevers and lions...

Still, much progress has been made! Three cheers for knowledge! =P
User avatar
Shelby Huffman
 
Posts: 3454
Joined: Wed Aug 08, 2007 11:06 am

Post » Thu Jun 21, 2012 11:49 pm

Actually it isn't obviously wrong--it isn't a string, it's an object. A better way to see that would be to use MessageBox rather than Notification; Notification truncates the message, but if you use MessageBox you'd see that it was a object type ("ActorBase") followed by the object ID. The bracket notation is just what the game does when you try to print out an object.
Thats good to know!

Good to see you got it working Phinix
User avatar
Miranda Taylor
 
Posts: 3406
Joined: Sat Feb 24, 2007 3:39 pm


Return to V - Skyrim