For example in the gui the following is displayed for a contact:

In this particular case there are detections from 2 sensors on 1 unit 'Stucture2'.
Now I can get the contact wrapper for this contact via VP_GetContact and interrogate .detectionBy field\table but it will only return {Radar=1};
Interestingly it also was nil till the second detection was made by the BigBird-D. Such that when the Bogey first appeared by being detected by the Cheese Board and shown in the gui .detectonBy was still coming back nil. IDK if it's a delay issue or something else such that the first one is being skipped. Additionally shouldn't that read {Radar=2} as pictured since there are now 2 radar sensors detecting it, or is # here the number of units and not sensors?
But now back to what I'm trying to accomplish. I can't seem to find a way of finding what unit(s) made the detection(s), either from information contained in the contact wrapper, or the underlying contact's unit. I can check the unit's .ascontact table but that just provides side,contactguid,name. I can't seem to find any way of getting what I want when the contact is_not being actively fired on, targeted by, targeting or firing on anyone. Is there a way I'm missing?
One might wonder why I wanted this information or an example of how I was going to use it.
So I've been working on a something I call YARC (yet another radar controller) at the moment.
Besides introducing customizable randomization into flipping on\off radars per desired unit(s) (and even per sensor or sensor type per hosting unit), I'm also trying to enable some more intelligence. Things like hey if this unit is currently in the middle of firing on someone maybe now is not the right time to turn a FCR off even if cycle time is up. But another option is to flag the unit-sensor entry as being able to use data from it's side to be arguably more intelligent. Such that if say contact is being tracked by that particular unit, and say only by that unit, maybe you want it not to turn off, or only turn off if range exceeded a certain threshold on it's own detection. That one requires me to know who has detected what - at least relatively recently.
Another option without getting into too much detail was basically using information from other side\allied side sources to know when to override activation\deactivation or not. Such that it might only activate when a contact is inside say munition and FCR range of a host unit using data fed by other units. Which I can do as is, but I wanted to optionally restrict that option relative to other radars\host units proximity who are feeding the data to the host. Such that unit X will turn on based on contact data with-in Y range of X, but only for contacts obtained by units friendly\allied units located with-in 50nm of X or for that matter only if certain comm-link exist between the parties. Basically simulating shared comms\cec as the user permits, but only to a point, not side-wide.
Anyway to do some of that stuff on I need info from the contact's detection table like exists in the gui, namely a detecting-unit guid. Also optionally (and more enabling), the associated sensor guid on that detecting-unit, and the age and range if it's already readily available to pass on to us.
I don't know what's the best place for this information though if added, be it on the contact or the unit or both or some other method. Not sure how many are actually kept either I assume it's similar # to the gui.
A .detectedByUnits table on a Contact wrapper:
{[1] {guid=detecting-unitguidhere,sensor_guid=sensor_guidhere,age=agehere,range=rangehere}
...
[10] {guid=detecting-unitguidhere,sensor_guid=sensor_guidhere,age=agehere,range=rangehere}}
:detectionByUnits() method could work too to avoid default bloat of the wrapper size with a table.
Or on the Unit wrapper as a method?:
:detectionsBy('Sidename' or all if nil) --returns table of contacts this unit has detected that have not timed out.
{ [1] {guid=contactguidhere,side='SidenameOrUnknown'} ...
[XXX] {guid=contactguidhere,side='SidenameOrUnknown'} }
Or maybe I'm just trying to do too much with this stuff. [:)]
Beyond the aforementioned I also ran into this challenge awhile back trying to design a piece of a scene that required the player to have a specific unit not get detected by a specific set of enemy units and enemy sensor dbids (when emissions were not involved). Which couldn't be done without containing each of those to their own separated sides and using detectedBySide as a inartful workaround.