Mikusch / ChaosModTF2

Chaos Mod for Team Fortress 2, powered by SourceMod and VScript
GNU General Public License v3.0
15 stars 5 forks source link

Add configurable effect intervals #13

Closed Mikusch closed 11 months ago

Mikusch commented 11 months ago

Effects can now define the rate at which they update. This both adds more control and heavily reduces CPU usage by not having to update several effects every frame.

The default value is defined in sm_chaos_effect_update_interval (def: 0.1). The update interval can be defined in the return value of the update function:

function ChaosEffect_Update()
{
    // Update in `sm_chaos_effect_update_interval` seconds
    if (someCondition)
        return null

    // Update in 0.5 seconds
    if (someOtherCondition)
        return 0.5

    // Update next frame
    return -1
}

To guarantee execution on the next frame for any effect type, return -1.