7Ramhat Posted September 15, 2017 Share Posted September 15, 2017 How can I get a list of NPCs that are at a certain distance from the position or reference? Link to comment Share on other sites More sharing options...
kitcat81 Posted September 16, 2017 Share Posted September 16, 2017 (edited) From wiki: ; Find all references with the ActorTypeAnimal keyword within 200 distance units of the playerObjectReference[] kActorArray = Game.GetPlayer().FindAllReferencesWithKeyword(ActorTypeAnimal, 200.0) ; Find all references that match ALL keywords in the actor type formlist within 200 distance units of the playerObjectReference[] kActorArray = Game.GetPlayer().FindAllReferencesWithKeyword(ActorTypeFormlist, 200.0) ; Find all references that match ANY keyword in the actor type formlist within 200 distance units of the playerInt i = 0While i < ActorTypeFormlist.GetSize()ObjectReference[] kActorArray = Game.GetPlayer().FindAllReferencesWithKeyword(ActorTypeFormlist.GetAt(i), 200.0)i += 1EndWhile If you want only humanoid actors ( humans, non feral ghouls and some types of synths ) you can use ActorTypeNPC keyword. Another way is to start a quest with RefCollectionAlias and conditions - ActorTypeNPC, GetDistance (your ref) etc. Edited September 16, 2017 by kitcat81 Link to comment Share on other sites More sharing options...
7Ramhat Posted September 18, 2017 Author Share Posted September 18, 2017 (edited) Kitcat thank you, that's exactly what I need. :smile: Edited September 18, 2017 by VigVam33 Link to comment Share on other sites More sharing options...
kitcat81 Posted September 18, 2017 Share Posted September 18, 2017 Glad to help :) Link to comment Share on other sites More sharing options...
ThoraldGM Posted September 21, 2017 Share Posted September 21, 2017 Is there a way to register/listen for the OnLoad event of all NPCs in one group that spawn via leveled list? I may use your method above as a workaround that somehow pings from the player as they walk, but I want to alter all Diamond City guards by script, as they spawn. I could put all 18 into reference aliases, but there are mods that add more guards and I want to handle that dynamically. Plus for other projects it would be useful to have a way to dynamically grab refs for all raiders, all supermutants, etc so that scripts can do something to each one OnLoad. Edit: Your method combined with OnLocationChange and a huge radius might be what I need, but I'm open to other ideas. Link to comment Share on other sites More sharing options...
kitcat81 Posted September 21, 2017 Share Posted September 21, 2017 You can add a new script to the actorbase that uses the leveled list in the CK. i don`t think you can grab references of all actors in game, at least not with papyrus.Most npc do unload together with the cell. Not just 3d, they fully unload and can`t be manipulated or even found while in this state.You can dynamically grab references of NPC-s in loaded area. Keeping hundreds of NPC-s persistent by alias or script can affect the game perfomance. Link to comment Share on other sites More sharing options...
ThoraldGM Posted September 22, 2017 Share Posted September 22, 2017 Is it true they are only persistent until the reference alias is cleared? I'm thinking of grabbing the guards in radius at OnLocationChange if GetParentCell is Diamond City, equipping them with player specified gear, making any other changes player specifies in MCM, then releasing them. I've been looking for a gold standard for scripted manipulation of NPCs for awhile, so pretty happy to see this thread. Edit (again): Not at home to test, but I may not need reference aliases at all. ObjectReference[] kActorArray handles dynamic sizing and would allow me to address each element/actor by index before the event ends. Link to comment Share on other sites More sharing options...
kitcat81 Posted September 24, 2017 Share Posted September 24, 2017 Yes, true unless you set the alias to be filled with some particular actor using his reference in the CK. There are different ways to achieve the same result. You can choose the one that fits your goal or your skills better. Link to comment Share on other sites More sharing options...
Recommended Posts