EagleFour Posted April 2, 2022 Share Posted April 2, 2022 Hello,I am looking for a way to find all the corpses in the world (not in the cell).How can I do this by script ?It doesn't have to be only corpses. It would be enough for me if I can scan all NPCs in the world.Therefore I would need a small script or a short instruction how to do this.Background is, I have programmed a mod that adds custom VoiceTypes to aliases of another mod. What I didn't know was that when the mod's alias died, the added voicetype remained on the NPC. After uninstalling my mod, FO4 crashes when saving. This is probably because the VoiceType form is no longer there, but the dead actor wants to access it. Normally no problem, because the corpses are removed after a certain time. But this does not happen with npcs added by mods.Since I've been playing with this mod for a while (several weeks) and now have to uninstall it because of a newer version, I only noticed this now. I still have dead NPCs lying around somewhere in the game world that have modified VoiceTypes and block saves, without my mod.I would have to find these broken NPCs. Then I can remove them or remove the custom VoiceType. But for that I would have to scan ALL NPCs. But how does that work for the whole world and not just the loaded cell ? Link to comment Share on other sites More sharing options...
SKKmods Posted April 2, 2022 Share Posted April 2, 2022 You cant. Most ObjectReferences in thw world are non persistent. Non persistent objects can not be found in the unloaded area outside the (default 10K) uGridsToLoad around the player, either by quest StoryManager lookup fills or scripted searches. The only workaround is to make design time placed objects persistent is by physically adding them to a form list or manual script properties in the Creation Kit at design time. Plus some other more complex methods with LocRefTypes and such. There is zero way of making unknown runtime spawned objects that are not spawned persistent and unloaded ... persistent, 'cos you cant find 'em in the first place ! I use a lot of realtime scans based on player movement to find and adjust non persistent placed and spawned stuff dynamically as it loads. Doing that without bogging down the script system needs a good understanding of how the game bolts together. Not a small script or youtube primer. Link to comment Share on other sites More sharing options...
Zorkaz Posted April 2, 2022 Share Posted April 2, 2022 Addendum to SKK50If your stuff is persistent and your actors unique to your mod you could try adding a simple script to them Event OnLoad() If Self.isdead() Self.delete() Endif EndEventMight work or not, depending on what you've set up. Just an idea Link to comment Share on other sites More sharing options...
EagleFour Posted April 2, 2022 Author Share Posted April 2, 2022 Thank you very much for the answers. I almost understood.But, one question.A concrete example:An Actor (an alias added by a quest) gets a Custom VoiceType via mod. This actor dies. The corpse remains lying.I continue to travel the world and I am well outside the loaded grids. Time passes. At some point I come back to the corpse, it is still lying there, so persistent ?I can also travel to it via player.moveto ref. So the ref is still in memory. My thought process was to find this ref.I can also read all refs via functionlist 1 and save them.Unfortunately I can't do much with this data in this case. Could I get from this data the information, that the NPC is dead, I have the REF and that would be enough for me to delete. For the Future i have modified the code, that this never happended again. But for my good old save, its too late.These data are in the functlist(example): FF16F030 1170/2252 E8040423 68 Raider-Psycho - Low(1187) Flags(6) Moved(0) Inventory(927) Life State(0) Leveled Actor(103) Leveled Inventory(927) Enc Zone Extra(5) Created Only Extra(0) Game Only Extra(8) I will kill an NPC to see if I can then recognise whether the entry, is a corpse. Link to comment Share on other sites More sharing options...
SKKmods Posted April 2, 2022 Share Posted April 2, 2022 No you misunderstand "persistence". Most basic it means "I dont have a permanet objectreference number/id/handle" to be found when unloaded. Second most basic is that "I can be removed from the game world when the appropriate object cleanup and scavenging system triggers" There are many different object cleanup and scavenging systems in play. Link to comment Share on other sites More sharing options...
LarannKiar Posted April 2, 2022 Share Posted April 2, 2022 Hello,I am looking for a way to find all the corpses in the world (not in the cell). How can I do this by script ?It doesn't have to be only corpses. It would be enough for me if I can scan all NPCs in the world. Therefore I would need a small script or a short instruction how to do this. Background is, I have programmed a mod that adds custom VoiceTypes to aliases of another mod. What I didn't know was that when the mod's alias died, the added voicetype remained on the NPC. After uninstalling my mod, FO4 crashes when saving. This is probably because the VoiceType form is no longer there, but the dead actor wants to access it. Normally no problem, because the corpses are removed after a certain time. But this does not happen with npcs added by mods. Since I've been playing with this mod for a while (several weeks) and now have to uninstall it because of a newer version, I only noticed this now. I still have dead NPCs lying around somewhere in the game world that have modified VoiceTypes and block saves, without my mod. Don't uninstall that mod, or at least not the voice type. Uninstalling mods is not recommended, but if you really want to, just remove all records from the plugin except that voice type. And don't change its FormID. When you start a new game, you can deactivate the plugin. Link to comment Share on other sites More sharing options...
EagleFour Posted April 2, 2022 Author Share Posted April 2, 2022 (edited) @Skk50Thank you, that makes sense. I have there probably still the one or other misunderstanding. Don't uninstall that mod, or at least not the voice type. Uninstalling mods is not recommended, but if you really want to, just remove all records from the plugin except that voice type. And don't change its FormID. When you start a new game, you can deactivate the plugin. Yes, I know.I can delete all the records except for the VoiceTypes, because the NPCs are connected to them.Since I don't like to carry garbage around with me, I would like to have this solved in an elegant way.But it looks like this is not possible.In the new version I used formlists, where I store all NPCs, which got a custom VoiceType. These are then regularly cleaned and reset. Edited April 2, 2022 by EagleFour Link to comment Share on other sites More sharing options...
niston Posted April 4, 2022 Share Posted April 4, 2022 Upcoming SUP F4SE Release will have something nice in it: Actor[] Function GetActorsInCell(Cell ChosenCell, int iDepth) global native It'll scan from ChosenCell outwards to max. iDepth cells in all directions and it's very, very fast.Only works for persistent actors in unloaded cells, of course. Link to comment Share on other sites More sharing options...
EagleFour Posted April 5, 2022 Author Share Posted April 5, 2022 (edited) That would simplify it a lot. Then you could create a form list with all cells and scan practically the whole world.What I don't know yet, though, is whether the problems I'm having at the moment come from persistent actors or from non-persistent ones. Is then already an approximate update date known or how far progressed the new version is?Since there is always a lot of time between versions, it could still take months.Edit: Oh, it's SUP F4SE, I read over that at first. I thought it was meant F4SE.Too bad, I don't use SupF4SE because I wanted the requirements as low as possible. Edited April 5, 2022 by EagleFour Link to comment Share on other sites More sharing options...
SKKmods Posted April 5, 2022 Share Posted April 5, 2022 >Then you could create a form list with all cells and scan practically the whole world. >Only works for persistent actors in unloaded cells, of course. To marry those two things up you would need a script that MoveTo the player to a persistent object in the center of each 5x5 set of cells to load them then scan. I have done that with the 30 workshops and 180 random encounter triggers, but finding persistent objects to target that cover the whole map is difficult even bumping up the uGreidsToLoad. Using Setposition with a mathamatical XYZ can be unpredictable on the player. Link to comment Share on other sites More sharing options...
Recommended Posts