0 of 0

File information

Last updated

Original upload

Created by

Petomatick

Uploaded by

Petomatick

Virus scan

Safe to use

Tags for this mod

About this mod

Automatically uncap framerate during fasttravel, sleep and wait, and recap it when done.

Permissions and credits
Changelogs
As summer is upon us, I often find myself limiting my FPS so that I don't cook myself in my room, however this slows down the passage of time when fast-traveling, sleeping or waiting, something which eventually bugged me enough to make this mod.

Normally, worldtimerate is about "15", whatever that means, however to accommodate for those who use custom day durations, I had to add a bit of math.

Every frame, we check if a second has passed since we last did anything,
If it has, we calculate how much GameTime - time in the world - has passed in the last second
If we are going more than 50% faster than we did a second ago, we can assume that we are in some sort of time-warp, and we uncap fps
If we are going slower than 75% the rate we used to, we can assume we just left the time-warp, and we recap the fps

If you're like me and code is easier to understand than language
local oldTime = 0;
local newTime;
local oldGameTime = 0;
local newGameTime;
local oldGameTimeDelta = 0;
local newGameTimeDelta;

-- This is called every frame given the entity has been spawned
function AutoFrameRateLimiterEntity.Client:OnUpdate()
    newTime = System.GetCurrTime();

    -- Has a second passed since we last ran?
    if (newTime - oldTime > 1) then
        oldTime = newTime;

        -- Calculate how much WorldTime has passed in the last second
        newGameTime = Calendar.GetWorldTime();
        newGameTimeDelta = newGameTime - oldGameTime;
        oldGameTime = newGameTime;

        -- If gameTime suddenly sped up, limit the FPS to 9999
        if (newGameTimeDelta > oldGameTimeDelta * 1.5) then
            System.ExecuteCommand('sys_MaxFPS 9999')
            oldGameTimeDelta = newGameTimeDelta;
        end

        -- If gameTime suddenly slowed down, lower the FPS
        if (newGameTimeDelta < oldGameTimeDelta * 0.75) then
            System.ExecuteCommand('sys_MaxFPS 80')
            oldGameTimeDelta = newGameTimeDelta;
        end
    end
end

This does however return the fps-cap a bit too early when waiting, that is, that last extra-slow hour is not uncapped, but the mod is good enough for me as it is ;)

Thanks to  dataframe for the excellent guide and mod template, especially since the documentation for CryEngine was gone again when I made this.