SCRMaps
/
Sign in

Time and frames

One second on the Countdown Timer is not one second.

7 min read

To measure time in a map you need to know how StarCraft counts it. Everything below is at Fastest; the ratios change at other speeds.

One frame, by game speed
Slowest · Slower · Slow0.167s, 0.111s, 0.083s
Normal0.067s
Fast · Faster0.056s, 0.048s
Fastest0.042s - effectively the only speed a UMS map is played at.
The reference numbers
Frame24 frames a second; one frame is 0.042 seconds.
Normal speedAbout 15 frames a second, 0.067 each. Normal to Fastest is 42:67, roughly 5:8.
Countdown timerTicks down once every 16 frames, so one timer second is 0.672 real seconds.
Elapsed TimeThe same 16-frame step - it is a second at Normal speed, so 0.672 at Fastest.
The in-game bottom timerMatches real time.
Triggers without hyperOne pass every 31 frames, 1.302 seconds - the counter resets to 30 and counts 30 down to 0, which is 31 frames between passes.
Classic turbo (Wait 0)One pass every 2 frames, 0.084 seconds.
EUD hyperOne pass every frame, 0.042 seconds.

Ask the Countdown Timer for 30 seconds and you get about 20 real ones. Anywhere the exact duration matters - an AFK judgement, a round limit, a save eligibility window - the Countdown Timer will not do what your design says.

Serious maps therefore count for themselves with a death counter. With hyper triggers the loop runs every frame, so you add one per pass and call 24 of them a second. That way there is exactly one definition of "a second" inside the map.

const FPS = 24;        // 실제 1초에 해당하는 사이클 수 / cycles in one real second
var tick = 0;  var seconds = 0;
function tickClock() {
    tick = tick + 1;
    if (tick < FPS) { return; }
    tick = 0;
    seconds = seconds + 1;
}
The idiom that keeps one definition of a second.

FPS = 24 is only right if the map leaves the game speed alone. A map that writes the speed table - anything made faster than Fastest - changes the length of a frame and therefore the number of cycles in a second. Write 29 ms a frame and a second is about 34.5 cycles, and every clock left at 24 runs 45% fast. In a map that writes the speed, FPS is 1000 divided by that millisecond figure.

If your map writes a game speed, one formula covers all of it. The speed value is how many milliseconds a frame takes, and Fastest's default is 42.

배율 = 42 / 속도값
1초의 프레임 수 = 24 × 배율 = 1008 / 속도값

속도값 29  ->  1.45배,  약 34.8프레임 = 1초
속도값 21  ->  2.00배,  48프레임 = 1초
속도값  4  -> 10.50배, 252프레임 = 1초
What people call 2x - #x2 - is speed value 29 and is really 1.45x. A true 2x is 21.

Those speed values live at 0x5124D8, an array of seven - one per game speed level - where each entry is how many milliseconds a frame takes at that level, and level 6, Fastest, is 42. If you prefer to think in percentages, treat Fastest as 100% and convert.

function SetGameSpeed(level, percent) {
    const mspf = 1000000 / (10000 / 42 * percent);
    dwwrite_epd(EPD(0x5124D8) + level, mspf);
}

SetGameSpeed(6, 200);   // 가장 빠름을 2배로 / Fastest at 2x
It takes the level, so you can change only the speed the player picked or flatten all seven to the same value.

Taking the speed value below 4 buys nothing. Measured, 1 through 4 all run at the same speed - about 10.5x - and from 6 down the game runs slower than the formula promises. Only 7 and above match the arithmetic; below that the number changes and the game does not follow.

Everything above makes time by counting cycles, and therefore depends on how smoothly the game is running: lag means fewer cycles, and writing the speed table changes what a cycle is worth. When you need a real clock, do not count - read one. That is 0x51CE8C.

const ms = dwread(0x51CE8C);     // 초당 1000. 게임 속도와 랑그에 영향받지 않습니다.
if (ms - startedAt >= 30 * 1000) { /* 정확히 30초 */ }
It counts 1,000 a second, whatever the game speed.

Which one to use comes down to what you are measuring. In-game events - a skill cooldown, round pacing, a regeneration rate - belong on the cycle count: when the game lags everything lags with it, which is what you want. Anything tied to real time - recorded play time, an AFK judgement, save eligibility - belongs on this clock. “An hour” measured in cycles is not an hour in a laggy game.

The editor's "seconds" are two different units. SCMD2's unit production time is a frame count - 24 is a real second, not the 15 the editor implies - while its upgrade and tech research time is seconds at Normal speed. Stim's 1200 is frames: 80.4 s at Normal, which is what SCMD2 prints as 80, but 50.4 s in a Fastest game.

A Wait is written in real milliseconds but can only end on a frame boundary, and the triggers run on the frame after it ends - so the real delay is always at least one frame longer than you asked for.

실제 지연 = ((N - 1) div 42) * 42 + 84 ms

Wait 0~42ms   ->  84ms      // 그래서 클래식 터보가 2프레임입니다
Wait 1000ms   ->  1050ms    // 1초가 아닙니다
Wait 0 already costs 84 ms, which is why a classic turbo trigger is two frames rather than one. Only the EUD hyper gets a pass every single frame.

ElapsedTime(Exactly, N) can be unreachable. Without hypers the triggers poll at 0.125, 2.0625, 4.0, 5.9375 and 7.875 game seconds, whose integer parts go 0, 2, 4, 5, 7 - so Exactly 6 is never true and the trigger silently never runs. Write once (ElapsedTime(AtLeast, 6)) instead.

A second source of truth for time will drift. The most common accident is copying a constant from another map that assumed a different frame rate, and the symptom is a timer running at twice the intended speed.