Jump to content

Adding an Ai Package to an NPC via Alias / script


Recommended Posts

Sorry, it's me again. Still trying to learn how AI packages work, but through Aliases. 

All I'm trying to do is this: I say to an NPC "Yes, you can follow me", and then an alias adds an AI Package to this NPC. 

 

Here is a solution. Tested in game, it works. 


1). If the NPC hasn't got a Reference ID, give the NPC a Reference ID in the Render window. Copy this name so it can be pasted. 

2). Make an alias on a quest. Right-click > New Reference Alias into the Alias window. 

3). Click Specific Reference as the Fill Type, and find the NPC's Reference in the scroll-bars. Conversely, Unique Actor can also be used, as long as the NPC is a (you guessed it) Unique Actor.

The alias can have the AI package attached directly to it, along with scripts, and all sorts of other good geekiness. And see: the advantage is, this frees up space in the NPC's AI Packages window. 🙂 From what I understand, adding packages this way works more flawlessly than adding packages directly to an AI stack. Although I've never had any problems doing so. 

4). Toggle Optional on, and this is the only flag which needs to be toggled. Sometimes if Optional is not toggled on this can cause a quest to not start. 

--These are the minimal features to add an alias (and therefore an AI Package) to an NPC. So click OK, or click into the Alias Name slot and press ENTER or RETURN. Click OK again, closing the quest panel, and save. Reopen, and head to Dialogue Views or Player Dialogue. 

5). At the moment (when speaking to the NPC) when I've got "Yes you can follow me" for a clickable topic, two properties are needed: 1. a ReferenceAlias (can be the same name as the alias just made) and 2). an Actor property. Paste the Ref ID copied in step 1, this way the property auto-fills.

6). Final script is: ReferenceAlias.ForceRefTo(ReferenceID) 


Aliases clear automatically when the quest stops. However if the quest is to continue running while the alias ends, the fragment is ReferenceAlias.Clear()

Edited by xenaclone
Link to comment
Share on other sites

Posted (edited)

Hmm, I think I'm onto something. DialogueGeneric has aliases which cause followers to wait, at least. Gonna study that. 

EDIT: yeah, getting this to work seems insane. So many factors need to come together. I've been at this on and off for hours now. Getting nowhere. 

 

EDIT 2: I give up! But it's okay. I made a FormList instead. Packed all of the AI so far into that list, so I can use it on all the NPCs in my party! If I need a separate package for a secondary NPC, I can just use a GetIsID to define this directly on the Package. Voila. 

Edited by xenaclone
Link to comment
Share on other sites

For information then...

You usually put an AI on an NPC by assigning the AI to a reference alias.

You can use any fill type you like, depending on how you want to use the quest that holds the alias.  Most fill types automate filling the alias when the quest starts.  Do that if you want the AI to be active while the quest is running. 

If you don't want to start/stop quests all the time, and just want to start/stop the AI from a script, use a quest that is always running and follow Isharas instructions: filltype == Specific Reference, leave the value unfilled, flag the Alias as Optional (or the quest may refuse to start).  You start the AI by putting the target actor in the alias, using npc_alias.forceRefTo( npc), and stop the AI with npc_alias.clear().

Instead you went with an AI package that is always assigned but whose validity is gated by a formlist.  That works too... sort of...

You may observe that the package does not come on and off exactly when you want.  Conditions on packages are not checked continuously, nor even periodically.  They are checked when the currently active procedure becomes invalid or is completed.

The forceRefTo/Clear method has the advantage that the effect is instant.

 

Edited by xkkmEl
precision
Link to comment
Share on other sites

Ah, very nice! See, and I already came up with a workaround!  🧑‍🎄 But that's okay, I can still use this info for the future. 

Hey, xkkmEL, thanks for taking the time. 🥞 Pancakes for you. 

Link to comment
Share on other sites

Posted (edited)
Quote

You start the AI by putting the target actor in the alias, using npc_alias.forceRefTo( npc), 

This isn't compiling.

Is npc_alias the actual Alias Name from the Alias Tab? 

And what is the "npc" in the end of the fragment, (in parenthesis). What's supposed to go in there? 

Creation kit page has it arranged like Alias_JohnDoe.ForceRefTo(self). But no matter how I try to arrange, it won't compile. From what I understand I don't need properties, right? I've still tried making properties anyway, nothing works. 

Edited by xenaclone
Link to comment
Share on other sites

My "npc_alias" needs to be a ReferenceAlias, and "npc" an Actor.  Perhaps like this:

ReferenceAlias property npc_alias Auto
Actor property npc Auto

Well, you could get your Actor reference some other way... from an event, as a parameter in a function called from elsewhere... etc..

I am unsure of how your code is structured, what kind of script you are trying to insert this into...  There are different options to access aliases depending on context.  The common case is that your code will run in a Quest script attached to the quest that holds the alias.  If that is not the case, please describe your setup.

For "Alias_JohnDoe.ForceRefTo(self)" to work, you'd need a ReferenceAlias property for "Alias_JohnDoe", and your code would need to run in an Actor or ObjectReference script (not a quest script!).  A reference alias property in such a script could fail to initialize properly in game, and I'd recommend a different method to access the alias.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...