To make an explosion happen at a spot, the usual approach is hunting for a unit that has that graphic. There is no need: the whole technique is three lines.
wwrite(0x666160 + 2*380, imageId); // 380번 스프라이트의 이미지를 바꾼다 CreateUnit(1, 33, loc, cp); // 유닛 33 = 스캐너 스윕 RemoveUnit(33, cp);
Why it composes matters: StarCraft reads the image only at creation and never looks again. So setting the image, creating, setting it again and creating gives you two different effects at once out of one shared sprite slot.
| It cannot be clicked | It cannot be clicked, not even by dragging. |
|---|---|
| It does not appear on the minimap | It is not drawn there at all. |
| Any number can overlap | Any number of them can occupy the same spot. |
| A unit underneath is not slowed | Putting one over a ground unit does not affect its movement. |
| Unit-moving triggers do not touch it | It will not be moved or swept up by accident. |
All of which is exactly what you want from a decoration. It is this list, not any graphic, that made unit 33 the effect vehicle everybody uses.
You have to make unit 33 trigger-creatable first, or CreateUnit silently does nothing - no error and no unit. Ticking "unit listing and palette" in DatEdit is this, and the same thing can be done in code: it is bit 0x0002 of the Staredit availability flags.
Put back what you changed. Sprite 380 is the slot the game uses for a real Scanner Sweep too, so without restoring the original image the next scan plays your explosion.
One more effect made of the same parts, because it fixes the pattern. The trail of fading copies behind a moving unit is nothing but a shadow spawned every frame and removed shortly after.
if (MemoryXEPD(u + 0x20/4, AtLeast, 1, 0x12)) { // 움직일 때만 / only while moving
const dir = bread_epd(u + 0x21/4, 0x21 % 4); // 유닛이 보는 방향 / its facing
// ... 각도로 바꾸고 180도 더해 ‘뒤에’ 놓고 ...
const x, y = lengthdir(8, reverse);
MoveLocation(loc, UNIT, p, "Anywhere"); addloc(loc, x, y);
TrgUnit("Nuclear Missile").startDirection = (angle * 32 / 360 + 8) & 31;
Sprite("Nuclear Missile").image = SHADOW_IMAGE; // 그 유닛의 이미지
Image(SHADOW_IMAGE).drawingFunction = 6; // VisionCloaked — 반투명 / translucent
const shadow = CUnit.from_next();
CreateUnit(1, "Nuclear Missile", loc, p);
shadow.statusFlags.NoCollide = true;
shadow.removeTimer = 6;
SHADOW.add(shadow);
SetMemoryEPD(shadow + 0x10/4, SetTo, 0); // 이동 목표 제거
Image(SHADOW_IMAGE).drawingFunction = 0; // 바로 되돌림
}| Mask 0x12 | 0x10 moving plus 0x02 accelerating on the movement flags - the trail only appears while the unit is actually moving. |
|---|---|
| Drawing function 6 | Function 6 is NOT shadow - it is VisionCloaked, the shimmer a cloaked unit shows to its own side. Shadow is 10. That is exactly why the trail reads as a ghost, and reaching for the name instead of the number gives you a flat black drop shadow. Setting and unsetting it around the single CreateUnit keeps anything else drawn this frame from picking it up. |
| startDirection is in 32 steps | startDirection is in 32 steps, not 256: (angle * 32 / 360 + 8) & 31. |
| removeTimer 6 | The length of the trail. Keep them in a UnitGroup and reap at removeTimer == 1 so no corpse is left. |
| The vehicle is a Nuclear Missile | The vehicle is a Nuclear Missile for the same reason unit 33 is used elsewhere: nobody else is using it. It needs its unit-listing flag turned on before it can be created. |
