SKKmods Posted August 9, 2018 Share Posted August 9, 2018 I need to establish if a actor is assigned to a workshop to run UnassignActor at scale, processing the whole world which is up to 1,000 active NPCs at once. (If ThisREF.GetValue(pWorkshopParent.workshopIDActorValue) >= 0) is the ultimate test, but it is slow and stuffs the log with errors on the 500 actors that are not workshop assigned. Looking for a fast high probability screening test to run before that call, any better ideas than: IsInfaction(pWorkshopNPCFaction) - too many false positives. IsCurrentPackage(pWorkshopMasterPackage) - only applies to assigned permanent actors.HasKeyword(pWorkshopItemKeyword) - looking good. Link to comment Share on other sites More sharing options...
Magicockerel Posted August 9, 2018 Share Posted August 9, 2018 Have you tried something like this?: If (ThisREF Is WorkshopNPCScript) ; ThisREF has the WorkshopNPCScript attached If (ThisREF.GetWorkshopID() >= 0) ; ThisREF is assigned to a workshop If (ThisREF.bIsWorker) ; This should tell you whether the settler is assigned or unassigned ; However, it is possible for this to be out of sync ; Either through the use of console commands or buggy mods that don't properly maintain this property EndIf EndIf EndIfEither way, the WorkshopNPCScript should have what you're looking for. I'm not sure whether the GetWorkshopID() function will be faster than what you've got, but that's the only other way that I can think to do it. The script does describe the value of this function as a mirror of the actor value that you're already calling, so there shouldn't be any disadvantage to using it. Maybe you could substitute it for the bWorkshopStatusOn property? I don't imagine that the bIsWorker property would have any false positives, but it will have false negatives. The only false negative that I know of is that bIsWorker doesn't account for provisioners. So, you'll also have to check whether the actor's in the CaravanActorAliases, which is a WorkshopParent alias/script property. Link to comment Share on other sites More sharing options...
SKKmods Posted August 9, 2018 Author Share Posted August 9, 2018 Perfect ! Disable everyone in the commonwealth and still leave the workshops clean for the replacement population: If (ThisREF Is WorkshopNPCScript) && ((ThisREF As WorkshopNPCScript).GetWorkshopID() > -1) pWorkshopParent.UnassignActor((ThisREF as WorkshopNPCScript), bRemoveFromWorkshop = true, bSendUnassignEvent = true) EndIf Memo: must use "Is" more. Link to comment Share on other sites More sharing options...
Recommended Posts