SMB92 Posted November 12, 2017 Share Posted November 12, 2017 Hi all. Thought I'd drop a post and hopefully gather some ideas from fresh minds, as mine is kinda spent on this issue right now :smile: So I am working on a spawn mod as some of you here may know, and one of the "systems", namely the very core and main one, I'd like to have actors travel to a random location in a region, effectively emulating patrol routes. I am already doing things for this of course, but I'd like to try and avoid persistence and also avoid costing too much performance overhead with Papyrus. Cos I suck at explaining things let me iterate over where I am at and what I know so far. The Random branch on AI package is straight up broken. And it wouldn't work with what I want anyway. Moving on. Currently I place a number of XmarkerHeadings at a few locations in a region, and these are the locations which actors will travel to. I then have multiple Travel packages that have a number of these "locations" in the procedure, with a sandbox package in between each one (so actors will arrive at said location, sandbox the area for a given time and move on). I then store each variation of package in Reference Aliases on the quest that controls that area. At spawn time, I select a random Ref Alias and apply it to each actor spawned (keywords and linked refs provided where need be through script as well) so they all follow the preset route/package. Now this means those Xmarkers are persistent always because they are pointed at via the packages etc etc. It's not actually that bad though because even if the mod was uninstalled this doesn't really pose a CTD risk, the game will just clean them up (albeit dropping an error in the log when player first walks into that area again for the first time after uninstall), as far as my testing has revealed. But I would like to just have one Travel package, and randomise the location (or linked ref) everytime the package completes. I can keep an array of the Xmarker "locations" for this purpose. Let me just talk about the spawn script so that you have an idea of that. When actors are spawned in, they are spawned one by one and data applied to them, including the ref alias with package. They are then stored in an array on that spawn point for later cleanup and manipulation. Its about that simple. There can be multiple groups of actors spawned at one point and different arrays stored for each group, but that's not of any major concern with this. Here is the current idea: At spawn time, applytoref to get the package, when actor reaches location run sandbox and then on complete call back to the spawnscript to change the linked ref randomly and restart the package (using array of Xmarkers for the region and if it rolls the same location well that will just emulate a longer sandboxing :D ). To do this though I will need to re-iterate through the actor array stored on spawnscript and reset the linked ref and re-evaluate. I would setup a custom function to handle this, but not sure I like that performance hit, maybe I am just being petty though. Could be potentially iterating through a fair few actors. I'm also not sure how I'm going to pass in the property of the actual script instance it will need to talk to, but shouldn't be that much of a problem, probably with a script applied by the ref alias to the actor (i'll cross that bridge when it comes I suppose) If anybody has any further ideas to this, would be happy to hear them :smile: OR maybe I should just stick with the way I had it. TL;DR: I'd like to use only one Package with a travel + sandbox procedure and change the location when it finishes by changing the linked ref on the actor and restarting the package if possible. This way the markers used as travel "locations" do not come persistent until they are pointed at through the script system. Link to comment Share on other sites More sharing options...
ThoraldGM Posted November 12, 2017 Share Posted November 12, 2017 So... not a fresh mind but nobody else answered yet. Scavver's travel package target is always pScavMarker000. However, I have a script on the travel package. When the package starts, I move marker000 to the next desired location. Thus the destination can be a "fixed target" in the package/procedure, but always moving in script to where I want Scavver to go. Travel package script: https://pastebin.com/0y7XxA4S When I made Scavver I didn't know much about persistence. If I was rewriting this script, I would pull the refs in from ref quests like I'm doing with Hitchhiker. Then I would stop the refs quest so the array dumps. Hitchhiker quest script (see OnQuestInit): https://pastebin.com/72WEQyDn Link to comment Share on other sites More sharing options...
SKKmods Posted November 12, 2017 Share Posted November 12, 2017 I don't follow the actual problem you are trying to solve, but I just happen to have just been testing arrays of 127 NPCs, apart from cleanup persist find there is zero performance difference storing ObjectReferences in a quest RefCollectionAlias.Find() or a kLocalArray.Find script array. PS do you have to worry about cell load state and 3d world functions for your spawning ? Link to comment Share on other sites More sharing options...
SMB92 Posted November 12, 2017 Author Share Posted November 12, 2017 Thanks for the replies, but seems I didn't get the email until just now. Thorald, that could possibly be an idea, to have a temporary marker stored on each spawn marker that could get placed around at different locations, although the end result is similar to the solution I came up with, I will have to restart the package on every actor using a while loop after moving said marker. But I think your method may be better for persistence. SKK50, the problem is the way I have packages atm with markers placed in the world, the markers are always persistent as they are the location target of packages. I also have to make multiple packages which means multiple ref aliases, to emulate random location travel. So each package has 3 locations for example, a predefined route that actors will just travel between and sandbox at each one (sometimes guard package as well). I am able to just use the option in the travel package to "linked ref" and then at spawn time select from a predefined array of location markers and link them, which means I can dump these array later and not have any persistent markers, but it means I have to iterate through each spawned actor and manually unlink/relink to new marker and restart the package. Fortunately this doesn't affect any of my clean up code either way, but I do not like the idea of having to iterate through every group and do this, especially if there becomes a lot of spawned actor groups active, and also it will be competing with any spawn points firing off. But maybe I am underestimating Papyrus and it might not hurt performance too much. Link to comment Share on other sites More sharing options...
SMB92 Posted November 13, 2017 Author Share Posted November 13, 2017 Just looking at your code there Thorald, so what I could do is place dummy markers at each location, which are simply only persistent when an array of them is filled, and then on my spawn marker I can point to a temporary marker and use placeatme at spawn time to instance it at a random dummy and move to another on package complete. Your code would also make the performance better cos I won't need to relink the ref. Now the headache remains, what will be the best way to deal with the whole group via the package script? It's easy enough on a single actor but gonna be a bit more challenging to deal with the whole group. I'm thinking I should keep a count on the spawn marker, each time one of the actors completes the package, increment the count, and have a while loop running every 30 seconds or so that will check the count vs the length of the group array, and once equal, run a function on the spawn marker that way. Something like this at least. Link to comment Share on other sites More sharing options...
FiftyTifty Posted November 14, 2017 Share Posted November 14, 2017 (edited) If you have Skyrim, you can check out the travel package I did for a mod that does the same thing without using scripts: https://www.nexusmods.com/skyrim/mods/74499/? It's got about 600 actors, with 150 or so of them being leaders with parties that travel, at random, to specific XMarkers I placed throughout the world. Edited November 14, 2017 by FiftyTifty Link to comment Share on other sites More sharing options...
SMB92 Posted November 19, 2017 Author Share Posted November 19, 2017 Thanks for the reply Fifty, I'll take a look at that when I get a chance. Got a few things on at the minute. Link to comment Share on other sites More sharing options...
Recommended Posts