Jump to content

Making an NPC immune to pickpocketing/hiding the pickpocket prompt


Minuos

Recommended Posts

Hello,

 

Some NPCs in a mod I'm working on have player dialogue disabled by design (i.e. when you stand in front of them, there is no 'talk' button prompt). Interacting with them instead brings up a message box from a script attached to them where the player can manage various things. Problem is, when the player is crouched, the pickpocket prompt still appears.

 

To be clear, they can't actually be pickpocketed due to a BlockActivation() line in their script, and my message box opens fine, but it bugs me that the option to pickpocket still appears. I've tried playing with BlockActivation() parameters, but any combination of true/false prevents OnActivate events altogether, so that's no good.

 

Anyone know if there's a way to make an NPC 'immune' to pickpocketing, or at least make it so that the option to pickpocket doesn't appear?

 

I tried compromising by using an Add Activate Choice / Button Label perk entry to replace 'Talk'/'Pickpocket' prompts with 'Interact', but ofc this overrides the OnActivate event from the script, so nothing happens at all, and I don't know how to call on functions in an actor script from a perk fragment.

 

Any help with this would be appreciated.

 

 

 

Edit:

I solved this problem by essentially making the NPC activate itself, using a player perk with an Add Activate Choice running the script fragment:

(akTargetRef as Actor).Activate(akTargetRef)

 

Combined with a Self.BlockActivation() line in the NPC's initialisation script, the standard interactions (talk/pickpocket) are blocked but the activation still triggers the OnActivate event.

Edited by Minuos
Link to comment
Share on other sites

Thanks. I've neglected working with aliases. I was hoping for an alternative since the groundwork for the mod is essentially complete without using them.

 

There could potentially be hundreds of these NPCs active in a save (via workshops). Could that be an issue doing it this way?

Link to comment
Share on other sites

Adding heaps of actors to a reference/collection alias makes them persistent which can increase the load/overhead in a game and you also need to handle cleanup.

 

You may want to look at the script function ApplyToRef which may apply the no pickpocket config from an alias, dont know you will ned to test it.

Link to comment
Share on other sites

There could potentially be hundreds of these NPCs active in a save (via workshops). Could that be an issue doing it this way?

 

Sorry, I didn't know that.

 

Adding them to a Reference Collection Alias (with the AddRef() function) is also an option.

 

I'm not sure about this but if you use ApplyToRef, I think you have to check the checkbox "Can Apply Data To Non-Aliases Refs" in the Reference Alias window (lower right corner).

 

By the way, are these NPCs settlers?

Edited by LarannKiar
Link to comment
Share on other sites

 

By the way, are these NPCs settlers?

 

Yes and no. They have the workshopnpc script and some workshop keywords for certain interactions, but they're more like turrets that move around.

 

Settlers and workshop turrets are persistent in the vanilla game so adding them to a ref coll won't increase your save size that much.

Link to comment
Share on other sites

 

 

Settlers and workshop turrets are persistent in the vanilla game so adding them to a ref coll won't increase your save size that much.

 

 

No that is not correct.

 

Whilst named unique and some placed (00) settlers are persistent, spawned (FF) base game settlers are not persistent.

 

It is why the function ApplyToRef was created, and the only use of that function to apply workshop packages to settlers, avoind adding them to a collection.

 

Making settlers persistent is a significant overhead on a game, I know because I take shame that one of my solutions has had to do it to manage them in a timely manner.

 

A base game new start has 106 persistent actors running WorkshopNPCScript (including companions). Additional settlers spawn/recruited using the base game beacon are not persistent WorkshopParentScript.CreateActor PlaceAtMe abForcePersist = false

To prove this to yourself, create a quest that fills a RefCollection with condition HasVMScript workshopnpcscript (dont forget MaxInitialFillCout 0), start it and sqv it. It will only find those initial ~100 settlers (and any local loaded actors) in an unmodified game.

 

Or, prove me wrong because misunderstanding on persistent actors is nearly as bad on game stability as misunderstanding on breaking precombines.

Link to comment
Share on other sites

For the record, my NPCs aren't initially persistent. I was toying with the idea of making them lite followers and they'd sometimes be unloaded when changing cells. I need to do some playtesting to gauge the potential impact of the mod if the NPCs are forced to persist.

 

