How to check if a unit is marked as an ESCORT?

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
boogabooga
Posts: 988
Joined: Wed Jul 18, 2018 12:05 am

How to check if a unit is marked as an ESCORT?

Post 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. [&:]
The boogabooga doctrine for CMO: Any intentional human intervention needs to be able to completely and reliably over-ride anything that the AI is doing at any time.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: How to check if a unit is marked as an ESCORT?

Post 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.




boogabooga
Posts: 988
Joined: Wed Jul 18, 2018 12:05 am

RE: How to check if a unit is marked as an ESCORT?

Post 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. ;)
The boogabooga doctrine for CMO: Any intentional human intervention needs to be able to completely and reliably over-ride anything that the AI is doing at any time.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: How to check if a unit is marked as an ESCORT?

Post 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.


User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: How to check if a unit is marked as an ESCORT?

Post 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]
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: How to check if a unit is marked as an ESCORT?

Post 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.
Post Reply

Return to “Lua Legion”