SCRMaps
/
Sign in

FireGraft: button sets and the unit panel

Where buttons are made - and the one side effect that merely switching it on causes.

12 min read

If DatEdit is what a unit can do, FireGraft is how a unit is operated: button sets, requirements, and how the panel looks when the unit is selected.

Merely enabling FireGraft has a side effect: selecting several units that share a button set stops showing the buttons properly. Select a Marine and a Firebat together and Stim Pack is gone; a Vessel and its hero together and the spell buttons are gone. Know this before deciding to use it.

There is a way back. Select two different unit types and the game does not merge their cards - it shows button set 244 (units), which holds the basic orders and nothing else. Copy the Stim Pack button into that set and Marine + Firebat shows Stim Pack again; the same works for Psionic Storm. For what it is worth, High Templar + Tassadar loses its spell buttons in an unmodified game too.

What copying into 244 costs
The portrait decidesIf the unit whose portrait is showing has the ability, the button appears even when the rest of the selection cannot use it.
Before the upgradeBefore the upgrade is researched it shows greyed on every mixed selection - including an all-Protoss one.
Combinations that do not workCarrier + Gantrithor still will not show Interceptor, and Reaver + Warbringer behaves the same way.

Take the stock btnset.dat apart and count: 250 button sets holding 896 button records between them, 89 of the sets empty. Set 244 holds exactly five - the basic orders, icons 228, 229, 230, 254 and 255, and nothing else. Set 228 holds none at all, which is where the rule against adding a button to it comes from (crash list #48).

Which unit's portrait appears in a mixed selection is decided by rank. Set ranks deliberately and you choose the card the player sees - by far the cheapest lever on this problem. A fix with no side effects at all means working on the selection struct rather than the button set.

The status list decides the shape of the panel. Which one you pick changes a great deal of what is shown, and some of them change behaviour too.

Status list
BuildingsOn a unit this removes the attack and armour upgrade display and the kill count, and adds a Stim Pack research that does nothing.
UnitAn ordinary unit. On something that can produce, the production queue is not shown.
Hangar unitThe Reaver and Carrier one: a five slot production queue, and it works on buildings too.
Hatching unitThe egg one. It looks like one slot but functions as five.
Transport unitDropship and Shuttle: loaded units are shown.
Not selectableEverything vanishes but the wireframe and the name.

There is a technique going around for switching the status list at run time with EUD, and 64-bit StarCraft ignores that region of memory entirely. For most players nothing happens - no error, it simply does not change. Unless your map is 32-bit only, do not use it. Setting it in the editor is fine.

The Reaver status list connects directly to build-queue detection: switch to it and you can see the five slots, which is how you watch a queue fill while debugging. Put it back for release.

The order of the button list does not matter, because each button carries its own position. And always scope a requirement to the unit it belongs to: left always-allowed, the button appears on units you did not mean.

Never leave a button set's requirement string empty: it crashes on 64-bit, crash list #15. And never add any button to button set 228 - #48.

The classic thing a button set is used for is the Warcraft random-defence shape: click the tower and it becomes the next tower. Four things have to line up.

  • Use a unit-production button set, not Hold or Stop: a production button brings the cost machinery with it, where Hold means writing the resource check yourself.
  • Set the tower units' supply cost to 0, or the upgrade fails on supply.
  • Copy the button data from Larva's Zergling button, and change the action from 38 (Unit Morph) to 3 (Create Unit). The original repeats that line three times in a row, which is a fair measure of how often it is missed.
  • Do not produce a hero unit directly. Heroes have no button string at all, so the button has to borrow a building's, and the hero's requirement has to be always-allowed, which is reported as bug-prone. Produce the ordinary unit and let a trigger swap the queued entry for the hero.

One piece of advice in the original is wrong. Because the trigger manages every created unit, real production from buildings breaks, and the fix offered is to start the loop past the pre-placed count - for i = 50,1699 with 50 buildings. That assumes pre-placed units fill from index 0 upward, and they do not: units load into index 0 and then 1699, 1698, 1697 downward, so 50 buildings sit at index 0 and 1699 down to 1651. Skipping the low range excludes free slots and still walks the buildings. Filter by unit type, or by a set you track yourself.

One barely-known property to finish with: button set data is not shared. Every machine holds its own copy and nothing compares them - so each player can have a different button layout. Per-class skill bars in an RPG, a button only a spectator sees, different icons per language: all of it is available.

// 로컬 플레이어만 분기합니다 / branch on who is actually sitting here
EPDSwitch(EPD(0x512684), 0xFF) {
    EPDSwitchCase(0);  /* 1피의 버튼 배치 */  EUDBreak();
    EPDSwitchCase(1);  /* 2피의 버튼 배치 */  EUDBreak();
}
0x512684 is the local Storm ID - who is sitting at this machine.

You do not have to gate this against desync. Branching on a local value normally drops the game, but what is being changed here is itself unshared, so no machine ever looks at another's copy. This is one of the rare cases of a local value driving local data, which needs no protection at all.

And a single unit's button set can be changed on its own: CUnit 0x94 is that unit's button set and it is writable per unit - a shipped example map uses it to give one Gantrithor different buttons. If you have seen “writing 0x94 is a hard crash”, that is a different thing: it is the units.dat ButtonSet field, where set 228 is reserved and must not be touched. The two share a name and nothing else.

Detecting a button press with the build queue