F4llfield Posted April 23, 2023 Share Posted April 23, 2023 Hi, I would like to get all the current settlers into an array. Not the settlers from a specific workshop but from all workshops. Maybe workshpnpcfaction, but how to call it on all workshops? Link to comment Share on other sites More sharing options...
DieFeM Posted April 23, 2023 Share Posted April 23, 2023 (edited) I don't think is safe trying to store all them in 1 array, because the array limit. You can iterate all the settlements though. WorkshopParentScript Function WorkshopParent() return Game.GetFormFromFile(0x0002058E, "Fallout4.esm") As WorkshopParentScript EndFunction Function IterateAllSettlers() WorkshopParentScript WP = WorkshopParent() Int i = 0 While i < WP.WorkshopsCollection.GetCount() WorkshopScript workshopRef = WP.WorkshopsCollection.GetAt(i) as WorkshopScript ObjectReference[] WorkshopActors = WP.GetWorkshopActors(workshopRef) Int j = 0 While j < WorkshopActors.Length WorkshopNPCScript theActor = WorkshopActors[j] as WorkShopNPCScript ;do something with theActor j += 1 endWhile i += 1 EndWhile EndFunction Edited April 23, 2023 by DieFeM Link to comment Share on other sites More sharing options...
SKKmods Posted April 23, 2023 Share Posted April 23, 2023 Dont forget that settlers are not persistent objects so they will not be found outside the loaded area unless they are: (a) Provisioners in the caravan quest alias. (b) Unique actors with a PersistLocation. © Made perstent by a mod adding them to quest aliases or persistent script arrays as the load. My own Combat Settlers does this, but you have visit each Workshop to load 'em in. Link to comment Share on other sites More sharing options...
F4llfield Posted April 23, 2023 Author Share Posted April 23, 2023 (edited) But then, how can we cast a spell/magic effect "to all settlers" by script without having to visit each settlement ? Edited April 23, 2023 by F4ll0uta Link to comment Share on other sites More sharing options...
Fantafaust Posted April 23, 2023 Share Posted April 23, 2023 I guess the questions are, what spell do you want to put on them and when do you actually need it to happen? Link to comment Share on other sites More sharing options...
F4llfield Posted April 23, 2023 Author Share Posted April 23, 2023 For learning purposes, I'm doing my own armor manager for followers and settlers. It changes the armor depending on different locations and Player faction choices. For Followers so far everything is working as expected. - The magic effect/ spell for settlers are basic already done. - The spell is added when the mod is initialized. From my testing, it seems the OnStartSpell is called when the spell is added and when the player exit the workshop building mod. So to answer your question, the magic effect will determine by the Magic Effect script. Unless there is a better way to do this? Link to comment Share on other sites More sharing options...
DieFeM Posted April 23, 2023 Share Posted April 23, 2023 Dont forget that settlers are not persistent objects so they will not be found outside the loaded area unless they are: (a) Provisioners in the caravan quest alias. (b) Unique actors with a PersistLocation. © Made perstent by a mod adding them to quest aliases or persistent script arrays as the load. My own Combat Settlers does this, but you have visit each Workshop to load 'em in. I've tested the function, and it worked with the settlers from all settlements, I guess because AddActorToWorkshop uses assignedActor.SetPersistLoc(workshopRef.myLocation), and that makes them persistent. Link to comment Share on other sites More sharing options...
F4llfield Posted April 23, 2023 Author Share Posted April 23, 2023 Even after reading the Creation wiki on spell:- A spell is a collection of one or more Magic Effects. and then on Magic Effect: - Magic Effects represent the primary visual and functional effects of the base object that use them. I should be an expert, right ? :-))) A spell has a target, that I can select with condition(s). But the OnStartEffect receives object "Actor akTarget" is not an array. So I can we have multiple actors as a target selected by condition(s) ? Link to comment Share on other sites More sharing options...
SKKmods Posted April 23, 2023 Share Posted April 23, 2023 Load a new game, vault exit save is fine and wait for WorkshopParent.Stage 20 registrations to complete. Run thisWorkshop.GetWorkshopResourceObjects(pWorkshopRatingPopulation, aiOption=0) or GetWorkshopActors which actually calls that base function against the workshop list. Be surprised when some do report population, but many workshops with population do not report the correct values: Somerville 001E81EA actual 3 found 0Country Crossing 0009B1DB actual 2 found 0Nordhagen 0009B1BE actual 3 found 0Tenpines 0009B1AC actual 2 found 0Greentop 0009B1F1 actual 2 found 0Oberland 0009B1D1 actual 2 found 1 Find after many many hours of benchmarking that resolving unloaded WorkshopResourceObjects is totally unreliable. Also be aware that workshop actors such as Robots, Cows, Dogs, Turrets are not found as their WorkshopRatingPopulation = 0, use thisWorkshop.GetActorsLinkedToMe(pWorkshopItemKeyword) to include them (when they are loaded). SKK_GETWorkshopActors WorkshopList 29 SKK_GetWorkshopActors 0 [workshopscript < (00019956)>] 6 SKK_GetWorkshopActors 1 [workshopscript < (001E81EA)>] 0 SKK_GetWorkshopActors 2 [workshopscript < (0006F5C5)>] 3 SKK_GetWorkshopActors 3 [workshopscript < (0009B197)>] 7 SKK_GetWorkshopActors 4 [workshopscript < (00161F4B)>] 0 SKK_GetWorkshopActors 5 [workshopscript < (000B3506)>] 0 SKK_GetWorkshopActors 6 [workshopscript < (001654BD)>] 0 SKK_GetWorkshopActors 7 [workshopscript < (00164321)>] 0 SKK_GetWorkshopActors 8 [workshopscript < (00054BAE)>] 0 SKK_GetWorkshopActors 9 [workshopscript < (0009B19D)>] 3 SKK_GetWorkshopActors 10 [workshopscript < (001654CF)>] 0 SKK_GetWorkshopActors 11 [workshopscript < (0009B1DB)>] 0 SKK_GetWorkshopActors 12 [workshopscript < (0001D0E2)>] 0 SKK_GetWorkshopActors 13 [workshopscript < (0009B1BE)>] 0 SKK_GetWorkshopActors 14 [workshopscript < (00024A26)>] 0 SKK_GetWorkshopActors 15 [workshopscript < (000E0505)>] 9 SKK_GetWorkshopActors 16 [workshopscript < (0009B18F)>] 6 SKK_GetWorkshopActors 17 [workshopscript < (0016D28E)>] 0 SKK_GetWorkshopActors 18 [workshopscript < (00135A90)>] 0 SKK_GetWorkshopActors 19 [workshopscript < (00168945)>] 0 SKK_GetWorkshopActors 20 [workshopscript < (001F0711)>] 0 SKK_GetWorkshopActors 21 [workshopscript < (00066EB6)>] 0 SKK_GetWorkshopActors 22 [workshopscript < (001654B8)>] 0 SKK_GetWorkshopActors 23 [workshopscript < (0009B1AC)>] 0 SKK_GetWorkshopActors 24 [workshopscript < (0009B1A5)>] 6 SKK_GetWorkshopActors 25 [workshopscript < (000250FE)>] 0 SKK_GetWorkshopActors 26 [workshopscript < (001654D5)>] 0 SKK_GetWorkshopActors 27 [workshopscript < (0009B1F1)>] 0 SKK_GetWorkshopActors 28 [workshopscript < (0009B1D1)>] 1 Link to comment Share on other sites More sharing options...
DieFeM Posted April 24, 2023 Share Posted April 24, 2023 (edited) Run thisWorkshop.GetWorkshopResourceObjects(pWorkshopRatingPopulation, aiOption=0) or GetWorkshopActors which actually calls that base function against the workshop list. Be surprised when some do report population, but many workshops with population do not report the correct values: Somerville 001E81EA actual 3 found 0Country Crossing 0009B1DB actual 2 found 0Nordhagen 0009B1BE actual 3 found 0Tenpines 0009B1AC actual 2 found 0Greentop 0009B1F1 actual 2 found 0Oberland 0009B1D1 actual 2 found 1 I don't get that kind of output from GetWorshopActors. I use the above mentioned function to get arrays which are iterated and every single reference of those arrays is used to move them to the player position, which ends up filling my position with hundreds of settlers. I don't know the code you use to analyze the resulting arrays, but it is clearly giving you a totally different outcome. Edited April 24, 2023 by DieFeM Link to comment Share on other sites More sharing options...
Recommended Posts