Jump to content

Dynamically add AI Packages to NPCs via Cloak Effect


Recommended Posts

Posted

Hi! I wonder what the easiest way is to dynamically add AI Packages to NPC that are close to me.

 

Right now I created a cloak ability with an applying spell. What would be the next step? I mean I could attach script to applying effect to initiates a quest. But then in that quest how would I forward an alias for the NPCs?

 

 

Posted

Attaching the package is not complex. But removing it can be problematic, if you don't keep track of the actors you already managed.

 

Add a faction.

Filter the cloak apply spell with the faction.

When the spell happens then add the actor to the faction, and use ActorUtil.addPackageOverride(theActor, yourPackage)

 

Remove the packageoverride in case you need to do it.

 

With this method you don't need aliases.

Posted

Attaching the package is not complex. But removing it can be problematic, if you don't keep track of the actors you already managed.

 

Add a faction.

Filter the cloak apply spell with the faction.

When the spell happens then add the actor to the faction, and use ActorUtil.addPackageOverride(theActor, yourPackage)

 

Remove the packageoverride in case you need to do it.

 

With this method you don't need aliases.

Wow I didn't know it was this simple. Just implemented it, works like a charm. I guess the way with aliases is much more cumbersome? Would really like to figure out how to do with aliases too, can't find anything on it though.

Otherwise thank you very much for keeping helping me in this frustrating journey! :D

Posted

Aliases are fine. But you need to create them in CK. So you may be limited by its number.

If you want to do something to everybody, then use a "mark" system (a faction usually is lightweight and fast), and use the SKSE functions to alter their statuses.

 

Now, you may want to change the cloak to an alias discovery system.

Slightly more complex to do, but is slightly more efficient. And can be run only when you need it.

 

Check this post I did in one of my mods to compare the performances of: cell scan, alias scan, and cloak scan.

 

Posted

I can explain how it works. It is quite easy.

 

Have two quests:

ymcMainQuest

ymcAliasesQuest

 

Set the ymcAliasesQuest to do not start automatically.

Create one or more aliases inside. Set them as Optional, Allow Reserved, Find matching Reference, In loaded Area.

Then add the conditions you want (the option Closest can be convenient in many cases.)

Recommendation: start with few conditions, and then add more after testing.

Save and Close this quest.

Recommendation 2: create one alias, set it up, and then duplicate it the number of times you need.

 

Define a script inside ymcMainQuest, this quest can start at game start.

 

Inside add a couple of properties.

 

 

Quest Property ymcAliasesQuest Auto
ReferenceAlias[] Property ymcAliases Auto
 

And a function that you will call when you want to update the actors in the aliases.

 

 

Function scanActors()
  ymcAliasesQuest.start()
  Utility.wait(0.5)
  int i = ymcAliases.length
  while i
    i -=1
    Actor a = ymcAliases[i].getActorRef()
    if a
      debug.notification("Found: " + a.getDisplayName())
      ; "Do here something with this actor, or add it to a variable or an array"
    endIf
  endWhile
  ymcAliasesQuest.stop()
  Utility.wait(0.1)
  ymcAliasesQuest.reset()
EndFunction
 
 
Then you just have to call the function when you want the actors to be re-checked.
You can do it when the cell changes (using a radiant cell change event, or another cell detection way.)
Or you can do it using a timed update (RegisterForSingleEvent(30.0), Event OnUpdate())
 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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