How to detecting when selected units have been given a command? (for incremental selection mod)


So I'm working on a selection helper mod where I want a given hotkey to sometimes add a unit to the current selection, and sometimes start a new selection, depending on context.

The way I have it set up currently is that, after you made your initial selection, (or add to a selection) it stays in 'incremental selection' mode for a fixed time. So if you press a selection hotkey several times in quick succession you get that many units of that type, but if you wait a certain amount of time before pressing again, it starts a new selection.

The problem with this is that this depends on the user having some idea of the time that has passed since the last key press, which ends up being not so intuitive (in that it will sometimes not do the selection action that the user wanted).

What I would really like is for incremental mode to remain in effect until the current selection is given some command, with selection mode then reverting back, such that the next hotkey press after the command is given starts a new selection.

For this, I need to detect when a command has been given, but I can't see an easy way to this.

Does anyone here know how this can be done (detecting when selected units have been given a command)?
Any other ideas?


hook OnCommandIssued, check if the unit is part of your selection -> do stuff.


Cool idea

[EDC] - EngineerDaycareCenter
Come and learn this game with us!


@uveso Looks like this works very nicely. Thank you!


thanks for reporting back, i am glad i could help.