An area skill has to work out who is inside the area. There are four ways, with different costs and different things that break them. Choose by what your map can guarantee.
| Mark with hit points | Set the target's hit points to a percentage, detect that exact value, restore it. The cheapest - one action and one condition per unit slot - and it breaks the moment anything else damages the unit. Defence maps only. |
|---|---|
| Change the unit type | CP-trick the unit's type field to an unused id, Bring on that id, restore. One loop pass, and this is the version that survives a versus map. |
| A location plus a unit loop | Move a location onto the caster and loop every unit checking whether it is inside. The slowest and the one that never breaks. |
| Compute from coordinates | Read each unit's position and compare it with the cast point. The cheapest per unit, though you still need a loop to visit them, and it ignores collision and elevation. |
| Borrow an unused player | GiveUnits everything in the area to a player nobody is using, loop only that player's units, and hand each one back. One action does the area search, and the loop costs the number of units actually hit. |
If you use the hit-point marker, make it a large one. Setting 10 and detecting 9 at 90% also catches any enemy whose health happens to be 9. Use 10,000 and detect 9,900 at 99% and far fewer things wander onto it by accident.
Of the five, the last is the one to reach for first: it makes StarCraft do the area search and hands you back exactly the units that were inside. EUDLoopPlayerUnit walks a per-player linked list, so the cost is the number of units hit rather than a sweep of all 1,700 slots - and there is nothing to mark, nothing to restore and no unit id to keep free.
setloc($L("Stun"), px - 48, py - 48);
dilateloc($L("Stun"), 96, 96); // 96x96 영역 / a 96x96 box
GiveUnits(100, $U("(any unit)"), P7, $L("Stun"), P9); // 거둬오기 / harvest
foreach(ptr, eEPD : EUDLoopPlayerUnit(P9)) {
const ex, ey = posread_epd(eEPD + 0x28/4);
bwrite_epd(eEPD + 0x124/4, 0, 10); // 기절 / stun
setloc($L("Stun"), ex, ey);
GiveUnits(1, $U("(any unit)"), P9, $L("Stun"), P7); // 돌려주기 / give back
}Three conditions on it. The borrowed player must be one no trigger and no AI touches, and not a human. Every path out of the loop has to give the unit back, or it is stranded on the wrong player. And ownership genuinely changes for that moment, so anything counting units per player sees it move.
A stun is a status timer, not a movement flag: one byte at CUnit 0x124, the Maelstrom timer. The unit is held for that many cycles with no code of yours running. Note the asymmetry - Maelstrom is one of the three spells whose overlay cannot be borrowed, so the hold is free and the graphic is not.
Cap how many targets an aura touches per tick. With no cap, units piling into one tile make the cost grow quadratically - the kind of failure that behaves perfectly until the moment everything bunches up.
Knockback and dash are the same structure, and it is not one big move: it is a small move repeated every cycle for a fixed number of cycles.
- 1Use a death counter as the push timer and take one off it every cycle.
- 2Work out the direction - the angle from the blast to the victim.
- 3Put a location on the victim, shift it a little in that direction, and MoveUnit the victim onto it.
| About 11 pixels per cycle | Move further than that in one cycle and it reads as teleporting rather than sliding. |
|---|---|
| Where zero points depends on the function | Where zero points depends on which function made the angle. atan2 and lengthdir, the 360-degree pair, use the mathematical convention with zero at three o'clock; atan2_256 and lengthdir_256 match the unit's own facing byte, where 0 is twelve, 64 is three, 128 is six and 192 is nine. Mix them and you are exactly a quarter-turn out. |
| The _256 functions changed convention in 0.9.9.8 | The _256 pair changed in euddraft 0.9.9.8: before that they also used the mathematical convention. Pasted-in old code goes a quarter-turn out silently, so if you do not know the version, probe atan2_256(10, 10) >= 90 once and branch on it. |
| Finish inside one second | While a unit is being pushed by MoveUnit it effectively cannot be hit, so a long knockback is an invulnerability window. Ten cycles - about 0.4 seconds at stock speed - is enough. |
One area effect is worth reading closely: the thing that orbits the hero. All of its design sits in one expression. Three knives circle the hero, and each is consumed when it hits.
if (W_stec[cp] > 0) {
var angle = 360 / W_stec[cp]; // 매 프레임 다시 계산합니다
for (var knife = 0; knife < W_stec[cp]; knife++) {
MoveLocation(memory_loc[cp], hero_player[cp], cp, "Anywhere");
var wheel = 8*W_03 + knife*angle; // 회전 + 균등 배치
if (W_03 <= 8) PolarLocation(memory_loc[cp], 6*W_03, wheel); // 퍼져나감
else PolarLocation(memory_loc[cp], 64, wheel); // 유지
...표시...
if (W_03 > 12 && W_05 == 0
&& Bring(Foes, AtLeast, 1, "(men)", memory_loc[cp])) {
W_stec[cp]--; // 한 자루 소모
AttackGround(memory_loc[cp], memory_loc[cp], atk[cp], victim, cp);
W_05 = 8; // 공유 명중 쿨다운
}
}
W_03++;
}| The spawn and the steady orbit are one loop | While W_03 <= 8 the radius is 6*W_03, so the knives fly outward from the hero over eight frames; after that the radius is the constant 64. No separate state, no second function - one branch on a frame counter. |
|---|---|
| angle = 360 / count, recomputed every frame | When a knife is spent the survivors re-space themselves for free, because the spacing is derived from the live count rather than stored - two remaining knives immediately sit opposite each other instead of leaving a gap. Deriving instead of caching is the whole trick. |
| 8*W_03 + knife*angle | The general form: a term that advances with time spins the set, a term in the loop index spaces it. Eight degrees a frame is one revolution in 45 frames, under two seconds. |
| An arm delay, W_03 > 12 | It stops the knives hitting during their own spawn animation. Without it a skill cast into a crowd resolves on frame one and the animation never plays. |
| The hit cooldown is shared, not per knife | Deliberately so: per-knife cooldowns would let all three land in the same frame on the same target. |
The drawing side is the dat-write latching rule applied per effect - set, create, restore, every frame. Image 511's own script would dolmen or loop forever, so it borrows a different iscript for the one frame it is created in and is restored immediately. And drawing function 16 is Hallucination, which is the free “upgraded” tint: the enhanced version of this skill is the same effect drawn with 16 and restored to the stock 9 afterwards. One number is the entire visual difference between the normal and buffed skill.
And there is a very short idiom for moving a location to a place whose coordinates you never read - the mouse being the usual case, where a location follows the cursor but you may not want to read its position. Create a throwaway unit inside the source location, snap the target location onto it, and delete it.
CreateUnit(1, probe, "mouse1", P1); // 원본 안에 만들고
MoveLocation("bullet destination", probe, P1, "mouse1"); // 목표를 거기에 붙이고
RemoveUnit(probe, P1); // 지웁니다