Page 1 of 1
How to check if a unit is marked as an ESCORT?
Posted: Wed Jul 14, 2021 5:18 pm
by boogabooga
I'm trying to find the flag that marks a unit as an escort. It does not seem to be a a property of the UNIT wrapper. Also, the unitlist of the mission does not seem to distinguish between escorts or strikers. [&:]
RE: How to check if a unit is marked as an ESCORT?
Posted: Wed Jul 14, 2021 11:30 pm
by KnightHawk75
While one can set it, one can not query such on a unit or a mission unit list via Lua. [:(]
Workaround is either filter the mission.unitlist members (after having to 'get' each) by a known set of characteristics (unit type,dbid,loadoutid,guid,etc) that applies only to the escorts, or simply say by name containing a string you add to all escorts like " [escort]", and hope the user doesn't rename the unit.
RE: How to check if a unit is marked as an ESCORT?
Posted: Fri Jul 16, 2021 12:11 am
by boogabooga
So how does Command know who the escorts are? Surely there has to be a flag somewhere?
To get to a point here, exposing the "Escort" status would be very useful and go very well with the new "UNASSIGN" feature, for those times where you want to remember exactly what someone was doing before they get unassigned.

RE: How to check if a unit is marked as an ESCORT?
Posted: Fri Jul 16, 2021 2:47 am
by KnightHawk75
ORIGINAL: boogabooga
So how does Command know who the escorts are? Surely there has to be a flag somewhere?
To get to a point here, exposing the "Escort" status would be very useful and go very well with the new "UNASSIGN" feature, for those times where you want to remember exactly what someone was doing before they get unassigned.
Yes it exists in the system one way or another already, but it's not LUA accessible, I've remarked on the lack of it in past posts but it was never the focus of a topic so probably easily overlooked even if seen in passing. Perhaps time for a direct feature request for it's addition. I recall finding the feature annoyingly limiting when I was writing a mass swap unit X for Y script and being unable to restore a units possible prior "escort" assignment cause I couldn't query for it.
The next question may become how might we prefer it be implemented. Flag on the unitwrapper or something like enhancing mission wrapper with mission.escortlist returning just the guid's that are escorts, something else, both?
While ideally I might prefer having .unitlist return something like table of tables{guid="guidhere",name="",isescort=true|false} like some others do, it would be a breaking change and would likely be nixed. If mission.escortlist existed one could match .unitlist members against members of .escortlist members (if not nil) if trying to avoid escorts in the list, and if you just want the escorts it's handy as well, and avoids the expense of having to 'get' all .unitlist members just to determine if a unit is an escort to it's assigned mission if it was flag. Not to mention the mission wrapper is already linked in unit wrapper via unit.mission (when one is assigned) anyway so in a way adding it to mission.escortlist actually adds it to both. That's what I was thinking anyway but I'm interested in others thoughts.
RE: How to check if a unit is marked as an ESCORT?
Posted: Fri Jul 16, 2021 4:29 am
by michaelm75au
The 'escort' flag is tied to the unit so it makes sense to add a property to the unit wrapper - '.isEscort'.
So from the 'mission.unitlist' you can check each assigned unit to see if it is part of the escort or not.
[Added for future build]
RE: How to check if a unit is marked as an ESCORT?
Posted: Fri Jul 16, 2021 6:14 pm
by KnightHawk75
So from the 'mission.unitlist' you can check each assigned unit to see if it is part of the escort or not.
? Doesn't that forces one to "get" all members of the list when just wanting to get a list of escorts, doesn't seem as efficient but I'm not really gonna quibble.