Files
totk-pc-recomp/recomp
shinodanpenandClaude fb252ebf6b Scale the thunderstorm's lightning chances by the frame so a storm above 30 fps has the lightning it has at 30 fps (#1287)
In a thunderstorm the world manager's lightning update (1.4.3 main+0x62aac4, 1.2.1 main+0xab849c) runs once per frame
and draws, each update, a random number in [0, 1) for each of three fixed chances: 0.013333 for a distant bolt (the
effect Far_Lightning), 0.01 to pick a near strike and 0.01 for the environment's lightning flag. Its timers follow the
frame step, the draws do not: above 30 fps a storm has more distant bolts and lightning flags the higher the frame
rate. The new set lightning (TOTK_LIGHTNING_FIX, lightning_fix, on by default) multiplies each chance by the time
object's frame ratio (+0x38), at most 1, on 1.2.1 and 1.4.3: above 30 fps the rates per second of 30 fps, and at 30 fps
and below the game's own chances.

Counted on 1.4.3 in the reporter's storm (205 s with the storm on, Link standing still) with a local build that logs
each draw that succeeds, which this change does not contain: distant bolts 22, 52 and 94 to 96 a minute at 30, 60 and
120 fps with lightning_fix = 0, and 26, 27 and 20 to 24 with lightning_fix = 1, each one a Far_Lightning effect; the
lightning flag 19, 34 and 64 to 80 times a minute of the storm's lightning phase with 0, and 12 to 17 with 1. Near
strikes stayed at 14 to 18 per run at every rate with either value: each lightning phase lets its last pick strike in
the phase after it, where nothing is drawn, and that phase ends with a strike of its own.

On 1.2.1, which the logging build does not cover, the distant bolts were counted in screenshots of a storm in Hyrule
Field (one every 0.2 s of game time, a detector of thin bright lines, each counted screenshot checked by eye at 30 fps
and at 120 fps with lightning_fix = 1, a sample of 48 with 0): 19 screenshots with a distant bolt a minute at 30 fps,
about 61 at 120 fps (105 to 107 fps in the storm) with lightning_fix = 0, and 15 with lightning_fix = 1. The same count
on the 1.4.3 runs gives 25 to 26, 65 to 68 and 16 to 20 a minute: at high rates it misses bolts that share a
screenshot.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-21 15:24:43 +00:00
..