Trying to understand how NPC spawning works?
-
First off, [c]toughness[/c] is not used in zones, so one more thing to forget about ([c]sort[/c], too).
Secondly, [c]longevity[/c] is read & tested, but doesn’t seem to have any effect.
After the first encounter is created, every five seconds or so (presumably related to [c]SpacePop, LOWEST[/c] in Freelancer.ini, didn’t track it down any further than that) there’s a [c](density - ships) / repop_time[/c] chance of creating another ship/encounter (didn’t test which). Of course, if [c]ships >= density[/c] nothing is created; [c]ships[/c] is the current number of ships in the zone (or perhaps vicinity). I only tested that in a non-overlapping zone, presumably overlapping zones have the sum I found earlier come into play.
-
Huh, so you reckon repop_time isn’t related to time at all, but is only a variable in the chance to spawn? That would explain why stuff seems so random - it’s literally always been a chance every 5 seconds, not a cooldown.
Thanks Adoxa, this is terrific to learn. I’ll try following your formula you’ve uncovered and see if things start doing what I’d expect.
Looking at what I have set up now, I can see that in a certain field in my mod, I have Density 16, Repop Time 420 - so without any enemies present, that would be 16 divided by 420 for 0.038 or a 3.8% chance for anything to spawn, every 5 seconds. Thinking about it, this makes a ton of sense why sometimes I get dry runs that seem to last forever, and other times, I just seem to luck out and get constant spawns.
Excellent investigating, thank you so much for saving my sanity here. Is there any way to adjust how often that chance pops? Make it roll every minute or two instead? EDIT: I see now that I can experiment with the Spacepop value you noted, I might try setting it to BELOW_NORMAL, NORMAL, HIGHEST so on and see what happens if anything.
Being able to adjust when the chance is rolled in any way would help smooth out this randomness a lot - having the chance be rolled every minute or thirty seconds, but a lot higher chance to spawn, for instance, would be a lot more reliable to balance with. Same as being able to adjust that per zone/encounter/whatever for different spawn rates, but that’s icing on the cake.
EDIT: Also, lol at the #17 at 17:17 - I’m same timezone as you so I saw it the same 8-)
-
Absolutely incredible work adoxa, thankyou for this! I’ve added the SpacePop offset to the Limit Breaking page. Presumably the formula is similar for [c]relief_time[/c] only that it occurs during encounters rather than between them?
-
-
[c]density[/c] is a soft cap. If there’s space for still 1 more ship to spawn, the game still may throw an entire encounter into the zone.
[c]density_restriction[/c] on the other hand is a hard limit on an npc’s ship-class from the encounter files.Also it should be noted the game does behave differently if you spawn into a zone via connecting/loading/docking/jumping, and when you fly into one.
@adoxa I noticed especially there that the game can spawn encounters with 18 ships max. With a little weird thing here. Spawning into a zone of those encounters spawns them fine. When flying in the zone, the server dies. But when I have the encounter with 17 ships, the server survives it.
-
The 18 ship crash thing is good to know, thanks Skotty.
Adoxa, thank you again for putting the pin on this; I can say now after a week this seems a totally solved issue. Your formula and understanding is bang on target in every way I can confirm, and your offset for the spawning interval heartbeat has worked perfectly.
This has completely changed our mod overnight a thousand times for the better, and we now have perfect control over what spawns when and tons of room for nuance in the future. Thank you so much! It’s the difference between night and day, and I’m super grateful to you for helping us get there.
Just going to pop in the right google search words in case someone’s trying to search engine find this in the future - this is how Freelancer NPC spawning works!
-
from this post by fox in my todo list:
foxUnit01 wrote:
content.dll, C4C01, 500f, min distance from player position at spawn moment that an NPC patrol with arrival = cruise will fly to when spawned ~Gold_Sear, M0tah content.dll, C4C06, 2000f, max distance from player position at spawn moment that an NPC patrol with arrival = cruise will fly to when spawned ~Gold_Sear, M0tah
This poses a problem when spawn range is big. Instead, it should be from the spawn position, not player position.
Increasing these does help large spawn ranges, but it is annoying. It’d be nice if this behavior could be eliminated altogether. As it stands, even with higher ranges, there’s a good chance high-range NPCs will end up cruising behind you, since this point is picked at spawn time and could be picked to the side of (or behind) your position at the time.
While trying to fix this problem, I found that NPCs won’t spawn if the max spawn distance
content.dll, 11BC68, 2500d, NPC max spawn distance in SP and MP ~Dev
is below 2500. The following patch fixes this:
content.dll, C1771, 7A --> EB = allow NPC max spawn distance below 2500 ~Gold_Sear
@Ruppetthemuppet: I currently cannot display the 101 list, is this correct?
-
@Ruppetthemuppet: I currently cannot display the 101 list, is this correct?
My bad! I broke the list up into pages by category a few days ago, and in doing so broke the existing link. Here’s the new one:
https://wiki.the-starport.net/FL Binaries/limit-breaking/
Unfortunately the wiki search module isn’t as good as I’d hoped, so I may end up recombining it or at least consider new/clearer categories for the offsets here.