Jump to content

[FO4 CK] General Help Thread


Recommended Posts

Could someone help me with implementing script that makes selected NPC follow player like in JS or SEU?

I got into point when I have NPC selected with Actor reference available in papyrus function. I saw other mods using AI Packages and factions etc. but haven't figured out how to make it work end-to-end.

Link to comment
6 hours ago, Oakern said:

Could someone help me with implementing script that makes selected NPC follow player like in JS or SEU?

I got into point when I have NPC selected with Actor reference available in papyrus function. I saw other mods using AI Packages and factions etc. but haven't figured out how to make it work end-to-end.

 

Simplest way is to add a ReferenceAlias to a quest, make the alias have that AI package, and then put the NPC in that alias using ReferenceAlias.ForceRefTo(Actor).  You can add packages to any number of Actors this way by using a RefCollectionAlias instead of a ReferenceAlias.

 

For example, here's an AI package that makes an NPC follow the player:

 

image.png

 

I want to be able to make NPCs use that package, so I have a quest that is always running.  I create a RefCollectionAlias in that quest and put that package in the Alias Package Data, along with factions, keywords to allow the Player to stimpak the NPC etc.  The Fill Type for the Alias is set to Specific Reference but left unfilled, and the Alias is flagged Optional so that the quest will run whether or not the Alias is filled:

 

image.png

 

Then in my code I have:
 

    RefCollectionAlias Property FreedCaptives Auto Const

    FreedCaptives.AddRef(akCaptive)
    akCaptive.EvaluatePackage()

 

If I want to stop this I just do:
 

    FreedCaptives.RemoveRef(akCaptive)
    akCaptive.EvaluatePackage()

 

The EvaluatePackage() isn't strictly necessary but it makes the package change take effect immediately, otherwise it might take a few seconds for the NPC to automatically evaluate its package stack.

 

Edited by EgoBallistic
Link to comment
  • 2 weeks later...

I have an ActiveMagicEffect script bound to a magic effect which is applied by consuming a potion. The script uses StartTimer() and OnTimer() events to try to be as asynchronous as possible. From time to time, I get errors in the Papyrus log about the script trying to start a timer while unbound, which seems to correspond with the potion being equipped while the effect is already active, refreshing it and starting a new instance of the script. The error seems benign, but I'm worried that it's a sign of unhygienic design on my part. I've tried wrapping the StartTimer() calls in If Self conditionals but this hasn't eliminated the logged errors. Is there a proper way to check whether an ActiveMagicEffect script has come unbound?

 

Edit: Should I be checking GetTargetActor() instead of Self?

 

Yet still moar edit: Yeah, I think checking GetTargetActor() solved it, though it's hard to say for sure other than continuing to playtest and monitoring papyrus logs for long enough that I feel like I should have seen it happen again. Fingers crossed!

Edited by vaultbait
Link to comment

Can someone tell me what my npc is doing?

I create a blank NPC but when i place them for example in vault 95, they just walk but don't act.

The test was if i can populate the vault with NPC's and get naughty there. But it's meh so far.

I did gave them a default sandbox package and so they talk a little and walk and do things but as far as AAF goes, they don't notice me. 

Link to comment
  • 3 weeks later...
On 3/28/2024 at 2:36 AM, TheFruitlessOne said:

Can someone tell me what my npc is doing?

I create a blank NPC but when i place them for example in vault 95, they just walk but don't act.

The test was if i can populate the vault with NPC's and get naughty there. But it's meh so far.

I did gave them a default sandbox package and so they talk a little and walk and do things but as far as AAF goes, they don't notice me. 

 

What does "they don't notice me" mean? AAF doesn't automatically initiate any scenes. You can use AAF's on-screen interface to manually put a scene together to make sure your NPCs are capable of those animations, but it sounds more like you're expecting some other mod to use the NPCs in some way and it isn't (like Sexual Harassment choosing them as approachers or something)?

 

Or are you saying they don't have any idle chatter and dialogue? You need to give them a voicetype with associated lines, and/or set up quest dialogue with an alias that gets filled with your actors. In many cases, it's easier to template an NPC from another one you're familiar with that already has all that set up than to make one from a base form and have to figure out everything it's missing.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use