NPC Spawn Process

Support for running, installing or compiling OpenMW

Before you submit a bug report for the first time, please read: Bug reporting guidelines
Post Reply
daemonprime
Posts: 1
Joined: 20 Apr 2022, 19:03

NPC Spawn Process

Post by daemonprime »

Good day and a HUGE thank you to the OpenMW Team. The work here is amazing.

I wasn't sure where to post this, so please point me elsewhere is needed.

I recently did a full load out of the Modding-OpenMW Total Overhaul list. After tweaking things a bit, I was able to maintain 60 fps comfortably in testing. I specifically focused on cities as that's where I seemed to see notable drops in framerates. Around 20 or so hours into a new character, I found the city FPS dropping from my new game testing. After digging around a bit, I've landed on the idea that NPC count may be dragging down the FPS. With that in mind, I reviewed the loadout and found Friends and Foes (a solid mod) spawns quite a few NPCs using levelled lists. There's a "scarce" optional plugin that reduces the chance of a spawn however I wanted to look more deeply into the problem.

My possibly incorrect assumptions:
  • Each spawn point placed in a cell will only spawn one NPC from the leveled list
    Each spawn point will not spawn another NPC if there is an existing one from that spawn point
    NPCs will not despawn once spawned unless they are killed
    Each time a cell is loaded any unfilled spawn point checks its chance to spawn a new NPC given it's chance setting and the limitations above
My theory then is that on a new game, entering say Balmora will spin up X number of NPCs with Y spawn points failing their chance to spawn. Let's say that means 3 of 10 NPCs spawned in Balmora. The game progresses, Balmora is left, things are done. The player then returns to Balmora. X NPCs are up and active from the first visit. Now all the Y spawn points, since they don't have an active NPC, check their chance to spawn one. This time Z NPCs come online. For the example, let's say 2 of the remaining 7 points spun up a new NPC. Now Balmora has 5 active NPCs and 5 open spawn points. After N number of visits to Balmora, following this theory, eventually all 10 points would have active NPCs regardless of their chance to spawn. If the assumptions are wrong, this idea falls apart of course, but if they hold it could explain why FPS tested smooth at game start and degraded over time as a slowly increasing NPC count ate away at CPU cycles.

Does the above fit the engine works?

I posted the same basic question in the Friends and Foes comments, but it sounded like asking those familiar with the how the engine works may be a better target audience.

Thank you for your time.
Post Reply