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; }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".
| Units inside a transport | AtLeast and Exactly count them. AtMost does not. |
|---|---|
| Buildings under construction | Only AtMost counts them. |
| Egg · Lurker Egg · Cocoon | Only AtMost counts them. |
| Units being produced | Neither counts them. |
| Units inside a transport | Both count them. |
|---|---|
| Buildings under construction | Only AtMost counts them. |
| Egg · Lurker Egg · Cocoon | Only AtMost counts them. |
| Units being produced | Only AtMost counts them - units that are not on the map yet. |
The transport row runs against every other row. Bring's AtMost is the only comparison in either condition that loses units inside a transport: a Dropship full of Marines sitting in the location still satisfies Bring(cp, AtMost, 0, "Terran Marine", "transport"). That is why a sweep meant to find everybody cannot be a Bring … AtMost.
A morphing egg, lurker egg or cocoon is not a "unit in production". It is its own unit type and follows the egg row above.
Once you are using EUD, though, most of this table stops mattering - because the game is already keeping the count in memory, per player and per unit type, live.
// 유닛 종류마다 12칸(플레이어), 각 4바이트 // 228 types x 12 players, 4 bytes each const n = dwread_epd(EPD(0x584DE4) + unitId*12 + cp); 0x582324 모두 세는 표 (생산 중인 것 포함) / all units, incomplete included 0x584DE4 완성된 것만 / completed only 0x5878A4 죽인 수 / units killed
Those two tables dissolve the completed-versus-incomplete problem above: how many are still being built is the all table minus the completed one. Reach for a condition only when the question is about a place, which is what Bring is for.
It is not only unit counts. A good deal of what people emulate with death counters the game already tracks per player, and all of it is writable. Every one is address plus four times the player.
| Minerals 0x57F0F0 · gas 0x57F120 | Totals harvested are at 0x57F180 and 0x57F150. |
|---|---|
| Units produced · lost · killed | 0x581DE4, 0x581E74, 0x581EA4 - and “Any Unit” kills live in the last one. |
| Buildings built · owned · lost · razed | 0x581F64, 0x581F94, 0x581FC4, 0x581FF4. |
| Custom score | 0x5822F4 - what SetScore(..., Custom) moves. |
| Alliance status | 0x58D634 - twelve bytes per player, one per target. |
Supply is here too, as available, used and max for each race.
| Zerg control | 0x582144 / 0x582174 / 0x5821A4 |
|---|---|
| Terran supply | 0x5821D4 / 0x582204 / 0x582234 |
| Protoss psi | 0x582264 / 0x582294 / 0x5822C4 |
All three are four bytes and the game displays them as u16, so the number on screen wraps at 65,536 while the stored value keeps climbing. That is the ceiling any “unlimited supply” scheme runs into.
The current-level tables for upgrades and techs are laid out the other way round. The deaths table is twelve players per unit; these are one row per player with one byte per item - address plus rowBytes times player plus id. And they are split in two: upgrades 0 to 45 sit at 0x58D088 with 46-byte rows, and 46 to 60 at 0x58F278 with 15-byte rows. One formula for all 61 is right for two thirds of them.
Which is the argument for scdata's Upgrade("...")[player]: it handles the split for you.
There is a free timer too. Write the countdown timer at 0x58D6F4 from EUD and it ticks down on its own without being drawn - an extra timer costing nothing per cycle. Beside it, 0x58D6F8 is elapsed time in game seconds, where one game second is 16 ticks, about 0.672 s on Fastest.
There is a case that shows exactly how this bites. Capping Pylons at 120, written like this, always lets 121 through.
if (Command(p, AtLeast, 121, "Protoss Pylon")) { ... } // 영영 안 걸림 / never firesif (!Command(p, AtMost, 120, "Protoss Pylon")) { ... } // 이쪽이 맞음 / this one worksFor a cap across several types a condition cannot do it - there is no way to add Gateways, Pylons and Cannons together. Read the live count table instead: 0x582324 is "all units including those under construction", one entry at bread_epd(EPD(0x582324) + 12*unitType + player). And read the sum once outside the unit loop - adding it up per unit inside the loop is the mistake that actually came up.
scdata: game data by name