Pendrokar wrote: (Spring.GetUnitTeam(unitID) == Spring.GetMyTeamID)
Or maybe
Code: Select all
local allUnits = Spring.GetTeamUnits(Spring.GetMyTeamID())
I stole that from quantum's Select n Center! for my own version (attached below). Works for me but I don't do multiplayer or replays, so I don't know how it reacts that that. This version can also be reloaded in the middle of the game to re-group the Commander after a morph or whatever.
As for morph/upgrade staying with the group, that probably should be handled in the unit_morph.lua gadget. It already reassigns units guarding the original commander to guard the morphed one in the function ReAssignAssists(newUnit,oldUnit). I also found where it makes sure selected units are still selected after a morph in the function SelectSwap(cmd, oldID, newID). One of these functions could probably fairly easily be changed to also check unit groups and assign the morphed unit to the same group. Then it's just a matter of convincing all your favorite mod authors to use your updated gadget.
