Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Papyrus Scripting and Enabling Quest Alias References.


Ravelen
 Share

Recommended Posts

UPDATE: Someone has helped me elsewhere, thankfully. Solution posted.

 

I apologize in advance if I am totally overlooking something or unaware of a broken rule I am violating, I am far from a Papyrus Skyrim coding expert and barely a novice. Okay, so this is the setup;

 

I have a quest. The quest is triggered and one of the reference aliases, an NPC, is spawned at a location. Okay, fine.

 

I select “Initially Disabled†for the NPC, so they’re created when the quest runs, but they’re initially disabled. We’ll enable them later.

 

This is how we’ll enable them; We have a very simple script that runs an OnInit, placed in the Quest scripts section. It runs when the Quest runs.

 

After a period of time with a single update event, we Enable the NPC the Quest created.

 

Seems simple, I have some things working, but the NPC still won’t be enabled.

 

Scriptname Sin7War_TimedEnable5 extends Quest 

ReferenceAlias property myAlias  auto

ObjectReference property SelfRef auto

 

Event OnInit()

Debug.Notification("OnInit Event activated.")

myAlias.ForceRefTo(SelfRef)

     RegisterForSingleUpdate(120.0)

EndEvent

 

Event OnUpdate()

Debug.Notification("Event OnUpdate activated..")

         SelfRef.Enable()

EndEvent

 

Note, earlier I tried to DIRECTLY enable the NPC Ref alias in the quest. Apparently you cannot do that? For example, this stated earlier line gives the compiler fits; myAlias.Enable(), it gives me:  Enable is not a function or does not exist.

 

Okay, so we can’t Enable the refAlias directly. It seems to only work on ObjectReferences. So I look around, I find ForceRefTo and try to shove the reference into that created ObjectReference holder, so I can actually enable the script.

 

That compiles. I of course go to the Quest section, properties for the script, and fill in the property for ReferenceAlias myAlias (The NPC), while keeping ObjectReference SelfRef default and unfilled. It runs in Skyrim, I get both ^ of  my debug notifications. NPC still does not enable. So I assume the reference is not being put into SelfRef.

 

I am at a loss. How can I enable an NPC initially disabled by the quest? I can’t point at it in the Cell Window, because of course it is not created yet. I have to use the reference set up by the quest, but I get “Enable is not a function or does not exist†with everything except ObjectReference.

 

Bonus Question: Is there a little snippet of code that allows me to generate a random number between two values? If I can somehow get my above script attempt to work, I’d like to use a random value between two sets of numbers for my SingleUpdate.

 

Thank you in advance for taking the time to read this, even if you don't have an answer.

 

UPDATE SOLUTION:

 

ReferenceAlias property myAlias  auto

 
Event OnInit()
;Debug.Notification("OnInit Event activated.")
int random = Utility.RandomInt(120, 1200)
     RegisterForSingleUpdate(random)
EndEvent
 
Event OnUpdate()
;Debug.Notification("Event OnUpdate activated..")
      myAlias.GetActorReference().Enable()
EndEvent
Edited by Ravelen
Link to comment
Share on other sites

  • 5 weeks later...

Thats a common one thats caught me out more than once. You can also use

 

MyAlias.GetActorRef()

 

or even

 

MyAlias.GetReference() as Actor

 

which is apparently faster as it doesn't requre an auto-cast, whatever that is.

 

Now if only I could figure out Cast Reference, and how to get an integer property from a vanilla script within another script I'd be a happy man. No-one seems to have an answer for that, at least none that will compile.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...