Understanding TOD

[V] IdolNinja

Volition Staff
I have tried to create new times of day in addition to the 4 standard ones, but have run into a snag that none of us can figure out. The new times of day do actually work and will randomly proc on save load or area change just like the original 4. The problem is that any entry past 4 in the table will stop all peds and vehicles from spawning leaving Steelport a ghost town.

For example, here are the original 4 TOD in default_global.xtbl
Code:
    <tod_segments>
        <segment>500</segment>
        <segment>930</segment>
        <segment>1430</segment>
        <segment>2100</segment>
    </tod_segments>

Here is the alternate times of day file from Sandbox+ I was working on:

Code:
    <tod_segments>
        <segment>330</segment>
        <segment>500</segment>
        <segment>530</segment>
        <segment>800</segment>
        <segment>930</segment>
        <segment>1000</segment>
        <segment>1430</segment>
        <segment>1500</segment>
        <segment>1600</segment>
        <segment>1700</segment>
        <segment>2100</segment>
        <segment>2130</segment>
        <segment>2330</segment>
    </tod_segments>

As you can see, the new times of day segments are integrated both before, during, and after the original 4. After doing a lot of testing, we found that only the first 4 entries (330, 500, 530, and 800) would spawn peds/vehicles. The rest past 4 resulted in the spawning problem. If we removed all but 5 of them, the 5th entry in the list wouldn't spawn. Also, all of the new segments referenced above did have full entries defined in default_districts.xtbl just like the original.

So, what are we missing here that could be causing this? I have attached the modded files with these new segments as well.
 

Attachments

Ambient Ped/Vehicle density is currently hard coded to an internal enum, which is why peds/vehicles/action nodes go away for any TOD segment above 4:

enum tod_day_phase {
TOD_PHASE_NIGHT,
TOD_PHASE_DAY,
TOD_PHASE_NOON,
TOD_PHASE_EVENING,

TOD_NUM_PHASES
};

Fixing this to handle additional TOD segments properly would require code changes. In the meantime, you could work around this somewhat with set_ped_density(float) & set_traffic_density(float) [0.0-1.0], which will override the code that is setting the densities to 0. The downside of this workaround would be that the normal variation of densities by notoriety/district/TOD will no longer function correctly. As such, I would not recommend setting the override density all the way to 1.0, as it may cause performance issues with high notoriety and some other areas.


BTW - Are you guys (IdolNinja or Knobby) keeping a list somewhere of potential changes for the patch?
 
Thanks! The automated time of day advancement in Sandbox+ actually gives me the opportunity to do just that. Hmm... I wonder if I could simply test for player's current district location and time and set the density accordingly. I'll give it some thought.
 
Poking around m06.lua, it looks like the density is temporarily changed to .1 during the mission for both peds and vehicles, then the script changes it back to the value of 1 for both functions on cleanup. I'm going to guess that a tod change post mission script cleanup will override that 1 value and go back to parsing the table for the actual correct spawning values? I can't imagine the density being stuck at 1 forever until you reload a save or restart the game...
 
UPDATE:
I listed the wrong Lua script functions previously. set_ped_density(float) & sec_traffic_density(float) do exist, but they only work to throttle the maximum density possible and do nothing to raise the density above what it would be otherwise. Meaning - they won't help with the TOD problem. :(

The function I meant to list is set_ped_override_density(float), which WILL actually override the final density used. At the time I assumed there was a similar function exposed to Lua for vehicles, but Unfortunately I was incorrect. There is code support for traffic override value, but it was never exposed to Lua :facepalm:.

TL/DR: You can get pedestrians back with set_ped_override_density(), but will need to wait for a patch to get ambient vehicles working with TOD segments above #4.
 
Ah, shame about the vehicle function. I'll just wait on the patch then before mucking about any further.
 
Back
Top