Honestly, the mod is a bit experimental. My own scripts are very conditional but there are a few events that will fire frequently in some situations, so it needs a good stability playtest in general.

Link to comment
Share on other sites

 

 

 

Settlers and workshop turrets are persistent in the vanilla game so adding them to a ref coll won't increase your save size that much.

 

 

No that is not correct.

 

Whilst named unique and some placed (00) settlers are persistent, spawned (FF) base game settlers are not persistent.

 

Are you sure?

 

I always though the easiest way to know whether an object is persistent or not is by using the prid console command on them. (Noting down their RefID, fast traveling so they'll be unloaded, then trying to "select" them using Prid RefID).

 

As far as I know:

 

- PP and EP (console) flags are the "persistence flags". So if an object has one of them, then it's persistent.

 

- Only those unloaded objects that are persistent can be selected in the console (prid) or filled to an alias / ref coll.

 

I tested it with a quick mod. In short: I tried to fill unloaded generators and settlers to reference collection aliases. In the vanilla game, settlers always have the PP or EP flag while generators don't have any flags. Unloaded generators couldn't be filled to ref colls, only settlers.

 

Here's how I tested it:

 

I created a Quest: Start Game Enabled, Allow Repeated Stages.

 

I added two Ref Aliases:

 

- Alias 1: points to the workbench ref of Murkwater construction site. Fill Type: Specific Reference.

 

- Alias 2: points to the workbench ref of Santuary Hills. Fill Type: Specific Reference.

 

I added four Reference Collection Aliases:

 

- RefColl 1: to get the settlers of Murkwater construction site. Max Initial Fill Count = 0, Optional, Fill Type: Find Matching Reference, Actors Only, Closest to: Alias 1. Match Conditions: 1. GetDistance: Reference Murkwater workbench ref (0016D28E) <= 10000, Run On: Subject. 2. HasVMScript: WorkshopNPCScript. (All conditions use "AND").

 

- RefColl 2: to get the generators of Murkwater construction site. Max Initial Fill Count = 0, Optional, Fill Type: Find Matching Reference, Closest to: Alias 1. Match Conditions: 1. GetDistance: Reference Murkwater workbench ref (0016D28E) <= 10000, Run On: Subject. 2. HasVMScript: WorkshopObjectScript. 3. GetValue: PowerGenerated >= 3.00, Run On: Subject. (All conditions use "AND").

 

- RefColl 3: to get the settlers of Sanctuary Hills. Max Initial Fill Count = 0, Optional, Fill Type: Find Matching Reference, Actors Only, Closest to: Alias 2. Match Conditions: 1. GetDistance: Reference Sanctuary workbench ref (000250FE) <= 10000, Run On: Subject. 2. HasVMScript: WorkshopNPCScript. (All conditions use "AND").

 

- RefColl 4: to get the generators of Sanctuary Hills. Max Initial Fill Count = 0, Optional, Fill Type: Find Matching Reference, Closest to: Alias 2. Match Conditions: 1. GetDistance: Reference Sanctuary workbench ref (000250FE) <= 10000, Run On: Subject. 2. HasVMScript: WorkshopObjectScript. 3. GetValue: PowerGenerated >= 3.00, Run On: Subject. (All conditions use "AND").

 

Both settlements, Murkwater and Sanctuary, had settlers and generators. When I opened the game, I was in Sanctuary. Every ref coll and alias were filled except RefColl 2 (Murkwater generators). I stopped the quest (console, StopQuest), fast traveled to Murkwater (Sanctuary was completely unloaded), then started it again (console, StartQuest). Every ref coll and alias were filled except RefColl 4 (Sanctuary generators).

 

Sorry if I misunderstood you. I know the WorkshopParentScript spawns non persistent settlers (abForcePersist isn't set to True) but they are always persistent in the game. I also checked DumpPapyrusPersistenceInfo but it doesn't list anything.

 

 

By the way, console spawned (Player.PlaceAtMe 00020593) settlers are not persistent until they get assigned to a workshop (WorkshNPCScript state assigned).

 

EDIT: Forgot to upload the test mod I created.

Edited by LarannKiar
Link to comment
Share on other sites

  • Recently Browsing   0 members

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