Reaction Time

Some introductory text about reaction time goes here.

How it works
Reaction time is implemented in the TdPlayerController. The properties bReactionTime and ReactionTimeEnergy keep track of the current state of reaction time. bReactionTime is false if reaction time is not activated.

Build up
When spawning into a level (when loading into a level or after dying), ReactionTimeEnergy is set to ReactionTimeSpawnLevel. As Faith moves, ReactionTimeEnergy grows according to ReactionTimeBuildRates and Faiths 3D velocity, up to a maximum value of 100. Once ReactionTimeEnergy reaches 100, the reaction time teaser effect is shown and reaction time can be enabled. event PlayerTick(float DeltaTime) { if (!bReactionTime && ReactionTimeEnergy < 100.0) { ReactionTimeEnergy += ReactionTimeEnergyBuildRate * DeltaTime * myPawn.VelocityMagnitude; if (ReactionTimeEnergy >= 100.0) { ReactionTimeEnergy = 100.0; TdHUD(myHUD).EffectManager.ActivateReactionTimeTeaser; }   } }

The default value for ReactionTimeSpawnLevel is 99.9, so reaction time can be activated after the tiniest movement. This is configured in section [TdGame.TdPlayerController] of the DefaultGame.ini configuration file: ReactionTimeSpawnLevel=99.9f

Build rates
The build rate of reaction time depends on the difficulty setting. The build rates are configured in section [TdGame.TdPlayerController] of the DefaultGame.ini configuration file: ReactionTimeBuildRates = (Easy = 0.007, Medium = 0.005, Hard = 0.003) This means that reaction time builds fastest when playing on easy difficulty.

Drain


Reaction time can only be activated if ReactionTimeEnergy has a value of 100. Once activated, bReactionTime is set to true and ReactionTimeEnergy drains down to a value of 0 over a period of ReactionTimeDrain seconds. The parameters of this drain are configured in section [TdGame.TdPlayerController] of the DefaultGame.ini configuration file: ReactionTimeMaxEffect=0.25 ReactionTimeDrain=8 ReactionTimeFadeIn=90 ReactionTimeFadeOut=20 Over that period, the amount that time is scaled down varies. ReactionTimeMaxEffect is a factor that defines how much time is slowed down once reaction time is fully active. The default value of 0.25 means that time progresses at 25% speed, which is four times slower. While ReactionTimeEnergy is between 100 and ReactionTimeFadeIn (default value: 90), time scaling is linearly interpolated from 1.0 to ReactionTimeMaxEffect. From ReactionTimeFadeIn to ReactionTimeFadeOut, time scaling remains constant at ReactionTimeMaxEffect. From ReactionTimeFadeOut to 0, time scaling is linearly interpolated from ReactionTimeMaxEffect back to 1.0. The fade-in and fade-out durations can be computed as follows: ReactionTimeFadeInDuration = ReactionTimeDrain * (100 - ReactionTimeFadeIn) / 100 ReactionTimeFadeOutDuration = ReactionTimeDrain * ReactionTimeFadeOut / 100 For the default configuration, this computes to: ReactionTimeFadeInDuration = 8 * (100 - 90) / 100 = 0.8 seconds ReactionTimeFadeOutDuration = 8 * 20 / 100 = 1.6 seconds Once ReactionTimeEnergy has drained to 0, bReactionTime is set back to false.

Time difference
In speedrun mode, the speedrun timer slows down when reaction time is used, according to the applied time scaling. However, real-time timers which are for example used in full game speedruns don't slow down for reaction time. For this reason, real-time times show an additional 5.1 seconds after the use of reaction time (for default reaction time settings). This is also the amount of time that is wasted when using reaction time on a difficult strat.

Formula
This formula can be used to compute the time difference between real-time and in-game time for a given reaction time configuration: TimeDifference = ReactionTimeDrain * (1 - ReactionTimeMaxEffect) * (100 + ReactionTimeFadeIn - ReactionTimeFadeOut) / 200 For the default configuration, this computes to: TimeDifference = 8 * (1 - 0.25) * (100 + 90 - 30) / 200 = 5.1 seconds

Derivation
To see why that is, one first needs to compute how much in-game time passes while reaction time is active. In real-time, reaction time is active for a period of ReactionTimeDrain seconds. The corresponding in-game time is the area below the time scale curve shown in the figure of section How it works, i.e. the integral from time 0 seconds to ReactionTimeDrain seconds.

This area can be separated into two triangles and one rectangle: ReactionTimeFadeInDuration = ReactionTimeDrain * (100 - ReactionTimeFadeIn) / 100 ReactionTimeFadeOutDuration = ReactionTimeDrain * ReactionTimeFadeOut / 100

AreaLeftTriangle = (1 - ReactionTimeMaxEffect) * ReactionTimeFadeInDuration / 2 AreaRightTriangle = (1 - ReactionTimeMaxEffect) * ReactionTimeFadeOutDuration / 2 AreaRectangle = ReactionTimeMaxEffect * ReactionTimeDrain The in-game duration is the sum of the three areas: InGameDuration = AreaLeftTriangle + AreaRightTriangle + AreaRectangle The time difference between real-time and in-game time can now be computed: TimeDifference = ReactionTimeDrain - InGameDuration

For the default configuration, this computes to: ReactionTimeFadeInDuration = 8 * (100 - 90) / 100 = 0.8 seconds ReactionTimeFadeOutDuration = 8 * 20 / 100 = 1.6 seconds

AreaLeftTriangle = (1 - 0.25) * 0.8 seconds / 2 = 0.3 seconds AreaRightTriangle = (1 - 0.25) * 1.6 seconds / 2 = 0.6 seconds AreaRectangle = ReactionTimeMaxEffect * ReactionTimeDrain = 2.0 seconds

InGameDuration = 0.3 seconds + 0.6 seconds + 2.0 seconds = 2.9 seconds

TimeDifference = 8 seconds - 2.9 seconds = 5.1 seconds This means that while reaction time is enabled, 2.9 in-game seconds pass. In real time, 8 seconds pass (because reaction time is active for ReactionTimeDrain seconds). The difference in time is 5.1 seconds.

Applications in speedrunning
The intended use of reaction time is to use the slowed-down time for harder strats. However, some methods were discovered to abuse the game mechanic.

When reaction time is active while sound playback using a Play Sound or Td Play Sound node is started in Kismet, the duration of the sound playback is not calculated correctly (see Play Sound Bug). If done correctly, this can lead to a major shortening of the total playback duration, which can save a lot of time. This bug is applied in Truck ride dialogue skip, Convoy dialogue skip and Beverage lift dialogue skip.