SCRMaps
/
Sign in

Counting units lags a cycle

A unit you just created is not counted yet.

4 min read

Bring and Command are the conditions that count units. Both read their number from a tally the game rebuilds once per pass. So if you CreateUnit and count in the same pass, you get zero: the unit is plainly there and the condition says it is not.

This bites hardest in checks like a minimum player count. Hand every player a unit at game start, count those units immediately, and you read zero players every time - so a legitimate game is defeated. The fix is to move the check later: to the moment the first wave is released, for instance.

Which of the two you use also matters. Bring counts only what stands inside a location, so it depends on that location - and a unit that flies, or sits at a different elevation, can disagree with it. Command counts what a player owns wherever it is, and its AtMost form is the most inclusive of all: it counts units inside transports, buildings under construction and units in production.

// 위치에 의지하지 않고, 가장 넓게 셉니다
if (Command(Force1, AtMost, 2, builder)) { tooFew = 1; }
Command counts ownership, and AtMost is its most inclusive form.

AtMost being more inclusive is not a figure of speech: the same condition counts different things depending on the comparison. This is the other source of "there is plainly one there and the condition disagrees".

What gets counted
수송선 안의 유닛AtMost counts them. Exactly and AtLeast do not.
건설 중인 건물AtMost counts them.
알·코쿤AtMost counts them.
생산 대기열의 유닛AtMost counts them - units that are not on the map yet.
Sign in to track your progress