I apologize ahead of time here as I don’t know your background in this stuff. Based on that question you are new to it…
‘Vec2’ is a 2 dimensional point. By convention referred to as X and Y (could be any letter but its a math thing).
However, most conventions I’ve used (decades ago to be sure), when talking about cartesian coordinates - on a 2D surface, like a map, x/y are:
x = east/west
y = north/south.
Guess what? ED flips these x = north/south, etc. It get screwier.
But DCS is a 3D world. Some values you get from the API give you: X, Y, Z. - a 3D coord where Y is now the altitude above mean sea level (all values are in meters BTW). So, given that funciton…
EngageTargetsInZone = {
id = ‘EngageTargetsInZone’,
params = {
point = Vec2,
zoneRadius = Distance,
targetTypes = array of AttributeName,
priority = number
}
}
Vec2 is a 2D point, relative to the origin (set by the devs’ that built the map).
If the Vec2 = x = 1234, y = 4678
Then the point is 1,234 meters north and 4,678 meters east (both are positive values here if you negate them then the point is South/West of the origin) from the origin. x = 0, y = 0. But you kinda don’t care you just want the value of, say a trigger.
You get this with:
local MyZone = trigger.misc.getZone(‘Name of some trigger’)
MyZone is a table with a bunch of values within. We want the coords of the point (center) of that zone:
local point3d = MyZone.point << the point portion of MyZone table.
Now, this is a 3D vector but EnageTargetsInZone wants a vector with 2 components:
params = {
point = point = {x = point3d.x, y = point3d.z}, << Z here, not Y
zoneRadius = zone.radius, << another value in the MyZone table.
…
}
We’ll ignore priority (that can complicate things and isn’t often, for me, necessary).
targetTypes = array of AttributeName
where AttributeName can be a lot of things and each is just text (a string - a key really but we don’t care about that right now), some examples:
Attribute describe a thing, if you will. Here’s how a Hawk search radar is described via its attributes table…
…not including all the Hawk SR attributes here, there are a couple dozen:
attribute = {…“Ground Units”, “Air Defence”, “SAM related”, …},
It tells you, most importantly for this example, that a Hawk SR is ‘SAM related’ - has something to do with SAM’s. It is also an ‘Air Defence’ object, etc.
So, back to targetTypes = array of AttributeName
params = {
point = point = {x = point3d.x, y = point3d.z}, << Z here, not Y
zoneRadius = zone.radius, << another value in the MyZone table.
targetTypes = {“SAM related”}
}
If we ‘pushTask’ using those values the group will search about that point, within radius meters and only target things that have something to do with SAMs. Note the AI has other priorities - wish they would tell us more on this but, alas…
From a Google AI search example (kinda handy I’d say):
local engageZone = {
id = 'EngageTargetsInZone',
params = {
point = {x = 123456, y = 789012}, -- Coordinates of the zone center
zoneRadius = 10000, -- Radius of the engagement zone in meters
targetTypes = {'Air', 'Ground', 'Sea'}, -- Types of targets to engage
priority = 10 -- Task priority (lower number = higher priority)
}
}
-- Assign this task to a group named "MyFighterGroup"
**>>> NOTE THIS CODE FROM THE AI IS NOT CORRECT <<<<**
local myGroup = Group.getByName("MyFighterGroup")
if myGroup then
myGroup:pushTask(engageZone)
end
NOTE the above code: myGroup:pushTask(engageZone) is NOT correct. Based on the API reference (I’ve never tried it however)
So, replace this
targetTypes = {‘Air’, ‘Ground’, ‘Sea’}, <<< this is basically saying “look for EVERYTHING”
with this
targetTypes = {‘SAM related’}, – only things having to do with SAMs
Buried deep within DCS there’s a conditonal branch like so:
FOR ALL targets NEAR point…
If target.attribute contains the symbol ‘SAM related’ THEN
Store it somewhere for later use…
END