A map does not know how many people will join. The count feeds minimum-player checks, difficulty and reward sharing, so you almost always need it.
Trigger { -- 각 플레이어마다 한 번씩
players = {Force1},
conditions = {
Command(CurrentPlayer, AtLeast, 1, "Terran Marine");
Deaths(CurrentPlayer, Exactly, 0, "Joined");
},
actions = {
SetDeaths(CurrentPlayer, SetTo, 1, "Joined");
SetDeaths(P8, Add, 1, "PlayerCount");
SetDeaths(CurrentPlayer, SetTo, 1, "Level");
DisplayText("\x13\x07환영합니다");
PreserveTrigger();
},
}To scale difficulty by headcount, put PlayerCount straight into the condition.
Trigger { -- 4명 이상이면 보스 체력을 올린다
players = {P8},
conditions = {
Deaths(P8, AtLeast, 4, "PlayerCount");
Command(P8, AtLeast, 1, "Boss Unit");
},
actions = {
ModifyUnitHitPoints(All, "Boss Unit", P8, "Boss Room", 100);
PreserveTrigger();
},
}A player who leaves keeps their counters. To keep PlayerCount honest you either move to EUD, where f_playerexist exists, or recount each time from who still owns a unit.
Put AllPlayers or a Force in a condition's player slot and it sums across players - and that sum leaves out an empty slot, a defeated player and a player who left. Measured directly: with one bit per player, a full room read 255, and the moment P1 left it read exactly 254.
Which means a guard written against a total quietly loosens. A "cannot create more units" check of the form "only spawn while the all-players counter is under 1300" counts less and less as people leave, so it opens up exactly when the map is in its worst state. Budget per surviving player, or count it yourself.
In EUD you can read who is in a slot rather than counting it. The player settings table sits at 0x57EEE8 with a stride of 36 bytes per player - EPD(0x57EEE8) + 9 * p - and the record's low byte is the slot type.
| 0 Inactive | Nobody is in it. |
|---|---|
| 1 Computer | A computer. |
| 2 Human | A human. |
| 3 Rescuable | A rescuable player. |
The same record also gives the race (0 Zerg, 1 Terran, 2 Protoss) and the force (1 to 4, with 7 meaning Neutral). And one property that matters: the value CHANGES when a player leaves. So unlike a death counter recording how many players there were at the start, this tells you the state now.
