Key presses are entirely local - no other machine knows you pressed A. To act on a key you have to turn that into something every machine agrees on, and MSQC is what does it: a press raises the death count of a unit you nominate.
[MSQC] NotTyping ; KeyDown(Q) : Cantina, 1 NotTyping ; KeyDown(W) : Cantina, 2 mouse : Mouse Loc QCLoc : 12 QC_XY : 960, 1024
| QCUnit | The unit that carries the input. Default 58, Terran Valkyrie - leave it there, because writing or removing that unit's data stops input arriving. |
|---|---|
| QCLoc | The location MSQC borrows. Never share it with one your map logic uses. |
| QC_XY | Where that location is parked, in pixels. The default is 128,128 - tile 4,4. |
| QCPlayer | Who owns the input units. Default 10, which is P11. |
| QCDebug | On by default, and it prints debug text on screen. Turn it off with false before release. |
MSQC samples the key state once per trigger execution. Without hyper triggers that is less than once a second, so most presses land between samples and vanish - which is what "I have to press it six times" is. eudTurbo is not optional here.
Enter opens the chat box, so StarCraft takes the first press. A menu opened with Enter looks like it needs two presses - that is the mechanism rather than a bug to fix, so pick another key.
Key names are Windows virtual-key names: A to Z, 0 to 9, F1 to F24, NUMPAD0 to NUMPAD9, ESC, ENTER, SPACE, TAB, BACK, DELETE, INSERT, HOME, END, PGUP, PGDN, the arrows as LEFT, UP, RIGHT and DOWN, and LSHIFT, RSHIFT, LCTRL, RCTRL, LALT, RALT. Punctuation is written literally - ` - = [ ] ' , . / - with the semicolon spelled SEMICOLON. Mouse buttons are L, R and M.
There is a second route that uses an array instead of death counts. Give an array a name with EUDRegisterObjectToNamespace and MSQC writes into it directly - taking the unshared local key state over to shared data on your behalf.
const Key_Input = PVariable();
function KeyInit() { EUDRegisterObjectToNamespace("Key", Key_Input); }
// 읽는 쪽 / reading it
if (Key_Input[cp] == 1) { /* ... */ }To tell simultaneous presses apart, give each key its own bit - 1, 2, 4, 8, 16 - not 1, 2, 3. With Q=1, W=2 and E=3 you cannot tell Q+W from E.
And there is a settled way to read the bits. The instinct is to build a 1024-entry table mapping each bit pattern to a key number, and it is unnecessary: one masked condition per key handles any combination as it is.
foreach(p : EUDLoopPlayer()) {
setcurpl(p);
RawTrigger(conditions = DeathsX(CurrentPlayer, AtLeast, 1, 105, 1), actions = ...); // 1번 키
RawTrigger(conditions = DeathsX(CurrentPlayer, AtLeast, 1, 105, 2), actions = ...); // 2번 키
RawTrigger(conditions = DeathsX(CurrentPlayer, AtLeast, 1, 105, 4), actions = ...); // 3번 키
}EUDArray and death counters have the same memory layout, so there is no performance difference between them. For a plain value comparison the EUDArray takes less space, and PVariable buys nothing.
MSQC is not always the right answer, though. If the key changes only the presser's own screen - opening a panel, switching a display unit, showing a help page - there is no reason to send it through shared data at all. For that, read the table where StarCraft already keeps the key state.
// 0x596A18 + 가상 키 코드, 키 하나당 1바이트
if (IsUserCP()) { // 나 자신의 패스에서만
if (bread(0x596A18 + 0x51) != 0) { ... } // Q
if (bread(0x596A18 + 45) != 0) { ... } // Insert
}This table is not shared. Its value differs per machine, so driving a shared action from it drops the game. Keep it strictly local - inside IsUserCP() or setcurpl(getuserplayerid()) - and send any key that must change shared state through MSQC instead. The test is one question: if only the presser's screen changes, read the table; if anyone else has to see it, use MSQC.
For a masked read the mask is 0xFF << (8 * (code % 4)). And it is true every cycle while the key is held, so turning one press into one event means detecting the edge yourself - a single boolean remembering the previous state, compared against the current one, is enough. A keyWait-style debounce that measures how long it was held is built in the same place.
Using chat as a command lineDesync, and the local player