Jump to content

removing all NPCs of certain class/faction/race


Recommended Posts

Hello

 

First of all - I'm a CK newbie so please have mercy if I say something stupid. :smile:

 

I'm trying to make a mod which removes all instances of NPCs from a certain faction or race (e.g. supermutants or feral ghouls) from the entire game, minus unique/named characters (e.g. Strong).

 

I want my mod to only affect the vanilla characters - for example if all ferals are removed and there's another mod which adds its own ferals in some location, I want those ferals to still be there. So I'm guessing I can't use the same approach as for example in SKK50's mods, which - if I understand correctly - dynamically disable all actors in loaded cells as soon as they are loaded, regardless of which master/plugin file put them there.

 

My first idea was to manually disable all unwanted actors cell-by-cell. However this was a real pain - they were often tied up in dependencies with markers/triggers/activators/quests/etc. so mass-disabling them with "reference batch action" tool wasn't an option. And even if it was, the sheer number of cells would still make it a pain.

 

My next idea was to create a duplicate of "EmptyIdleMarker" object, check the "ignored by sandbox" option in the duplicate, and then search & replace all instances of a certain actor type (e.g. LvlSupermutantRanged) in the entire game with instances of that new marker. This actually worked - I briefly tested it and there were no crashes or glitches, NPCs just disappeared. Is this approach even remotely proper or correct? :smile:

 

Then I found all the Random Encounter quests involving that particular faction/race and removed their quest nodes from Story Manager. Again, is this approach valid?

 

But still, some NPCs just keep appearing. Is there any other way an actor can spawn in the world, other than manual placement, quests or random encounters? Is there any way to check in-game in which manner an actor was spawned? I'm already using Better Console mod but it doesn't seem to provide that info (it only shows that an actor comes from Fallout4.esm).

 

Any help, insight and guidance will be highly appreciated. Thank you in advance. :smile:

Link to comment
Share on other sites

If you are using script or conditions to identify target actors then the validation functions/conditions of interest will be;

((ThisRef as Actor).GetActorBase().IsUnique() == False)

(ThisRef.IsCreated() == True) ;placed not spawned

(ThisRef.IsQuestItem() == False) 

As objects or actors that have Enable State Parents can not be disabled, and quests can be held open if they just disappear, the elegant way to deal with actors is to move them to a holding cell and KillEssential.

 

Enable State doesnt prevent move and most quests will either progress or shutdown with a dependent actor OnDeath event. Its the fundamental mech that all SKK actor management solutions are based on.

 

Just doing Disable on large populations will not deliver predictable results.

Link to comment
Share on other sites

Your title immediately made me think of this:

 

 

 

ObjectReference[] Function TryToDisableEverybody(Keyword akKeyword)
    ; Disables all actors found that has this keyword, returning the array of actors as well
    ; to check if they were able to be disabled.

 ObjectReference[] akActorRefs = Game.GetPlayer().FindAllReferencesWithKeyword(akKeyword, 105000.0)
    ; should cover most of the cells loaded around the player in accordance with UGridsToLoad default of 5(5x5)
 
    int index = akActorRefs.Length
    
    if (index < 1)
       return akActorRefs 
       ; return an empty array if none were found
    endif  

    while index
        index -= 1
        if akActorRefs[index] != Game.GetPlayer()
            akActorRefs[index].Disable()
        endif
    endwhile

return akActorRefs
EndFunction
Int Function GetActorsNotDisabledCount(ObjectReference[] akActorRefs)
    ; returns how many actors were not disabled.

    int index = akActorsRef.Length
    int count
 
   while index
        index -= 1
        if akActors[index].IsDisabled() == FALSE
            count += 1
        endif
   endwhile
 
return count
EndFunction
Keyword property ActorTypeNPC auto

...some Event...
Int ActorsNotDisabled = GetActorsNotDisabledCount(TryToDisableEverybody(ActorTypeNPC))
...some EndEvent...

 

 

 

 

This will cover a lot of ground, but you will still have to move around the map to get all the cells, that were out of the radius range. Cell sizes are 4,096x4,096. You can always know how many cells you need to jump by doing simple multiplication.

For actor specific functions(just throwing this in there) ~

(akActorsRef[index] as Actor).SomeFunctionThatNeedsActorsAstheCaller()
Edited by AnishaDawn
Link to comment
Share on other sites

This looks useful, thanks.

 

In the meantime, I found what all those NPCs who stubbornly refuse to disappear seem to have in common. In CK they are normally showing up in their respective cells, but in FO4Edit they are showing up in "Persistent Worldspace Cell" instead of the cells in which they physically appear in the game. According to FO4Edit this cell's ID is 00018AA2, it contains a ZILLION entries, and I can't even find it in CK. I tried googling it obviously but couldn't find anything useful. CK Wiki doesn't have anything either. WTF?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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