SCRMaps
/
Sign in

Triggered spells: targeting and energy

A skill that spends energy, takes a target, and fires - built out of triggers.

8 min read

The source for this is 2020 Brood War era and the corpus itself marks it unverified. So every address used here was checked against eud_book's SC:R support levels - CUnit's Secondary Order ID and Build Queue are both Supported. Test it on Remastered anyway.

A skill is three pieces: knowing it was pressed, choosing a target, and charging for it. The first is the build-queue lesson; this is the other two.

A spell with no target is easiest: the effect lands on the unit that pressed the button, and there is nothing to do beyond putting the queue back.

A targeted spell borrows the game's own targeting. Make the button an ordinary spell button and the cursor changes, the player picks a target, and the choice lands in the unit's Secondary Order and its target field. You read that, cancel the order, and produce the effect yourself.

You charge the energy yourself: read it from the structure offset, do nothing if it is short, subtract and fire if it is not. The reason you cannot use the game's own check is simple - as far as the game is concerned this button is not a spell.

Do not reset by emptying the queue. Setting every slot to 228 is the same as cancelling production: the unit goes invisible or the game crashes. Always keep the first slot filled - the build-queue lesson has the detail.

Detecting a button press with the build queue
Sign in to track your progress