RedShirtBaseActorProperty.SetEssential(false)

Post » Thu Jun 21, 2012 7:47 am

Why this isn't working in a fragment stage section?

It keeps telling me

Starting 1 compile threads for 1 files...Compiling "QF_ISSGARDJourney01_0107303D"...e:\giochi\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\QF_ISSGARDJourney01_0107303D.psc(53,34): SetEssential is not a function or does not existNo output generated for QF_ISSGARDJourney01_0107303D, compilation failed.Batch compile of 1 files finished. 0 succeeded, 1 failed.Failed on QF_ISSGARDJourney01_0107303D

While I am using this code type ...


Debug.Notification("Quest is 80 ")Debug.Notification("Scene Starts ")NPC.GetActorReference().SetEssential(false)
User avatar
Natasha Biss
 
Posts: 3491
Joined: Mon Jul 10, 2006 8:47 am

Post » Thu Jun 21, 2012 10:50 am

http://www.creationkit.com/SetEssential_-_ActorBase
http://www.creationkit.com/GetActorReference_-_ReferenceAlias

As you can see on the first page, ''SetEssentail(bool abEssential)'' is a function of the ActorBase script, whereas GetActorReference() returns an Actor script. You'll have to add one more function to it, which is this one:

http://www.creationkit.com/GetActorBase_-_Actor

So the following should work:

NPC.GetActorReference().GetActorBase().SetEssential(false)
User avatar
Nicola
 
Posts: 3365
Joined: Wed Jul 19, 2006 7:57 am

Post » Thu Jun 21, 2012 9:04 pm

I haven't understood how it works but it works ...
User avatar
Wanda Maximoff
 
Posts: 3493
Joined: Mon Jun 12, 2006 7:05 am

Post » Thu Jun 21, 2012 5:08 pm

Did the line of code I suggested work? If so, let me try to explain again why that works and why what you tried didn't work, and why you got the error you did.

Your ''NPC'' variable is of the type ReferenceAlias. You called the function GetActorReference() on NPC. If you look at this page:

http://www.creationkit.com/GetActorReference_-_ReferenceAlias

you will get 2 important pieces of information. The first is at the very top of the page, and says: ''Member of: ReferenceAlias Script''. What this means is that the function can be called on objects of the type ReferenceAlias, which your NPC variable indeed is. If you also had another variable of the type integer for example (just a number), and tried to call GetActorReference() on that, it would have failed, because GetActorReference() is not a member of the integer script.

The second important piece of information is the Return value, which is of type Actor. This means that the piece of code ''NPC.GetActorReference()'' ends up being a pointer to something of the type Actor.

If you then look at the function which you were trying to use, the SetEssential() function, you will see on this page:

http://www.creationkit.com/SetEssential_-_ActorBase

by again looking at the top of the page, that this function is a member of the ActorBase Script. This means that you cannot call SetEssential() on ReferenceAliases, you cannot call it on integers, you cannot call it on apples, and indeed you cannot call it on an Actor. It can ONLY be called on something of type ActorBase. Because you only had a pointer to something of type Actor, the compiler did not understand what you were trying to do (because there is no SetEssential() function in the Actor script) and therefore threw the error at you which it did.

Because you can see on the function's wiki page that the function is a member of the ActorBase script, you also know already that if you want to call it on your actor, you need to figure out a way to convert your Actor into an ActorBase, and that is precisely what the function GetActorBase() is for:

http://www.creationkit.com/GetActorBase_-_Actor

As you can see on that page, the function is a member of the Actor script (and you have an Actor), and the return value is of type ActorBase (which is the type that you want to end up with), so that's how you can see that this function can be used, and that it gives you what you want.
User avatar
Noely Ulloa
 
Posts: 3596
Joined: Tue Jul 04, 2006 1:33 am

Post » Thu Jun 21, 2012 9:17 pm

I am using this

Alias_NPC.GetActorReference().GetActorBase().SetEssential(false)

but The alias of the npc is set to essential , at a certain stage I give this command , but the NPC even ifkilled stays essential and goes just unconscious and restarts with full health soon after ... how can I do to force it to be set essential to false status? or how I debug to check whats going wrong?
User avatar
luke trodden
 
Posts: 3445
Joined: Sun Jun 24, 2007 12:48 am

Post » Thu Jun 21, 2012 6:10 pm

Is your NPC a leveled actor? I doubt it is, pretty uncommon to have essential leveled actors, but if it is, take a look at the Notes here: http://www.creationkit.com/GetActorBase_-_Actor
User avatar
Colton Idonthavealastna
 
Posts: 3337
Joined: Sun Sep 30, 2007 2:13 am

Post » Thu Jun 21, 2012 9:34 am

My understanding is that an alias with the essential flag makes the NPC it points to essential as long as it's referenced. To make that NPC stop being essential you would have to clear the alias.

So you might try doing things in reverse. Don't set the Essential flag in the alias and use the SetEssential function to make the NPC essential at the beginning then the same function should be able to make it unessential again. You could also have two aliases and swap the NPC between them. Of course if there's another alias (with the essential flag) pointing at the same NPC you're going to be out of luck.
User avatar
Matthew Barrows
 
Posts: 3388
Joined: Thu Jun 28, 2007 11:24 pm

Post » Thu Jun 21, 2012 11:29 am

I dunno why but I am having problems with my quest the essential didnt get out of way with the command so I decided to set the Alias npc to immortal status and remve it after , that seemed to work better , but I get sometimes strange debug notes like the quest is stage 95 and 100 when instead should be just 80 ...
User avatar
Christina Trayler
 
Posts: 3434
Joined: Tue Nov 07, 2006 3:27 am


Return to V - Skyrim