The obvious way to turn one unit into another is to remove it and make a new one, which drops the selection, loses the state and flashes. StarCraft already has an order that does this properly - the Zerg morph - and writing that order onto the unit keeps it selected the whole way through.
0x4D (명령 번호) = 42 0x4E (명령 상태) = 2 0x4F (명령 신호) = 4 0x98 (생산 대기열) = 바뀔 유닛 번호 (2바이트)
| Hit points come back full | Save the hit points before and restore them once the morph completes. |
|---|---|
| The production-complete voice plays | There is no clean fix. Suppressing it by changing the player value gives a wrong selection-circle colour, allied units occasionally attacking, and occasional crashes - the voice is the lesser evil. |
| The subunit is left behind | A unit with a turret, like the Goliath or Siege Tank, leaves it behind. Write the turret pointer back to 0x70 to reattach it; an orphaned turret normally crashes. |
| A death animation plays | That comes from using the remove timer. Use a RemoveUnit trigger instead, or point the new unit's image at iscript 89 - which is the Science Vessel turret's script, and so has no death motion. |
Some target units leave a dolmen. Morphing into a Marine, Wraith, Battlecruiser or Arbiter is reported to, while Vulture and Firebat are clean, and nobody knows why - not the author of the original post either. Test the specific unit you intend to use.
There is no field that makes a morph faster. For one particular case, though - a toggle between two forms - there is a way to not morph at all. Siege Mode is the standard example: keep a pool of already-sieged tanks offscreen and cross-swap the turret pointers.
// 한 번만: 두 모드 모두 서플라이를 0으로 — 군대 풀이 공짜가 됩니다
bwrite(0x663CE8 + $U("Terran Siege Tank (Tank Mode)"), 0);
bwrite(0x663CE8 + $U("Terran Siege Tank (Siege Mode)"), 0);
// 매 패스: 숨겨둔 풀을 채워 둡니다
for (var n = 0; Memory(0x628438, AtLeast, 0x59CCA8) && n <= 11; n++) {
const dummy = CUnit.from_read(EPD(0x628438));
CreateUnit(1, "Terran Siege Tank (Siege Mode)", "dummyTankStorage", P8);
dummy.remove_collision();
dummy.set_invincible();
if (dummy.subUnit == 0) { dummy.removeTimer = 1; break; } // 불량품
}
// 바꿀 때: 0x70을 세 방향으로 교환
dummyTank.subUnit = oldTurret.ptr;
oldTurret.subUnit = dummyTank.ptr;
newTurret.subUnit = tankPtr;| Memory(0x628438, AtLeast, 0x59CCA8) | The clean “is there a free slot” test: compare against the unit table's BASE address rather than against 0. eudplib's own error printer does the same. |
|---|---|
| subUnit == 0 means a defective creation | On a unit you just created it means the turret did not come with it. Kill it with removeTimer = 1 and stop, rather than swapping a null pointer in. |
| A turret swap needs a PTR, not an EPD | The way from an EPD to a pointer is 0x58A364 + 4 * epd. |
| Give the turret back | The author's own update: returning the Tank-mode turret to the pool on the reverse swap made it much more stable and removed the mode animation entirely. A pool you only drain leaks, and the animation comes back. |
| Let a new unit age one pass | The animation occasionally still appeared, and the fix was a second staging store so that only tanks that had existed for a while were eligible. Treat “created this pass” as not yet ready for anything structural. |
Zeroing the supply (0x663CE8, one byte per unit id, and the value is twice the displayed number) is what makes an offscreen pool of sixty to a hundred units affordable at all. The pattern generalises past Siege Mode to anything that toggles between two forms often.
Iscript 89 is worth remembering as the useful blank: it draws and stops, with no death motion, which is what you want for any image that should simply appear. And a transform clears any overlay on the unit, so if you use both, transform first and attach the overlay second.
