antoinebidault / DynamicCivilWar

A dynamic singleplayer/cooperative scenario for Arma III
17 stars 6 forks source link

Too many civilians/Units simultaneously causing FPS issues and delayed enemy spawning. #60

Open lsvalmont opened 5 years ago

lsvalmont commented 5 years ago

I love the realistic way the Civilians behave but there are some performance issues because of the many scritps/addactions on them.

I believe because of that, that 25 civilians for most settlements is too much and the mission Lags because of that.

I suggest reducing the Civilians amounts to: Big Cities: 12 Civilians, Max 3 running cars and 3 parked cars. Small Cities: 8 Civilians, Max 2 running cars and 2 parked cars. Towns: 5 Civilians, Max 1 running cars and 1 parked cars. Smaller Settlements: 3 Civilians, 0 running cars and 1 parked vehicle.

Also I had some instances of getting into a enemy position and having enemies spawn right in front of me because of the delay on their spawning checks is too long or the area distance the player has to get for them to spawn is too small.

antoinebidault commented 5 years ago

On my machine, I do not experiment this kind of problem. But I'm not surprised with your issue's description. The cache engine is pretty memory consuming. In the scripts there is a parameter named POPULATION_RATIO which represents the number of civilian per enterable building. It is set at 1.4 at the moment which could be a bit lowered... Or maybe I could make a parameter in the startup setting's panel with predefined config.

There is also a MAX_POPULATION set to 25. The SPAWN_DISTANCE param is set to 800 meters. It can takes up to 20-30 seconds to spawn units in a compound. If there is too much huge compounds in a sector and you arrive very fast with a car, you can probably have close spawning units... Maybe the solution is to reduce the amount of civilian and increasing to 1000m the spawning distance. There is another mecanism which lock the spawning system when the player is inside a chopper (It was terrible for performance). I don't think the addAction is responsible of the major performance's issue, the pathfinding may be more consuming. If you desire to test a better balanced system : it is possible to tweak this config directly in the scenario by adding the following lines in the description.ext

DCW_spawn_distance = 800 // Spawn distance
DCW_ratio_population = 1.3  // Number unit (civ or enemy) per enterable building
DCW_max_population = 25 // Max pop per compound
DCW_ratio_cars = .06 // Number cars per enterable building
DCW_max_random_civilian = 4 // Maximum of civilian just wandering around in land
lsvalmont commented 5 years ago

Exactly, it would be a great idea to increase DCW_spawn_distance a little bit and reduce the other numbers like DCW_ratio_population.

If fact it would be even better if we could better control the enemy and the civilian population by using different variables such as:

DCW_spawn_distance_civ = 1000 DCW_spawn_distance_enemy = 1200 DCW_ratio_population_civ = 0.7 DCW_ratio_population_enemy = 0.3 DCW_max_population_civ = 12 DCW_max_population_enemy = 8 DCW_ratio_cars_parked_civ = 0.5 DCW_ratio_cars_moving_civ = 0.3 DCW_max_random_civilian = 2

I love the pathfinding of the Civilians, it is very realistic and random so they really feel "alive". Perhaps adding a little more delays so they are not "thinking" all the time would help with performance even more.

Also, because the path finding is so cool, even if there are not many civilians it would still feel like if the city is "alive" because how well they use the street, buildings etc! It shouldn't be so easy finding civilians too, it is a warzone remember, most civilians probably fleed or are hiding.