A defence map is three things: spawn enemies on a period, send them toward a goal, and count the ones that arrive. The timer and spawn lessons carry over unchanged.
Trigger { -- 생성된 적을 계속 목표 지점으로 보낸다
players = {P8},
conditions = {
Deaths(P8, AtLeast, 24, "OrderTimer");
},
actions = {
SetDeaths(P8, SetTo, 0, "OrderTimer");
Order("Men", P8, "Track", Move, "Goal");
PreserveTrigger();
},
}Leak handling is the heart of it: when an enemy enters the goal, remove it and take a life.
Trigger {
players = {P8},
conditions = {
Bring(P8, AtLeast, 1, "Men", "Goal");
},
actions = {
RemoveUnitAt(All, "Men", "Goal", P8);
SetDeaths(P8, Subtract, 1, "Lives");
DisplayText("\x13\x06적이 통과했습니다");
PreserveTrigger();
},
}
Trigger { -- 생명이 다 떨어지면 패배
players = {Force1},
conditions = {
Deaths(P8, Exactly, 0, "Lives");
},
actions = {
DisplayText("\x13\x06방어에 실패했습니다");
Defeat();
},
}If each player defends their own lane rather than a shared one, keep lives on CurrentPlayer and eliminate only the player who runs out. Win conditions are covered in a later lesson.
A defence map has two failures that never appear when you test it alone. Neither is a code bug: both come from thousands of deaths and thousands of creations.
First, effects stop drawing at some point and never come back. Corpses, spell effects and scans share one pool of roughly 500, and in a defence map the corpses fill it. No plugin raises that limit. The fix is to build the dying mobs out of units that leave nothing behind when they die.
You do not have to guess which units those are. A unit's image script carries a starting point per animation and death is the second of them, so the test is exact: if that death script contains no opcode that spawns a new sprite or image - sprol, imgol, lowsprul and their relatives - the unit leaves nothing.
Counted on the shipped file: 92 of the 398 image scripts send death to the same two-opcode stub - wait 1, then end - which removes the sprite and leaves nothing, the Goliath Turret and the Science Vessel turret among them. Another 52 have no death entry at all, and a good share of those are the corpse scripts themselves.
Second, from somewhere around 2,000 to 3,000 kills, units start appearing at 0 HP and never dying. Scan effects stop too, and eventually StarCraft crashes. It only shows up in maps with very frequent death and creation, and it needs no EUD death detection or order editing to happen. The best available explanation is that the order buffer fills and the death order is never delivered.
So a defence map has to be tested over a long game. Running ten waves and calling it fine misses both of these, because both only appear after thousands of accumulated events.
