| 가스 | Handled with SetResources and Accumulate. Already on screen, needs no unit, and survives the hero dying - but it is per player, so it cannot differ between units. |
|---|---|
| 에너지 | Per unit and drawn by the game for free - but the game regenerates it on its own schedule, and it freezes while cloaked. |
| 변수 (PVariable) | One per player and entirely yours - but invisible unless you draw it. |
With energy the numbers are always 256 times what the player sees: a 25-energy skill compares against 25*256 and subtracts 25*256.
Mana that fills at 0.3 a second cannot be written as a division, because the resource has no fractional part. Accumulate points instead and hand over one whole unit each time the accumulator fills.
const Manaup = PVariable(); // 회복 속도 / the rate, per player
const Manapoint = PVariable(); // 적립함 / the accumulator
foreach(cp : EUDLoopPlayer()) {
setcurpl(cp);
Manapoint[cp] += Manaup[cp];
if (Manapoint[cp] >= 24) { // 24점 = 가스 1
Manapoint[cp] -= 24;
SetResources(CurrentPlayer, Add, 1, Gas);
}
}That 24 is the assumption that a second is 24 cycles, and a map that writes the game speed breaks it: at 29 ms a frame a second is about 35 cycles, so mana set up against 24 fills 45% too fast. And not only mana - every clock built on that number moves together.
Time and frames